|
|
|
|
@ -70,36 +70,43 @@ class SystemTagNodeTest extends \Test\TestCase { |
|
|
|
|
[ |
|
|
|
|
true, |
|
|
|
|
new SystemTag('1', 'Original', true, true), |
|
|
|
|
['Renamed', true, true, null] |
|
|
|
|
['Renamed', true, true, null], |
|
|
|
|
true, |
|
|
|
|
], |
|
|
|
|
[ |
|
|
|
|
true, |
|
|
|
|
new SystemTag('1', 'Original', true, true), |
|
|
|
|
['Original', false, false, null] |
|
|
|
|
['Original', false, false, null], |
|
|
|
|
true, |
|
|
|
|
], |
|
|
|
|
// non-admin |
|
|
|
|
[ |
|
|
|
|
// renaming allowed |
|
|
|
|
// renaming not allowed |
|
|
|
|
false, |
|
|
|
|
new SystemTag('1', 'Original', true, true), |
|
|
|
|
['Rename', true, true, '0082c9'] |
|
|
|
|
['Renamed', true, true, null], |
|
|
|
|
false, |
|
|
|
|
], |
|
|
|
|
]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#[\PHPUnit\Framework\Attributes\DataProvider(methodName: 'tagNodeProvider')] |
|
|
|
|
public function testUpdateTag(bool $isAdmin, ISystemTag $originalTag, array $changedArgs): void { |
|
|
|
|
$this->tagManager->expects($this->once()) |
|
|
|
|
->method('canUserSeeTag') |
|
|
|
|
public function testUpdateTag(bool $isAdmin, ISystemTag $originalTag, $changedArgs, $allowed): void { |
|
|
|
|
$this->tagManager->method('canUserSeeTag') |
|
|
|
|
->with($originalTag) |
|
|
|
|
->willReturn($originalTag->isUserVisible() || $isAdmin); |
|
|
|
|
$this->tagManager->expects($this->once()) |
|
|
|
|
->method('canUserAssignTag') |
|
|
|
|
$this->tagManager->method('canUserAssignTag') |
|
|
|
|
->with($originalTag) |
|
|
|
|
->willReturn($originalTag->isUserAssignable() || $isAdmin); |
|
|
|
|
$this->tagManager->expects($this->once()) |
|
|
|
|
->method('updateTag') |
|
|
|
|
->with(1, $changedArgs[0], $changedArgs[1], $changedArgs[2], $changedArgs[3]); |
|
|
|
|
if ($allowed) { |
|
|
|
|
$this->tagManager->expects($this->once()) |
|
|
|
|
->method('updateTag') |
|
|
|
|
->with(1, $changedArgs[0], $changedArgs[1], $changedArgs[2], $changedArgs[3]); |
|
|
|
|
} else { |
|
|
|
|
$this->expectException(\Sabre\DAV\Exception\Forbidden::class); |
|
|
|
|
$this->tagManager->expects($this->never()) |
|
|
|
|
->method('updateTag'); |
|
|
|
|
} |
|
|
|
|
$this->getTagNode($isAdmin, $originalTag) |
|
|
|
|
->update($changedArgs[0], $changedArgs[1], $changedArgs[2], $changedArgs[3]); |
|
|
|
|
} |
|
|
|
|
@ -186,7 +193,7 @@ class SystemTagNodeTest extends \Test\TestCase { |
|
|
|
|
->method('updateTag') |
|
|
|
|
->with(1, 'Renamed', true, true) |
|
|
|
|
->willThrowException(new TagAlreadyExistsException()); |
|
|
|
|
$this->getTagNode(false, $tag)->update('Renamed', true, true, null); |
|
|
|
|
$this->getTagNode(true, $tag)->update('Renamed', true, true, null); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function testUpdateTagNotFound(): void { |
|
|
|
|
@ -205,7 +212,7 @@ class SystemTagNodeTest extends \Test\TestCase { |
|
|
|
|
->method('updateTag') |
|
|
|
|
->with(1, 'Renamed', true, true) |
|
|
|
|
->willThrowException(new TagNotFoundException()); |
|
|
|
|
$this->getTagNode(false, $tag)->update('Renamed', true, true, null); |
|
|
|
|
$this->getTagNode(true, $tag)->update('Renamed', true, true, null); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#[\PHPUnit\Framework\Attributes\DataProvider(methodName: 'adminFlagProvider')] |
|
|
|
|
|