|
@@ 3333-3354 (lines=22) @@
|
| 3330 |
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\BadStateException |
| 3331 |
|
* @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testAddRelation |
| 3332 |
|
*/ |
| 3333 |
|
public function testAddRelationThrowsBadStateException() |
| 3334 |
|
{ |
| 3335 |
|
$repository = $this->getRepository(); |
| 3336 |
|
|
| 3337 |
|
$contentService = $repository->getContentService(); |
| 3338 |
|
|
| 3339 |
|
/* BEGIN: Use Case */ |
| 3340 |
|
// RemoteId of the "Media" page of an eZ Publish demo installation |
| 3341 |
|
$mediaRemoteId = 'a6e35cbcb7cd6ae4b691f3eee30cd262'; |
| 3342 |
|
|
| 3343 |
|
$content = $this->createContentVersion1(); |
| 3344 |
|
|
| 3345 |
|
$media = $contentService->loadContentInfoByRemoteId($mediaRemoteId); |
| 3346 |
|
|
| 3347 |
|
// This call will fail with a "BadStateException", because content is |
| 3348 |
|
// published and not a draft. |
| 3349 |
|
$contentService->addRelation( |
| 3350 |
|
$content->getVersionInfo(), |
| 3351 |
|
$media |
| 3352 |
|
); |
| 3353 |
|
/* END: Use Case */ |
| 3354 |
|
} |
| 3355 |
|
|
| 3356 |
|
/** |
| 3357 |
|
* Test for the loadRelations() method. |
|
@@ 3897-3919 (lines=23) @@
|
| 3894 |
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
| 3895 |
|
* @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testDeleteRelation |
| 3896 |
|
*/ |
| 3897 |
|
public function testDeleteRelationThrowsInvalidArgumentException() |
| 3898 |
|
{ |
| 3899 |
|
$repository = $this->getRepository(); |
| 3900 |
|
|
| 3901 |
|
$contentService = $repository->getContentService(); |
| 3902 |
|
|
| 3903 |
|
/* BEGIN: Use Case */ |
| 3904 |
|
// RemoteId of the "Media" page of an eZ Publish demo installation |
| 3905 |
|
$mediaRemoteId = 'a6e35cbcb7cd6ae4b691f3eee30cd262'; |
| 3906 |
|
|
| 3907 |
|
$draft = $this->createContentDraftVersion1(); |
| 3908 |
|
|
| 3909 |
|
// Load the destination object |
| 3910 |
|
$media = $contentService->loadContentInfoByRemoteId($mediaRemoteId); |
| 3911 |
|
|
| 3912 |
|
// This call will fail with a "InvalidArgumentException", because no |
| 3913 |
|
// relation exists between $draft and $media. |
| 3914 |
|
$contentService->deleteRelation( |
| 3915 |
|
$draft->getVersionInfo(), |
| 3916 |
|
$media |
| 3917 |
|
); |
| 3918 |
|
/* END: Use Case */ |
| 3919 |
|
} |
| 3920 |
|
|
| 3921 |
|
/** |
| 3922 |
|
* Test for the createContent() method. |