Code Duplication    Length = 14-17 lines in 3 locations

eZ/Publish/API/Repository/Tests/BaseContentServiceTest.php 1 location

@@ 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

eZ/Publish/API/Repository/Tests/ContentServiceTest.php 2 locations

@@ 948-964 (lines=17) @@
945
     * @expectedException \eZ\Publish\API\Repository\Exceptions\BadStateException
946
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersion
947
     */
948
    public function testPublishVersionThrowsBadStateException()
949
    {
950
        $repository = $this->getRepository();
951
952
        $contentService = $repository->getContentService();
953
954
        /* BEGIN: Use Case */
955
        $draft = $this->createContentDraftVersion1();
956
957
        // Publish the content draft
958
        $contentService->publishVersion($draft->getVersionInfo());
959
960
        // This call will fail with a "BadStateException", because the version
961
        // is already published.
962
        $contentService->publishVersion($draft->getVersionInfo());
963
        /* END: Use Case */
964
    }
965
966
    /**
967
     * Test for the createContentDraft() method.
@@ 2731-2744 (lines=14) @@
2728
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContent
2729
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersion
2730
     */
2731
    public function testDeleteVersionThrowsBadStateExceptionOnLastVersion()
2732
    {
2733
        $repository = $this->getRepository();
2734
2735
        $contentService = $repository->getContentService();
2736
2737
        /* BEGIN: Use Case */
2738
        $draft = $this->createContentDraftVersion1();
2739
2740
        // This call will fail with a "BadStateException", because the Content
2741
        // version is the last version of the Content.
2742
        $contentService->deleteVersion($draft->getVersionInfo());
2743
        /* END: Use Case */
2744
    }
2745
2746
    /**
2747
     * Test for the loadVersions() method.