| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * @copyright Copyright (C) eZ Systems AS. All rights reserved. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * @license For full copyright and license information view LICENSE file distributed with this source code. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | namespace eZ\Publish\API\Repository\Tests; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | use eZ\Publish\API\Repository\Exceptions\UnauthorizedException; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | use eZ\Publish\API\Repository\Repository; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | use eZ\Publish\API\Repository\Values\Content\ContentInfo; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | use eZ\Publish\API\Repository\Values\Content\Location; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | use eZ\Publish\API\Repository\Values\User\Limitation\LocationLimitation; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | use eZ\Publish\API\Repository\Values\User\Limitation\SubtreeLimitation; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |  * Test case for operations in the ContentServiceAuthorization using in memory storage. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |  * @see eZ\Publish\API\Repository\ContentService | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |  * @depends eZ\Publish\API\Repository\Tests\UserServiceTest::testLoadAnonymousUser | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |  * @group integration | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |  * @group authorization | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  | class ContentServiceAuthorizationTest extends BaseContentServiceTest | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |     /** @var \eZ\Publish\API\Repository\Values\User\User */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |     private $administratorUser; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |     /** @var \eZ\Publish\API\Repository\Values\User\User */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |     private $anonymousUser; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |     /** @var \eZ\Publish\API\Repository\Repository */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |     private $repository; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |     /** @var \eZ\Publish\API\Repository\PermissionResolver */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |     private $permissionResolver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |     /** @var \eZ\Publish\API\Repository\UserService */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |     private $userService; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |     /** @var \eZ\Publish\API\Repository\ContentService */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |     private $contentService; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |     public function setUp(): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |         parent::setUp(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |         $anonymousUserId = $this->generateId('user', 10); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |         $administratorUserId = $this->generateId('user', 14); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |         $this->repository = $this->getRepository(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |         $this->permissionResolver = $this->repository->getPermissionResolver(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |         $this->userService = $this->repository->getUserService(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |         $this->contentService = $this->repository->getContentService(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |         $this->administratorUser = $this->userService->loadUser($administratorUserId); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |         $this->anonymousUser = $this->userService->loadUser($anonymousUserId); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |      * Test for the createContent() method. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |      * @see \eZ\Publish\API\Repository\ContentService::createContent() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |      * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContent | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |      */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 66 |  | View Code Duplication |     public function testCreateContentThrowsUnauthorizedException() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |         $this->permissionResolver->setCurrentUserReference($this->anonymousUser); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |         $contentTypeService = $this->getRepository()->getContentTypeService(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |         $contentType = $contentTypeService->loadContentTypeByIdentifier('forum'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |         $contentCreate = $this->contentService->newContentCreateStruct($contentType, 'eng-US'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |         $contentCreate->setField('name', 'Awesome Sindelfingen forum'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |         $contentCreate->remoteId = 'abcdef0123456789abcdef0123456789'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |         $contentCreate->alwaysAvailable = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |         $this->expectException(UnauthorizedException::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |         $this->expectExceptionMessageRegExp('/\'create\' \'content\'/'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |         $this->contentService->createContent($contentCreate); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |      * Test for the createContent() method. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |      * @see \eZ\Publish\API\Repository\ContentService::createContent($contentCreateStruct, $locationCreateStructs) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |      * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContent | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |     public function testCreateContentThrowsUnauthorizedExceptionWithSecondParameter() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |         $this->permissionResolver->setCurrentUserReference($this->anonymousUser); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |         $this->expectException(UnauthorizedException::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |         $this->expectExceptionMessageRegExp('/\'create\' \'content\'/'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |         $this->createContentDraftVersion1(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |      * Test for the loadContentInfo() method. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |      * @see \eZ\Publish\API\Repository\ContentService::loadContentInfo() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |      * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentInfo | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |      */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 108 |  | View Code Duplication |     public function testLoadContentInfoThrowsUnauthorizedException() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |         $contentId = $this->generateId('object', 10); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |         $this->setRestrictedEditorUser(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |         $this->expectException(UnauthorizedException::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |         $this->expectExceptionMessageRegExp('/\'read\' \'content\'/'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |         // $contentId contains a content object ID not accessible for anonymous | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |         $this->contentService->loadContentInfo($contentId); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |      * Test for the sudo() method. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |      * @see \eZ\Publish\API\Repository\Repository::sudo() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |      * @depends testLoadContentInfoThrowsUnauthorizedException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |     public function testSudo() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |         $repository = $this->getRepository(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |         $contentId = $this->generateId('object', 10); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |         $this->setRestrictedEditorUser(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |         $contentInfo = $repository->sudo(function (Repository $repository) use ($contentId) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |             return $repository->getContentService()->loadContentInfo($contentId); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  |         }); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |         $this->assertInstanceOf( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |             ContentInfo::class, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |             $contentInfo | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  |      * Test for the loadContentInfoList() method. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |      * @see \eZ\Publish\API\Repository\ContentService::loadContentInfoList() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  |      * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentInfoList | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  |     public function testLoadContentInfoListSkipsUnauthorizedItems() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  |         $contentId = $this->generateId('object', 10); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |         $this->setRestrictedEditorUser(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  |         $this->assertCount(0, $this->contentService->loadContentInfoList([$contentId])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  |      * Test for the loadContentInfoByRemoteId() method. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  |      * @see \eZ\Publish\API\Repository\ContentService::loadContentInfoByRemoteId() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  |      * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentInfoByRemoteId | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  |      */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 162 |  | View Code Duplication |     public function testLoadContentInfoByRemoteIdThrowsUnauthorizedException() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  |         $anonymousRemoteId = 'faaeb9be3bd98ed09f606fc16d144eca'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  |         $this->setRestrictedEditorUser(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  |         $this->expectException(UnauthorizedException::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  |         $this->expectExceptionMessageRegExp('/\'read\' \'content\'/'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  |         $this->contentService->loadContentInfoByRemoteId($anonymousRemoteId); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  |      * Test for the loadVersionInfo() method. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  |      * @see \eZ\Publish\API\Repository\ContentService::loadVersionInfo() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  |      * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadVersionInfo | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  |     public function testLoadVersionInfoThrowsUnauthorizedException() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  |         $contentInfo = $this->getContentInfoForAnonymousUser(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  |         $this->setRestrictedEditorUser(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  |         $this->expectException(UnauthorizedException::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  |         $this->expectExceptionMessageRegExp('/\'read\' \'content\'/'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  |         $this->contentService->loadVersionInfo($contentInfo); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  |      * Test for the loadVersionInfo() method. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  |      * @see \eZ\Publish\API\Repository\ContentService::loadVersionInfo($contentInfo, $versionNo) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 |  |  |      * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadVersionInfoWithSecondParameter | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 |  |  |     public function testLoadVersionInfoThrowsUnauthorizedExceptionWithSecondParameter() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  |         $contentInfo = $this->getContentInfoForAnonymousUser(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 |  |  |         $this->setRestrictedEditorUser(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 |  |  |         $this->expectException(UnauthorizedException::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 |  |  |         $this->expectExceptionMessageRegExp('/\'read\' \'content\'/'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 |  |  |         $this->contentService->loadVersionInfo($contentInfo, 2); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 |  |  |      * Test for the loadVersionInfoById() method. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 |  |  |      * @see \eZ\Publish\API\Repository\ContentService::loadVersionInfoById() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 |  |  |      * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadVersionInfoById | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 |  |  |      */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 216 |  | View Code Duplication |     public function testLoadVersionInfoByIdThrowsUnauthorizedException() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 |  |  |         $anonymousUserId = $this->generateId('user', 10); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 |  |  |         $this->setRestrictedEditorUser(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 |  |  |         $this->expectException(UnauthorizedException::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 |  |  |         $this->expectExceptionMessageRegExp('/\'read\' \'content\'/'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 |  |  |         $this->contentService->loadVersionInfoById($anonymousUserId); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 226 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 227 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 228 |  |  |      * Test for the loadVersionInfoById() method. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 229 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 230 |  |  |      * @see \eZ\Publish\API\Repository\ContentService::loadVersionInfoById($contentId, $versionNo) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 231 |  |  |      * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadVersionInfoByIdWithSecondParameter | 
            
                                                                                                            
                            
            
                                    
            
            
                | 232 |  |  |      */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 233 |  | View Code Duplication |     public function testLoadVersionInfoByIdThrowsUnauthorizedExceptionWithSecondParameter() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 234 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 235 |  |  |         $anonymousUserId = $this->generateId('user', 10); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 236 |  |  |         $this->setRestrictedEditorUser(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 237 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 238 |  |  |         $this->expectException(UnauthorizedException::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 239 |  |  |         $this->expectExceptionMessageRegExp('/\'read\' \'content\'/'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 240 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 241 |  |  |         $this->contentService->loadVersionInfoById($anonymousUserId, 2); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 242 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 243 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 244 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 245 |  |  |      * Test for the loadVersionInfoById() method. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 246 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 247 |  |  |      * @see \eZ\Publish\API\Repository\ContentService::loadVersionInfoById($contentId, $versionNo) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 248 |  |  |      * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadVersionInfoById | 
            
                                                                                                            
                            
            
                                    
            
            
                | 249 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 250 |  |  |     public function testLoadVersionInfoByIdThrowsUnauthorizedExceptionForFirstDraft() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 251 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 252 |  |  |         $contentDraft = $this->createContentDraftVersion1(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 253 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 254 |  |  |         $this->permissionResolver->setCurrentUserReference($this->anonymousUser); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 255 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 256 |  |  |         $this->expectException(UnauthorizedException::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 257 |  |  |         // content versionread policy is needed because it is a draft | 
            
                                                                                                            
                            
            
                                    
            
            
                | 258 |  |  |         $this->expectExceptionMessageRegExp('/\'versionread\' \'content\'/'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 259 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 260 |  |  |         $this->contentService->loadVersionInfoById( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 261 |  |  |             $contentDraft->id, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 262 |  |  |             $contentDraft->contentInfo->currentVersionNo | 
            
                                                                                                            
                            
            
                                    
            
            
                | 263 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 264 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 265 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 266 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 267 |  |  |      * Test for the loadContentByContentInfo() method. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 268 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 269 |  |  |      * @see \eZ\Publish\API\Repository\ContentService::loadContentByContentInfo() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 270 |  |  |      * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentByContentInfo | 
            
                                                                                                            
                            
            
                                    
            
            
                | 271 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 272 |  |  |     public function testLoadContentByContentInfoThrowsUnauthorizedException() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 273 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 274 |  |  |         $contentInfo = $this->getContentInfoForAnonymousUser(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 275 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 276 |  |  |         $this->setRestrictedEditorUser(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 277 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 278 |  |  |         $this->expectException(UnauthorizedException::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 279 |  |  |         $this->expectExceptionMessageRegExp('/\'read\' \'content\'/'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 280 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 281 |  |  |         $this->contentService->loadContentByContentInfo($contentInfo); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 282 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 283 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 284 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 285 |  |  |      * Test for the loadContentByContentInfo() method. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 286 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 287 |  |  |      * @see \eZ\Publish\API\Repository\ContentService::loadContentByContentInfo($contentInfo, $languages) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 288 |  |  |      * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentByContentInfoWithLanguageParameters | 
            
                                                                                                            
                            
            
                                    
            
            
                | 289 |  |  |      */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 290 |  | View Code Duplication |     public function testLoadContentByContentInfoThrowsUnauthorizedExceptionWithSecondParameter() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 291 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 292 |  |  |         $contentInfo = $this->getContentInfoForAnonymousUser(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 293 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 294 |  |  |         $this->setRestrictedEditorUser(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 295 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 296 |  |  |         $this->expectException(UnauthorizedException::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 297 |  |  |         $this->expectExceptionMessageRegExp('/\'read\' \'content\'/'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 298 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 299 |  |  |         $this->contentService->loadContentByContentInfo($contentInfo, ['eng-US']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 300 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 301 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 302 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 303 |  |  |      * Test for the loadContentByContentInfo() method. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 304 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 305 |  |  |      * @see \eZ\Publish\API\Repository\ContentService::loadContentByContentInfo($contentInfo, $languages, $versionNo) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 306 |  |  |      * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentByContentInfoWithVersionNumberParameter | 
            
                                                                                                            
                            
            
                                    
            
            
                | 307 |  |  |      */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 308 |  | View Code Duplication |     public function testLoadContentByContentInfoThrowsUnauthorizedExceptionWithThirdParameter() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 309 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 310 |  |  |         $contentInfo = $this->getContentInfoForAnonymousUser(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 311 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 312 |  |  |         $this->setRestrictedEditorUser(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 313 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 314 |  |  |         $this->expectException(UnauthorizedException::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 315 |  |  |         $this->expectExceptionMessageRegExp('/\'read\' \'content\'/'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 316 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 317 |  |  |         $this->contentService->loadContentByContentInfo($contentInfo, ['eng-US'], 2); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 318 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 319 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 320 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 321 |  |  |      * Test for the loadContentByVersionInfo() method. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 322 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 323 |  |  |      * @see \eZ\Publish\API\Repository\ContentService::loadContentByVersionInfo() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 324 |  |  |      * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentByVersionInfo | 
            
                                                                                                            
                            
            
                                    
            
            
                | 325 |  |  |      */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 326 |  | View Code Duplication |     public function testLoadContentByVersionInfoThrowsUnauthorizedException() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 327 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 328 |  |  |         $contentInfo = $this->getContentInfoForAnonymousUser(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 329 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 330 |  |  |         $versionInfo = $this->contentService->loadVersionInfo($contentInfo); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 331 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 332 |  |  |         $this->setRestrictedEditorUser(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 333 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 334 |  |  |         $this->expectException(UnauthorizedException::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 335 |  |  |         $this->expectExceptionMessageRegExp('/\'read\' \'content\'/'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 336 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 337 |  |  |         $this->contentService->loadContentByVersionInfo($versionInfo); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 338 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 339 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 340 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 341 |  |  |      * Test for the loadContentByVersionInfo() method. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 342 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 343 |  |  |      * @see \eZ\Publish\API\Repository\ContentService::loadContentByVersionInfo($versionInfo, $languages) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 344 |  |  |      * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentByVersionInfoWithSecondParameter | 
            
                                                                                                            
                            
            
                                    
            
            
                | 345 |  |  |      */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 346 |  | View Code Duplication |     public function testLoadContentByVersionInfoThrowsUnauthorizedExceptionWithSecondParameter() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 347 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 348 |  |  |         $contentInfo = $this->getContentInfoForAnonymousUser(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 349 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 350 |  |  |         $versionInfo = $this->contentService->loadVersionInfo($contentInfo); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 351 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 352 |  |  |         $this->setRestrictedEditorUser(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 353 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 354 |  |  |         $this->expectException(UnauthorizedException::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 355 |  |  |         $this->expectExceptionMessageRegExp('/\'read\' \'content\'/'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 356 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 357 |  |  |         $this->contentService->loadContentByVersionInfo($versionInfo, ['eng-US']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 358 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 359 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 360 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 361 |  |  |      * Test for the loadContent() method. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 362 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 363 |  |  |      * @see \eZ\Publish\API\Repository\ContentService::loadContent() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 364 |  |  |      * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContent | 
            
                                                                                                            
                            
            
                                    
            
            
                | 365 |  |  |      */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 366 |  | View Code Duplication |     public function testLoadContentThrowsUnauthorizedException() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 367 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 368 |  |  |         $anonymousUserId = $this->generateId('user', 10); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 369 |  |  |         $this->setRestrictedEditorUser(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 370 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 371 |  |  |         $this->expectException(UnauthorizedException::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 372 |  |  |         $this->expectExceptionMessageRegExp('/\'read\' \'content\'/'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 373 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 374 |  |  |         $this->contentService->loadContent($anonymousUserId); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 375 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 376 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 377 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 378 |  |  |      * Test for the loadContent() method. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 379 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 380 |  |  |      * @see \eZ\Publish\API\Repository\ContentService::loadContent($contentId, $languages) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 381 |  |  |      * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentWithPrioritizedLanguages | 
            
                                                                                                            
                            
            
                                    
            
            
                | 382 |  |  |      */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 383 |  | View Code Duplication |     public function testLoadContentThrowsUnauthorizedExceptionWithSecondParameter() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 384 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 385 |  |  |         $anonymousUserId = $this->generateId('user', 10); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 386 |  |  |         $this->setRestrictedEditorUser(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 387 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 388 |  |  |         $this->expectException(UnauthorizedException::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 389 |  |  |         $this->expectExceptionMessageRegExp('/\'read\' \'content\'/'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 390 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 391 |  |  |         $this->contentService->loadContent($anonymousUserId, ['eng-US']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 392 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 393 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 394 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 395 |  |  |      * Test for the loadContent() method. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 396 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 397 |  |  |      * @see \eZ\Publish\API\Repository\ContentService::loadContent($contentId, $languages, $versionNo) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 398 |  |  |      * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentWithThirdParameter | 
            
                                                                                                            
                            
            
                                    
            
            
                | 399 |  |  |      */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 400 |  | View Code Duplication |     public function testLoadContentThrowsUnauthorizedExceptionWithThirdParameter() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 401 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 402 |  |  |         $anonymousUserId = $this->generateId('user', 10); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 403 |  |  |         $this->setRestrictedEditorUser(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 404 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 405 |  |  |         $this->expectException(UnauthorizedException::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 406 |  |  |         $this->expectExceptionMessageRegExp('/\'read\' \'content\'/'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 407 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 408 |  |  |         $this->contentService->loadContent($anonymousUserId, ['eng-US'], 2); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 409 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 410 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 411 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 412 |  |  |      * Test for the loadContent() method on a draft. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 413 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 414 |  |  |      * @see \eZ\Publish\API\Repository\ContentService::loadContent() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 415 |  |  |      * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContent | 
            
                                                                                                            
                            
            
                                    
            
            
                | 416 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 417 |  |  |     public function testLoadContentThrowsUnauthorizedExceptionOnDrafts() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 418 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 419 |  |  |         $editorUser = $this->createUserVersion1(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 420 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 421 |  |  |         $this->permissionResolver->setCurrentUserReference($editorUser); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 422 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 423 |  |  |         // Create draft with this user | 
            
                                                                                                            
                            
            
                                    
            
            
                | 424 |  |  |         $draft = $this->createContentDraftVersion1(2, 'folder'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 425 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 426 |  |  |         $this->permissionResolver->setCurrentUserReference($this->anonymousUser); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 427 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 428 |  |  |         // Try to load the draft with anonymous user to make sure access won't be allowed by throwing an exception | 
            
                                                                                                            
                            
            
                                    
            
            
                | 429 |  |  |         $this->expectException(UnauthorizedException::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 430 |  |  |         // content versionread policy is needed because it is a draft | 
            
                                                                                                            
                            
            
                                    
            
            
                | 431 |  |  |         $this->expectExceptionMessageRegExp('/\'versionread\' \'content\'/'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 432 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 433 |  |  |         $this->contentService->loadContent($draft->id); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 434 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 435 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 436 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 437 |  |  |      * Test for the ContentService::loadContent() method on an archive. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 438 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 439 |  |  |      * This test the version permission on loading archived versions | 
            
                                                                                                            
                            
            
                                    
            
            
                | 440 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 441 |  |  |      * @see \eZ\Publish\API\Repository\ContentService::loadContent() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 442 |  |  |      * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContent | 
            
                                                                                                            
                            
            
                                    
            
            
                | 443 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 444 |  |  |     public function testLoadContentThrowsUnauthorizedExceptionsOnArchives() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 445 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 446 |  |  |         $contentTypeService = $this->getRepository()->getContentTypeService(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 447 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 448 |  |  |         // set admin as current user | 
            
                                                                                                            
                            
            
                                    
            
            
                | 449 |  |  |         $this->permissionResolver->setCurrentUserReference($this->administratorUser); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 450 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 451 |  |  |         // create folder | 
            
                                                                                                            
                            
            
                                    
            
            
                | 452 |  |  |         $newStruct = $this->contentService->newContentCreateStruct( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 453 |  |  |             $contentTypeService->loadContentTypeByIdentifier('folder'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 454 |  |  |             'eng-US' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 455 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 456 |  |  |         $newStruct->setField('name', 'Test Folder'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 457 |  |  |         $draft = $this->contentService->createContent( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 458 |  |  |             $newStruct, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 459 |  |  |             [$this->repository->getLocationService()->newLocationCreateStruct(2)] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 460 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 461 |  |  |         $object = $this->contentService->publishVersion($draft->versionInfo); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 462 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 463 |  |  |         // update folder to make an archived version | 
            
                                                                                                            
                            
            
                                    
            
            
                | 464 |  |  |         $updateStruct = $this->contentService->newContentUpdateStruct(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 465 |  |  |         $updateStruct->setField('name', 'Test Folder Updated'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 466 |  |  |         $draftUpdated = $this->contentService->updateContent( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 467 |  |  |             $this->contentService->createContentDraft($object->contentInfo)->versionInfo, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 468 |  |  |             $updateStruct | 
            
                                                                                                            
                            
            
                                    
            
            
                | 469 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 470 |  |  |         $objectUpdated = $this->contentService->publishVersion($draftUpdated->versionInfo); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 471 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 472 |  |  |         // set an anonymous as current user | 
            
                                                                                                            
                            
            
                                    
            
            
                | 473 |  |  |         $this->permissionResolver->setCurrentUserReference($this->anonymousUser); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 474 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 475 |  |  |         $this->expectException(UnauthorizedException::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 476 |  |  |         // content versionread policy is needed because it is a draft | 
            
                                                                                                            
                            
            
                                    
            
            
                | 477 |  |  |         $this->expectExceptionMessageRegExp('/\'versionread\' \'content\'/'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 478 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 479 |  |  |         $this->contentService->loadContent($objectUpdated->id, null, 1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 480 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 481 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 482 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 483 |  |  |      * Test for the loadContentByRemoteId() method. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 484 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 485 |  |  |      * @see \eZ\Publish\API\Repository\ContentService::loadContentByRemoteId() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 486 |  |  |      * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentByRemoteId | 
            
                                                                                                            
                            
            
                                    
            
            
                | 487 |  |  |      */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 488 |  | View Code Duplication |     public function testLoadContentByRemoteIdThrowsUnauthorizedException() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 489 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 490 |  |  |         $anonymousRemoteId = 'faaeb9be3bd98ed09f606fc16d144eca'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 491 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 492 |  |  |         $this->setRestrictedEditorUser(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 493 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 494 |  |  |         $this->expectException(UnauthorizedException::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 495 |  |  |         $this->expectExceptionMessageRegExp('/\'read\' \'content\'/'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 496 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 497 |  |  |         $this->contentService->loadContentByRemoteId($anonymousRemoteId); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 498 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 499 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 500 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 501 |  |  |      * Test for the loadContentByRemoteId() method. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 502 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 503 |  |  |      * @see \eZ\Publish\API\Repository\ContentService::loadContentByRemoteId($remoteId, $languages) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 504 |  |  |      * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentByRemoteIdWithSecondParameter | 
            
                                                                                                            
                            
            
                                    
            
            
                | 505 |  |  |      */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 506 |  | View Code Duplication |     public function testLoadContentByRemoteIdThrowsUnauthorizedExceptionWithSecondParameter() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 507 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 508 |  |  |         $anonymousRemoteId = 'faaeb9be3bd98ed09f606fc16d144eca'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 509 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 510 |  |  |         $this->setRestrictedEditorUser(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 511 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 512 |  |  |         $this->expectException(UnauthorizedException::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 513 |  |  |         $this->expectExceptionMessageRegExp('/\'read\' \'content\'/'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 514 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 515 |  |  |         $this->contentService->loadContentByRemoteId($anonymousRemoteId, ['eng-US']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 516 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 517 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 518 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 519 |  |  |      * Test for the loadContentByRemoteId() method. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 520 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 521 |  |  |      * @see \eZ\Publish\API\Repository\ContentService::loadContentByRemoteId($remoteId, $languages, $versionNo) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 522 |  |  |      * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentByRemoteIdWithThirdParameter | 
            
                                                                                                            
                            
            
                                    
            
            
                | 523 |  |  |      */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 524 |  | View Code Duplication |     public function testLoadContentByRemoteIdThrowsUnauthorizedExceptionWithThirdParameter() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 525 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 526 |  |  |         $anonymousRemoteId = 'faaeb9be3bd98ed09f606fc16d144eca'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 527 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 528 |  |  |         $this->setRestrictedEditorUser(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 529 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 530 |  |  |         $this->expectException(UnauthorizedException::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 531 |  |  |         $this->expectExceptionMessageRegExp('/\'read\' \'content\'/'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 532 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 533 |  |  |         $this->contentService->loadContentByRemoteId($anonymousRemoteId, ['eng-US'], 2); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 534 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 535 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 536 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 537 |  |  |      * Test for the updateContentMetadata() method. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 538 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 539 |  |  |      * @see \eZ\Publish\API\Repository\ContentService::updateContentMetadata() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 540 |  |  |      * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testUpdateContentMetadata | 
            
                                                                                                            
                            
            
                                    
            
            
                | 541 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 542 |  |  |     public function testUpdateContentMetadataThrowsUnauthorizedException() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 543 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 544 |  |  |         $content = $this->createContentVersion1(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 545 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 546 |  |  |         $contentInfo = $content->contentInfo; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 547 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 548 |  |  |         $this->permissionResolver->setCurrentUserReference($this->anonymousUser); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 549 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 550 |  |  |         $metadataUpdate = $this->contentService->newContentMetadataUpdateStruct(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 551 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 552 |  |  |         $metadataUpdate->remoteId = 'aaaabbbbccccddddeeeeffff11112222'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 553 |  |  |         $metadataUpdate->mainLanguageCode = 'eng-US'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 554 |  |  |         $metadataUpdate->alwaysAvailable = false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 555 |  |  |         $metadataUpdate->publishedDate = $this->createDateTime(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 556 |  |  |         $metadataUpdate->modificationDate = $this->createDateTime(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 557 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 558 |  |  |         $this->expectException(UnauthorizedException::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 559 |  |  |         $this->expectExceptionMessageRegExp('/\'edit\' \'content\'/'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 560 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 561 |  |  |         $this->contentService->updateContentMetadata( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 562 |  |  |             $contentInfo, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 563 |  |  |             $metadataUpdate | 
            
                                                                                                            
                            
            
                                    
            
            
                | 564 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 565 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 566 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 567 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 568 |  |  |      * Test for the deleteContent() method. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 569 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 570 |  |  |      * @see \eZ\Publish\API\Repository\ContentService::deleteContent() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 571 |  |  |      * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testDeleteContent | 
            
                                                                                                            
                            
            
                                    
            
            
                | 572 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 573 |  |  |     public function testDeleteContentThrowsUnauthorizedException() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 574 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 575 |  |  |         $contentVersion2 = $this->createContentVersion2(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 576 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 577 |  |  |         $contentInfo = $contentVersion2->contentInfo; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 578 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 579 |  |  |         $this->permissionResolver->setCurrentUserReference($this->anonymousUser); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 580 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 581 |  |  |         $this->expectException(UnauthorizedException::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 582 |  |  |         $this->expectExceptionMessageRegExp('/\'remove\' \'content\'/'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 583 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 584 |  |  |         $this->contentService->deleteContent($contentInfo); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 585 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 586 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 587 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 588 |  |  |      * Test for the createContentDraft() method. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 589 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 590 |  |  |      * @see \eZ\Publish\API\Repository\ContentService::createContentDraft() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 591 |  |  |      * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContentDraft | 
            
                                                                                                            
                            
            
                                    
            
            
                | 592 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 593 |  |  |     public function testCreateContentDraftThrowsUnauthorizedException() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 594 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 595 |  |  |         $content = $this->createContentVersion1(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 596 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 597 |  |  |         $contentInfo = $content->contentInfo; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 598 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 599 |  |  |         $this->permissionResolver->setCurrentUserReference($this->anonymousUser); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 600 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 601 |  |  |         $this->expectException(UnauthorizedException::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 602 |  |  |         $this->expectExceptionMessageRegExp('/\'edit\' \'content\'/'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 603 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 604 |  |  |         $this->contentService->createContentDraft($contentInfo); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 605 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 606 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 607 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 608 |  |  |      * Test for the createContentDraft() method. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 609 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 610 |  |  |      * @see \eZ\Publish\API\Repository\ContentService::createContentDraft($contentInfo, $versionInfo) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 611 |  |  |      * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContentDraftWithSecondParameter | 
            
                                                                                                            
                            
            
                                    
            
            
                | 612 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 613 |  |  |     public function testCreateContentDraftThrowsUnauthorizedExceptionWithSecondParameter() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 614 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 615 |  |  |         $content = $this->createContentVersion1(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 616 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 617 |  |  |         $contentInfo = $content->contentInfo; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 618 |  |  |         $versionInfo = $content->getVersionInfo(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 619 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 620 |  |  |         $this->permissionResolver->setCurrentUserReference($this->anonymousUser); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 621 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 622 |  |  |         $this->expectException(UnauthorizedException::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 623 |  |  |         $this->expectExceptionMessageRegExp('/\'edit\' \'content\'/'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 624 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 625 |  |  |         $this->contentService->createContentDraft($contentInfo, $versionInfo); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 626 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 627 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 628 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 629 |  |  |      * Test for the countContentDrafts() method. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 630 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 631 |  |  |      * @see \eZ\Publish\API\Repository\ContentService::countContentDrafts() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 632 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 633 |  |  |     public function testCountContentDraftsReturnZero() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 634 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 635 |  |  |         $this->permissionResolver->setCurrentUserReference($this->anonymousUser); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 636 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 637 |  |  |         $this->assertSame(0, $this->contentService->countContentDrafts()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 638 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 639 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 640 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 641 |  |  |      * Test for the loadContentDrafts() method. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 642 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 643 |  |  |      * @see \eZ\Publish\API\Repository\ContentService::loadContentDrafts() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 644 |  |  |      * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentDrafts | 
            
                                                                                                            
                            
            
                                    
            
            
                | 645 |  |  |      * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentDrafts | 
            
                                                                                                            
                            
            
                                    
            
            
                | 646 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 647 |  |  |     public function testLoadContentDraftsThrowsUnauthorizedException() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 648 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 649 |  |  |         $this->permissionResolver->setCurrentUserReference($this->anonymousUser); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 650 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 651 |  |  |         $this->expectException(UnauthorizedException::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 652 |  |  |         $this->expectExceptionMessageRegExp('/\'versionread\' \'content\'/'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 653 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 654 |  |  |         $this->contentService->loadContentDrafts(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 655 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 656 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 657 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 658 |  |  |      * Test for the loadContentDrafts() method. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 659 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 660 |  |  |      * @see \eZ\Publish\API\Repository\ContentService::loadContentDrafts($user) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 661 |  |  |      * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentDrafts | 
            
                                                                                                            
                            
            
                                    
            
            
                | 662 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 663 |  |  |     public function testLoadContentDraftsThrowsUnauthorizedExceptionWithUser() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 664 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 665 |  |  |         $this->permissionResolver->setCurrentUserReference($this->anonymousUser); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 666 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 667 |  |  |         $this->expectException(UnauthorizedException::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 668 |  |  |         $this->expectExceptionMessageRegExp('/\'versionread\' \'content\'/'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 669 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 670 |  |  |         $this->contentService->loadContentDrafts($this->administratorUser); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 671 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 672 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 673 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 674 |  |  |      * Test for the updateContent() method. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 675 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 676 |  |  |      * @see \eZ\Publish\API\Repository\ContentService::updateContent() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 677 |  |  |      * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testUpdateContent | 
            
                                                                                                            
                            
            
                                    
            
            
                | 678 |  |  |      */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 679 |  | View Code Duplication |     public function testUpdateContentThrowsUnauthorizedException() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 680 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 681 |  |  |         $draftVersion2 = $this->createContentDraftVersion2(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 682 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 683 |  |  |         $versionInfo = $draftVersion2->getVersionInfo(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 684 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 685 |  |  |         $this->permissionResolver->setCurrentUserReference($this->anonymousUser); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 686 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 687 |  |  |         // Create an update struct and modify some fields | 
            
                                                                                                            
                            
            
                                    
            
            
                | 688 |  |  |         $contentUpdate = $this->contentService->newContentUpdateStruct(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 689 |  |  |         $contentUpdate->setField('name', 'An awesome² story about ezp.'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 690 |  |  |         $contentUpdate->setField('name', 'An awesome²³ story about ezp.', 'eng-GB'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 691 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 692 |  |  |         $contentUpdate->initialLanguageCode = 'eng-US'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 693 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 694 |  |  |         $this->expectException(UnauthorizedException::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 695 |  |  |         /* TODO - the `content/edit` policy should be probably needed */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 696 |  |  |         $this->expectExceptionMessageRegExp('/\'versionread\' \'content\'/'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 697 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 698 |  |  |         $this->contentService->updateContent($versionInfo, $contentUpdate); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 699 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 700 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 701 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 702 |  |  |      * Test for the publishVersion() method. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 703 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 704 |  |  |      * @see \eZ\Publish\API\Repository\ContentService::publishVersion() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 705 |  |  |      * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersion | 
            
                                                                                                            
                            
            
                                    
            
            
                | 706 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 707 |  |  |     public function testPublishVersionThrowsUnauthorizedException() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 708 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 709 |  |  |         $draft = $this->createContentDraftVersion1(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 710 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 711 |  |  |         $this->permissionResolver->setCurrentUserReference($this->anonymousUser); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 712 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 713 |  |  |         $this->expectException(UnauthorizedException::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 714 |  |  |         $this->expectExceptionMessageRegExp('/\'publish\' \'content\'/'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 715 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 716 |  |  |         $this->contentService->publishVersion($draft->getVersionInfo()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 717 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 718 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 719 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 720 |  |  |      * Test for the deleteVersion() method. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 721 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 722 |  |  |      * @see \eZ\Publish\API\Repository\ContentService::deleteVersion() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 723 |  |  |      * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testDeleteVersion | 
            
                                                                                                            
                            
            
                                    
            
            
                | 724 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 725 |  |  |     public function testDeleteVersionThrowsUnauthorizedException() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 726 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 727 |  |  |         $draft = $this->createContentDraftVersion1(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 728 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 729 |  |  |         $this->permissionResolver->setCurrentUserReference($this->anonymousUser); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 730 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 731 |  |  |         $this->expectException(UnauthorizedException::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 732 |  |  |         $this->expectExceptionMessageRegExp('/\'versionremove\' \'content\'/'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 733 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 734 |  |  |         $this->contentService->deleteVersion($draft->getVersionInfo()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 735 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 736 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 737 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 738 |  |  |      * Test for the loadVersions() method. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 739 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 740 |  |  |      * @see \eZ\Publish\API\Repository\ContentService::loadVersions() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 741 |  |  |      * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadVersions | 
            
                                                                                                            
                            
            
                                    
            
            
                | 742 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 743 |  |  |     public function testLoadVersionsThrowsUnauthorizedException() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 744 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 745 |  |  |         $contentVersion2 = $this->createContentVersion2(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 746 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 747 |  |  |         $contentInfo = $contentVersion2->contentInfo; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 748 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 749 |  |  |         $this->permissionResolver->setCurrentUserReference($this->anonymousUser); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 750 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 751 |  |  |         $this->expectException(UnauthorizedException::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 752 |  |  |         $this->expectExceptionMessageRegExp('/\'versionread\' \'content\'/'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 753 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 754 |  |  |         $this->contentService->loadVersions($contentInfo); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 755 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 756 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 757 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 758 |  |  |      * Test for the copyContent() method. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 759 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 760 |  |  |      * @see \eZ\Publish\API\Repository\ContentService::copyContent() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 761 |  |  |      * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCopyContent | 
            
                                                                                                            
                            
            
                                    
            
            
                | 762 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 763 |  |  |     public function testCopyContentThrowsUnauthorizedException() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 764 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 765 |  |  |         $parentLocationId = $this->generateId('location', 52); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 766 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 767 |  |  |         $locationService = $this->repository->getLocationService(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 768 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 769 |  |  |         $contentVersion2 = $this->createMultipleLanguageContentVersion2(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 770 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 771 |  |  |         $contentInfo = $contentVersion2->contentInfo; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 772 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 773 |  |  |         $this->permissionResolver->setCurrentUserReference($this->anonymousUser); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 774 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 775 |  |  |         // Configure new target location | 
            
                                                                                                            
                            
            
                                    
            
            
                | 776 |  |  |         $targetLocationCreate = $locationService->newLocationCreateStruct($parentLocationId); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 777 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 778 |  |  |         $targetLocationCreate->priority = 42; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 779 |  |  |         $targetLocationCreate->hidden = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 780 |  |  |         $targetLocationCreate->remoteId = '01234abcdef5678901234abcdef56789'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 781 |  |  |         $targetLocationCreate->sortField = Location::SORT_FIELD_NODE_ID; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 782 |  |  |         $targetLocationCreate->sortOrder = Location::SORT_ORDER_DESC; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 783 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 784 |  |  |         $this->expectException(UnauthorizedException::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 785 |  |  |         $this->expectExceptionMessageRegExp('/\'read\' \'content\'/'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 786 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 787 |  |  |         $this->contentService->copyContent( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 788 |  |  |             $contentInfo, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 789 |  |  |             $targetLocationCreate | 
            
                                                                                                            
                            
            
                                    
            
            
                | 790 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 791 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 792 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 793 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 794 |  |  |      * Test for the copyContent() method. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 795 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 796 |  |  |      * @see \eZ\Publish\API\Repository\ContentService::copyContent($contentInfo, $destinationLocationCreateStruct, $versionInfo) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 797 |  |  |      * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCopyContentWithGivenVersion | 
            
                                                                                                            
                            
            
                                    
            
            
                | 798 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 799 |  |  |     public function testCopyContentThrowsUnauthorizedExceptionWithGivenVersion() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 800 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 801 |  |  |         $parentLocationId = $this->generateId('location', 52); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 802 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 803 |  |  |         $contentVersion2 = $this->createContentVersion2(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 804 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 805 |  |  |         $this->permissionResolver->setCurrentUserReference($this->anonymousUser); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 806 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 807 |  |  |         // Configure new target location | 
            
                                                                                                            
                            
            
                                    
            
            
                | 808 |  |  |         $targetLocationCreate = $this->repository->getLocationService()->newLocationCreateStruct($parentLocationId); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 809 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 810 |  |  |         $targetLocationCreate->priority = 42; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 811 |  |  |         $targetLocationCreate->hidden = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 812 |  |  |         $targetLocationCreate->remoteId = '01234abcdef5678901234abcdef56789'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 813 |  |  |         $targetLocationCreate->sortField = Location::SORT_FIELD_NODE_ID; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 814 |  |  |         $targetLocationCreate->sortOrder = Location::SORT_ORDER_DESC; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 815 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 816 |  |  |         $this->expectException(UnauthorizedException::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 817 |  |  |         $this->expectExceptionMessageRegExp('/\'versionread\' \'content\'/'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 818 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 819 |  |  |         $this->contentService->copyContent( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 820 |  |  |             $contentVersion2->contentInfo, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 821 |  |  |             $targetLocationCreate, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 822 |  |  |             $this->contentService->loadVersionInfo($contentVersion2->contentInfo, 1) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 823 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 824 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 825 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 826 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 827 |  |  |      * Test for the loadRelations() method. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 828 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 829 |  |  |      * @see \eZ\Publish\API\Repository\ContentService::loadRelations() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 830 |  |  |      * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadRelations | 
            
                                                                                                            
                            
            
                                    
            
            
                | 831 |  |  |      */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 832 |  | View Code Duplication |     public function testLoadRelationsThrowsUnauthorizedException() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 833 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 834 |  |  |         $mediaEditor = $this->createMediaUserVersion1(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 835 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 836 |  |  |         $setupRemoteId = '241d538ce310074e602f29f49e44e938'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 837 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 838 |  |  |         $versionInfo = $this->contentService->loadVersionInfo( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 839 |  |  |             $this->contentService->loadContentInfoByRemoteId( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 840 |  |  |                 $setupRemoteId | 
            
                                                                                                            
                            
            
                                    
            
            
                | 841 |  |  |             ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 842 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 843 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 844 |  |  |         $this->permissionResolver->setCurrentUserReference($mediaEditor); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 845 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 846 |  |  |         $this->expectException(UnauthorizedException::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 847 |  |  |         $this->expectExceptionMessageRegExp('/\'read\' \'content\'/'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 848 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 849 |  |  |         $this->contentService->loadRelations($versionInfo); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 850 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 851 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 852 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 853 |  |  |      * Test for the loadRelations() method. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 854 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 855 |  |  |      * @see \eZ\Publish\API\Repository\ContentService::loadRelations() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 856 |  |  |      * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadRelations | 
            
                                                                                                            
                            
            
                                    
            
            
                | 857 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 858 |  |  |     public function testLoadRelationsForDraftVersionThrowsUnauthorizedException() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 859 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 860 |  |  |         $draft = $this->createContentDraftVersion1(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 861 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 862 |  |  |         $this->permissionResolver->setCurrentUserReference($this->anonymousUser); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 863 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 864 |  |  |         $this->expectException(UnauthorizedException::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 865 |  |  |         $this->expectExceptionMessageRegExp('/\'versionread\' \'content\'/'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 866 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 867 |  |  |         $this->contentService->loadRelations($draft->versionInfo); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 868 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 869 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 870 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 871 |  |  |      * Test for the loadReverseRelations() method. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 872 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 873 |  |  |      * @see \eZ\Publish\API\Repository\ContentService::loadReverseRelations() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 874 |  |  |      * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadReverseRelations | 
            
                                                                                                            
                            
            
                                    
            
            
                | 875 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 876 |  |  |     public function testLoadReverseRelationsThrowsUnauthorizedException() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 877 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 878 |  |  |         $mediaEditor = $this->createMediaUserVersion1(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 879 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 880 |  |  |         $mediaRemoteId = 'a6e35cbcb7cd6ae4b691f3eee30cd262'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 881 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 882 |  |  |         $contentInfo = $this->contentService->loadContentInfoByRemoteId($mediaRemoteId); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 883 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 884 |  |  |         $this->permissionResolver->setCurrentUserReference($mediaEditor); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 885 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 886 |  |  |         $this->expectException(UnauthorizedException::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 887 |  |  |         $this->expectExceptionMessageRegExp('/\'reverserelatedlist\' \'content\'/'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 888 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 889 |  |  |         $this->contentService->loadReverseRelations($contentInfo); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 890 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 891 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 892 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 893 |  |  |      * Test for the addRelation() method. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 894 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 895 |  |  |      * @see \eZ\Publish\API\Repository\ContentService::addRelation() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 896 |  |  |      * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testAddRelation | 
            
                                                                                                            
                            
            
                                    
            
            
                | 897 |  |  |      */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 898 |  | View Code Duplication |     public function testAddRelationThrowsUnauthorizedException() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 899 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 900 |  |  |         $mediaRemoteId = 'a6e35cbcb7cd6ae4b691f3eee30cd262'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 901 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 902 |  |  |         $draft = $this->createContentDraftVersion1(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 903 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 904 |  |  |         $versionInfo = $draft->getVersionInfo(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 905 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 906 |  |  |         $media = $this->contentService->loadContentInfoByRemoteId($mediaRemoteId); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 907 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 908 |  |  |         $this->permissionResolver->setCurrentUserReference($this->anonymousUser); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 909 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 910 |  |  |         $this->expectException(UnauthorizedException::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 911 |  |  |         $this->expectExceptionMessageRegExp('/\'versionread\' \'content\'/'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 912 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 913 |  |  |         $this->contentService->addRelation( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 914 |  |  |             $versionInfo, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 915 |  |  |             $media | 
            
                                                                                                            
                            
            
                                    
            
            
                | 916 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 917 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 918 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 919 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 920 |  |  |      * Test for the deleteRelation() method. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 921 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 922 |  |  |      * @see \eZ\Publish\API\Repository\ContentService::deleteRelation() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 923 |  |  |      * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testDeleteRelation | 
            
                                                                                                            
                            
            
                                    
            
            
                | 924 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 925 |  |  |     public function testDeleteRelationThrowsUnauthorizedException() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 926 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 927 |  |  |         $mediaRemoteId = 'a6e35cbcb7cd6ae4b691f3eee30cd262'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 928 |  |  |         $demoDesignRemoteId = '8b8b22fe3c6061ed500fbd2b377b885f'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 929 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 930 |  |  |         $draft = $this->createContentDraftVersion1(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 931 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 932 |  |  |         $versionInfo = $draft->getVersionInfo(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 933 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 934 |  |  |         $media = $this->contentService->loadContentInfoByRemoteId($mediaRemoteId); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 935 |  |  |         $demoDesign = $this->contentService->loadContentInfoByRemoteId($demoDesignRemoteId); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 936 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 937 |  |  |         // Establish some relations | 
            
                                                                                                            
                            
            
                                    
            
            
                | 938 |  |  |         $this->contentService->addRelation($draft->getVersionInfo(), $media); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 939 |  |  |         $this->contentService->addRelation($draft->getVersionInfo(), $demoDesign); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 940 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 941 |  |  |         $this->permissionResolver->setCurrentUserReference($this->anonymousUser); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 942 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 943 |  |  |         $this->expectException(UnauthorizedException::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 944 |  |  |         $this->expectExceptionMessageRegExp('/\'versionread\' \'content\'/'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 945 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 946 |  |  |         $this->contentService->deleteRelation($versionInfo, $media); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 947 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 948 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 949 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 950 |  |  |      * Creates a pseudo editor with a limitation to objects in the "Media/Images" | 
            
                                                                                                            
                            
            
                                    
            
            
                | 951 |  |  |      * subtree. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 952 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 953 |  |  |      * @return \eZ\Publish\API\Repository\Values\User\User | 
            
                                                                                                            
                            
            
                                    
            
            
                | 954 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 955 |  |  |     private function createAnonymousWithEditorRole() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 956 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 957 |  |  |         $roleService = $this->repository->getRoleService(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 958 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 959 |  |  |         $user = $this->anonymousUser; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 960 |  |  |         $role = $roleService->loadRoleByIdentifier('Editor'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 961 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 962 |  |  |         // Assign "Editor" role with limitation to "Media/Images" | 
            
                                                                                                            
                            
            
                                    
            
            
                | 963 |  |  |         $roleService->assignRoleToUser( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 964 |  |  |             $role, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 965 |  |  |             $user, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 966 |  |  |             new \eZ\Publish\API\Repository\Values\User\Limitation\SubtreeLimitation( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 967 |  |  |                 [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 968 |  |  |                     'limitationValues' => ['/1/43/51/'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 969 |  |  |                 ] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 970 |  |  |             ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 971 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 972 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 973 |  |  |         return $this->userService->loadUser($user->id); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 974 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 975 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 976 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 977 |  |  |      * Test that for an user that doesn't have access (read permissions) to an | 
            
                                                                                                            
                            
            
                                    
            
            
                | 978 |  |  |      * related object, executing loadRelations() would not throw any exception, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 979 |  |  |      * only that the non-readable related object(s) won't be loaded. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 980 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 981 |  |  |      * @see \eZ\Publish\API\Repository\ContentService::loadRelations() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 982 |  |  |      * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testAddRelation | 
            
                                                                                                            
                            
            
                                    
            
            
                | 983 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 984 |  |  |     public function testLoadRelationsWithUnauthorizedRelations() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 985 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 986 |  |  |         $mainLanguage = 'eng-GB'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 987 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 988 |  |  |         $contentTypeService = $this->repository->getContentTypeService(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 989 |  |  |         $locationService = $this->repository->getLocationService(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 990 |  |  |         $sectionService = $this->repository->getSectionService(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 991 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 992 |  |  |         // set the current user as admin to create the environment to test | 
            
                                                                                                            
                            
            
                                    
            
            
                | 993 |  |  |         $this->permissionResolver->setCurrentUserReference($this->administratorUser); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 994 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 995 |  |  |         // create section | 
            
                                                                                                            
                            
            
                                    
            
            
                | 996 |  |  |         // since anonymous users have their read permissions to specific sections | 
            
                                                                                                            
                            
            
                                    
            
            
                | 997 |  |  |         // the created section will be non-readable to them | 
            
                                                                                                            
                            
            
                                    
            
            
                | 998 |  |  |         $sectionCreate = $sectionService->newSectionCreateStruct(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 999 |  |  |         $sectionCreate->identifier = 'private'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1000 |  |  |         $sectionCreate->name = 'Private Section'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1001 |  |  |         $section = $sectionService->createSection($sectionCreate); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1002 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1003 |  |  |         // create objects for testing | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1004 |  |  |         // here we will create 4 objects which 2 will be readable by an anonymous | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1005 |  |  |         // user, and the other 2 wont these last 2 will go to a private section | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1006 |  |  |         // where anonymous can't read, just like: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1007 |  |  |         // readable object 1 -> /Main Folder | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1008 |  |  |         // readable object 2 -> /Main Folder/Available Folder | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1009 |  |  |         // non-readable object 1 -> /Restricted Folder | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1010 |  |  |         // non-readable object 2 -> /Restricted Folder/Unavailable Folder | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1011 |  |  |         // | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1012 |  |  |         // here is created - readable object 1 -> /Main Folder | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1013 |  |  |         $mainFolder = $this->createFolder([$mainLanguage => 'Main Folder'], 2); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1014 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1015 |  |  |         // here is created readable object 2 -> /Main Folder/Available Folder | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1016 |  |  |         $availableFolder = $this->createFolder( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1017 |  |  |             [$mainLanguage => 'Avaliable Folder'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1018 |  |  |             $mainFolder->contentInfo->mainLocationId | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1019 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1020 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1021 |  |  |         // here is created the non-readable object 1 -> /Restricted Folder | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1022 |  |  |         $restrictedFolderCreate = $this->contentService->newContentCreateStruct( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1023 |  |  |             $contentTypeService->loadContentTypeByIdentifier('folder'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1024 |  |  |             $mainLanguage | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1025 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1026 |  |  |         $restrictedFolderCreate->setField('name', 'Restricted Folder'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1027 |  |  |         $restrictedFolderCreate->sectionId = $section->id; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1028 |  |  |         $restrictedFolder = $this->contentService->publishVersion( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1029 |  |  |             $this->contentService->createContent( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1030 |  |  |                 $restrictedFolderCreate, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1031 |  |  |                 [$locationService->newLocationCreateStruct(2)] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1032 |  |  |             )->versionInfo | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1033 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1034 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1035 |  |  |         // here is created non-readable object 2 -> /Restricted Folder/Unavailable Folder | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1036 |  |  |         $unavailableFolder = $this->createFolder( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1037 |  |  |             [$mainLanguage => 'Unavailable Folder'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1038 |  |  |             $restrictedFolder->contentInfo->mainLocationId | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1039 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1040 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1041 |  |  |         // this will be our test object, which will have all the relations (as source) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1042 |  |  |         // and it is readable by the anonymous user | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1043 |  |  |         $testFolderCreate = $this->contentService->newContentCreateStruct( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1044 |  |  |             $contentTypeService->loadContentTypeByIdentifier('folder'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1045 |  |  |             $mainLanguage | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1046 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1047 |  |  |         $testFolderCreate->setField('name', 'Test Folder'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1048 |  |  |         $testFolderDraft = $this->contentService->createContent( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1049 |  |  |             $testFolderCreate, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1050 |  |  |             [$locationService->newLocationCreateStruct(2)] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1051 |  |  |         )->versionInfo; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1052 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1053 |  |  |         // add relations to test folder (as source) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1054 |  |  |         // the first 2 will be read by the user | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1055 |  |  |         // and the other 2 wont | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1056 |  |  |         // | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1057 |  |  |         // create relation from Test Folder to Main Folder | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1058 |  |  |         $mainRelation = $this->contentService->addRelation( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1059 |  |  |             $testFolderDraft, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1060 |  |  |             $mainFolder->getVersionInfo()->getContentInfo() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1061 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1062 |  |  |         // create relation from Test Folder to Available Folder | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1063 |  |  |         $availableRelation = $this->contentService->addRelation( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1064 |  |  |             $testFolderDraft, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1065 |  |  |             $availableFolder->getVersionInfo()->getContentInfo() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1066 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1067 |  |  |         // create relation from Test Folder to Restricted Folder | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1068 |  |  |         $this->contentService->addRelation( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1069 |  |  |             $testFolderDraft, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1070 |  |  |             $restrictedFolder->getVersionInfo()->getContentInfo() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1071 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1072 |  |  |         //create relation from Test Folder to Unavailable Folder | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1073 |  |  |         $this->contentService->addRelation( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1074 |  |  |             $testFolderDraft, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1075 |  |  |             $unavailableFolder->getVersionInfo()->getContentInfo() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1076 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1077 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1078 |  |  |         // publish Test Folder | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1079 |  |  |         $testFolder = $this->contentService->publishVersion($testFolderDraft); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1080 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1081 |  |  |         // set the current user to be an anonymous user since we want to test that | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1082 |  |  |         // if the user doesn't have access to an related object that object wont | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1083 |  |  |         // be loaded and no exception will be thrown | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1084 |  |  |         $this->permissionResolver->setCurrentUserReference($this->anonymousUser); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1085 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1086 |  |  |         // finaly load relations ( verify no exception is thrown ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1087 |  |  |         $actualRelations = $this->contentService->loadRelations($testFolder->getVersionInfo()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1088 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1089 |  |  |         // assert results | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1090 |  |  |         // verify that the only expected relations are from the 2 readable objects | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1091 |  |  |         // Main Folder and Available Folder | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1092 |  |  |         $expectedRelations = [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1093 |  |  |             $mainRelation->destinationContentInfo->id => $mainRelation, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1094 |  |  |             $availableRelation->destinationContentInfo->id => $availableRelation, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1095 |  |  |         ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1096 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1097 |  |  |         // assert there are as many expected relations as actual ones | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1098 |  |  |         $this->assertEquals( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1099 |  |  |             count($expectedRelations), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1100 |  |  |             count($actualRelations), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1101 |  |  |             "Expected '" . count($expectedRelations) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1102 |  |  |             . "' relations found '" . count($actualRelations) . "'" | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1103 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1104 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1105 |  |  |         // assert each relation | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1106 |  |  |         foreach ($actualRelations as $relation) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1107 |  |  |             $destination = $relation->destinationContentInfo; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1108 |  |  |             $expected = $expectedRelations[$destination->id]->destinationContentInfo; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1109 |  |  |             $this->assertNotEmpty($expected, "Non expected relation with '{$destination->id}' id found"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1110 |  |  |             $this->assertEquals( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1111 |  |  |                 $expected->id, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1112 |  |  |                 $destination->id, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1113 |  |  |                 "Expected relation with '{$expected->id}' id found '{$destination->id}' id" | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1114 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1115 |  |  |             $this->assertEquals( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1116 |  |  |                 $expected->name, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1117 |  |  |                 $destination->name, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1118 |  |  |                 "Expected relation with '{$expected->name}' name found '{$destination->name}' name" | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1119 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1120 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1121 |  |  |             // remove from list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1122 |  |  |             unset($expectedRelations[$destination->id]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1123 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1124 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1125 |  |  |         // verify all expected relations were found | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1126 |  |  |         $this->assertEquals( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1127 |  |  |             0, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1128 |  |  |             count($expectedRelations), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1129 |  |  |             "Expected to find '" . (count($expectedRelations) + count($actualRelations)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1130 |  |  |             . "' relations found '" . count($actualRelations) . "'" | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1131 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1132 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1133 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1134 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1135 |  |  |      * Test copying Content to the authorized Location (limited by policies). | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 1136 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 1137 |  |  |     public function testCopyContentToAuthorizedLocation() | 
            
                                                                        
                            
            
                                    
            
            
                | 1138 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 1139 |  |  |         $locationService = $this->repository->getLocationService(); | 
            
                                                                        
                            
            
                                    
            
            
                | 1140 |  |  |         $roleService = $this->repository->getRoleService(); | 
            
                                                                        
                            
            
                                    
            
            
                | 1141 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 1142 |  |  |         // Create and publish folders for the test case | 
            
                                                                        
                            
            
                                    
            
            
                | 1143 |  |  |         $folderDraft = $this->createContentDraft('folder', 2, ['name' => 'Folder1']); | 
            
                                                                        
                            
            
                                    
            
            
                | 1144 |  |  |         $this->contentService->publishVersion($folderDraft->versionInfo); | 
            
                                                                        
                            
            
                                    
            
            
                | 1145 |  |  |         $authorizedFolderDraft = $this->createContentDraft('folder', 2, ['name' => 'AuthorizedFolder']); | 
            
                                                                        
                            
            
                                    
            
            
                | 1146 |  |  |         $authorizedFolder = $this->contentService->publishVersion($authorizedFolderDraft->versionInfo); | 
            
                                                                        
                            
            
                                    
            
            
                | 1147 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 1148 |  |  |         // Prepare Role for the test case | 
            
                                                                        
                            
            
                                    
            
            
                | 1149 |  |  |         $roleIdentifier = 'authorized_folder'; | 
            
                                                                        
                            
            
                                    
            
            
                | 1150 |  |  |         $roleCreateStruct = $roleService->newRoleCreateStruct($roleIdentifier); | 
            
                                                                        
                            
            
                                    
            
            
                | 1151 |  |  |         $locationLimitation = new LocationLimitation( | 
            
                                                                        
                            
            
                                    
            
            
                | 1152 |  |  |             ['limitationValues' => [$authorizedFolder->contentInfo->mainLocationId]] | 
            
                                                                        
                            
            
                                    
            
            
                | 1153 |  |  |         ); | 
            
                                                                        
                            
            
                                    
            
            
                | 1154 |  |  |         $roleCreateStruct->addPolicy($roleService->newPolicyCreateStruct('content', 'read')); | 
            
                                                                        
                            
            
                                    
            
            
                | 1155 |  |  |         $roleCreateStruct->addPolicy($roleService->newPolicyCreateStruct('content', 'versionread')); | 
            
                                                                        
                            
            
                                    
            
            
                | 1156 |  |  |         $roleCreateStruct->addPolicy($roleService->newPolicyCreateStruct('content', 'manage_locations')); | 
            
                                                                        
                            
            
                                    
            
            
                | 1157 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 1158 |  |  |         $policyCreateStruct = $roleService->newPolicyCreateStruct('content', 'create'); | 
            
                                                                        
                            
            
                                    
            
            
                | 1159 |  |  |         $policyCreateStruct->addLimitation($locationLimitation); | 
            
                                                                        
                            
            
                                    
            
            
                | 1160 |  |  |         $roleCreateStruct->addPolicy($policyCreateStruct); | 
            
                                                                        
                            
            
                                    
            
            
                | 1161 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 1162 |  |  |         $roleDraft = $roleService->createRole($roleCreateStruct); | 
            
                                                                        
                            
            
                                    
            
            
                | 1163 |  |  |         $roleService->publishRoleDraft($roleDraft); | 
            
                                                                        
                            
            
                                    
            
            
                | 1164 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 1165 |  |  |         // Create a user with that Role | 
            
                                                                        
                            
            
                                    
            
            
                | 1166 |  |  |         $user = $this->createCustomUserVersion1('Users', $roleIdentifier); | 
            
                                                                        
                            
            
                                    
            
            
                | 1167 |  |  |         $this->permissionResolver->setCurrentUserReference($user); | 
            
                                                                        
                            
            
                                    
            
            
                | 1168 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 1169 |  |  |         // Test copying Content to the authorized Location | 
            
                                                                        
                            
            
                                    
            
            
                | 1170 |  |  |         $this->contentService->copyContent( | 
            
                                                                        
                            
            
                                    
            
            
                | 1171 |  |  |             $authorizedFolder->contentInfo, | 
            
                                                                        
                            
            
                                    
            
            
                | 1172 |  |  |             $locationService->newLocationCreateStruct( | 
            
                                                                        
                            
            
                                    
            
            
                | 1173 |  |  |                 $authorizedFolder->contentInfo->mainLocationId | 
            
                                                                        
                            
            
                                    
            
            
                | 1174 |  |  |             ) | 
            
                                                                        
                            
            
                                    
            
            
                | 1175 |  |  |         ); | 
            
                                                                        
                            
            
                                    
            
            
                | 1176 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1177 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1178 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1179 |  |  |      * Test copying Content to the authorized Location (limited by policies). | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1180 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1181 |  |  |     public function testCopyContentToAuthorizedLocationWithSubtreeLimitation() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1182 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1183 |  |  |         $locationService = $this->repository->getLocationService(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1184 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1185 |  |  |         // Create and publish folders for the test case | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1186 |  |  |         $folderDraft = $this->createContentDraft('folder', 2, ['name' => 'Folder1']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1187 |  |  |         $this->contentService->publishVersion($folderDraft->versionInfo); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1188 |  |  |         $authorizedFolderDraft = $this->createContentDraft('folder', 2, ['name' => 'AuthorizedFolder']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1189 |  |  |         $authorizedFolder = $this->contentService->publishVersion($authorizedFolderDraft->versionInfo); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1190 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1191 |  |  |         // Prepare Role for the test case | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1192 |  |  |         $roleIdentifier = 'authorized_subree'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1193 |  |  |         $subtreeLimitation = new SubtreeLimitation( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1194 |  |  |             ['limitationValues' => ['/1/2']] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1195 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1196 |  |  |         $policiesData = [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1197 |  |  |             [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1198 |  |  |                 'module' => 'content', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1199 |  |  |                 'function' => 'read', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1200 |  |  |                 'limitations' => [$subtreeLimitation], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1201 |  |  |             ], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1202 |  |  |             [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1203 |  |  |                 'module' => 'content', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1204 |  |  |                 'function' => 'versionread', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1205 |  |  |                 'limitations' => [$subtreeLimitation], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1206 |  |  |             ], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1207 |  |  |             [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1208 |  |  |                 'module' => 'content', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1209 |  |  |                 'function' => 'create', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1210 |  |  |                 'limitations' => [$subtreeLimitation], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1211 |  |  |             ], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1212 |  |  |             [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1213 |  |  |                 'module' => 'content', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1214 |  |  |                 'function' => 'manage_locations', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1215 |  |  |             ], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1216 |  |  |         ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1217 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1218 |  |  |         $this->createRoleWithPolicies($roleIdentifier, $policiesData); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1219 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1220 |  |  |         // Create a user with that Role | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1221 |  |  |         $user = $this->createCustomUserVersion1('Users', $roleIdentifier); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1222 |  |  |         $this->permissionResolver->setCurrentUserReference($user); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1223 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1224 |  |  |         // Test copying Content to the authorized Location | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1225 |  |  |         $this->contentService->copyContent( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1226 |  |  |             $authorizedFolder->contentInfo, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1227 |  |  |             $locationService->newLocationCreateStruct( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1228 |  |  |                 $authorizedFolder->contentInfo->mainLocationId | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1229 |  |  |             ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1230 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1231 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1232 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1233 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1234 |  |  |      * @return \eZ\Publish\API\Repository\Values\Content\ContentInfo | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1235 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1236 |  |  |      * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1237 |  |  |      * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1238 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1239 |  |  |     private function getContentInfoForAnonymousUser(): ContentInfo | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1240 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1241 |  |  |         $anonymousUserId = $this->generateId('user', 10); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1242 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1243 |  |  |         return $this->contentService->loadContentInfo($anonymousUserId); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1244 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1245 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1246 |  |  |     private function setRestrictedEditorUser(): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1247 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1248 |  |  |         $this->permissionResolver->setCurrentUserReference($this->createAnonymousWithEditorRole()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1249 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 1250 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 1251 |  |  |  |