Code Duplication    Length = 23-30 lines in 3 locations

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

@@ 2447-2476 (lines=30) @@
2444
     * @see \eZ\Publish\API\Repository\ContentService::loadContentByContentInfo($contentInfo, $languages, $versionNo)
2445
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentByContentInfo
2446
     */
2447
    public function testLoadContentByContentInfoWithVersionNumberParameter()
2448
    {
2449
        $repository = $this->getRepository();
2450
2451
        $contentService = $repository->getContentService();
2452
2453
        /* BEGIN: Use Case */
2454
        $publishedContent = $this->createContentVersion1();
2455
2456
        $draftContent = $contentService->createContentDraft($publishedContent->contentInfo);
2457
2458
        // This content instance is identical to $draftContent
2459
        $draftContentReloaded = $contentService->loadContentByContentInfo(
2460
            $publishedContent->contentInfo,
2461
            null,
2462
            2
2463
        );
2464
        /* END: Use Case */
2465
2466
        $this->assertEquals(
2467
            2,
2468
            $draftContentReloaded->getVersionInfo()->versionNo
2469
        );
2470
2471
        // Check that ContentInfo contained in reloaded draft Content has correct main Location id set
2472
        $this->assertEquals(
2473
            $publishedContent->versionInfo->contentInfo->mainLocationId,
2474
            $draftContentReloaded->versionInfo->contentInfo->mainLocationId
2475
        );
2476
    }
2477
2478
    /**
2479
     * Test for the loadContentByContentInfo() method.
@@ 2528-2550 (lines=23) @@
2525
     * @see \eZ\Publish\API\Repository\ContentService::loadContent($contentId, $languages, $versionNo)
2526
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersionFromContentDraft
2527
     */
2528
    public function testLoadContentWithThirdParameter()
2529
    {
2530
        $repository = $this->getRepository();
2531
2532
        $contentService = $repository->getContentService();
2533
2534
        /* BEGIN: Use Case */
2535
        $publishedContent = $this->createContentVersion1();
2536
2537
        $draftContent = $contentService->createContentDraft($publishedContent->contentInfo);
2538
2539
        // This content instance is identical to $draftContent
2540
        $draftContentReloaded = $contentService->loadContent($publishedContent->id, null, 2);
2541
        /* END: Use Case */
2542
2543
        $this->assertEquals(2, $draftContentReloaded->getVersionInfo()->versionNo);
2544
2545
        // Check that ContentInfo contained in reloaded draft Content has correct main Location id set
2546
        $this->assertEquals(
2547
            $publishedContent->versionInfo->contentInfo->mainLocationId,
2548
            $draftContentReloaded->versionInfo->contentInfo->mainLocationId
2549
        );
2550
    }
2551
2552
    /**
2553
     * Test for the loadContent() method.
@@ 2609-2635 (lines=27) @@
2606
     * @see \eZ\Publish\API\Repository\ContentService::loadContentByRemoteId($remoteId, $languages, $versionNo)
2607
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersionFromContentDraft
2608
     */
2609
    public function testLoadContentByRemoteIdWithThirdParameter()
2610
    {
2611
        $repository = $this->getRepository();
2612
2613
        $contentService = $repository->getContentService();
2614
2615
        /* BEGIN: Use Case */
2616
        $publishedContent = $this->createContentVersion1();
2617
2618
        $draftContent = $contentService->createContentDraft($publishedContent->contentInfo);
2619
2620
        // This content instance is identical to $draftContent
2621
        $draftContentReloaded = $contentService->loadContentByRemoteId(
2622
            $publishedContent->contentInfo->remoteId,
2623
            null,
2624
            2
2625
        );
2626
        /* END: Use Case */
2627
2628
        $this->assertEquals(2, $draftContentReloaded->getVersionInfo()->versionNo);
2629
2630
        // Check that ContentInfo contained in reloaded draft Content has correct main Location id set
2631
        $this->assertEquals(
2632
            $publishedContent->versionInfo->contentInfo->mainLocationId,
2633
            $draftContentReloaded->versionInfo->contentInfo->mainLocationId
2634
        );
2635
    }
2636
2637
    /**
2638
     * Test for the loadContentByRemoteId() method.