| @@ 213-232 (lines=20) @@ | ||
| 210 | * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException |
|
| 211 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadVersionInfoById |
|
| 212 | */ |
|
| 213 | public function testLoadVersionInfoByIdThrowsUnauthorizedException() |
|
| 214 | { |
|
| 215 | $repository = $this->getRepository(); |
|
| 216 | ||
| 217 | $anonymousUserId = $this->generateId('user', 10); |
|
| 218 | /* BEGIN: Use Case */ |
|
| 219 | // $anonymousUserId is the ID of the "Anonymous User" in an eZ Publish |
|
| 220 | // demo installation |
|
| 221 | ||
| 222 | $contentService = $repository->getContentService(); |
|
| 223 | ||
| 224 | $pseudoEditor = $this->createAnonymousWithEditorRole(); |
|
| 225 | ||
| 226 | // Set restricted editor user |
|
| 227 | $repository->setCurrentUser($pseudoEditor); |
|
| 228 | ||
| 229 | // This call will fail with a "UnauthorizedException" |
|
| 230 | $contentService->loadVersionInfoById($anonymousUserId); |
|
| 231 | /* END: Use Case */ |
|
| 232 | } |
|
| 233 | ||
| 234 | /** |
|
| 235 | * Test for the loadVersionInfoById() method. |
|
| @@ 241-260 (lines=20) @@ | ||
| 238 | * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException |
|
| 239 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadVersionInfoByIdWithSecondParameter |
|
| 240 | */ |
|
| 241 | public function testLoadVersionInfoByIdThrowsUnauthorizedExceptionWithSecondParameter() |
|
| 242 | { |
|
| 243 | $repository = $this->getRepository(); |
|
| 244 | ||
| 245 | $anonymousUserId = $this->generateId('user', 10); |
|
| 246 | /* BEGIN: Use Case */ |
|
| 247 | // $anonymousUserId is the ID of the "Anonymous User" in an eZ Publish |
|
| 248 | // demo installation |
|
| 249 | ||
| 250 | $contentService = $repository->getContentService(); |
|
| 251 | ||
| 252 | $pseudoEditor = $this->createAnonymousWithEditorRole(); |
|
| 253 | ||
| 254 | // Set restricted editor user |
|
| 255 | $repository->setCurrentUser($pseudoEditor); |
|
| 256 | ||
| 257 | // This call will fail with a "UnauthorizedException" |
|
| 258 | $contentService->loadVersionInfoById($anonymousUserId, 2); |
|
| 259 | /* END: Use Case */ |
|
| 260 | } |
|
| 261 | ||
| 262 | /** |
|
| 263 | * Test for the loadVersionInfoById() method. |
|
| @@ 493-511 (lines=19) @@ | ||
| 490 | * @see \eZ\Publish\API\Repository\ContentService::loadContentInfo() |
|
| 491 | * @group user |
|
| 492 | */ |
|
| 493 | public function testLoadContentInfo() |
|
| 494 | { |
|
| 495 | $repository = $this->getRepository(); |
|
| 496 | ||
| 497 | $mediaFolderId = $this->generateId('object', 41); |
|
| 498 | /* BEGIN: Use Case */ |
|
| 499 | $contentService = $repository->getContentService(); |
|
| 500 | ||
| 501 | // Load the ContentInfo for "Media" folder |
|
| 502 | $contentInfo = $contentService->loadContentInfo($mediaFolderId); |
|
| 503 | /* END: Use Case */ |
|
| 504 | ||
| 505 | $this->assertInstanceOf( |
|
| 506 | '\\eZ\\Publish\\API\\Repository\\Values\\Content\\ContentInfo', |
|
| 507 | $contentInfo |
|
| 508 | ); |
|
| 509 | ||
| 510 | return $contentInfo; |
|
| 511 | } |
|
| 512 | ||
| 513 | /** |
|
| 514 | * Test for the returned value of the loadContentInfo() method. |
|
| @@ 626-647 (lines=22) @@ | ||
| 623 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentInfo |
|
| 624 | * @group user |
|
| 625 | */ |
|
| 626 | public function testLoadVersionInfo() |
|
| 627 | { |
|
| 628 | $repository = $this->getRepository(); |
|
| 629 | ||
| 630 | $mediaFolderId = $this->generateId('object', 41); |
|
| 631 | /* BEGIN: Use Case */ |
|
| 632 | // $mediaFolderId contains the ID of the "Media" folder |
|
| 633 | ||
| 634 | $contentService = $repository->getContentService(); |
|
| 635 | ||
| 636 | // Load the ContentInfo for "Media" folder |
|
| 637 | $contentInfo = $contentService->loadContentInfo($mediaFolderId); |
|
| 638 | ||
| 639 | // Now load the current version info of the "Media" folder |
|
| 640 | $versionInfo = $contentService->loadVersionInfo($contentInfo); |
|
| 641 | /* END: Use Case */ |
|
| 642 | ||
| 643 | $this->assertInstanceOf( |
|
| 644 | '\\eZ\\Publish\\API\\Repository\\Values\\Content\\VersionInfo', |
|
| 645 | $versionInfo |
|
| 646 | ); |
|
| 647 | } |
|
| 648 | ||
| 649 | /** |
|
| 650 | * Test for the loadVersionInfoById() method. |
|
| @@ 654-674 (lines=21) @@ | ||
| 651 | * |
|
| 652 | * @see \eZ\Publish\API\Repository\ContentService::loadVersionInfoById() |
|
| 653 | */ |
|
| 654 | public function testLoadVersionInfoById() |
|
| 655 | { |
|
| 656 | $repository = $this->getRepository(); |
|
| 657 | ||
| 658 | $mediaFolderId = $this->generateId('object', 41); |
|
| 659 | /* BEGIN: Use Case */ |
|
| 660 | // $mediaFolderId contains the ID of the "Media" folder |
|
| 661 | ||
| 662 | $contentService = $repository->getContentService(); |
|
| 663 | ||
| 664 | // Load the VersionInfo for "Media" folder |
|
| 665 | $versionInfo = $contentService->loadVersionInfoById($mediaFolderId); |
|
| 666 | /* END: Use Case */ |
|
| 667 | ||
| 668 | $this->assertInstanceOf( |
|
| 669 | '\\eZ\\Publish\\API\\Repository\\Values\\Content\\VersionInfo', |
|
| 670 | $versionInfo |
|
| 671 | ); |
|
| 672 | ||
| 673 | return $versionInfo; |
|
| 674 | } |
|
| 675 | ||
| 676 | /** |
|
| 677 | * Test for the returned value of the loadVersionInfoById() method. |
|
| @@ 736-757 (lines=22) @@ | ||
| 733 | * @see \eZ\Publish\API\Repository\ContentService::loadContentByContentInfo() |
|
| 734 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentInfo |
|
| 735 | */ |
|
| 736 | public function testLoadContentByContentInfo() |
|
| 737 | { |
|
| 738 | $repository = $this->getRepository(); |
|
| 739 | ||
| 740 | $mediaFolderId = $this->generateId('object', 41); |
|
| 741 | /* BEGIN: Use Case */ |
|
| 742 | // $mediaFolderId contains the ID of the "Media" folder |
|
| 743 | ||
| 744 | $contentService = $repository->getContentService(); |
|
| 745 | ||
| 746 | // Load the ContentInfo for "Media" folder |
|
| 747 | $contentInfo = $contentService->loadContentInfo($mediaFolderId); |
|
| 748 | ||
| 749 | // Now load the current content version for the info instance |
|
| 750 | $content = $contentService->loadContentByContentInfo($contentInfo); |
|
| 751 | /* END: Use Case */ |
|
| 752 | ||
| 753 | $this->assertInstanceOf( |
|
| 754 | '\\eZ\\Publish\\API\\Repository\\Values\\Content\\Content', |
|
| 755 | $content |
|
| 756 | ); |
|
| 757 | } |
|
| 758 | ||
| 759 | /** |
|
| 760 | * Test for the loadContentByVersionInfo() method. |
|
| @@ 798-816 (lines=19) @@ | ||
| 795 | * @group user |
|
| 796 | * @group field-type |
|
| 797 | */ |
|
| 798 | public function testLoadContent() |
|
| 799 | { |
|
| 800 | $repository = $this->getRepository(); |
|
| 801 | ||
| 802 | $mediaFolderId = $this->generateId('object', 41); |
|
| 803 | /* BEGIN: Use Case */ |
|
| 804 | // $mediaFolderId contains the ID of the "Media" folder |
|
| 805 | ||
| 806 | $contentService = $repository->getContentService(); |
|
| 807 | ||
| 808 | // Load the Content for "Media" folder, any language and current version |
|
| 809 | $content = $contentService->loadContent($mediaFolderId); |
|
| 810 | /* END: Use Case */ |
|
| 811 | ||
| 812 | $this->assertInstanceOf( |
|
| 813 | '\\eZ\\Publish\\API\\Repository\\Values\\Content\\Content', |
|
| 814 | $content |
|
| 815 | ); |
|
| 816 | } |
|
| 817 | ||
| 818 | /** |
|
| 819 | * Test for the loadContent() method. |
|