Code Duplication    Length = 23-30 lines in 3 locations

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

@@ 2326-2355 (lines=30) @@
2323
     * @see \eZ\Publish\API\Repository\ContentService::loadContentByContentInfo($contentInfo, $languages, $versionNo)
2324
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentByContentInfo
2325
     */
2326
    public function testLoadContentByContentInfoWithVersionNumberParameter()
2327
    {
2328
        $repository = $this->getRepository();
2329
2330
        $contentService = $repository->getContentService();
2331
2332
        /* BEGIN: Use Case */
2333
        $publishedContent = $this->createContentVersion1();
2334
2335
        $draftContent = $contentService->createContentDraft($publishedContent->contentInfo);
2336
2337
        // This content instance is identical to $draftContent
2338
        $draftContentReloaded = $contentService->loadContentByContentInfo(
2339
            $publishedContent->contentInfo,
2340
            null,
2341
            2
2342
        );
2343
        /* END: Use Case */
2344
2345
        $this->assertEquals(
2346
            2,
2347
            $draftContentReloaded->getVersionInfo()->versionNo
2348
        );
2349
2350
        // Check that ContentInfo contained in reloaded draft Content has correct main Location id set
2351
        $this->assertEquals(
2352
            $publishedContent->versionInfo->contentInfo->mainLocationId,
2353
            $draftContentReloaded->versionInfo->contentInfo->mainLocationId
2354
        );
2355
    }
2356
2357
    /**
2358
     * Test for the loadContentByContentInfo() method.
@@ 2407-2429 (lines=23) @@
2404
     * @see \eZ\Publish\API\Repository\ContentService::loadContent($contentId, $languages, $versionNo)
2405
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersionFromContentDraft
2406
     */
2407
    public function testLoadContentWithThirdParameter()
2408
    {
2409
        $repository = $this->getRepository();
2410
2411
        $contentService = $repository->getContentService();
2412
2413
        /* BEGIN: Use Case */
2414
        $publishedContent = $this->createContentVersion1();
2415
2416
        $draftContent = $contentService->createContentDraft($publishedContent->contentInfo);
2417
2418
        // This content instance is identical to $draftContent
2419
        $draftContentReloaded = $contentService->loadContent($publishedContent->id, null, 2);
2420
        /* END: Use Case */
2421
2422
        $this->assertEquals(2, $draftContentReloaded->getVersionInfo()->versionNo);
2423
2424
        // Check that ContentInfo contained in reloaded draft Content has correct main Location id set
2425
        $this->assertEquals(
2426
            $publishedContent->versionInfo->contentInfo->mainLocationId,
2427
            $draftContentReloaded->versionInfo->contentInfo->mainLocationId
2428
        );
2429
    }
2430
2431
    /**
2432
     * Test for the loadContent() method.
@@ 2488-2514 (lines=27) @@
2485
     * @see \eZ\Publish\API\Repository\ContentService::loadContentByRemoteId($remoteId, $languages, $versionNo)
2486
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersionFromContentDraft
2487
     */
2488
    public function testLoadContentByRemoteIdWithThirdParameter()
2489
    {
2490
        $repository = $this->getRepository();
2491
2492
        $contentService = $repository->getContentService();
2493
2494
        /* BEGIN: Use Case */
2495
        $publishedContent = $this->createContentVersion1();
2496
2497
        $draftContent = $contentService->createContentDraft($publishedContent->contentInfo);
2498
2499
        // This content instance is identical to $draftContent
2500
        $draftContentReloaded = $contentService->loadContentByRemoteId(
2501
            $publishedContent->contentInfo->remoteId,
2502
            null,
2503
            2
2504
        );
2505
        /* END: Use Case */
2506
2507
        $this->assertEquals(2, $draftContentReloaded->getVersionInfo()->versionNo);
2508
2509
        // Check that ContentInfo contained in reloaded draft Content has correct main Location id set
2510
        $this->assertEquals(
2511
            $publishedContent->versionInfo->contentInfo->mainLocationId,
2512
            $draftContentReloaded->versionInfo->contentInfo->mainLocationId
2513
        );
2514
    }
2515
2516
    /**
2517
     * Test for the loadContentByRemoteId() method.