| @@ 829-853 (lines=25) @@ | ||
| 826 | * @see \eZ\Publish\API\Repository\ContentService::loadContentByVersionInfo() |
|
| 827 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadVersionInfo |
|
| 828 | */ |
|
| 829 | public function testLoadContentByVersionInfo() |
|
| 830 | { |
|
| 831 | $repository = $this->getRepository(); |
|
| 832 | ||
| 833 | $mediaFolderId = $this->generateId('object', 41); |
|
| 834 | /* BEGIN: Use Case */ |
|
| 835 | // $mediaFolderId contains the ID of the "Media" folder |
|
| 836 | ||
| 837 | $contentService = $repository->getContentService(); |
|
| 838 | ||
| 839 | // Load the ContentInfo for "Media" folder |
|
| 840 | $contentInfo = $contentService->loadContentInfo($mediaFolderId); |
|
| 841 | ||
| 842 | // Load the current VersionInfo |
|
| 843 | $versionInfo = $contentService->loadVersionInfo($contentInfo); |
|
| 844 | ||
| 845 | // Now load the current content version for the info instance |
|
| 846 | $content = $contentService->loadContentByVersionInfo($versionInfo); |
|
| 847 | /* END: Use Case */ |
|
| 848 | ||
| 849 | $this->assertInstanceOf( |
|
| 850 | '\\eZ\\Publish\\API\\Repository\\Values\\Content\\Content', |
|
| 851 | $content |
|
| 852 | ); |
|
| 853 | } |
|
| 854 | ||
| 855 | /** |
|
| 856 | * Test for the loadContent() method. |
|
| @@ 169-193 (lines=25) @@ | ||
| 166 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testNewLocationCreateStruct |
|
| 167 | * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
|
| 168 | */ |
|
| 169 | public function testCreateLocationThrowsInvalidArgumentExceptionContentAlreadyBelowParent() |
|
| 170 | { |
|
| 171 | $repository = $this->getRepository(); |
|
| 172 | ||
| 173 | $contentId = $this->generateId('object', 11); |
|
| 174 | $parentLocationId = $this->generateId('location', 5); |
|
| 175 | /* BEGIN: Use Case */ |
|
| 176 | // $contentId is the ID of an existing content object |
|
| 177 | // $parentLocationId is the ID of an existing location which already |
|
| 178 | // has the content assigned to one of its descendant locations |
|
| 179 | $contentService = $repository->getContentService(); |
|
| 180 | $locationService = $repository->getLocationService(); |
|
| 181 | ||
| 182 | // ContentInfo for "How to use eZ Publish" |
|
| 183 | $contentInfo = $contentService->loadContentInfo($contentId); |
|
| 184 | ||
| 185 | $locationCreate = $locationService->newLocationCreateStruct($parentLocationId); |
|
| 186 | ||
| 187 | // Throws exception, since content is already located at "/1/2/107/110/" |
|
| 188 | $locationService->createLocation( |
|
| 189 | $contentInfo, |
|
| 190 | $locationCreate |
|
| 191 | ); |
|
| 192 | /* END: Use Case */ |
|
| 193 | } |
|
| 194 | ||
| 195 | /** |
|
| 196 | * Test for the createLocation() method. |
|
| @@ 202-226 (lines=25) @@ | ||
| 199 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testNewLocationCreateStruct |
|
| 200 | * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
|
| 201 | */ |
|
| 202 | public function testCreateLocationThrowsInvalidArgumentExceptionParentIsSubLocationOfContent() |
|
| 203 | { |
|
| 204 | $repository = $this->getRepository(); |
|
| 205 | ||
| 206 | $contentId = $this->generateId('object', 4); |
|
| 207 | $parentLocationId = $this->generateId('location', 12); |
|
| 208 | /* BEGIN: Use Case */ |
|
| 209 | // $contentId is the ID of an existing content object |
|
| 210 | // $parentLocationId is the ID of an existing location which is below a |
|
| 211 | // location that is assigned to the content |
|
| 212 | $contentService = $repository->getContentService(); |
|
| 213 | $locationService = $repository->getLocationService(); |
|
| 214 | ||
| 215 | // ContentInfo for "How to use eZ Publish" |
|
| 216 | $contentInfo = $contentService->loadContentInfo($contentId); |
|
| 217 | ||
| 218 | $locationCreate = $locationService->newLocationCreateStruct($parentLocationId); |
|
| 219 | ||
| 220 | // Throws exception, since content is already located at "/1/2/" |
|
| 221 | $locationService->createLocation( |
|
| 222 | $contentInfo, |
|
| 223 | $locationCreate |
|
| 224 | ); |
|
| 225 | /* END: Use Case */ |
|
| 226 | } |
|
| 227 | ||
| 228 | /** |
|
| 229 | * Test for the createLocation() method. |
|
| @@ 648-672 (lines=25) @@ | ||
| 645 | * @depends eZ\Publish\API\Repository\Tests\RepositoryTest::testGetContentService |
|
| 646 | * @depends eZ\Publish\API\Repository\Tests\RepositoryTest::testHasAccessLimited |
|
| 647 | */ |
|
| 648 | public function testCanUserWithLimitationYes() |
|
| 649 | { |
|
| 650 | $repository = $this->getRepository(); |
|
| 651 | ||
| 652 | $imagesFolderId = $this->generateId('object', 49); |
|
| 653 | ||
| 654 | /* BEGIN: Use Case */ |
|
| 655 | // $imagesFolderId contains the ID of the "Images" folder |
|
| 656 | ||
| 657 | $user = $this->createUserVersion1(); |
|
| 658 | ||
| 659 | // Set created user as current user |
|
| 660 | $repository->setCurrentUser($user); |
|
| 661 | ||
| 662 | $contentService = $repository->getContentService(); |
|
| 663 | ||
| 664 | // Performing an action having necessary permissions will succeed |
|
| 665 | $imagesFolder = $contentService->loadContent($imagesFolderId); |
|
| 666 | ||
| 667 | // This call will return true |
|
| 668 | $canUser = $repository->canUser('content', 'read', $imagesFolder); |
|
| 669 | /* END: Use Case */ |
|
| 670 | ||
| 671 | $this->assertTrue($canUser); |
|
| 672 | } |
|
| 673 | ||
| 674 | /** |
|
| 675 | * Test for the canUser() method. |
|