Code Duplication    Length = 23-30 lines in 3 locations

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

@@ 2694-2723 (lines=30) @@
2691
     * @see \eZ\Publish\API\Repository\ContentService::loadContentByContentInfo($contentInfo, $languages, $versionNo)
2692
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentByContentInfo
2693
     */
2694
    public function testLoadContentByContentInfoWithVersionNumberParameter()
2695
    {
2696
        $repository = $this->getRepository();
2697
2698
        $contentService = $repository->getContentService();
2699
2700
        /* BEGIN: Use Case */
2701
        $publishedContent = $this->createContentVersion1();
2702
2703
        $draftContent = $contentService->createContentDraft($publishedContent->contentInfo);
2704
2705
        // This content instance is identical to $draftContent
2706
        $draftContentReloaded = $contentService->loadContentByContentInfo(
2707
            $publishedContent->contentInfo,
2708
            null,
2709
            2
2710
        );
2711
        /* END: Use Case */
2712
2713
        $this->assertEquals(
2714
            2,
2715
            $draftContentReloaded->getVersionInfo()->versionNo
2716
        );
2717
2718
        // Check that ContentInfo contained in reloaded draft Content has correct main Location id set
2719
        $this->assertEquals(
2720
            $publishedContent->versionInfo->contentInfo->mainLocationId,
2721
            $draftContentReloaded->versionInfo->contentInfo->mainLocationId
2722
        );
2723
    }
2724
2725
    /**
2726
     * Test for the loadContentByContentInfo() method.
@@ 2794-2816 (lines=23) @@
2791
     * @see \eZ\Publish\API\Repository\ContentService::loadContent($contentId, $languages, $versionNo)
2792
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersionFromContentDraft
2793
     */
2794
    public function testLoadContentWithThirdParameter()
2795
    {
2796
        $repository = $this->getRepository();
2797
2798
        $contentService = $repository->getContentService();
2799
2800
        /* BEGIN: Use Case */
2801
        $publishedContent = $this->createContentVersion1();
2802
2803
        $draftContent = $contentService->createContentDraft($publishedContent->contentInfo);
2804
2805
        // This content instance is identical to $draftContent
2806
        $draftContentReloaded = $contentService->loadContent($publishedContent->id, null, 2);
2807
        /* END: Use Case */
2808
2809
        $this->assertEquals(2, $draftContentReloaded->getVersionInfo()->versionNo);
2810
2811
        // Check that ContentInfo contained in reloaded draft Content has correct main Location id set
2812
        $this->assertEquals(
2813
            $publishedContent->versionInfo->contentInfo->mainLocationId,
2814
            $draftContentReloaded->versionInfo->contentInfo->mainLocationId
2815
        );
2816
    }
2817
2818
    /**
2819
     * Test for the loadContent() method.
@@ 2875-2901 (lines=27) @@
2872
     * @see \eZ\Publish\API\Repository\ContentService::loadContentByRemoteId($remoteId, $languages, $versionNo)
2873
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersionFromContentDraft
2874
     */
2875
    public function testLoadContentByRemoteIdWithThirdParameter()
2876
    {
2877
        $repository = $this->getRepository();
2878
2879
        $contentService = $repository->getContentService();
2880
2881
        /* BEGIN: Use Case */
2882
        $publishedContent = $this->createContentVersion1();
2883
2884
        $draftContent = $contentService->createContentDraft($publishedContent->contentInfo);
2885
2886
        // This content instance is identical to $draftContent
2887
        $draftContentReloaded = $contentService->loadContentByRemoteId(
2888
            $publishedContent->contentInfo->remoteId,
2889
            null,
2890
            2
2891
        );
2892
        /* END: Use Case */
2893
2894
        $this->assertEquals(2, $draftContentReloaded->getVersionInfo()->versionNo);
2895
2896
        // Check that ContentInfo contained in reloaded draft Content has correct main Location id set
2897
        $this->assertEquals(
2898
            $publishedContent->versionInfo->contentInfo->mainLocationId,
2899
            $draftContentReloaded->versionInfo->contentInfo->mainLocationId
2900
        );
2901
    }
2902
2903
    /**
2904
     * Test for the loadContentByRemoteId() method.