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