| @@ 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. |
|
| @@ 2940-2961 (lines=22) @@ | ||
| 2937 | * @expectedException \eZ\Publish\API\Repository\Exceptions\BadStateException |
|
| 2938 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testAddRelation |
|
| 2939 | */ |
|
| 2940 | public function testAddRelationThrowsBadStateException() |
|
| 2941 | { |
|
| 2942 | $repository = $this->getRepository(); |
|
| 2943 | ||
| 2944 | $contentService = $repository->getContentService(); |
|
| 2945 | ||
| 2946 | /* BEGIN: Use Case */ |
|
| 2947 | // RemoteId of the "Media" page of an eZ Publish demo installation |
|
| 2948 | $mediaRemoteId = 'a6e35cbcb7cd6ae4b691f3eee30cd262'; |
|
| 2949 | ||
| 2950 | $content = $this->createContentVersion1(); |
|
| 2951 | ||
| 2952 | $media = $contentService->loadContentInfoByRemoteId($mediaRemoteId); |
|
| 2953 | ||
| 2954 | // This call will fail with a "BadStateException", because content is |
|
| 2955 | // published and not a draft. |
|
| 2956 | $contentService->addRelation( |
|
| 2957 | $content->getVersionInfo(), |
|
| 2958 | $media |
|
| 2959 | ); |
|
| 2960 | /* END: Use Case */ |
|
| 2961 | } |
|
| 2962 | ||
| 2963 | /** |
|
| 2964 | * Test for the loadRelations() method. |
|
| @@ 3504-3526 (lines=23) @@ | ||
| 3501 | * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
|
| 3502 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testDeleteRelation |
|
| 3503 | */ |
|
| 3504 | public function testDeleteRelationThrowsInvalidArgumentException() |
|
| 3505 | { |
|
| 3506 | $repository = $this->getRepository(); |
|
| 3507 | ||
| 3508 | $contentService = $repository->getContentService(); |
|
| 3509 | ||
| 3510 | /* BEGIN: Use Case */ |
|
| 3511 | // RemoteId of the "Media" page of an eZ Publish demo installation |
|
| 3512 | $mediaRemoteId = 'a6e35cbcb7cd6ae4b691f3eee30cd262'; |
|
| 3513 | ||
| 3514 | $draft = $this->createContentDraftVersion1(); |
|
| 3515 | ||
| 3516 | // Load the destination object |
|
| 3517 | $media = $contentService->loadContentInfoByRemoteId($mediaRemoteId); |
|
| 3518 | ||
| 3519 | // This call will fail with a "InvalidArgumentException", because no |
|
| 3520 | // relation exists between $draft and $media. |
|
| 3521 | $contentService->deleteRelation( |
|
| 3522 | $draft->getVersionInfo(), |
|
| 3523 | $media |
|
| 3524 | ); |
|
| 3525 | /* END: Use Case */ |
|
| 3526 | } |
|
| 3527 | ||
| 3528 | /** |
|
| 3529 | * Test for the createContent() method. |
|