| @@ 117-131 (lines=15) @@ | ||
| 114 | * |
|
| 115 | * @return \eZ\Publish\API\Repository\Values\Content\Content |
|
| 116 | */ |
|
| 117 | protected function createContentVersion1() |
|
| 118 | { |
|
| 119 | $repository = $this->getRepository(); |
|
| 120 | ||
| 121 | $contentService = $repository->getContentService(); |
|
| 122 | ||
| 123 | /* BEGIN: Inline */ |
|
| 124 | $draft = $this->createContentDraftVersion1(); |
|
| 125 | ||
| 126 | // Publish this draft |
|
| 127 | $content = $contentService->publishVersion($draft->getVersionInfo()); |
|
| 128 | /* END: Inline */ |
|
| 129 | ||
| 130 | return $content; |
|
| 131 | } |
|
| 132 | ||
| 133 | /** |
|
| 134 | * Creates a new content draft named <b>$draftVersion2</b> from a currently |
|
| @@ 1069-1085 (lines=17) @@ | ||
| 1066 | * @expectedException \eZ\Publish\API\Repository\Exceptions\BadStateException |
|
| 1067 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersion |
|
| 1068 | */ |
|
| 1069 | public function testPublishVersionThrowsBadStateException() |
|
| 1070 | { |
|
| 1071 | $repository = $this->getRepository(); |
|
| 1072 | ||
| 1073 | $contentService = $repository->getContentService(); |
|
| 1074 | ||
| 1075 | /* BEGIN: Use Case */ |
|
| 1076 | $draft = $this->createContentDraftVersion1(); |
|
| 1077 | ||
| 1078 | // Publish the content draft |
|
| 1079 | $contentService->publishVersion($draft->getVersionInfo()); |
|
| 1080 | ||
| 1081 | // This call will fail with a "BadStateException", because the version |
|
| 1082 | // is already published. |
|
| 1083 | $contentService->publishVersion($draft->getVersionInfo()); |
|
| 1084 | /* END: Use Case */ |
|
| 1085 | } |
|
| 1086 | ||
| 1087 | /** |
|
| 1088 | * Test that publishVersion() does not affect publishedDate (assuming previous version exists). |
|
| @@ 2999-3012 (lines=14) @@ | ||
| 2996 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContent |
|
| 2997 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersion |
|
| 2998 | */ |
|
| 2999 | public function testDeleteVersionThrowsBadStateExceptionOnLastVersion() |
|
| 3000 | { |
|
| 3001 | $repository = $this->getRepository(); |
|
| 3002 | ||
| 3003 | $contentService = $repository->getContentService(); |
|
| 3004 | ||
| 3005 | /* BEGIN: Use Case */ |
|
| 3006 | $draft = $this->createContentDraftVersion1(); |
|
| 3007 | ||
| 3008 | // This call will fail with a "BadStateException", because the Content |
|
| 3009 | // version is the last version of the Content. |
|
| 3010 | $contentService->deleteVersion($draft->getVersionInfo()); |
|
| 3011 | /* END: Use Case */ |
|
| 3012 | } |
|
| 3013 | ||
| 3014 | /** |
|
| 3015 | * Test for the loadVersions() method. |
|