Code Duplication    Length = 13-18 lines in 6 locations

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.

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

@@ 1124-1141 (lines=18) @@
1121
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContentDraft
1122
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadVersionInfo
1123
     */
1124
    public function testCreateContentDraftLoadVersionInfoStillLoadsPublishedVersion($draft)
1125
    {
1126
        $repository = $this->getRepository();
1127
1128
        $contentService = $repository->getContentService();
1129
1130
        /* BEGIN: Use Case */
1131
        $content = $this->createContentVersion1();
1132
1133
        // Now we create a new draft from the published content
1134
        $contentService->createContentDraft($content->contentInfo);
1135
1136
        // This call will still load the published version
1137
        $versionInfoPublished = $contentService->loadVersionInfo($content->contentInfo);
1138
        /* END: Use Case */
1139
1140
        $this->assertEquals(1, $versionInfoPublished->versionNo);
1141
    }
1142
1143
    /**
1144
     * Test for the createContentDraft() method.
@@ 1150-1167 (lines=18) @@
1147
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContent
1148
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContentDraft
1149
     */
1150
    public function testCreateContentDraftLoadContentStillLoadsPublishedVersion()
1151
    {
1152
        $repository = $this->getRepository();
1153
1154
        $contentService = $repository->getContentService();
1155
1156
        /* BEGIN: Use Case */
1157
        $content = $this->createContentVersion1();
1158
1159
        // Now we create a new draft from the published content
1160
        $contentService->createContentDraft($content->contentInfo);
1161
1162
        // This call will still load the published content version
1163
        $contentPublished = $contentService->loadContent($content->id);
1164
        /* END: Use Case */
1165
1166
        $this->assertEquals(1, $contentPublished->getVersionInfo()->versionNo);
1167
    }
1168
1169
    /**
1170
     * Test for the createContentDraft() method.
@@ 1176-1193 (lines=18) @@
1173
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentByRemoteId
1174
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContentDraft
1175
     */
1176
    public function testCreateContentDraftLoadContentByRemoteIdStillLoadsPublishedVersion()
1177
    {
1178
        $repository = $this->getRepository();
1179
1180
        $contentService = $repository->getContentService();
1181
1182
        /* BEGIN: Use Case */
1183
        $content = $this->createContentVersion1();
1184
1185
        // Now we create a new draft from the published content
1186
        $contentService->createContentDraft($content->contentInfo);
1187
1188
        // This call will still load the published content version
1189
        $contentPublished = $contentService->loadContentByRemoteId('abcdef0123456789abcdef0123456789');
1190
        /* END: Use Case */
1191
1192
        $this->assertEquals(1, $contentPublished->getVersionInfo()->versionNo);
1193
    }
1194
1195
    /**
1196
     * Test for the createContentDraft() method.
@@ 1202-1219 (lines=18) @@
1199
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentByContentInfo
1200
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContentDraft
1201
     */
1202
    public function testCreateContentDraftLoadContentByContentInfoStillLoadsPublishedVersion()
1203
    {
1204
        $repository = $this->getRepository();
1205
1206
        $contentService = $repository->getContentService();
1207
1208
        /* BEGIN: Use Case */
1209
        $content = $this->createContentVersion1();
1210
1211
        // Now we create a new draft from the published content
1212
        $contentService->createContentDraft($content->contentInfo);
1213
1214
        // This call will still load the published content version
1215
        $contentPublished = $contentService->loadContentByContentInfo($content->contentInfo);
1216
        /* END: Use Case */
1217
1218
        $this->assertEquals(1, $contentPublished->getVersionInfo()->versionNo);
1219
    }
1220
1221
    /**
1222
     * Test for the newContentUpdateStruct() method.
@@ 1586-1603 (lines=18) @@
1583
     * @see \eZ\Publish\API\Repository\ContentService::createContentDraft($contentInfo, $versionInfo)
1584
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testUpdateContent
1585
     */
1586
    public function testCreateContentDraftWithSecondParameter()
1587
    {
1588
        $repository = $this->getRepository();
1589
1590
        $contentService = $repository->getContentService();
1591
1592
        /* BEGIN: Use Case */
1593
        $contentVersion2 = $this->createContentVersion2();
1594
1595
        // Now we create a new draft from the initial version
1596
        $draftedContentReloaded = $contentService->createContentDraft(
1597
            $contentVersion2->contentInfo,
1598
            $contentVersion2->getVersionInfo()
1599
        );
1600
        /* END: Use Case */
1601
1602
        $this->assertEquals(3, $draftedContentReloaded->getVersionInfo()->versionNo);
1603
    }
1604
1605
    /**
1606
     * Test for the publishVersion() method.