Code Duplication    Length = 23-30 lines in 3 locations

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

@@ 2679-2708 (lines=30) @@
2676
     * @see \eZ\Publish\API\Repository\ContentService::loadContentByContentInfo($contentInfo, $languages, $versionNo)
2677
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentByContentInfo
2678
     */
2679
    public function testLoadContentByContentInfoWithVersionNumberParameter()
2680
    {
2681
        $repository = $this->getRepository();
2682
2683
        $contentService = $repository->getContentService();
2684
2685
        /* BEGIN: Use Case */
2686
        $publishedContent = $this->createContentVersion1();
2687
2688
        $draftContent = $contentService->createContentDraft($publishedContent->contentInfo);
2689
2690
        // This content instance is identical to $draftContent
2691
        $draftContentReloaded = $contentService->loadContentByContentInfo(
2692
            $publishedContent->contentInfo,
2693
            null,
2694
            2
2695
        );
2696
        /* END: Use Case */
2697
2698
        $this->assertEquals(
2699
            2,
2700
            $draftContentReloaded->getVersionInfo()->versionNo
2701
        );
2702
2703
        // Check that ContentInfo contained in reloaded draft Content has correct main Location id set
2704
        $this->assertEquals(
2705
            $publishedContent->versionInfo->contentInfo->mainLocationId,
2706
            $draftContentReloaded->versionInfo->contentInfo->mainLocationId
2707
        );
2708
    }
2709
2710
    /**
2711
     * Test for the loadContentByContentInfo() method.
@@ 2779-2801 (lines=23) @@
2776
     * @see \eZ\Publish\API\Repository\ContentService::loadContent($contentId, $languages, $versionNo)
2777
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersionFromContentDraft
2778
     */
2779
    public function testLoadContentWithThirdParameter()
2780
    {
2781
        $repository = $this->getRepository();
2782
2783
        $contentService = $repository->getContentService();
2784
2785
        /* BEGIN: Use Case */
2786
        $publishedContent = $this->createContentVersion1();
2787
2788
        $draftContent = $contentService->createContentDraft($publishedContent->contentInfo);
2789
2790
        // This content instance is identical to $draftContent
2791
        $draftContentReloaded = $contentService->loadContent($publishedContent->id, null, 2);
2792
        /* END: Use Case */
2793
2794
        $this->assertEquals(2, $draftContentReloaded->getVersionInfo()->versionNo);
2795
2796
        // Check that ContentInfo contained in reloaded draft Content has correct main Location id set
2797
        $this->assertEquals(
2798
            $publishedContent->versionInfo->contentInfo->mainLocationId,
2799
            $draftContentReloaded->versionInfo->contentInfo->mainLocationId
2800
        );
2801
    }
2802
2803
    /**
2804
     * Test for the loadContent() method.
@@ 2860-2886 (lines=27) @@
2857
     * @see \eZ\Publish\API\Repository\ContentService::loadContentByRemoteId($remoteId, $languages, $versionNo)
2858
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersionFromContentDraft
2859
     */
2860
    public function testLoadContentByRemoteIdWithThirdParameter()
2861
    {
2862
        $repository = $this->getRepository();
2863
2864
        $contentService = $repository->getContentService();
2865
2866
        /* BEGIN: Use Case */
2867
        $publishedContent = $this->createContentVersion1();
2868
2869
        $draftContent = $contentService->createContentDraft($publishedContent->contentInfo);
2870
2871
        // This content instance is identical to $draftContent
2872
        $draftContentReloaded = $contentService->loadContentByRemoteId(
2873
            $publishedContent->contentInfo->remoteId,
2874
            null,
2875
            2
2876
        );
2877
        /* END: Use Case */
2878
2879
        $this->assertEquals(2, $draftContentReloaded->getVersionInfo()->versionNo);
2880
2881
        // Check that ContentInfo contained in reloaded draft Content has correct main Location id set
2882
        $this->assertEquals(
2883
            $publishedContent->versionInfo->contentInfo->mainLocationId,
2884
            $draftContentReloaded->versionInfo->contentInfo->mainLocationId
2885
        );
2886
    }
2887
2888
    /**
2889
     * Test for the loadContentByRemoteId() method.