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

@@ 1079-1095 (lines=17) @@
1076
     * @expectedException \eZ\Publish\API\Repository\Exceptions\BadStateException
1077
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersion
1078
     */
1079
    public function testPublishVersionThrowsBadStateException()
1080
    {
1081
        $repository = $this->getRepository();
1082
1083
        $contentService = $repository->getContentService();
1084
1085
        /* BEGIN: Use Case */
1086
        $draft = $this->createContentDraftVersion1();
1087
1088
        // Publish the content draft
1089
        $contentService->publishVersion($draft->getVersionInfo());
1090
1091
        // This call will fail with a "BadStateException", because the version
1092
        // is already published.
1093
        $contentService->publishVersion($draft->getVersionInfo());
1094
        /* END: Use Case */
1095
    }
1096
1097
    /**
1098
     * Test that publishVersion() does not affect publishedDate (assuming previous version exists).
@@ 3037-3050 (lines=14) @@
3034
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContent
3035
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersion
3036
     */
3037
    public function testDeleteVersionThrowsBadStateExceptionOnLastVersion()
3038
    {
3039
        $repository = $this->getRepository();
3040
3041
        $contentService = $repository->getContentService();
3042
3043
        /* BEGIN: Use Case */
3044
        $draft = $this->createContentDraftVersion1();
3045
3046
        // This call will fail with a "BadStateException", because the Content
3047
        // version is the last version of the Content.
3048
        $contentService->deleteVersion($draft->getVersionInfo());
3049
        /* END: Use Case */
3050
    }
3051
3052
    /**
3053
     * Test for the loadVersions() method.