|
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; |
|
32 | 33 | use OCP\WorkflowEngine\IEntityEvent; |
33 | 34 | use OCP\WorkflowEngine\IManager; |
34 | 35 | use OCP\WorkflowEngine\IOperation; |
| 36 | +use OCP\WorkflowEngine\IRuleMatcher; |
35 | 37 | use PHPUnit\Framework\MockObject\MockObject; |
36 | 38 | use Psr\Log\LoggerInterface; |
37 | 39 | use Test\TestCase; |
38 | 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 | + |
39 | 71 | /** |
40 | 72 | * Class ManagerTest |
41 | 73 | * |
@@ -400,19 +432,19 @@ public function testUpdateOperation() { |
400 | 432 | $opId1 = $this->invokePrivate( |
401 | 433 | $this->manager, |
402 | 434 | 'insertOperation', |
403 | | - ['OCA\WFE\TestAdminOp', 'Test01', [11, 22], 'foo', $entity, []] |
| 435 | + [TestAdminOp::class, 'Test01', [11, 22], 'foo', $entity, []] |
404 | 436 | ); |
405 | 437 | $this->invokePrivate($this->manager, 'addScope', [$opId1, $adminScope]); |
406 | 438 |
|
407 | 439 | $opId2 = $this->invokePrivate( |
408 | 440 | $this->manager, |
409 | 441 | 'insertOperation', |
410 | | - ['OCA\WFE\TestUserOp', 'Test02', [33, 22], 'bar', $entity, []] |
| 442 | + [TestUserOp::class, 'Test02', [33, 22], 'bar', $entity, []] |
411 | 443 | ); |
412 | 444 | $this->invokePrivate($this->manager, 'addScope', [$opId2, $userScope]); |
413 | 445 |
|
414 | | - $check1 = ['class' => 'OCA\WFE\C22', 'operator' => 'eq', 'value' => 'asdf']; |
415 | | - $check2 = ['class' => 'OCA\WFE\C33', 'operator' => 'eq', 'value' => 23456]; |
| 446 | + $check1 = ['class' => ICheck::class, 'operator' => 'eq', 'value' => 'asdf']; |
| 447 | + $check2 = ['class' => ICheck::class, 'operator' => 'eq', 'value' => 23456]; |
416 | 448 |
|
417 | 449 | /** @noinspection PhpUnhandledExceptionInspection */ |
418 | 450 | $op = $this->manager->updateOperation($opId1, 'Test01a', [$check1, $check2], 'foohur', $adminScope, $entity, ['\OCP\Files::postDelete']); |
@@ -675,11 +707,6 @@ public function testValidateOperationDataLengthError() { |
675 | 707 | ->method('getScope') |
676 | 708 | ->willReturn(IManager::SCOPE_ADMIN); |
677 | 709 |
|
678 | | - $operationMock->expects($this->once()) |
679 | | - ->method('isAvailableForScope') |
680 | | - ->with(IManager::SCOPE_ADMIN) |
681 | | - ->willReturn(true); |
682 | | - |
683 | 710 | $operationMock->expects($this->never()) |
684 | 711 | ->method('validateOperation'); |
685 | 712 |
|
@@ -727,7 +754,7 @@ public function testValidateOperationScopeNotAvailable() { |
727 | 754 | 'operator' => 'is', |
728 | 755 | 'value' => 'barfoo', |
729 | 756 | ]; |
730 | | - $operationData = str_pad('', IManager::MAX_OPERATION_VALUE_BYTES + 1, 'FooBar'); |
| 757 | + $operationData = str_pad('', IManager::MAX_OPERATION_VALUE_BYTES - 1, 'FooBar'); |
731 | 758 |
|
732 | 759 | $operationMock = $this->createMock(IOperation::class); |
733 | 760 | $entityMock = $this->createMock(IEntity::class); |
|
0 commit comments