Code Duplication    Length = 16-21 lines in 3 locations

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

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