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