| @@ 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. |
|
| @@ 3060-3081 (lines=22) @@ | ||
| 3057 | * @expectedException \eZ\Publish\API\Repository\Exceptions\BadStateException |
|
| 3058 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testAddRelation |
|
| 3059 | */ |
|
| 3060 | public function testAddRelationThrowsBadStateException() |
|
| 3061 | { |
|
| 3062 | $repository = $this->getRepository(); |
|
| 3063 | ||
| 3064 | $contentService = $repository->getContentService(); |
|
| 3065 | ||
| 3066 | /* BEGIN: Use Case */ |
|
| 3067 | // RemoteId of the "Media" page of an eZ Publish demo installation |
|
| 3068 | $mediaRemoteId = 'a6e35cbcb7cd6ae4b691f3eee30cd262'; |
|
| 3069 | ||
| 3070 | $content = $this->createContentVersion1(); |
|
| 3071 | ||
| 3072 | $media = $contentService->loadContentInfoByRemoteId($mediaRemoteId); |
|
| 3073 | ||
| 3074 | // This call will fail with a "BadStateException", because content is |
|
| 3075 | // published and not a draft. |
|
| 3076 | $contentService->addRelation( |
|
| 3077 | $content->getVersionInfo(), |
|
| 3078 | $media |
|
| 3079 | ); |
|
| 3080 | /* END: Use Case */ |
|
| 3081 | } |
|
| 3082 | ||
| 3083 | /** |
|
| 3084 | * Test for the loadRelations() method. |
|
| @@ 3624-3646 (lines=23) @@ | ||
| 3621 | * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
|
| 3622 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testDeleteRelation |
|
| 3623 | */ |
|
| 3624 | public function testDeleteRelationThrowsInvalidArgumentException() |
|
| 3625 | { |
|
| 3626 | $repository = $this->getRepository(); |
|
| 3627 | ||
| 3628 | $contentService = $repository->getContentService(); |
|
| 3629 | ||
| 3630 | /* BEGIN: Use Case */ |
|
| 3631 | // RemoteId of the "Media" page of an eZ Publish demo installation |
|
| 3632 | $mediaRemoteId = 'a6e35cbcb7cd6ae4b691f3eee30cd262'; |
|
| 3633 | ||
| 3634 | $draft = $this->createContentDraftVersion1(); |
|
| 3635 | ||
| 3636 | // Load the destination object |
|
| 3637 | $media = $contentService->loadContentInfoByRemoteId($mediaRemoteId); |
|
| 3638 | ||
| 3639 | // This call will fail with a "InvalidArgumentException", because no |
|
| 3640 | // relation exists between $draft and $media. |
|
| 3641 | $contentService->deleteRelation( |
|
| 3642 | $draft->getVersionInfo(), |
|
| 3643 | $media |
|
| 3644 | ); |
|
| 3645 | /* END: Use Case */ |
|
| 3646 | } |
|
| 3647 | ||
| 3648 | /** |
|
| 3649 | * Test for the createContent() method. |
|