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