Code Duplication    Length = 23-30 lines in 3 locations

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

@@ 2839-2868 (lines=30) @@
2836
     * @see \eZ\Publish\API\Repository\ContentService::loadContentByContentInfo($contentInfo, $languages, $versionNo)
2837
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentByContentInfo
2838
     */
2839
    public function testLoadContentByContentInfoWithVersionNumberParameter()
2840
    {
2841
        $repository = $this->getRepository();
2842
2843
        $contentService = $repository->getContentService();
2844
2845
        /* BEGIN: Use Case */
2846
        $publishedContent = $this->createContentVersion1();
2847
2848
        $draftContent = $contentService->createContentDraft($publishedContent->contentInfo);
2849
2850
        // This content instance is identical to $draftContent
2851
        $draftContentReloaded = $contentService->loadContentByContentInfo(
2852
            $publishedContent->contentInfo,
2853
            null,
2854
            2
2855
        );
2856
        /* END: Use Case */
2857
2858
        $this->assertEquals(
2859
            2,
2860
            $draftContentReloaded->getVersionInfo()->versionNo
2861
        );
2862
2863
        // Check that ContentInfo contained in reloaded draft Content has correct main Location id set
2864
        $this->assertEquals(
2865
            $publishedContent->versionInfo->contentInfo->mainLocationId,
2866
            $draftContentReloaded->versionInfo->contentInfo->mainLocationId
2867
        );
2868
    }
2869
2870
    /**
2871
     * Test for the loadContentByContentInfo() method.
@@ 2939-2961 (lines=23) @@
2936
     * @see \eZ\Publish\API\Repository\ContentService::loadContent($contentId, $languages, $versionNo)
2937
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersionFromContentDraft
2938
     */
2939
    public function testLoadContentWithThirdParameter()
2940
    {
2941
        $repository = $this->getRepository();
2942
2943
        $contentService = $repository->getContentService();
2944
2945
        /* BEGIN: Use Case */
2946
        $publishedContent = $this->createContentVersion1();
2947
2948
        $draftContent = $contentService->createContentDraft($publishedContent->contentInfo);
2949
2950
        // This content instance is identical to $draftContent
2951
        $draftContentReloaded = $contentService->loadContent($publishedContent->id, null, 2);
2952
        /* END: Use Case */
2953
2954
        $this->assertEquals(2, $draftContentReloaded->getVersionInfo()->versionNo);
2955
2956
        // Check that ContentInfo contained in reloaded draft Content has correct main Location id set
2957
        $this->assertEquals(
2958
            $publishedContent->versionInfo->contentInfo->mainLocationId,
2959
            $draftContentReloaded->versionInfo->contentInfo->mainLocationId
2960
        );
2961
    }
2962
2963
    /**
2964
     * Test for the loadContent() method.
@@ 3020-3046 (lines=27) @@
3017
     * @see \eZ\Publish\API\Repository\ContentService::loadContentByRemoteId($remoteId, $languages, $versionNo)
3018
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersionFromContentDraft
3019
     */
3020
    public function testLoadContentByRemoteIdWithThirdParameter()
3021
    {
3022
        $repository = $this->getRepository();
3023
3024
        $contentService = $repository->getContentService();
3025
3026
        /* BEGIN: Use Case */
3027
        $publishedContent = $this->createContentVersion1();
3028
3029
        $draftContent = $contentService->createContentDraft($publishedContent->contentInfo);
3030
3031
        // This content instance is identical to $draftContent
3032
        $draftContentReloaded = $contentService->loadContentByRemoteId(
3033
            $publishedContent->contentInfo->remoteId,
3034
            null,
3035
            2
3036
        );
3037
        /* END: Use Case */
3038
3039
        $this->assertEquals(2, $draftContentReloaded->getVersionInfo()->versionNo);
3040
3041
        // Check that ContentInfo contained in reloaded draft Content has correct main Location id set
3042
        $this->assertEquals(
3043
            $publishedContent->versionInfo->contentInfo->mainLocationId,
3044
            $draftContentReloaded->versionInfo->contentInfo->mainLocationId
3045
        );
3046
    }
3047
3048
    /**
3049
     * Test for the loadContentByRemoteId() method.