| @@ 2420-2432 (lines=13) @@ | ||
| 2417 | * @covers \eZ\Publish\Core\Repository\ContentService::addRelation |
|
| 2418 | * @expectedException \eZ\Publish\API\Repository\Exceptions\BadStateException |
|
| 2419 | */ |
|
| 2420 | public function testAddRelationThrowsBadStateException() |
|
| 2421 | { |
|
| 2422 | $contentService = $this->repository->getContentService(); |
|
| 2423 | list($contentDraft, $contentType) = $this->createTestContent(); |
|
| 2424 | $publishedContent = $contentService->publishVersion($contentDraft->versionInfo); |
|
| 2425 | ||
| 2426 | $mediaContentInfo = $contentService->loadContentInfoByRemoteId('a6e35cbcb7cd6ae4b691f3eee30cd262'); |
|
| 2427 | ||
| 2428 | $contentService->addRelation( |
|
| 2429 | $publishedContent->getVersionInfo(), |
|
| 2430 | $mediaContentInfo |
|
| 2431 | ); |
|
| 2432 | } |
|
| 2433 | ||
| 2434 | /** |
|
| 2435 | * Test for the deleteRelation() method. |
|
| @@ 3115-3136 (lines=22) @@ | ||
| 3112 | * @expectedException \eZ\Publish\API\Repository\Exceptions\BadStateException |
|
| 3113 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testAddRelation |
|
| 3114 | */ |
|
| 3115 | public function testAddRelationThrowsBadStateException() |
|
| 3116 | { |
|
| 3117 | $repository = $this->getRepository(); |
|
| 3118 | ||
| 3119 | $contentService = $repository->getContentService(); |
|
| 3120 | ||
| 3121 | /* BEGIN: Use Case */ |
|
| 3122 | // RemoteId of the "Media" page of an eZ Publish demo installation |
|
| 3123 | $mediaRemoteId = 'a6e35cbcb7cd6ae4b691f3eee30cd262'; |
|
| 3124 | ||
| 3125 | $content = $this->createContentVersion1(); |
|
| 3126 | ||
| 3127 | $media = $contentService->loadContentInfoByRemoteId($mediaRemoteId); |
|
| 3128 | ||
| 3129 | // This call will fail with a "BadStateException", because content is |
|
| 3130 | // published and not a draft. |
|
| 3131 | $contentService->addRelation( |
|
| 3132 | $content->getVersionInfo(), |
|
| 3133 | $media |
|
| 3134 | ); |
|
| 3135 | /* END: Use Case */ |
|
| 3136 | } |
|
| 3137 | ||
| 3138 | /** |
|
| 3139 | * Test for the loadRelations() method. |
|
| @@ 3679-3701 (lines=23) @@ | ||
| 3676 | * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
|
| 3677 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testDeleteRelation |
|
| 3678 | */ |
|
| 3679 | public function testDeleteRelationThrowsInvalidArgumentException() |
|
| 3680 | { |
|
| 3681 | $repository = $this->getRepository(); |
|
| 3682 | ||
| 3683 | $contentService = $repository->getContentService(); |
|
| 3684 | ||
| 3685 | /* BEGIN: Use Case */ |
|
| 3686 | // RemoteId of the "Media" page of an eZ Publish demo installation |
|
| 3687 | $mediaRemoteId = 'a6e35cbcb7cd6ae4b691f3eee30cd262'; |
|
| 3688 | ||
| 3689 | $draft = $this->createContentDraftVersion1(); |
|
| 3690 | ||
| 3691 | // Load the destination object |
|
| 3692 | $media = $contentService->loadContentInfoByRemoteId($mediaRemoteId); |
|
| 3693 | ||
| 3694 | // This call will fail with a "InvalidArgumentException", because no |
|
| 3695 | // relation exists between $draft and $media. |
|
| 3696 | $contentService->deleteRelation( |
|
| 3697 | $draft->getVersionInfo(), |
|
| 3698 | $media |
|
| 3699 | ); |
|
| 3700 | /* END: Use Case */ |
|
| 3701 | } |
|
| 3702 | ||
| 3703 | /** |
|
| 3704 | * Test for the createContent() method. |
|