| @@ 148-158 (lines=11) @@ | ||
| 145 | * @see \eZ\Publish\API\Repository\ContentService::loadContentInfoList() |
|
| 146 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentInfoList |
|
| 147 | */ |
|
| 148 | public function testLoadContentInfoListSkipsUnauthorizedItems() |
|
| 149 | { |
|
| 150 | $repository = $this->getRepository(); |
|
| 151 | $contentId = $this->generateId('object', 10); |
|
| 152 | $contentService = $repository->getContentService(); |
|
| 153 | $repository->setCurrentUser($this->createAnonymousWithEditorRole()); |
|
| 154 | ||
| 155 | $list = $contentService->loadContentInfoList([$contentId]); |
|
| 156 | ||
| 157 | $this->assertCount(0, $list); |
|
| 158 | } |
|
| 159 | ||
| 160 | /** |
|
| 161 | * Test for the loadContentInfoByRemoteId() method. |
|
| @@ 256-275 (lines=20) @@ | ||
| 253 | * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException |
|
| 254 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadVersionInfoById |
|
| 255 | */ |
|
| 256 | public function testLoadVersionInfoByIdThrowsUnauthorizedException() |
|
| 257 | { |
|
| 258 | $repository = $this->getRepository(); |
|
| 259 | ||
| 260 | $anonymousUserId = $this->generateId('user', 10); |
|
| 261 | /* BEGIN: Use Case */ |
|
| 262 | // $anonymousUserId is the ID of the "Anonymous User" in an eZ Publish |
|
| 263 | // demo installation |
|
| 264 | ||
| 265 | $contentService = $repository->getContentService(); |
|
| 266 | ||
| 267 | $pseudoEditor = $this->createAnonymousWithEditorRole(); |
|
| 268 | ||
| 269 | // Set restricted editor user |
|
| 270 | $repository->setCurrentUser($pseudoEditor); |
|
| 271 | ||
| 272 | // This call will fail with a "UnauthorizedException" |
|
| 273 | $contentService->loadVersionInfoById($anonymousUserId); |
|
| 274 | /* END: Use Case */ |
|
| 275 | } |
|
| 276 | ||
| 277 | /** |
|
| 278 | * Test for the loadVersionInfoById() method. |
|
| @@ 284-303 (lines=20) @@ | ||
| 281 | * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException |
|
| 282 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadVersionInfoByIdWithSecondParameter |
|
| 283 | */ |
|
| 284 | public function testLoadVersionInfoByIdThrowsUnauthorizedExceptionWithSecondParameter() |
|
| 285 | { |
|
| 286 | $repository = $this->getRepository(); |
|
| 287 | ||
| 288 | $anonymousUserId = $this->generateId('user', 10); |
|
| 289 | /* BEGIN: Use Case */ |
|
| 290 | // $anonymousUserId is the ID of the "Anonymous User" in an eZ Publish |
|
| 291 | // demo installation |
|
| 292 | ||
| 293 | $contentService = $repository->getContentService(); |
|
| 294 | ||
| 295 | $pseudoEditor = $this->createAnonymousWithEditorRole(); |
|
| 296 | ||
| 297 | // Set restricted editor user |
|
| 298 | $repository->setCurrentUser($pseudoEditor); |
|
| 299 | ||
| 300 | // This call will fail with a "UnauthorizedException" |
|
| 301 | $contentService->loadVersionInfoById($anonymousUserId, 2); |
|
| 302 | /* END: Use Case */ |
|
| 303 | } |
|
| 304 | ||
| 305 | /** |
|
| 306 | * Test for the loadVersionInfoById() method. |
|
| @@ 519-537 (lines=19) @@ | ||
| 516 | * @see \eZ\Publish\API\Repository\ContentService::loadContentInfo() |
|
| 517 | * @group user |
|
| 518 | */ |
|
| 519 | public function testLoadContentInfo() |
|
| 520 | { |
|
| 521 | $repository = $this->getRepository(); |
|
| 522 | ||
| 523 | $mediaFolderId = $this->generateId('object', 41); |
|
| 524 | /* BEGIN: Use Case */ |
|
| 525 | $contentService = $repository->getContentService(); |
|
| 526 | ||
| 527 | // Load the ContentInfo for "Media" folder |
|
| 528 | $contentInfo = $contentService->loadContentInfo($mediaFolderId); |
|
| 529 | /* END: Use Case */ |
|
| 530 | ||
| 531 | $this->assertInstanceOf( |
|
| 532 | '\\eZ\\Publish\\API\\Repository\\Values\\Content\\ContentInfo', |
|
| 533 | $contentInfo |
|
| 534 | ); |
|
| 535 | ||
| 536 | return $contentInfo; |
|
| 537 | } |
|
| 538 | ||
| 539 | /** |
|
| 540 | * Test for the returned value of the loadContentInfo() method. |
|
| @@ 602-611 (lines=10) @@ | ||
| 599 | * @see \eZ\Publish\API\Repository\ContentService::loadContentInfoList() |
|
| 600 | * @depends testLoadContentInfoList |
|
| 601 | */ |
|
| 602 | public function testLoadContentInfoListSkipsNotFoundItems() |
|
| 603 | { |
|
| 604 | $repository = $this->getRepository(); |
|
| 605 | ||
| 606 | $nonExistentContentId = $this->generateId('object', self::DB_INT_MAX); |
|
| 607 | $contentService = $repository->getContentService(); |
|
| 608 | $list = $contentService->loadContentInfoList([$nonExistentContentId]); |
|
| 609 | ||
| 610 | $this->assertCount(0, $list); |
|
| 611 | } |
|
| 612 | ||
| 613 | /** |
|
| 614 | * Test for the loadContentInfoByRemoteId() method. |
|
| @@ 690-711 (lines=22) @@ | ||
| 687 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentInfo |
|
| 688 | * @group user |
|
| 689 | */ |
|
| 690 | public function testLoadVersionInfo() |
|
| 691 | { |
|
| 692 | $repository = $this->getRepository(); |
|
| 693 | ||
| 694 | $mediaFolderId = $this->generateId('object', 41); |
|
| 695 | /* BEGIN: Use Case */ |
|
| 696 | // $mediaFolderId contains the ID of the "Media" folder |
|
| 697 | ||
| 698 | $contentService = $repository->getContentService(); |
|
| 699 | ||
| 700 | // Load the ContentInfo for "Media" folder |
|
| 701 | $contentInfo = $contentService->loadContentInfo($mediaFolderId); |
|
| 702 | ||
| 703 | // Now load the current version info of the "Media" folder |
|
| 704 | $versionInfo = $contentService->loadVersionInfo($contentInfo); |
|
| 705 | /* END: Use Case */ |
|
| 706 | ||
| 707 | $this->assertInstanceOf( |
|
| 708 | '\\eZ\\Publish\\API\\Repository\\Values\\Content\\VersionInfo', |
|
| 709 | $versionInfo |
|
| 710 | ); |
|
| 711 | } |
|
| 712 | ||
| 713 | /** |
|
| 714 | * Test for the loadVersionInfoById() method. |
|
| @@ 718-738 (lines=21) @@ | ||
| 715 | * |
|
| 716 | * @see \eZ\Publish\API\Repository\ContentService::loadVersionInfoById() |
|
| 717 | */ |
|
| 718 | public function testLoadVersionInfoById() |
|
| 719 | { |
|
| 720 | $repository = $this->getRepository(); |
|
| 721 | ||
| 722 | $mediaFolderId = $this->generateId('object', 41); |
|
| 723 | /* BEGIN: Use Case */ |
|
| 724 | // $mediaFolderId contains the ID of the "Media" folder |
|
| 725 | ||
| 726 | $contentService = $repository->getContentService(); |
|
| 727 | ||
| 728 | // Load the VersionInfo for "Media" folder |
|
| 729 | $versionInfo = $contentService->loadVersionInfoById($mediaFolderId); |
|
| 730 | /* END: Use Case */ |
|
| 731 | ||
| 732 | $this->assertInstanceOf( |
|
| 733 | '\\eZ\\Publish\\API\\Repository\\Values\\Content\\VersionInfo', |
|
| 734 | $versionInfo |
|
| 735 | ); |
|
| 736 | ||
| 737 | return $versionInfo; |
|
| 738 | } |
|
| 739 | ||
| 740 | /** |
|
| 741 | * Test for the returned value of the loadVersionInfoById() method. |
|
| @@ 800-821 (lines=22) @@ | ||
| 797 | * @see \eZ\Publish\API\Repository\ContentService::loadContentByContentInfo() |
|
| 798 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentInfo |
|
| 799 | */ |
|
| 800 | public function testLoadContentByContentInfo() |
|
| 801 | { |
|
| 802 | $repository = $this->getRepository(); |
|
| 803 | ||
| 804 | $mediaFolderId = $this->generateId('object', 41); |
|
| 805 | /* BEGIN: Use Case */ |
|
| 806 | // $mediaFolderId contains the ID of the "Media" folder |
|
| 807 | ||
| 808 | $contentService = $repository->getContentService(); |
|
| 809 | ||
| 810 | // Load the ContentInfo for "Media" folder |
|
| 811 | $contentInfo = $contentService->loadContentInfo($mediaFolderId); |
|
| 812 | ||
| 813 | // Now load the current content version for the info instance |
|
| 814 | $content = $contentService->loadContentByContentInfo($contentInfo); |
|
| 815 | /* END: Use Case */ |
|
| 816 | ||
| 817 | $this->assertInstanceOf( |
|
| 818 | '\\eZ\\Publish\\API\\Repository\\Values\\Content\\Content', |
|
| 819 | $content |
|
| 820 | ); |
|
| 821 | } |
|
| 822 | ||
| 823 | /** |
|
| 824 | * Test for the loadContentByVersionInfo() method. |
|
| @@ 862-880 (lines=19) @@ | ||
| 859 | * @group user |
|
| 860 | * @group field-type |
|
| 861 | */ |
|
| 862 | public function testLoadContent() |
|
| 863 | { |
|
| 864 | $repository = $this->getRepository(); |
|
| 865 | ||
| 866 | $mediaFolderId = $this->generateId('object', 41); |
|
| 867 | /* BEGIN: Use Case */ |
|
| 868 | // $mediaFolderId contains the ID of the "Media" folder |
|
| 869 | ||
| 870 | $contentService = $repository->getContentService(); |
|
| 871 | ||
| 872 | // Load the Content for "Media" folder, any language and current version |
|
| 873 | $content = $contentService->loadContent($mediaFolderId); |
|
| 874 | /* END: Use Case */ |
|
| 875 | ||
| 876 | $this->assertInstanceOf( |
|
| 877 | '\\eZ\\Publish\\API\\Repository\\Values\\Content\\Content', |
|
| 878 | $content |
|
| 879 | ); |
|
| 880 | } |
|
| 881 | ||
| 882 | /** |
|
| 883 | * Test for the loadContent() method. |
|