| @@ 2389-2401 (lines=13) @@ | ||
| 2386 | * @covers \eZ\Publish\Core\Repository\ContentService::addRelation |
|
| 2387 | * @expectedException \eZ\Publish\API\Repository\Exceptions\BadStateException |
|
| 2388 | */ |
|
| 2389 | public function testAddRelationThrowsBadStateException() |
|
| 2390 | { |
|
| 2391 | $contentService = $this->repository->getContentService(); |
|
| 2392 | list($contentDraft, $contentType) = $this->createTestContent(); |
|
| 2393 | $publishedContent = $contentService->publishVersion($contentDraft->versionInfo); |
|
| 2394 | ||
| 2395 | $mediaContentInfo = $contentService->loadContentInfoByRemoteId('a6e35cbcb7cd6ae4b691f3eee30cd262'); |
|
| 2396 | ||
| 2397 | $contentService->addRelation( |
|
| 2398 | $publishedContent->getVersionInfo(), |
|
| 2399 | $mediaContentInfo |
|
| 2400 | ); |
|
| 2401 | } |
|
| 2402 | ||
| 2403 | /** |
|
| 2404 | * Test for the deleteRelation() method. |
|
| @@ 2956-2977 (lines=22) @@ | ||
| 2953 | * @expectedException \eZ\Publish\API\Repository\Exceptions\BadStateException |
|
| 2954 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testAddRelation |
|
| 2955 | */ |
|
| 2956 | public function testAddRelationThrowsBadStateException() |
|
| 2957 | { |
|
| 2958 | $repository = $this->getRepository(); |
|
| 2959 | ||
| 2960 | $contentService = $repository->getContentService(); |
|
| 2961 | ||
| 2962 | /* BEGIN: Use Case */ |
|
| 2963 | // RemoteId of the "Media" page of an eZ Publish demo installation |
|
| 2964 | $mediaRemoteId = 'a6e35cbcb7cd6ae4b691f3eee30cd262'; |
|
| 2965 | ||
| 2966 | $content = $this->createContentVersion1(); |
|
| 2967 | ||
| 2968 | $media = $contentService->loadContentInfoByRemoteId($mediaRemoteId); |
|
| 2969 | ||
| 2970 | // This call will fail with a "BadStateException", because content is |
|
| 2971 | // published and not a draft. |
|
| 2972 | $contentService->addRelation( |
|
| 2973 | $content->getVersionInfo(), |
|
| 2974 | $media |
|
| 2975 | ); |
|
| 2976 | /* END: Use Case */ |
|
| 2977 | } |
|
| 2978 | ||
| 2979 | /** |
|
| 2980 | * Test for the loadRelations() method. |
|
| @@ 3520-3542 (lines=23) @@ | ||
| 3517 | * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
|
| 3518 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testDeleteRelation |
|
| 3519 | */ |
|
| 3520 | public function testDeleteRelationThrowsInvalidArgumentException() |
|
| 3521 | { |
|
| 3522 | $repository = $this->getRepository(); |
|
| 3523 | ||
| 3524 | $contentService = $repository->getContentService(); |
|
| 3525 | ||
| 3526 | /* BEGIN: Use Case */ |
|
| 3527 | // RemoteId of the "Media" page of an eZ Publish demo installation |
|
| 3528 | $mediaRemoteId = 'a6e35cbcb7cd6ae4b691f3eee30cd262'; |
|
| 3529 | ||
| 3530 | $draft = $this->createContentDraftVersion1(); |
|
| 3531 | ||
| 3532 | // Load the destination object |
|
| 3533 | $media = $contentService->loadContentInfoByRemoteId($mediaRemoteId); |
|
| 3534 | ||
| 3535 | // This call will fail with a "InvalidArgumentException", because no |
|
| 3536 | // relation exists between $draft and $media. |
|
| 3537 | $contentService->deleteRelation( |
|
| 3538 | $draft->getVersionInfo(), |
|
| 3539 | $media |
|
| 3540 | ); |
|
| 3541 | /* END: Use Case */ |
|
| 3542 | } |
|
| 3543 | ||
| 3544 | /** |
|
| 3545 | * Test for the createContent() method. |
|