Code Duplication    Length = 23-30 lines in 3 locations

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

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