Code Duplication    Length = 13-18 lines in 6 locations

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

@@ 1122-1139 (lines=18) @@
1119
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContentDraft
1120
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadVersionInfo
1121
     */
1122
    public function testCreateContentDraftLoadVersionInfoStillLoadsPublishedVersion($draft)
1123
    {
1124
        $repository = $this->getRepository();
1125
1126
        $contentService = $repository->getContentService();
1127
1128
        /* BEGIN: Use Case */
1129
        $content = $this->createContentVersion1();
1130
1131
        // Now we create a new draft from the published content
1132
        $contentService->createContentDraft($content->contentInfo);
1133
1134
        // This call will still load the published version
1135
        $versionInfoPublished = $contentService->loadVersionInfo($content->contentInfo);
1136
        /* END: Use Case */
1137
1138
        $this->assertEquals(1, $versionInfoPublished->versionNo);
1139
    }
1140
1141
    /**
1142
     * Test for the createContentDraft() method.
@@ 1148-1165 (lines=18) @@
1145
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContent
1146
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContentDraft
1147
     */
1148
    public function testCreateContentDraftLoadContentStillLoadsPublishedVersion()
1149
    {
1150
        $repository = $this->getRepository();
1151
1152
        $contentService = $repository->getContentService();
1153
1154
        /* BEGIN: Use Case */
1155
        $content = $this->createContentVersion1();
1156
1157
        // Now we create a new draft from the published content
1158
        $contentService->createContentDraft($content->contentInfo);
1159
1160
        // This call will still load the published content version
1161
        $contentPublished = $contentService->loadContent($content->id);
1162
        /* END: Use Case */
1163
1164
        $this->assertEquals(1, $contentPublished->getVersionInfo()->versionNo);
1165
    }
1166
1167
    /**
1168
     * Test for the createContentDraft() method.
@@ 1174-1191 (lines=18) @@
1171
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentByRemoteId
1172
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContentDraft
1173
     */
1174
    public function testCreateContentDraftLoadContentByRemoteIdStillLoadsPublishedVersion()
1175
    {
1176
        $repository = $this->getRepository();
1177
1178
        $contentService = $repository->getContentService();
1179
1180
        /* BEGIN: Use Case */
1181
        $content = $this->createContentVersion1();
1182
1183
        // Now we create a new draft from the published content
1184
        $contentService->createContentDraft($content->contentInfo);
1185
1186
        // This call will still load the published content version
1187
        $contentPublished = $contentService->loadContentByRemoteId('abcdef0123456789abcdef0123456789');
1188
        /* END: Use Case */
1189
1190
        $this->assertEquals(1, $contentPublished->getVersionInfo()->versionNo);
1191
    }
1192
1193
    /**
1194
     * Test for the createContentDraft() method.
@@ 1200-1217 (lines=18) @@
1197
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentByContentInfo
1198
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContentDraft
1199
     */
1200
    public function testCreateContentDraftLoadContentByContentInfoStillLoadsPublishedVersion()
1201
    {
1202
        $repository = $this->getRepository();
1203
1204
        $contentService = $repository->getContentService();
1205
1206
        /* BEGIN: Use Case */
1207
        $content = $this->createContentVersion1();
1208
1209
        // Now we create a new draft from the published content
1210
        $contentService->createContentDraft($content->contentInfo);
1211
1212
        // This call will still load the published content version
1213
        $contentPublished = $contentService->loadContentByContentInfo($content->contentInfo);
1214
        /* END: Use Case */
1215
1216
        $this->assertEquals(1, $contentPublished->getVersionInfo()->versionNo);
1217
    }
1218
1219
    /**
1220
     * Test for the newContentUpdateStruct() method.
@@ 1530-1547 (lines=18) @@
1527
     * @see \eZ\Publish\API\Repository\ContentService::createContentDraft($contentInfo, $versionInfo)
1528
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testUpdateContent
1529
     */
1530
    public function testCreateContentDraftWithSecondParameter()
1531
    {
1532
        $repository = $this->getRepository();
1533
1534
        $contentService = $repository->getContentService();
1535
1536
        /* BEGIN: Use Case */
1537
        $contentVersion2 = $this->createContentVersion2();
1538
1539
        // Now we create a new draft from the initial version
1540
        $draftedContentReloaded = $contentService->createContentDraft(
1541
            $contentVersion2->contentInfo,
1542
            $contentVersion2->getVersionInfo()
1543
        );
1544
        /* END: Use Case */
1545
1546
        $this->assertEquals(3, $draftedContentReloaded->getVersionInfo()->versionNo);
1547
    }
1548
1549
    /**
1550
     * Test for the publishVersion() method.

eZ/Publish/Core/Repository/Tests/Service/Integration/ContentBase.php 1 location

@@ 1772-1784 (lines=13) @@
1769
     * @covers \eZ\Publish\Core\Repository\ContentService::createContentDraft
1770
     * @expectedException \eZ\Publish\API\Repository\Exceptions\BadStateException
1771
     */
1772
    public function testCreateContentDraftThrowsBadStateException()
1773
    {
1774
        $contentService = $this->repository->getContentService();
1775
        $contentInfo = $contentService->loadContentInfo(4);
1776
        $draftContent = $contentService->createContentDraft($contentInfo);
1777
1778
        // Throws an exception because version status is not
1779
        // VersionInfo::STATUS_PUBLISHED nor VersionInfo::STATUS_ARCHIVED
1780
        $draftContent = $contentService->createContentDraft(
1781
            $draftContent->contentInfo,
1782
            $draftContent->getVersionInfo()
1783
        );
1784
    }
1785
1786
    /**
1787
     * Test for the createContentDraft() method.