Code Duplication    Length = 14-17 lines in 3 locations

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

@@ 118-132 (lines=15) @@
115
     *
116
     * @return \eZ\Publish\API\Repository\Values\Content\Content
117
     */
118
    protected function createContentVersion1()
119
    {
120
        $repository = $this->getRepository();
121
122
        $contentService = $repository->getContentService();
123
124
        /* BEGIN: Inline */
125
        $draft = $this->createContentDraftVersion1();
126
127
        // Publish this draft
128
        $content = $contentService->publishVersion($draft->getVersionInfo());
129
        /* END: Inline */
130
131
        return $content;
132
    }
133
134
    /**
135
     * Creates a new content draft named <b>$draftVersion2</b> from a currently

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

@@ 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.
@@ 2613-2626 (lines=14) @@
2610
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContent
2611
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersion
2612
     */
2613
    public function testDeleteVersionThrowsBadStateExceptionOnLastVersion()
2614
    {
2615
        $repository = $this->getRepository();
2616
2617
        $contentService = $repository->getContentService();
2618
2619
        /* BEGIN: Use Case */
2620
        $draft = $this->createContentDraftVersion1();
2621
2622
        // This call will fail with a "BadStateException", because the Content
2623
        // version is the last version of the Content.
2624
        $contentService->deleteVersion($draft->getVersionInfo());
2625
        /* END: Use Case */
2626
    }
2627
2628
    /**
2629
     * Test for the loadVersions() method.