|
@@ 3632-3653 (lines=22) @@
|
| 3629 |
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\BadStateException |
| 3630 |
|
* @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testAddRelation |
| 3631 |
|
*/ |
| 3632 |
|
public function testAddRelationThrowsBadStateException() |
| 3633 |
|
{ |
| 3634 |
|
$repository = $this->getRepository(); |
| 3635 |
|
|
| 3636 |
|
$contentService = $repository->getContentService(); |
| 3637 |
|
|
| 3638 |
|
/* BEGIN: Use Case */ |
| 3639 |
|
// RemoteId of the "Media" page of an eZ Publish demo installation |
| 3640 |
|
$mediaRemoteId = 'a6e35cbcb7cd6ae4b691f3eee30cd262'; |
| 3641 |
|
|
| 3642 |
|
$content = $this->createContentVersion1(); |
| 3643 |
|
|
| 3644 |
|
$media = $contentService->loadContentInfoByRemoteId($mediaRemoteId); |
| 3645 |
|
|
| 3646 |
|
// This call will fail with a "BadStateException", because content is |
| 3647 |
|
// published and not a draft. |
| 3648 |
|
$contentService->addRelation( |
| 3649 |
|
$content->getVersionInfo(), |
| 3650 |
|
$media |
| 3651 |
|
); |
| 3652 |
|
/* END: Use Case */ |
| 3653 |
|
} |
| 3654 |
|
|
| 3655 |
|
/** |
| 3656 |
|
* Test for the loadRelations() method. |
|
@@ 4196-4218 (lines=23) @@
|
| 4193 |
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
| 4194 |
|
* @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testDeleteRelation |
| 4195 |
|
*/ |
| 4196 |
|
public function testDeleteRelationThrowsInvalidArgumentException() |
| 4197 |
|
{ |
| 4198 |
|
$repository = $this->getRepository(); |
| 4199 |
|
|
| 4200 |
|
$contentService = $repository->getContentService(); |
| 4201 |
|
|
| 4202 |
|
/* BEGIN: Use Case */ |
| 4203 |
|
// RemoteId of the "Media" page of an eZ Publish demo installation |
| 4204 |
|
$mediaRemoteId = 'a6e35cbcb7cd6ae4b691f3eee30cd262'; |
| 4205 |
|
|
| 4206 |
|
$draft = $this->createContentDraftVersion1(); |
| 4207 |
|
|
| 4208 |
|
// Load the destination object |
| 4209 |
|
$media = $contentService->loadContentInfoByRemoteId($mediaRemoteId); |
| 4210 |
|
|
| 4211 |
|
// This call will fail with a "InvalidArgumentException", because no |
| 4212 |
|
// relation exists between $draft and $media. |
| 4213 |
|
$contentService->deleteRelation( |
| 4214 |
|
$draft->getVersionInfo(), |
| 4215 |
|
$media |
| 4216 |
|
); |
| 4217 |
|
/* END: Use Case */ |
| 4218 |
|
} |
| 4219 |
|
|
| 4220 |
|
/** |
| 4221 |
|
* Test for the createContent() method. |