| @@ 126-140 (lines=15) @@ | ||
| 123 | * |
|
| 124 | * @return \eZ\Publish\API\Repository\Values\Content\Content |
|
| 125 | */ |
|
| 126 | protected function createContentVersion1() |
|
| 127 | { |
|
| 128 | $repository = $this->getRepository(); |
|
| 129 | ||
| 130 | $contentService = $repository->getContentService(); |
|
| 131 | ||
| 132 | /* BEGIN: Inline */ |
|
| 133 | $draft = $this->createContentDraftVersion1(); |
|
| 134 | ||
| 135 | // Publish this draft |
|
| 136 | $content = $contentService->publishVersion($draft->getVersionInfo()); |
|
| 137 | /* END: Inline */ |
|
| 138 | ||
| 139 | return $content; |
|
| 140 | } |
|
| 141 | ||
| 142 | /** |
|
| 143 | * Creates a new content draft named <b>$draftVersion2</b> from a currently |
|
| @@ 949-965 (lines=17) @@ | ||
| 946 | * @expectedException \eZ\Publish\API\Repository\Exceptions\BadStateException |
|
| 947 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersion |
|
| 948 | */ |
|
| 949 | public function testPublishVersionThrowsBadStateException() |
|
| 950 | { |
|
| 951 | $repository = $this->getRepository(); |
|
| 952 | ||
| 953 | $contentService = $repository->getContentService(); |
|
| 954 | ||
| 955 | /* BEGIN: Use Case */ |
|
| 956 | $draft = $this->createContentDraftVersion1(); |
|
| 957 | ||
| 958 | // Publish the content draft |
|
| 959 | $contentService->publishVersion($draft->getVersionInfo()); |
|
| 960 | ||
| 961 | // This call will fail with a "BadStateException", because the version |
|
| 962 | // is already published. |
|
| 963 | $contentService->publishVersion($draft->getVersionInfo()); |
|
| 964 | /* END: Use Case */ |
|
| 965 | } |
|
| 966 | ||
| 967 | /** |
|
| 968 | * Test for the createContentDraft() method. |
|
| @@ 2732-2745 (lines=14) @@ | ||
| 2729 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContent |
|
| 2730 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersion |
|
| 2731 | */ |
|
| 2732 | public function testDeleteVersionThrowsBadStateExceptionOnLastVersion() |
|
| 2733 | { |
|
| 2734 | $repository = $this->getRepository(); |
|
| 2735 | ||
| 2736 | $contentService = $repository->getContentService(); |
|
| 2737 | ||
| 2738 | /* BEGIN: Use Case */ |
|
| 2739 | $draft = $this->createContentDraftVersion1(); |
|
| 2740 | ||
| 2741 | // This call will fail with a "BadStateException", because the Content |
|
| 2742 | // version is the last version of the Content. |
|
| 2743 | $contentService->deleteVersion($draft->getVersionInfo()); |
|
| 2744 | /* END: Use Case */ |
|
| 2745 | } |
|
| 2746 | ||
| 2747 | /** |
|
| 2748 | * Test for the loadVersions() method. |
|