Code Duplication    Length = 23-30 lines in 3 locations

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

@@ 2847-2876 (lines=30) @@
2844
     * @see \eZ\Publish\API\Repository\ContentService::loadContentByContentInfo($contentInfo, $languages, $versionNo)
2845
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentByContentInfo
2846
     */
2847
    public function testLoadContentByContentInfoWithVersionNumberParameter()
2848
    {
2849
        $repository = $this->getRepository();
2850
2851
        $contentService = $repository->getContentService();
2852
2853
        /* BEGIN: Use Case */
2854
        $publishedContent = $this->createContentVersion1();
2855
2856
        $draftContent = $contentService->createContentDraft($publishedContent->contentInfo);
2857
2858
        // This content instance is identical to $draftContent
2859
        $draftContentReloaded = $contentService->loadContentByContentInfo(
2860
            $publishedContent->contentInfo,
2861
            null,
2862
            2
2863
        );
2864
        /* END: Use Case */
2865
2866
        $this->assertEquals(
2867
            2,
2868
            $draftContentReloaded->getVersionInfo()->versionNo
2869
        );
2870
2871
        // Check that ContentInfo contained in reloaded draft Content has correct main Location id set
2872
        $this->assertEquals(
2873
            $publishedContent->versionInfo->contentInfo->mainLocationId,
2874
            $draftContentReloaded->versionInfo->contentInfo->mainLocationId
2875
        );
2876
    }
2877
2878
    /**
2879
     * Test for the loadContentByContentInfo() method.
@@ 2947-2969 (lines=23) @@
2944
     * @see \eZ\Publish\API\Repository\ContentService::loadContent($contentId, $languages, $versionNo)
2945
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersionFromContentDraft
2946
     */
2947
    public function testLoadContentWithThirdParameter()
2948
    {
2949
        $repository = $this->getRepository();
2950
2951
        $contentService = $repository->getContentService();
2952
2953
        /* BEGIN: Use Case */
2954
        $publishedContent = $this->createContentVersion1();
2955
2956
        $draftContent = $contentService->createContentDraft($publishedContent->contentInfo);
2957
2958
        // This content instance is identical to $draftContent
2959
        $draftContentReloaded = $contentService->loadContent($publishedContent->id, null, 2);
2960
        /* END: Use Case */
2961
2962
        $this->assertEquals(2, $draftContentReloaded->getVersionInfo()->versionNo);
2963
2964
        // Check that ContentInfo contained in reloaded draft Content has correct main Location id set
2965
        $this->assertEquals(
2966
            $publishedContent->versionInfo->contentInfo->mainLocationId,
2967
            $draftContentReloaded->versionInfo->contentInfo->mainLocationId
2968
        );
2969
    }
2970
2971
    /**
2972
     * Test for the loadContent() method.
@@ 3028-3054 (lines=27) @@
3025
     * @see \eZ\Publish\API\Repository\ContentService::loadContentByRemoteId($remoteId, $languages, $versionNo)
3026
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersionFromContentDraft
3027
     */
3028
    public function testLoadContentByRemoteIdWithThirdParameter()
3029
    {
3030
        $repository = $this->getRepository();
3031
3032
        $contentService = $repository->getContentService();
3033
3034
        /* BEGIN: Use Case */
3035
        $publishedContent = $this->createContentVersion1();
3036
3037
        $draftContent = $contentService->createContentDraft($publishedContent->contentInfo);
3038
3039
        // This content instance is identical to $draftContent
3040
        $draftContentReloaded = $contentService->loadContentByRemoteId(
3041
            $publishedContent->contentInfo->remoteId,
3042
            null,
3043
            2
3044
        );
3045
        /* END: Use Case */
3046
3047
        $this->assertEquals(2, $draftContentReloaded->getVersionInfo()->versionNo);
3048
3049
        // Check that ContentInfo contained in reloaded draft Content has correct main Location id set
3050
        $this->assertEquals(
3051
            $publishedContent->versionInfo->contentInfo->mainLocationId,
3052
            $draftContentReloaded->versionInfo->contentInfo->mainLocationId
3053
        );
3054
    }
3055
3056
    /**
3057
     * Test for the loadContentByRemoteId() method.