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