|
32 | 32 | use OCA\WorkflowEngine\Helper\ScopeContext; |
33 | 33 | use OCA\WorkflowEngine\Manager; |
34 | 34 | use OCP\AppFramework\QueryException; |
| 35 | +use OCP\EventDispatcher\Event; |
35 | 36 | use OCP\EventDispatcher\IEventDispatcher; |
36 | 37 | use OCP\Files\Events\Node\NodeCreatedEvent; |
37 | 38 | use OCP\Files\IRootFolder; |
|
52 | 53 | use OCP\WorkflowEngine\IEntityEvent; |
53 | 54 | use OCP\WorkflowEngine\IManager; |
54 | 55 | use OCP\WorkflowEngine\IOperation; |
| 56 | +use OCP\WorkflowEngine\IRuleMatcher; |
55 | 57 | use PHPUnit\Framework\MockObject\MockObject; |
56 | 58 | use Psr\Log\LoggerInterface; |
57 | 59 | use Test\TestCase; |
58 | 60 |
|
| 61 | +class TestAdminOp implements IOperation { |
| 62 | + public function getDisplayName(): string { |
| 63 | + return 'Admin'; |
| 64 | + } |
| 65 | + |
| 66 | + public function getDescription(): string { |
| 67 | + return ''; |
| 68 | + } |
| 69 | + |
| 70 | + public function getIcon(): string { |
| 71 | + return ''; |
| 72 | + } |
| 73 | + |
| 74 | + public function isAvailableForScope(int $scope): bool { |
| 75 | + return true; |
| 76 | + } |
| 77 | + |
| 78 | + public function validateOperation(string $name, array $checks, string $operation): void { |
| 79 | + } |
| 80 | + |
| 81 | + public function onEvent(string $eventName, Event $event, IRuleMatcher $ruleMatcher): void { |
| 82 | + } |
| 83 | +} |
| 84 | + |
| 85 | +class TestUserOp extends TestAdminOp { |
| 86 | + public function getDisplayName(): string { |
| 87 | + return 'User'; |
| 88 | + } |
| 89 | +} |
| 90 | + |
59 | 91 | /** |
60 | 92 | * Class ManagerTest |
61 | 93 | * |
@@ -420,19 +452,19 @@ public function testUpdateOperation() { |
420 | 452 | $opId1 = $this->invokePrivate( |
421 | 453 | $this->manager, |
422 | 454 | 'insertOperation', |
423 | | - ['OCA\WFE\TestAdminOp', 'Test01', [11, 22], 'foo', $entity, []] |
| 455 | + [TestAdminOp::class, 'Test01', [11, 22], 'foo', $entity, []] |
424 | 456 | ); |
425 | 457 | $this->invokePrivate($this->manager, 'addScope', [$opId1, $adminScope]); |
426 | 458 |
|
427 | 459 | $opId2 = $this->invokePrivate( |
428 | 460 | $this->manager, |
429 | 461 | 'insertOperation', |
430 | | - ['OCA\WFE\TestUserOp', 'Test02', [33, 22], 'bar', $entity, []] |
| 462 | + [TestUserOp::class, 'Test02', [33, 22], 'bar', $entity, []] |
431 | 463 | ); |
432 | 464 | $this->invokePrivate($this->manager, 'addScope', [$opId2, $userScope]); |
433 | 465 |
|
434 | | - $check1 = ['class' => 'OCA\WFE\C22', 'operator' => 'eq', 'value' => 'asdf']; |
435 | | - $check2 = ['class' => 'OCA\WFE\C33', 'operator' => 'eq', 'value' => 23456]; |
| 466 | + $check1 = ['class' => ICheck::class, 'operator' => 'eq', 'value' => 'asdf']; |
| 467 | + $check2 = ['class' => ICheck::class, 'operator' => 'eq', 'value' => 23456]; |
436 | 468 |
|
437 | 469 | /** @noinspection PhpUnhandledExceptionInspection */ |
438 | 470 | $op = $this->manager->updateOperation($opId1, 'Test01a', [$check1, $check2], 'foohur', $adminScope, $entity, ['\OCP\Files::postDelete']); |
@@ -695,11 +727,6 @@ public function testValidateOperationDataLengthError() { |
695 | 727 | ->method('getScope') |
696 | 728 | ->willReturn(IManager::SCOPE_ADMIN); |
697 | 729 |
|
698 | | - $operationMock->expects($this->once()) |
699 | | - ->method('isAvailableForScope') |
700 | | - ->with(IManager::SCOPE_ADMIN) |
701 | | - ->willReturn(true); |
702 | | - |
703 | 730 | $operationMock->expects($this->never()) |
704 | 731 | ->method('validateOperation'); |
705 | 732 |
|
@@ -747,7 +774,7 @@ public function testValidateOperationScopeNotAvailable() { |
747 | 774 | 'operator' => 'is', |
748 | 775 | 'value' => 'barfoo', |
749 | 776 | ]; |
750 | | - $operationData = str_pad('', IManager::MAX_OPERATION_VALUE_BYTES + 1, 'FooBar'); |
| 777 | + $operationData = str_pad('', IManager::MAX_OPERATION_VALUE_BYTES - 1, 'FooBar'); |
751 | 778 |
|
752 | 779 | $operationMock = $this->createMock(IOperation::class); |
753 | 780 | $entityMock = $this->createMock(IEntity::class); |
|
0 commit comments