Code Duplication    Length = 22-23 lines in 2 locations

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

@@ 3481-3502 (lines=22) @@
3478
     * @expectedException \eZ\Publish\API\Repository\Exceptions\BadStateException
3479
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testAddRelation
3480
     */
3481
    public function testAddRelationThrowsBadStateException()
3482
    {
3483
        $repository = $this->getRepository();
3484
3485
        $contentService = $repository->getContentService();
3486
3487
        /* BEGIN: Use Case */
3488
        // RemoteId of the "Media" page of an eZ Publish demo installation
3489
        $mediaRemoteId = 'a6e35cbcb7cd6ae4b691f3eee30cd262';
3490
3491
        $content = $this->createContentVersion1();
3492
3493
        $media = $contentService->loadContentInfoByRemoteId($mediaRemoteId);
3494
3495
        // This call will fail with a "BadStateException", because content is
3496
        // published and not a draft.
3497
        $contentService->addRelation(
3498
            $content->getVersionInfo(),
3499
            $media
3500
        );
3501
        /* END: Use Case */
3502
    }
3503
3504
    /**
3505
     * Test for the loadRelations() method.
@@ 4045-4067 (lines=23) @@
4042
     * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException
4043
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testDeleteRelation
4044
     */
4045
    public function testDeleteRelationThrowsInvalidArgumentException()
4046
    {
4047
        $repository = $this->getRepository();
4048
4049
        $contentService = $repository->getContentService();
4050
4051
        /* BEGIN: Use Case */
4052
        // RemoteId of the "Media" page of an eZ Publish demo installation
4053
        $mediaRemoteId = 'a6e35cbcb7cd6ae4b691f3eee30cd262';
4054
4055
        $draft = $this->createContentDraftVersion1();
4056
4057
        // Load the destination object
4058
        $media = $contentService->loadContentInfoByRemoteId($mediaRemoteId);
4059
4060
        // This call will fail with a "InvalidArgumentException", because no
4061
        // relation exists between $draft and $media.
4062
        $contentService->deleteRelation(
4063
            $draft->getVersionInfo(),
4064
            $media
4065
        );
4066
        /* END: Use Case */
4067
    }
4068
4069
    /**
4070
     * Test for the createContent() method.