Code Duplication    Length = 16-21 lines in 3 locations

eZ/Publish/Core/Repository/Tests/Service/Integration/ContentBase.php 3 locations

@@ 2317-2332 (lines=16) @@
2314
     * @covers \eZ\Publish\Core\Repository\ContentService::loadRelations
2315
     * @covers \eZ\Publish\Core\Repository\ContentService::addRelation
2316
     */
2317
    public function testLoadRelations()
2318
    {
2319
        list($contentDraft, $contentType) = $this->createTestContent();
2320
        $contentService = $this->repository->getContentService();
2321
2322
        $mediaContentInfo = $contentService->loadContentInfoByRemoteId('a6e35cbcb7cd6ae4b691f3eee30cd262');
2323
2324
        $contentService->addRelation(
2325
            $contentDraft->getVersionInfo(),
2326
            $mediaContentInfo
2327
        );
2328
2329
        $relations = $contentService->loadRelations($contentDraft->versionInfo);
2330
2331
        $this->assertRelations($relations, $contentDraft->contentInfo, $mediaContentInfo);
2332
    }
2333
2334
    protected function assertRelations($relations, $sourceContentInfo, $destinationContentInfo)
2335
    {
@@ 2441-2461 (lines=21) @@
2438
     *
2439
     * @covers \eZ\Publish\Core\Repository\ContentService::deleteRelation
2440
     */
2441
    public function testDeleteRelation()
2442
    {
2443
        list($contentDraft, $contentType) = $this->createTestContent();
2444
        $contentService = $this->repository->getContentService();
2445
2446
        $mediaContentInfo = $contentService->loadContentInfoByRemoteId('a6e35cbcb7cd6ae4b691f3eee30cd262');
2447
2448
        $contentService->addRelation(
2449
            $contentDraft->getVersionInfo(),
2450
            $mediaContentInfo
2451
        );
2452
2453
        $contentService->deleteRelation(
2454
            $contentDraft->getVersionInfo(),
2455
            $mediaContentInfo
2456
        );
2457
2458
        $relations = $contentService->loadRelations($contentDraft->versionInfo);
2459
2460
        self::assertCount(0, $relations);
2461
    }
2462
2463
    /**
2464
     * Test for the deleteRelation() method.
@@ 2496-2514 (lines=19) @@
2493
     * @covers \eZ\Publish\Core\Repository\ContentService::deleteRelation
2494
     * @expectedException \eZ\Publish\API\Repository\Exceptions\BadStateException
2495
     */
2496
    public function testDeleteRelationThrowsBadStateException()
2497
    {
2498
        $contentService = $this->repository->getContentService();
2499
        list($contentDraft, $contentType) = $this->createTestContent();
2500
2501
        $mediaContentInfo = $contentService->loadContentInfoByRemoteId('a6e35cbcb7cd6ae4b691f3eee30cd262');
2502
2503
        $contentService->addRelation(
2504
            $contentDraft->getVersionInfo(),
2505
            $mediaContentInfo
2506
        );
2507
2508
        $publishedContent = $contentService->publishVersion($contentDraft->versionInfo);
2509
2510
        $contentService->deleteRelation(
2511
            $publishedContent->getVersionInfo(),
2512
            $mediaContentInfo
2513
        );
2514
    }
2515
2516
    /**
2517
     * Test for the deleteRelation() method.