Code Duplication    Length = 18-21 lines in 3 locations

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

@@ 1847-1867 (lines=21) @@
1844
     * @see \eZ\Publish\API\Repository\ContentService::publishVersion()
1845
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersionFromContentDraft
1846
     */
1847
    public function testPublishVersionFromOldContentDraftArchivesNewerVersionNo()
1848
    {
1849
        /* BEGIN: Use Case */
1850
        $content = $this->createContentVersion1();
1851
1852
        // Create a new draft with versionNo = 2
1853
        $draftedContentVersion2 = $this->contentService->createContentDraft($content->contentInfo);
1854
1855
        // Create another new draft with versionNo = 3
1856
        $draftedContentVersion3 = $this->contentService->createContentDraft($content->contentInfo);
1857
1858
        // Publish draft with versionNo = 3
1859
        $this->contentService->publishVersion($draftedContentVersion3->getVersionInfo());
1860
1861
        // Publish the first draft with versionNo = 2
1862
        // currentVersionNo is now 2, versionNo 3 will be archived
1863
        $publishedDraft = $this->contentService->publishVersion($draftedContentVersion2->getVersionInfo());
1864
        /* END: Use Case */
1865
1866
        $this->assertEquals(2, $publishedDraft->contentInfo->currentVersionNo);
1867
    }
1868
1869
    /**
1870
     * Test for the publishVersion() method, and that it creates limited archives.
@@ 2394-2412 (lines=19) @@
2391
     * @see \eZ\Publish\API\Repository\ContentService::loadVersionInfo($contentInfo, $versionNo)
2392
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersionFromContentDraft
2393
     */
2394
    public function testLoadVersionInfoWithSecondParameter()
2395
    {
2396
        /* BEGIN: Use Case */
2397
        $publishedContent = $this->createContentVersion1();
2398
2399
        $draftContent = $this->contentService->createContentDraft($publishedContent->contentInfo);
2400
2401
        // Will return the VersionInfo of the $draftContent
2402
        $versionInfo = $this->contentService->loadVersionInfoById($publishedContent->id, 2);
2403
        /* END: Use Case */
2404
2405
        $this->assertEquals(2, $versionInfo->versionNo);
2406
2407
        // Check that ContentInfo contained in VersionInfo has correct main Location id set
2408
        $this->assertEquals(
2409
            $publishedContent->getVersionInfo()->getContentInfo()->mainLocationId,
2410
            $versionInfo->getContentInfo()->mainLocationId
2411
        );
2412
    }
2413
2414
    /**
2415
     * Test for the loadVersionInfo() method.
@@ 3411-3428 (lines=18) @@
3408
     * @see \eZ\Publish\API\Repository\ContentService::createContentDraft()
3409
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testAddRelationSetsExpectedRelations
3410
     */
3411
    public function testCreateContentDraftWithRelations()
3412
    {
3413
        // RemoteId of the "Media" content of an eZ Publish demo installation
3414
        $mediaRemoteId = 'a6e35cbcb7cd6ae4b691f3eee30cd262';
3415
        $draft = $this->createContentDraftVersion1();
3416
        $media = $this->contentService->loadContentInfoByRemoteId($mediaRemoteId);
3417
3418
        // Create relation between new content object and "Media" page
3419
        $this->contentService->addRelation(
3420
            $draft->getVersionInfo(),
3421
            $media
3422
        );
3423
3424
        $content = $this->contentService->publishVersion($draft->versionInfo);
3425
        $newDraft = $this->contentService->createContentDraft($content->contentInfo);
3426
3427
        return $this->contentService->loadRelations($newDraft->getVersionInfo());
3428
    }
3429
3430
    /**
3431
     * Test for the createContentDraft() method.