Code Duplication    Length = 13-23 lines in 3 locations

eZ/Publish/Core/Repository/Tests/Service/Integration/ContentBase.php 1 location

@@ 2422-2434 (lines=13) @@
2419
     * @covers \eZ\Publish\Core\Repository\ContentService::addRelation
2420
     * @expectedException \eZ\Publish\API\Repository\Exceptions\BadStateException
2421
     */
2422
    public function testAddRelationThrowsBadStateException()
2423
    {
2424
        $contentService = $this->repository->getContentService();
2425
        list($contentDraft, $contentType) = $this->createTestContent();
2426
        $publishedContent = $contentService->publishVersion($contentDraft->versionInfo);
2427
2428
        $mediaContentInfo = $contentService->loadContentInfoByRemoteId('a6e35cbcb7cd6ae4b691f3eee30cd262');
2429
2430
        $contentService->addRelation(
2431
            $publishedContent->getVersionInfo(),
2432
            $mediaContentInfo
2433
        );
2434
    }
2435
2436
    /**
2437
     * Test for the deleteRelation() method.

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

@@ 2942-2963 (lines=22) @@
2939
     * @expectedException \eZ\Publish\API\Repository\Exceptions\BadStateException
2940
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testAddRelation
2941
     */
2942
    public function testAddRelationThrowsBadStateException()
2943
    {
2944
        $repository = $this->getRepository();
2945
2946
        $contentService = $repository->getContentService();
2947
2948
        /* BEGIN: Use Case */
2949
        // RemoteId of the "Media" page of an eZ Publish demo installation
2950
        $mediaRemoteId = 'a6e35cbcb7cd6ae4b691f3eee30cd262';
2951
2952
        $content = $this->createContentVersion1();
2953
2954
        $media = $contentService->loadContentInfoByRemoteId($mediaRemoteId);
2955
2956
        // This call will fail with a "BadStateException", because content is
2957
        // published and not a draft.
2958
        $contentService->addRelation(
2959
            $content->getVersionInfo(),
2960
            $media
2961
        );
2962
        /* END: Use Case */
2963
    }
2964
2965
    /**
2966
     * Test for the loadRelations() method.
@@ 3506-3528 (lines=23) @@
3503
     * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException
3504
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testDeleteRelation
3505
     */
3506
    public function testDeleteRelationThrowsInvalidArgumentException()
3507
    {
3508
        $repository = $this->getRepository();
3509
3510
        $contentService = $repository->getContentService();
3511
3512
        /* BEGIN: Use Case */
3513
        // RemoteId of the "Media" page of an eZ Publish demo installation
3514
        $mediaRemoteId = 'a6e35cbcb7cd6ae4b691f3eee30cd262';
3515
3516
        $draft = $this->createContentDraftVersion1();
3517
3518
        // Load the destination object
3519
        $media = $contentService->loadContentInfoByRemoteId($mediaRemoteId);
3520
3521
        // This call will fail with a "InvalidArgumentException", because no
3522
        // relation exists between $draft and $media.
3523
        $contentService->deleteRelation(
3524
            $draft->getVersionInfo(),
3525
            $media
3526
        );
3527
        /* END: Use Case */
3528
    }
3529
3530
    /**
3531
     * Test for the createContent() method.