Code Duplication    Length = 22-23 lines in 2 locations

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

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