|
@@ 3535-3556 (lines=22) @@
|
| 3532 |
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\BadStateException |
| 3533 |
|
* @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testAddRelation |
| 3534 |
|
*/ |
| 3535 |
|
public function testAddRelationThrowsBadStateException() |
| 3536 |
|
{ |
| 3537 |
|
$repository = $this->getRepository(); |
| 3538 |
|
|
| 3539 |
|
$contentService = $repository->getContentService(); |
| 3540 |
|
|
| 3541 |
|
/* BEGIN: Use Case */ |
| 3542 |
|
// RemoteId of the "Media" page of an eZ Publish demo installation |
| 3543 |
|
$mediaRemoteId = 'a6e35cbcb7cd6ae4b691f3eee30cd262'; |
| 3544 |
|
|
| 3545 |
|
$content = $this->createContentVersion1(); |
| 3546 |
|
|
| 3547 |
|
$media = $contentService->loadContentInfoByRemoteId($mediaRemoteId); |
| 3548 |
|
|
| 3549 |
|
// This call will fail with a "BadStateException", because content is |
| 3550 |
|
// published and not a draft. |
| 3551 |
|
$contentService->addRelation( |
| 3552 |
|
$content->getVersionInfo(), |
| 3553 |
|
$media |
| 3554 |
|
); |
| 3555 |
|
/* END: Use Case */ |
| 3556 |
|
} |
| 3557 |
|
|
| 3558 |
|
/** |
| 3559 |
|
* Test for the loadRelations() method. |
|
@@ 4099-4121 (lines=23) @@
|
| 4096 |
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
| 4097 |
|
* @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testDeleteRelation |
| 4098 |
|
*/ |
| 4099 |
|
public function testDeleteRelationThrowsInvalidArgumentException() |
| 4100 |
|
{ |
| 4101 |
|
$repository = $this->getRepository(); |
| 4102 |
|
|
| 4103 |
|
$contentService = $repository->getContentService(); |
| 4104 |
|
|
| 4105 |
|
/* BEGIN: Use Case */ |
| 4106 |
|
// RemoteId of the "Media" page of an eZ Publish demo installation |
| 4107 |
|
$mediaRemoteId = 'a6e35cbcb7cd6ae4b691f3eee30cd262'; |
| 4108 |
|
|
| 4109 |
|
$draft = $this->createContentDraftVersion1(); |
| 4110 |
|
|
| 4111 |
|
// Load the destination object |
| 4112 |
|
$media = $contentService->loadContentInfoByRemoteId($mediaRemoteId); |
| 4113 |
|
|
| 4114 |
|
// This call will fail with a "InvalidArgumentException", because no |
| 4115 |
|
// relation exists between $draft and $media. |
| 4116 |
|
$contentService->deleteRelation( |
| 4117 |
|
$draft->getVersionInfo(), |
| 4118 |
|
$media |
| 4119 |
|
); |
| 4120 |
|
/* END: Use Case */ |
| 4121 |
|
} |
| 4122 |
|
|
| 4123 |
|
/** |
| 4124 |
|
* Test for the createContent() method. |