| @@ 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 |
|
| @@ 947-963 (lines=17) @@ | ||
| 944 | * @expectedException \eZ\Publish\API\Repository\Exceptions\BadStateException |
|
| 945 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersion |
|
| 946 | */ |
|
| 947 | public function testPublishVersionThrowsBadStateException() |
|
| 948 | { |
|
| 949 | $repository = $this->getRepository(); |
|
| 950 | ||
| 951 | $contentService = $repository->getContentService(); |
|
| 952 | ||
| 953 | /* BEGIN: Use Case */ |
|
| 954 | $draft = $this->createContentDraftVersion1(); |
|
| 955 | ||
| 956 | // Publish the content draft |
|
| 957 | $contentService->publishVersion($draft->getVersionInfo()); |
|
| 958 | ||
| 959 | // This call will fail with a "BadStateException", because the version |
|
| 960 | // is already published. |
|
| 961 | $contentService->publishVersion($draft->getVersionInfo()); |
|
| 962 | /* END: Use Case */ |
|
| 963 | } |
|
| 964 | ||
| 965 | /** |
|
| 966 | * Test for the createContentDraft() method. |
|
| @@ 2611-2624 (lines=14) @@ | ||
| 2608 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContent |
|
| 2609 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersion |
|
| 2610 | */ |
|
| 2611 | public function testDeleteVersionThrowsBadStateExceptionOnLastVersion() |
|
| 2612 | { |
|
| 2613 | $repository = $this->getRepository(); |
|
| 2614 | ||
| 2615 | $contentService = $repository->getContentService(); |
|
| 2616 | ||
| 2617 | /* BEGIN: Use Case */ |
|
| 2618 | $draft = $this->createContentDraftVersion1(); |
|
| 2619 | ||
| 2620 | // This call will fail with a "BadStateException", because the Content |
|
| 2621 | // version is the last version of the Content. |
|
| 2622 | $contentService->deleteVersion($draft->getVersionInfo()); |
|
| 2623 | /* END: Use Case */ |
|
| 2624 | } |
|
| 2625 | ||
| 2626 | /** |
|
| 2627 | * Test for the loadVersions() method. |
|