|
33 | 33 | use OCP\WorkflowEngine\IEntityEvent; |
34 | 34 | use OCP\WorkflowEngine\IManager; |
35 | 35 | use OCP\WorkflowEngine\IOperation; |
| 36 | +use OCP\WorkflowEngine\IRuleMatcher; |
36 | 37 | use PHPUnit\Framework\MockObject\MockObject; |
37 | 38 | use Psr\Log\LoggerInterface; |
38 | 39 | use Test\TestCase; |
39 | 40 |
|
| 41 | +class TestAdminOp implements IOperation { |
| 42 | + public function getDisplayName(): string { |
| 43 | + return 'Admin'; |
| 44 | + } |
| 45 | + |
| 46 | + public function getDescription(): string { |
| 47 | + return ''; |
| 48 | + } |
| 49 | + |
| 50 | + public function getIcon(): string { |
| 51 | + return ''; |
| 52 | + } |
| 53 | + |
| 54 | + public function isAvailableForScope(int $scope): bool { |
| 55 | + return true; |
| 56 | + } |
| 57 | + |
| 58 | + public function validateOperation(string $name, array $checks, string $operation): void { |
| 59 | + } |
| 60 | + |
| 61 | + public function onEvent(string $eventName, Event $event, IRuleMatcher $ruleMatcher): void { |
| 62 | + } |
| 63 | +} |
| 64 | + |
| 65 | +class TestUserOp extends TestAdminOp { |
| 66 | + public function getDisplayName(): string { |
| 67 | + return 'User'; |
| 68 | + } |
| 69 | +} |
| 70 | + |
40 | 71 | /** |
41 | 72 | * Class ManagerTest |
42 | 73 | * |
@@ -407,19 +438,19 @@ public function testUpdateOperation(): void { |
407 | 438 | $opId1 = $this->invokePrivate( |
408 | 439 | $this->manager, |
409 | 440 | 'insertOperation', |
410 | | - ['OCA\WFE\TestAdminOp', 'Test01', [11, 22], 'foo', $entity, []] |
| 441 | + [TestAdminOp::class, 'Test01', [11, 22], 'foo', $entity, []] |
411 | 442 | ); |
412 | 443 | $this->invokePrivate($this->manager, 'addScope', [$opId1, $adminScope]); |
413 | 444 |
|
414 | 445 | $opId2 = $this->invokePrivate( |
415 | 446 | $this->manager, |
416 | 447 | 'insertOperation', |
417 | | - ['OCA\WFE\TestUserOp', 'Test02', [33, 22], 'bar', $entity, []] |
| 448 | + [TestUserOp::class, 'Test02', [33, 22], 'bar', $entity, []] |
418 | 449 | ); |
419 | 450 | $this->invokePrivate($this->manager, 'addScope', [$opId2, $userScope]); |
420 | 451 |
|
421 | | - $check1 = ['class' => 'OCA\WFE\C22', 'operator' => 'eq', 'value' => 'asdf']; |
422 | | - $check2 = ['class' => 'OCA\WFE\C33', 'operator' => 'eq', 'value' => 23456]; |
| 452 | + $check1 = ['class' => ICheck::class, 'operator' => 'eq', 'value' => 'asdf']; |
| 453 | + $check2 = ['class' => ICheck::class, 'operator' => 'eq', 'value' => 23456]; |
423 | 454 |
|
424 | 455 | /** @noinspection PhpUnhandledExceptionInspection */ |
425 | 456 | $op = $this->manager->updateOperation($opId1, 'Test01a', [$check1, $check2], 'foohur', $adminScope, $entity, ['\OCP\Files::postDelete']); |
@@ -682,11 +713,6 @@ public function testValidateOperationDataLengthError(): void { |
682 | 713 | ->method('getScope') |
683 | 714 | ->willReturn(IManager::SCOPE_ADMIN); |
684 | 715 |
|
685 | | - $operationMock->expects($this->once()) |
686 | | - ->method('isAvailableForScope') |
687 | | - ->with(IManager::SCOPE_ADMIN) |
688 | | - ->willReturn(true); |
689 | | - |
690 | 716 | $operationMock->expects($this->never()) |
691 | 717 | ->method('validateOperation'); |
692 | 718 |
|
@@ -734,7 +760,7 @@ public function testValidateOperationScopeNotAvailable(): void { |
734 | 760 | 'operator' => 'is', |
735 | 761 | 'value' => 'barfoo', |
736 | 762 | ]; |
737 | | - $operationData = str_pad('', IManager::MAX_OPERATION_VALUE_BYTES + 1, 'FooBar'); |
| 763 | + $operationData = str_pad('', IManager::MAX_OPERATION_VALUE_BYTES - 1, 'FooBar'); |
738 | 764 |
|
739 | 765 | $operationMock = $this->createMock(IOperation::class); |
740 | 766 | $entityMock = $this->createMock(IEntity::class); |
|
0 commit comments