| @@ 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. |
|
| @@ 487-505 (lines=19) @@ | ||
| 484 | * @see \eZ\Publish\API\Repository\ContentService::loadContentInfo() |
|
| 485 | * @group user |
|
| 486 | */ |
|
| 487 | public function testLoadContentInfo() |
|
| 488 | { |
|
| 489 | $repository = $this->getRepository(); |
|
| 490 | ||
| 491 | $mediaFolderId = $this->generateId('object', 41); |
|
| 492 | /* BEGIN: Use Case */ |
|
| 493 | $contentService = $repository->getContentService(); |
|
| 494 | ||
| 495 | // Load the ContentInfo for "Media" folder |
|
| 496 | $contentInfo = $contentService->loadContentInfo($mediaFolderId); |
|
| 497 | /* END: Use Case */ |
|
| 498 | ||
| 499 | $this->assertInstanceOf( |
|
| 500 | '\\eZ\\Publish\\API\\Repository\\Values\\Content\\ContentInfo', |
|
| 501 | $contentInfo |
|
| 502 | ); |
|
| 503 | ||
| 504 | return $contentInfo; |
|
| 505 | } |
|
| 506 | ||
| 507 | /** |
|
| 508 | * Test for the returned value of the loadContentInfo() method. |
|
| @@ 648-668 (lines=21) @@ | ||
| 645 | * |
|
| 646 | * @see \eZ\Publish\API\Repository\ContentService::loadVersionInfoById() |
|
| 647 | */ |
|
| 648 | public function testLoadVersionInfoById() |
|
| 649 | { |
|
| 650 | $repository = $this->getRepository(); |
|
| 651 | ||
| 652 | $mediaFolderId = $this->generateId('object', 41); |
|
| 653 | /* BEGIN: Use Case */ |
|
| 654 | // $mediaFolderId contains the ID of the "Media" folder |
|
| 655 | ||
| 656 | $contentService = $repository->getContentService(); |
|
| 657 | ||
| 658 | // Load the VersionInfo for "Media" folder |
|
| 659 | $versionInfo = $contentService->loadVersionInfoById($mediaFolderId); |
|
| 660 | /* END: Use Case */ |
|
| 661 | ||
| 662 | $this->assertInstanceOf( |
|
| 663 | '\\eZ\\Publish\\API\\Repository\\Values\\Content\\VersionInfo', |
|
| 664 | $versionInfo |
|
| 665 | ); |
|
| 666 | ||
| 667 | return $versionInfo; |
|
| 668 | } |
|
| 669 | ||
| 670 | /** |
|
| 671 | * Test for the returned value of the loadVersionInfoById() method. |
|
| @@ 792-810 (lines=19) @@ | ||
| 789 | * @group user |
|
| 790 | * @group field-type |
|
| 791 | */ |
|
| 792 | public function testLoadContent() |
|
| 793 | { |
|
| 794 | $repository = $this->getRepository(); |
|
| 795 | ||
| 796 | $mediaFolderId = $this->generateId('object', 41); |
|
| 797 | /* BEGIN: Use Case */ |
|
| 798 | // $mediaFolderId contains the ID of the "Media" folder |
|
| 799 | ||
| 800 | $contentService = $repository->getContentService(); |
|
| 801 | ||
| 802 | // Load the Content for "Media" folder, any language and current version |
|
| 803 | $content = $contentService->loadContent($mediaFolderId); |
|
| 804 | /* END: Use Case */ |
|
| 805 | ||
| 806 | $this->assertInstanceOf( |
|
| 807 | '\\eZ\\Publish\\API\\Repository\\Values\\Content\\Content', |
|
| 808 | $content |
|
| 809 | ); |
|
| 810 | } |
|
| 811 | ||
| 812 | /** |
|
| 813 | * Test for the loadContent() method. |
|