Code Duplication    Length = 22-23 lines in 2 locations

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

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