| @@ 716-750 (lines=35) @@ | ||
| 713 | * @depends eZ\Publish\API\Repository\Tests\PermissionResolverTest::testHasAccessLimited |
|
| 714 | * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
|
| 715 | */ |
|
| 716 | public function testCanUserWithTargetThrowsInvalidArgumentException() |
|
| 717 | { |
|
| 718 | $repository = $this->getRepository(); |
|
| 719 | ||
| 720 | /* BEGIN: Use Case */ |
|
| 721 | $user = $this->createUserVersion1(); |
|
| 722 | ||
| 723 | $permissionResolver = $repository->getPermissionResolver(); |
|
| 724 | ||
| 725 | // Set created user as current user reference |
|
| 726 | $permissionResolver->setCurrentUserReference($user); |
|
| 727 | ||
| 728 | $contentTypeService = $repository->getContentTypeService(); |
|
| 729 | ||
| 730 | $contentType = $contentTypeService->loadContentTypeByIdentifier('forum'); |
|
| 731 | ||
| 732 | $contentService = $repository->getContentService(); |
|
| 733 | ||
| 734 | $contentCreateStruct = $contentService->newContentCreateStruct($contentType, 'eng-US'); |
|
| 735 | $contentCreateStruct->setField('name', 'My awesome forum'); |
|
| 736 | $contentCreateStruct->remoteId = 'abcdef0123456789abcdef0123456789'; |
|
| 737 | $contentCreateStruct->alwaysAvailable = true; |
|
| 738 | ||
| 739 | $urlAliasService = $repository->getURLAliasService(); |
|
| 740 | $rootUrlAlias = $urlAliasService->lookup('/'); |
|
| 741 | ||
| 742 | // This call will throw "InvalidArgumentException" because $rootAlias is not a valid target object |
|
| 743 | $canUser = $permissionResolver->canUser( |
|
| 744 | 'content', |
|
| 745 | 'create', |
|
| 746 | $contentCreateStruct, |
|
| 747 | [$rootUrlAlias] |
|
| 748 | ); |
|
| 749 | /* END: Use Case */ |
|
| 750 | } |
|
| 751 | ||
| 752 | /** |
|
| 753 | * Test for the canUser() method. |
|
| @@ 1037-1069 (lines=33) @@ | ||
| 1034 | * @depends eZ\Publish\API\Repository\Tests\RepositoryTest::testHasAccessLimited |
|
| 1035 | * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
|
| 1036 | */ |
|
| 1037 | public function testCanUserWithTargetThrowsInvalidArgumentExceptionVariant() |
|
| 1038 | { |
|
| 1039 | $repository = $this->getRepository(); |
|
| 1040 | ||
| 1041 | /* BEGIN: Use Case */ |
|
| 1042 | $user = $this->createUserVersion1(); |
|
| 1043 | ||
| 1044 | // Set created user as current user |
|
| 1045 | $repository->setCurrentUser($user); |
|
| 1046 | ||
| 1047 | $contentTypeService = $repository->getContentTypeService(); |
|
| 1048 | ||
| 1049 | $contentType = $contentTypeService->loadContentTypeByIdentifier('forum'); |
|
| 1050 | ||
| 1051 | $contentService = $repository->getContentService(); |
|
| 1052 | ||
| 1053 | $contentCreateStruct = $contentService->newContentCreateStruct($contentType, 'eng-US'); |
|
| 1054 | $contentCreateStruct->setField('name', 'My awesome forum'); |
|
| 1055 | $contentCreateStruct->remoteId = 'abcdef0123456789abcdef0123456789'; |
|
| 1056 | $contentCreateStruct->alwaysAvailable = true; |
|
| 1057 | ||
| 1058 | $urlAliasService = $repository->getURLAliasService(); |
|
| 1059 | $rootUrlAlias = $urlAliasService->lookUp('/'); |
|
| 1060 | ||
| 1061 | // This call will throw "InvalidArgumentException" because $rootAlias is not a valid target object |
|
| 1062 | $canUser = $repository->canUser( |
|
| 1063 | 'content', |
|
| 1064 | 'create', |
|
| 1065 | $contentCreateStruct, |
|
| 1066 | $rootUrlAlias |
|
| 1067 | ); |
|
| 1068 | /* END: Use Case */ |
|
| 1069 | } |
|
| 1070 | ||
| 1071 | /** |
|
| 1072 | * Test for the canUser() method. |
|