Code Duplication    Length = 22-23 lines in 2 locations

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

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