Code Duplication    Length = 23-30 lines in 3 locations

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

@@ 2655-2684 (lines=30) @@
2652
     * @see \eZ\Publish\API\Repository\ContentService::loadContentByContentInfo($contentInfo, $languages, $versionNo)
2653
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentByContentInfo
2654
     */
2655
    public function testLoadContentByContentInfoWithVersionNumberParameter()
2656
    {
2657
        $repository = $this->getRepository();
2658
2659
        $contentService = $repository->getContentService();
2660
2661
        /* BEGIN: Use Case */
2662
        $publishedContent = $this->createContentVersion1();
2663
2664
        $draftContent = $contentService->createContentDraft($publishedContent->contentInfo);
2665
2666
        // This content instance is identical to $draftContent
2667
        $draftContentReloaded = $contentService->loadContentByContentInfo(
2668
            $publishedContent->contentInfo,
2669
            null,
2670
            2
2671
        );
2672
        /* END: Use Case */
2673
2674
        $this->assertEquals(
2675
            2,
2676
            $draftContentReloaded->getVersionInfo()->versionNo
2677
        );
2678
2679
        // Check that ContentInfo contained in reloaded draft Content has correct main Location id set
2680
        $this->assertEquals(
2681
            $publishedContent->versionInfo->contentInfo->mainLocationId,
2682
            $draftContentReloaded->versionInfo->contentInfo->mainLocationId
2683
        );
2684
    }
2685
2686
    /**
2687
     * Test for the loadContentByContentInfo() method.
@@ 2755-2777 (lines=23) @@
2752
     * @see \eZ\Publish\API\Repository\ContentService::loadContent($contentId, $languages, $versionNo)
2753
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersionFromContentDraft
2754
     */
2755
    public function testLoadContentWithThirdParameter()
2756
    {
2757
        $repository = $this->getRepository();
2758
2759
        $contentService = $repository->getContentService();
2760
2761
        /* BEGIN: Use Case */
2762
        $publishedContent = $this->createContentVersion1();
2763
2764
        $draftContent = $contentService->createContentDraft($publishedContent->contentInfo);
2765
2766
        // This content instance is identical to $draftContent
2767
        $draftContentReloaded = $contentService->loadContent($publishedContent->id, null, 2);
2768
        /* END: Use Case */
2769
2770
        $this->assertEquals(2, $draftContentReloaded->getVersionInfo()->versionNo);
2771
2772
        // Check that ContentInfo contained in reloaded draft Content has correct main Location id set
2773
        $this->assertEquals(
2774
            $publishedContent->versionInfo->contentInfo->mainLocationId,
2775
            $draftContentReloaded->versionInfo->contentInfo->mainLocationId
2776
        );
2777
    }
2778
2779
    /**
2780
     * Test for the loadContent() method.
@@ 2836-2862 (lines=27) @@
2833
     * @see \eZ\Publish\API\Repository\ContentService::loadContentByRemoteId($remoteId, $languages, $versionNo)
2834
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersionFromContentDraft
2835
     */
2836
    public function testLoadContentByRemoteIdWithThirdParameter()
2837
    {
2838
        $repository = $this->getRepository();
2839
2840
        $contentService = $repository->getContentService();
2841
2842
        /* BEGIN: Use Case */
2843
        $publishedContent = $this->createContentVersion1();
2844
2845
        $draftContent = $contentService->createContentDraft($publishedContent->contentInfo);
2846
2847
        // This content instance is identical to $draftContent
2848
        $draftContentReloaded = $contentService->loadContentByRemoteId(
2849
            $publishedContent->contentInfo->remoteId,
2850
            null,
2851
            2
2852
        );
2853
        /* END: Use Case */
2854
2855
        $this->assertEquals(2, $draftContentReloaded->getVersionInfo()->versionNo);
2856
2857
        // Check that ContentInfo contained in reloaded draft Content has correct main Location id set
2858
        $this->assertEquals(
2859
            $publishedContent->versionInfo->contentInfo->mainLocationId,
2860
            $draftContentReloaded->versionInfo->contentInfo->mainLocationId
2861
        );
2862
    }
2863
2864
    /**
2865
     * Test for the loadContentByRemoteId() method.