Code Duplication    Length = 18-21 lines in 3 locations

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

@@ 1845-1865 (lines=21) @@
1842
     * @see \eZ\Publish\API\Repository\ContentService::publishVersion()
1843
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersionFromContentDraft
1844
     */
1845
    public function testPublishVersionFromOldContentDraftArchivesNewerVersionNo()
1846
    {
1847
        /* BEGIN: Use Case */
1848
        $content = $this->createContentVersion1();
1849
1850
        // Create a new draft with versionNo = 2
1851
        $draftedContentVersion2 = $this->contentService->createContentDraft($content->contentInfo);
1852
1853
        // Create another new draft with versionNo = 3
1854
        $draftedContentVersion3 = $this->contentService->createContentDraft($content->contentInfo);
1855
1856
        // Publish draft with versionNo = 3
1857
        $this->contentService->publishVersion($draftedContentVersion3->getVersionInfo());
1858
1859
        // Publish the first draft with versionNo = 2
1860
        // currentVersionNo is now 2, versionNo 3 will be archived
1861
        $publishedDraft = $this->contentService->publishVersion($draftedContentVersion2->getVersionInfo());
1862
        /* END: Use Case */
1863
1864
        $this->assertEquals(2, $publishedDraft->contentInfo->currentVersionNo);
1865
    }
1866
1867
    /**
1868
     * Test for the publishVersion() method, and that it creates limited archives.
@@ 2360-2378 (lines=19) @@
2357
     * @see \eZ\Publish\API\Repository\ContentService::loadVersionInfo($contentInfo, $versionNo)
2358
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersionFromContentDraft
2359
     */
2360
    public function testLoadVersionInfoWithSecondParameter()
2361
    {
2362
        /* BEGIN: Use Case */
2363
        $publishedContent = $this->createContentVersion1();
2364
2365
        $draftContent = $this->contentService->createContentDraft($publishedContent->contentInfo);
2366
2367
        // Will return the VersionInfo of the $draftContent
2368
        $versionInfo = $this->contentService->loadVersionInfoById($publishedContent->id, 2);
2369
        /* END: Use Case */
2370
2371
        $this->assertEquals(2, $versionInfo->versionNo);
2372
2373
        // Check that ContentInfo contained in VersionInfo has correct main Location id set
2374
        $this->assertEquals(
2375
            $publishedContent->getVersionInfo()->getContentInfo()->mainLocationId,
2376
            $versionInfo->getContentInfo()->mainLocationId
2377
        );
2378
    }
2379
2380
    /**
2381
     * Test for the loadVersionInfo() method.
@@ 3377-3394 (lines=18) @@
3374
     * @see \eZ\Publish\API\Repository\ContentService::createContentDraft()
3375
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testAddRelationSetsExpectedRelations
3376
     */
3377
    public function testCreateContentDraftWithRelations()
3378
    {
3379
        // RemoteId of the "Media" content of an eZ Publish demo installation
3380
        $mediaRemoteId = 'a6e35cbcb7cd6ae4b691f3eee30cd262';
3381
        $draft = $this->createContentDraftVersion1();
3382
        $media = $this->contentService->loadContentInfoByRemoteId($mediaRemoteId);
3383
3384
        // Create relation between new content object and "Media" page
3385
        $this->contentService->addRelation(
3386
            $draft->getVersionInfo(),
3387
            $media
3388
        );
3389
3390
        $content = $this->contentService->publishVersion($draft->versionInfo);
3391
        $newDraft = $this->contentService->createContentDraft($content->contentInfo);
3392
3393
        return $this->contentService->loadRelations($newDraft->getVersionInfo());
3394
    }
3395
3396
    /**
3397
     * Test for the createContentDraft() method.