| @@ 752-786 (lines=35) @@ | ||
| 749 | * @depends eZ\Publish\API\Repository\Tests\PermissionServiceTest::testHasAccessLimited |
|
| 750 | * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
|
| 751 | */ |
|
| 752 | public function testCanUserWithTargetThrowsInvalidArgumentExceptionVariant() |
|
| 753 | { |
|
| 754 | $repository = $this->getRepository(); |
|
| 755 | ||
| 756 | /* BEGIN: Use Case */ |
|
| 757 | $user = $this->createUserVersion1(); |
|
| 758 | ||
| 759 | $permissionService = $repository->getPermissionService(); |
|
| 760 | ||
| 761 | // Set created user as current user reference |
|
| 762 | $permissionService->setCurrentUserReference($user); |
|
| 763 | ||
| 764 | $contentTypeService = $repository->getContentTypeService(); |
|
| 765 | ||
| 766 | $contentType = $contentTypeService->loadContentTypeByIdentifier('forum'); |
|
| 767 | ||
| 768 | $contentService = $repository->getContentService(); |
|
| 769 | ||
| 770 | $contentCreateStruct = $contentService->newContentCreateStruct($contentType, 'eng-US'); |
|
| 771 | $contentCreateStruct->setField('name', 'My awesome forum'); |
|
| 772 | $contentCreateStruct->remoteId = 'abcdef0123456789abcdef0123456789'; |
|
| 773 | $contentCreateStruct->alwaysAvailable = true; |
|
| 774 | ||
| 775 | $urlAliasService = $repository->getURLAliasService(); |
|
| 776 | $rootUrlAlias = $urlAliasService->lookup('/'); |
|
| 777 | ||
| 778 | // This call will throw "InvalidArgumentException" because $rootAlias is not a valid target object |
|
| 779 | $canUser = $permissionService->canUser( |
|
| 780 | 'content', |
|
| 781 | 'create', |
|
| 782 | $contentCreateStruct, |
|
| 783 | $rootUrlAlias |
|
| 784 | ); |
|
| 785 | /* END: Use Case */ |
|
| 786 | } |
|
| 787 | ||
| 788 | /** |
|
| 789 | * Test for the canUser() method. |
|
| @@ 1013-1045 (lines=33) @@ | ||
| 1010 | * @depends eZ\Publish\API\Repository\Tests\RepositoryTest::testHasAccessLimited |
|
| 1011 | * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
|
| 1012 | */ |
|
| 1013 | public function testCanUserWithTargetThrowsInvalidArgumentExceptionVariant() |
|
| 1014 | { |
|
| 1015 | $repository = $this->getRepository(); |
|
| 1016 | ||
| 1017 | /* BEGIN: Use Case */ |
|
| 1018 | $user = $this->createUserVersion1(); |
|
| 1019 | ||
| 1020 | // Set created user as current user |
|
| 1021 | $repository->setCurrentUser($user); |
|
| 1022 | ||
| 1023 | $contentTypeService = $repository->getContentTypeService(); |
|
| 1024 | ||
| 1025 | $contentType = $contentTypeService->loadContentTypeByIdentifier('forum'); |
|
| 1026 | ||
| 1027 | $contentService = $repository->getContentService(); |
|
| 1028 | ||
| 1029 | $contentCreateStruct = $contentService->newContentCreateStruct($contentType, 'eng-US'); |
|
| 1030 | $contentCreateStruct->setField('name', 'My awesome forum'); |
|
| 1031 | $contentCreateStruct->remoteId = 'abcdef0123456789abcdef0123456789'; |
|
| 1032 | $contentCreateStruct->alwaysAvailable = true; |
|
| 1033 | ||
| 1034 | $urlAliasService = $repository->getURLAliasService(); |
|
| 1035 | $rootUrlAlias = $urlAliasService->lookUp('/'); |
|
| 1036 | ||
| 1037 | // This call will throw "InvalidArgumentException" because $rootAlias is not a valid target object |
|
| 1038 | $canUser = $repository->canUser( |
|
| 1039 | 'content', |
|
| 1040 | 'create', |
|
| 1041 | $contentCreateStruct, |
|
| 1042 | $rootUrlAlias |
|
| 1043 | ); |
|
| 1044 | /* END: Use Case */ |
|
| 1045 | } |
|
| 1046 | ||
| 1047 | /** |
|
| 1048 | * Test for the canUser() method. |
|