| @@ 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 |
|
| @@ 955-971 (lines=17) @@ | ||
| 952 | * @expectedException \eZ\Publish\API\Repository\Exceptions\BadStateException |
|
| 953 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersion |
|
| 954 | */ |
|
| 955 | public function testPublishVersionThrowsBadStateException() |
|
| 956 | { |
|
| 957 | $repository = $this->getRepository(); |
|
| 958 | ||
| 959 | $contentService = $repository->getContentService(); |
|
| 960 | ||
| 961 | /* BEGIN: Use Case */ |
|
| 962 | $draft = $this->createContentDraftVersion1(); |
|
| 963 | ||
| 964 | // Publish the content draft |
|
| 965 | $contentService->publishVersion($draft->getVersionInfo()); |
|
| 966 | ||
| 967 | // This call will fail with a "BadStateException", because the version |
|
| 968 | // is already published. |
|
| 969 | $contentService->publishVersion($draft->getVersionInfo()); |
|
| 970 | /* END: Use Case */ |
|
| 971 | } |
|
| 972 | ||
| 973 | /** |
|
| 974 | * Test for the createContentDraft() method. |
|
| @@ 2684-2697 (lines=14) @@ | ||
| 2681 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContent |
|
| 2682 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersion |
|
| 2683 | */ |
|
| 2684 | public function testDeleteVersionThrowsBadStateExceptionOnLastVersion() |
|
| 2685 | { |
|
| 2686 | $repository = $this->getRepository(); |
|
| 2687 | ||
| 2688 | $contentService = $repository->getContentService(); |
|
| 2689 | ||
| 2690 | /* BEGIN: Use Case */ |
|
| 2691 | $draft = $this->createContentDraftVersion1(); |
|
| 2692 | ||
| 2693 | // This call will fail with a "BadStateException", because the Content |
|
| 2694 | // version is the last version of the Content. |
|
| 2695 | $contentService->deleteVersion($draft->getVersionInfo()); |
|
| 2696 | /* END: Use Case */ |
|
| 2697 | } |
|
| 2698 | ||
| 2699 | /** |
|
| 2700 | * Test for the loadVersions() method. |
|