| @@ 710-744 (lines=35) @@ | ||
| 707 | * @depends eZ\Publish\API\Repository\Tests\PermissionResolverTest::testHasAccessLimited |
|
| 708 | * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
|
| 709 | */ |
|
| 710 | public function testCanUserWithTargetThrowsInvalidArgumentException() |
|
| 711 | { |
|
| 712 | $repository = $this->getRepository(); |
|
| 713 | ||
| 714 | /* BEGIN: Use Case */ |
|
| 715 | $user = $this->createUserVersion1(); |
|
| 716 | ||
| 717 | $permissionResolver = $repository->getPermissionResolver(); |
|
| 718 | ||
| 719 | // Set created user as current user reference |
|
| 720 | $permissionResolver->setCurrentUserReference($user); |
|
| 721 | ||
| 722 | $contentTypeService = $repository->getContentTypeService(); |
|
| 723 | ||
| 724 | $contentType = $contentTypeService->loadContentTypeByIdentifier('forum'); |
|
| 725 | ||
| 726 | $contentService = $repository->getContentService(); |
|
| 727 | ||
| 728 | $contentCreateStruct = $contentService->newContentCreateStruct($contentType, 'eng-US'); |
|
| 729 | $contentCreateStruct->setField('name', 'My awesome forum'); |
|
| 730 | $contentCreateStruct->remoteId = 'abcdef0123456789abcdef0123456789'; |
|
| 731 | $contentCreateStruct->alwaysAvailable = true; |
|
| 732 | ||
| 733 | $urlAliasService = $repository->getURLAliasService(); |
|
| 734 | $rootUrlAlias = $urlAliasService->lookup('/'); |
|
| 735 | ||
| 736 | // This call will throw "InvalidArgumentException" because $rootAlias is not a valid target object |
|
| 737 | $canUser = $permissionResolver->canUser( |
|
| 738 | 'content', |
|
| 739 | 'create', |
|
| 740 | $contentCreateStruct, |
|
| 741 | [$rootUrlAlias] |
|
| 742 | ); |
|
| 743 | /* END: Use Case */ |
|
| 744 | } |
|
| 745 | ||
| 746 | /** |
|
| 747 | * 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. |
|