Code Duplication    Length = 18-21 lines in 3 locations

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

@@ 1844-1864 (lines=21) @@
1841
     * @see \eZ\Publish\API\Repository\ContentService::publishVersion()
1842
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersionFromContentDraft
1843
     */
1844
    public function testPublishVersionFromOldContentDraftArchivesNewerVersionNo()
1845
    {
1846
        /* BEGIN: Use Case */
1847
        $content = $this->createContentVersion1();
1848
1849
        // Create a new draft with versionNo = 2
1850
        $draftedContentVersion2 = $this->contentService->createContentDraft($content->contentInfo);
1851
1852
        // Create another new draft with versionNo = 3
1853
        $draftedContentVersion3 = $this->contentService->createContentDraft($content->contentInfo);
1854
1855
        // Publish draft with versionNo = 3
1856
        $this->contentService->publishVersion($draftedContentVersion3->getVersionInfo());
1857
1858
        // Publish the first draft with versionNo = 2
1859
        // currentVersionNo is now 2, versionNo 3 will be archived
1860
        $publishedDraft = $this->contentService->publishVersion($draftedContentVersion2->getVersionInfo());
1861
        /* END: Use Case */
1862
1863
        $this->assertEquals(2, $publishedDraft->contentInfo->currentVersionNo);
1864
    }
1865
1866
    /**
1867
     * Test for the publishVersion() method, and that it creates limited archives.
@@ 2260-2278 (lines=19) @@
2257
     * @see \eZ\Publish\API\Repository\ContentService::loadVersionInfo($contentInfo, $versionNo)
2258
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersionFromContentDraft
2259
     */
2260
    public function testLoadVersionInfoWithSecondParameter()
2261
    {
2262
        /* BEGIN: Use Case */
2263
        $publishedContent = $this->createContentVersion1();
2264
2265
        $draftContent = $this->contentService->createContentDraft($publishedContent->contentInfo);
2266
2267
        // Will return the VersionInfo of the $draftContent
2268
        $versionInfo = $this->contentService->loadVersionInfoById($publishedContent->id, 2);
2269
        /* END: Use Case */
2270
2271
        $this->assertEquals(2, $versionInfo->versionNo);
2272
2273
        // Check that ContentInfo contained in VersionInfo has correct main Location id set
2274
        $this->assertEquals(
2275
            $publishedContent->getVersionInfo()->getContentInfo()->mainLocationId,
2276
            $versionInfo->getContentInfo()->mainLocationId
2277
        );
2278
    }
2279
2280
    /**
2281
     * Test for the loadVersionInfo() method.
@@ 3277-3294 (lines=18) @@
3274
     * @see \eZ\Publish\API\Repository\ContentService::createContentDraft()
3275
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testAddRelationSetsExpectedRelations
3276
     */
3277
    public function testCreateContentDraftWithRelations()
3278
    {
3279
        // RemoteId of the "Media" content of an eZ Publish demo installation
3280
        $mediaRemoteId = 'a6e35cbcb7cd6ae4b691f3eee30cd262';
3281
        $draft = $this->createContentDraftVersion1();
3282
        $media = $this->contentService->loadContentInfoByRemoteId($mediaRemoteId);
3283
3284
        // Create relation between new content object and "Media" page
3285
        $this->contentService->addRelation(
3286
            $draft->getVersionInfo(),
3287
            $media
3288
        );
3289
3290
        $content = $this->contentService->publishVersion($draft->versionInfo);
3291
        $newDraft = $this->contentService->createContentDraft($content->contentInfo);
3292
3293
        return $this->contentService->loadRelations($newDraft->getVersionInfo());
3294
    }
3295
3296
    /**
3297
     * Test for the createContentDraft() method.