| @@ 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. |
|
| @@ 489-507 (lines=19) @@ | ||
| 486 | * @see \eZ\Publish\API\Repository\ContentService::loadContentInfo() |
|
| 487 | * @group user |
|
| 488 | */ |
|
| 489 | public function testLoadContentInfo() |
|
| 490 | { |
|
| 491 | $repository = $this->getRepository(); |
|
| 492 | ||
| 493 | $mediaFolderId = $this->generateId('object', 41); |
|
| 494 | /* BEGIN: Use Case */ |
|
| 495 | $contentService = $repository->getContentService(); |
|
| 496 | ||
| 497 | // Load the ContentInfo for "Media" folder |
|
| 498 | $contentInfo = $contentService->loadContentInfo($mediaFolderId); |
|
| 499 | /* END: Use Case */ |
|
| 500 | ||
| 501 | $this->assertInstanceOf( |
|
| 502 | '\\eZ\\Publish\\API\\Repository\\Values\\Content\\ContentInfo', |
|
| 503 | $contentInfo |
|
| 504 | ); |
|
| 505 | ||
| 506 | return $contentInfo; |
|
| 507 | } |
|
| 508 | ||
| 509 | /** |
|
| 510 | * Test for the returned value of the loadContentInfo() method. |
|
| @@ 622-643 (lines=22) @@ | ||
| 619 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentInfo |
|
| 620 | * @group user |
|
| 621 | */ |
|
| 622 | public function testLoadVersionInfo() |
|
| 623 | { |
|
| 624 | $repository = $this->getRepository(); |
|
| 625 | ||
| 626 | $mediaFolderId = $this->generateId('object', 41); |
|
| 627 | /* BEGIN: Use Case */ |
|
| 628 | // $mediaFolderId contains the ID of the "Media" folder |
|
| 629 | ||
| 630 | $contentService = $repository->getContentService(); |
|
| 631 | ||
| 632 | // Load the ContentInfo for "Media" folder |
|
| 633 | $contentInfo = $contentService->loadContentInfo($mediaFolderId); |
|
| 634 | ||
| 635 | // Now load the current version info of the "Media" folder |
|
| 636 | $versionInfo = $contentService->loadVersionInfo($contentInfo); |
|
| 637 | /* END: Use Case */ |
|
| 638 | ||
| 639 | $this->assertInstanceOf( |
|
| 640 | '\\eZ\\Publish\\API\\Repository\\Values\\Content\\VersionInfo', |
|
| 641 | $versionInfo |
|
| 642 | ); |
|
| 643 | } |
|
| 644 | ||
| 645 | /** |
|
| 646 | * Test for the loadVersionInfoById() method. |
|
| @@ 650-670 (lines=21) @@ | ||
| 647 | * |
|
| 648 | * @see \eZ\Publish\API\Repository\ContentService::loadVersionInfoById() |
|
| 649 | */ |
|
| 650 | public function testLoadVersionInfoById() |
|
| 651 | { |
|
| 652 | $repository = $this->getRepository(); |
|
| 653 | ||
| 654 | $mediaFolderId = $this->generateId('object', 41); |
|
| 655 | /* BEGIN: Use Case */ |
|
| 656 | // $mediaFolderId contains the ID of the "Media" folder |
|
| 657 | ||
| 658 | $contentService = $repository->getContentService(); |
|
| 659 | ||
| 660 | // Load the VersionInfo for "Media" folder |
|
| 661 | $versionInfo = $contentService->loadVersionInfoById($mediaFolderId); |
|
| 662 | /* END: Use Case */ |
|
| 663 | ||
| 664 | $this->assertInstanceOf( |
|
| 665 | '\\eZ\\Publish\\API\\Repository\\Values\\Content\\VersionInfo', |
|
| 666 | $versionInfo |
|
| 667 | ); |
|
| 668 | ||
| 669 | return $versionInfo; |
|
| 670 | } |
|
| 671 | ||
| 672 | /** |
|
| 673 | * Test for the returned value of the loadVersionInfoById() method. |
|
| @@ 732-753 (lines=22) @@ | ||
| 729 | * @see \eZ\Publish\API\Repository\ContentService::loadContentByContentInfo() |
|
| 730 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentInfo |
|
| 731 | */ |
|
| 732 | public function testLoadContentByContentInfo() |
|
| 733 | { |
|
| 734 | $repository = $this->getRepository(); |
|
| 735 | ||
| 736 | $mediaFolderId = $this->generateId('object', 41); |
|
| 737 | /* BEGIN: Use Case */ |
|
| 738 | // $mediaFolderId contains the ID of the "Media" folder |
|
| 739 | ||
| 740 | $contentService = $repository->getContentService(); |
|
| 741 | ||
| 742 | // Load the ContentInfo for "Media" folder |
|
| 743 | $contentInfo = $contentService->loadContentInfo($mediaFolderId); |
|
| 744 | ||
| 745 | // Now load the current content version for the info instance |
|
| 746 | $content = $contentService->loadContentByContentInfo($contentInfo); |
|
| 747 | /* END: Use Case */ |
|
| 748 | ||
| 749 | $this->assertInstanceOf( |
|
| 750 | '\\eZ\\Publish\\API\\Repository\\Values\\Content\\Content', |
|
| 751 | $content |
|
| 752 | ); |
|
| 753 | } |
|
| 754 | ||
| 755 | /** |
|
| 756 | * Test for the loadContentByVersionInfo() method. |
|
| @@ 794-812 (lines=19) @@ | ||
| 791 | * @group user |
|
| 792 | * @group field-type |
|
| 793 | */ |
|
| 794 | public function testLoadContent() |
|
| 795 | { |
|
| 796 | $repository = $this->getRepository(); |
|
| 797 | ||
| 798 | $mediaFolderId = $this->generateId('object', 41); |
|
| 799 | /* BEGIN: Use Case */ |
|
| 800 | // $mediaFolderId contains the ID of the "Media" folder |
|
| 801 | ||
| 802 | $contentService = $repository->getContentService(); |
|
| 803 | ||
| 804 | // Load the Content for "Media" folder, any language and current version |
|
| 805 | $content = $contentService->loadContent($mediaFolderId); |
|
| 806 | /* END: Use Case */ |
|
| 807 | ||
| 808 | $this->assertInstanceOf( |
|
| 809 | '\\eZ\\Publish\\API\\Repository\\Values\\Content\\Content', |
|
| 810 | $content |
|
| 811 | ); |
|
| 812 | } |
|
| 813 | ||
| 814 | /** |
|
| 815 | * Test for the loadContent() method. |
|