Code Duplication    Length = 23-30 lines in 3 locations

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

@@ 2744-2773 (lines=30) @@
2741
     * @see \eZ\Publish\API\Repository\ContentService::loadContentByContentInfo($contentInfo, $languages, $versionNo)
2742
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentByContentInfo
2743
     */
2744
    public function testLoadContentByContentInfoWithVersionNumberParameter()
2745
    {
2746
        $repository = $this->getRepository();
2747
2748
        $contentService = $repository->getContentService();
2749
2750
        /* BEGIN: Use Case */
2751
        $publishedContent = $this->createContentVersion1();
2752
2753
        $draftContent = $contentService->createContentDraft($publishedContent->contentInfo);
2754
2755
        // This content instance is identical to $draftContent
2756
        $draftContentReloaded = $contentService->loadContentByContentInfo(
2757
            $publishedContent->contentInfo,
2758
            null,
2759
            2
2760
        );
2761
        /* END: Use Case */
2762
2763
        $this->assertEquals(
2764
            2,
2765
            $draftContentReloaded->getVersionInfo()->versionNo
2766
        );
2767
2768
        // Check that ContentInfo contained in reloaded draft Content has correct main Location id set
2769
        $this->assertEquals(
2770
            $publishedContent->versionInfo->contentInfo->mainLocationId,
2771
            $draftContentReloaded->versionInfo->contentInfo->mainLocationId
2772
        );
2773
    }
2774
2775
    /**
2776
     * Test for the loadContentByContentInfo() method.
@@ 2844-2866 (lines=23) @@
2841
     * @see \eZ\Publish\API\Repository\ContentService::loadContent($contentId, $languages, $versionNo)
2842
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersionFromContentDraft
2843
     */
2844
    public function testLoadContentWithThirdParameter()
2845
    {
2846
        $repository = $this->getRepository();
2847
2848
        $contentService = $repository->getContentService();
2849
2850
        /* BEGIN: Use Case */
2851
        $publishedContent = $this->createContentVersion1();
2852
2853
        $draftContent = $contentService->createContentDraft($publishedContent->contentInfo);
2854
2855
        // This content instance is identical to $draftContent
2856
        $draftContentReloaded = $contentService->loadContent($publishedContent->id, null, 2);
2857
        /* END: Use Case */
2858
2859
        $this->assertEquals(2, $draftContentReloaded->getVersionInfo()->versionNo);
2860
2861
        // Check that ContentInfo contained in reloaded draft Content has correct main Location id set
2862
        $this->assertEquals(
2863
            $publishedContent->versionInfo->contentInfo->mainLocationId,
2864
            $draftContentReloaded->versionInfo->contentInfo->mainLocationId
2865
        );
2866
    }
2867
2868
    /**
2869
     * Test for the loadContent() method.
@@ 2925-2951 (lines=27) @@
2922
     * @see \eZ\Publish\API\Repository\ContentService::loadContentByRemoteId($remoteId, $languages, $versionNo)
2923
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersionFromContentDraft
2924
     */
2925
    public function testLoadContentByRemoteIdWithThirdParameter()
2926
    {
2927
        $repository = $this->getRepository();
2928
2929
        $contentService = $repository->getContentService();
2930
2931
        /* BEGIN: Use Case */
2932
        $publishedContent = $this->createContentVersion1();
2933
2934
        $draftContent = $contentService->createContentDraft($publishedContent->contentInfo);
2935
2936
        // This content instance is identical to $draftContent
2937
        $draftContentReloaded = $contentService->loadContentByRemoteId(
2938
            $publishedContent->contentInfo->remoteId,
2939
            null,
2940
            2
2941
        );
2942
        /* END: Use Case */
2943
2944
        $this->assertEquals(2, $draftContentReloaded->getVersionInfo()->versionNo);
2945
2946
        // Check that ContentInfo contained in reloaded draft Content has correct main Location id set
2947
        $this->assertEquals(
2948
            $publishedContent->versionInfo->contentInfo->mainLocationId,
2949
            $draftContentReloaded->versionInfo->contentInfo->mainLocationId
2950
        );
2951
    }
2952
2953
    /**
2954
     * Test for the loadContentByRemoteId() method.