| @@ 116-130 (lines=15) @@ | ||
| 113 | * |
|
| 114 | * @return \eZ\Publish\API\Repository\Values\Content\Content |
|
| 115 | */ |
|
| 116 | protected function createContentVersion1() |
|
| 117 | { |
|
| 118 | $repository = $this->getRepository(); |
|
| 119 | ||
| 120 | $contentService = $repository->getContentService(); |
|
| 121 | ||
| 122 | /* BEGIN: Inline */ |
|
| 123 | $draft = $this->createContentDraftVersion1(); |
|
| 124 | ||
| 125 | // Publish this draft |
|
| 126 | $content = $contentService->publishVersion($draft->getVersionInfo()); |
|
| 127 | /* END: Inline */ |
|
| 128 | ||
| 129 | return $content; |
|
| 130 | } |
|
| 131 | ||
| 132 | /** |
|
| 133 | * Creates a new content draft named <b>$draftVersion2</b> from a currently |
|
| @@ 1068-1084 (lines=17) @@ | ||
| 1065 | * @expectedException \eZ\Publish\API\Repository\Exceptions\BadStateException |
|
| 1066 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersion |
|
| 1067 | */ |
|
| 1068 | public function testPublishVersionThrowsBadStateException() |
|
| 1069 | { |
|
| 1070 | $repository = $this->getRepository(); |
|
| 1071 | ||
| 1072 | $contentService = $repository->getContentService(); |
|
| 1073 | ||
| 1074 | /* BEGIN: Use Case */ |
|
| 1075 | $draft = $this->createContentDraftVersion1(); |
|
| 1076 | ||
| 1077 | // Publish the content draft |
|
| 1078 | $contentService->publishVersion($draft->getVersionInfo()); |
|
| 1079 | ||
| 1080 | // This call will fail with a "BadStateException", because the version |
|
| 1081 | // is already published. |
|
| 1082 | $contentService->publishVersion($draft->getVersionInfo()); |
|
| 1083 | /* END: Use Case */ |
|
| 1084 | } |
|
| 1085 | ||
| 1086 | /** |
|
| 1087 | * Test that publishVersion() does not affect publishedDate (assuming previous version exists). |
|
| @@ 2959-2972 (lines=14) @@ | ||
| 2956 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContent |
|
| 2957 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersion |
|
| 2958 | */ |
|
| 2959 | public function testDeleteVersionThrowsBadStateExceptionOnLastVersion() |
|
| 2960 | { |
|
| 2961 | $repository = $this->getRepository(); |
|
| 2962 | ||
| 2963 | $contentService = $repository->getContentService(); |
|
| 2964 | ||
| 2965 | /* BEGIN: Use Case */ |
|
| 2966 | $draft = $this->createContentDraftVersion1(); |
|
| 2967 | ||
| 2968 | // This call will fail with a "BadStateException", because the Content |
|
| 2969 | // version is the last version of the Content. |
|
| 2970 | $contentService->deleteVersion($draft->getVersionInfo()); |
|
| 2971 | /* END: Use Case */ |
|
| 2972 | } |
|
| 2973 | ||
| 2974 | /** |
|
| 2975 | * Test for the loadVersions() method. |
|