|
@@ 3577-3598 (lines=22) @@
|
| 3574 |
|
* @see \eZ\Publish\API\Repository\ContentService::createContentDraft() |
| 3575 |
|
* @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testAddRelationSetsExpectedRelations |
| 3576 |
|
*/ |
| 3577 |
|
public function testCreateContentDraftWithRelations() |
| 3578 |
|
{ |
| 3579 |
|
$repository = $this->getRepository(); |
| 3580 |
|
|
| 3581 |
|
$contentService = $repository->getContentService(); |
| 3582 |
|
|
| 3583 |
|
// RemoteId of the "Media" content of an eZ Publish demo installation |
| 3584 |
|
$mediaRemoteId = 'a6e35cbcb7cd6ae4b691f3eee30cd262'; |
| 3585 |
|
$draft = $this->createContentDraftVersion1(); |
| 3586 |
|
$media = $contentService->loadContentInfoByRemoteId($mediaRemoteId); |
| 3587 |
|
|
| 3588 |
|
// Create relation between new content object and "Media" page |
| 3589 |
|
$contentService->addRelation( |
| 3590 |
|
$draft->getVersionInfo(), |
| 3591 |
|
$media |
| 3592 |
|
); |
| 3593 |
|
|
| 3594 |
|
$content = $contentService->publishVersion($draft->versionInfo); |
| 3595 |
|
$newDraft = $contentService->createContentDraft($content->contentInfo); |
| 3596 |
|
|
| 3597 |
|
return $contentService->loadRelations($newDraft->getVersionInfo()); |
| 3598 |
|
} |
| 3599 |
|
|
| 3600 |
|
/** |
| 3601 |
|
* Test for the createContentDraft() method. |
|
@@ 4159-4192 (lines=34) @@
|
| 4156 |
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\BadStateException |
| 4157 |
|
* @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testDeleteRelation |
| 4158 |
|
*/ |
| 4159 |
|
public function testDeleteRelationThrowsBadStateException() |
| 4160 |
|
{ |
| 4161 |
|
$repository = $this->getRepository(); |
| 4162 |
|
|
| 4163 |
|
$contentService = $repository->getContentService(); |
| 4164 |
|
|
| 4165 |
|
/* BEGIN: Use Case */ |
| 4166 |
|
// RemoteId of the "Media" page of an eZ Publish demo installation |
| 4167 |
|
$mediaRemoteId = 'a6e35cbcb7cd6ae4b691f3eee30cd262'; |
| 4168 |
|
|
| 4169 |
|
$content = $this->createContentVersion1(); |
| 4170 |
|
|
| 4171 |
|
// Load the destination object |
| 4172 |
|
$media = $contentService->loadContentInfoByRemoteId($mediaRemoteId); |
| 4173 |
|
|
| 4174 |
|
// Create a new draft |
| 4175 |
|
$draftVersion2 = $contentService->createContentDraft($content->contentInfo); |
| 4176 |
|
|
| 4177 |
|
// Add a relation |
| 4178 |
|
$contentService->addRelation($draftVersion2->getVersionInfo(), $media); |
| 4179 |
|
|
| 4180 |
|
// Publish new version |
| 4181 |
|
$contentVersion2 = $contentService->publishVersion( |
| 4182 |
|
$draftVersion2->getVersionInfo() |
| 4183 |
|
); |
| 4184 |
|
|
| 4185 |
|
// This call will fail with a "BadStateException", because content is |
| 4186 |
|
// published and not a draft. |
| 4187 |
|
$contentService->deleteRelation( |
| 4188 |
|
$contentVersion2->getVersionInfo(), |
| 4189 |
|
$media |
| 4190 |
|
); |
| 4191 |
|
/* END: Use Case */ |
| 4192 |
|
} |
| 4193 |
|
|
| 4194 |
|
/** |
| 4195 |
|
* Test for the deleteRelation() method. |