Code Duplication    Length = 22-23 lines in 2 locations

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

@@ 3531-3552 (lines=22) @@
3528
     * @expectedException \eZ\Publish\API\Repository\Exceptions\BadStateException
3529
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testAddRelation
3530
     */
3531
    public function testAddRelationThrowsBadStateException()
3532
    {
3533
        $repository = $this->getRepository();
3534
3535
        $contentService = $repository->getContentService();
3536
3537
        /* BEGIN: Use Case */
3538
        // RemoteId of the "Media" page of an eZ Publish demo installation
3539
        $mediaRemoteId = 'a6e35cbcb7cd6ae4b691f3eee30cd262';
3540
3541
        $content = $this->createContentVersion1();
3542
3543
        $media = $contentService->loadContentInfoByRemoteId($mediaRemoteId);
3544
3545
        // This call will fail with a "BadStateException", because content is
3546
        // published and not a draft.
3547
        $contentService->addRelation(
3548
            $content->getVersionInfo(),
3549
            $media
3550
        );
3551
        /* END: Use Case */
3552
    }
3553
3554
    /**
3555
     * Test for the loadRelations() method.
@@ 4095-4117 (lines=23) @@
4092
     * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException
4093
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testDeleteRelation
4094
     */
4095
    public function testDeleteRelationThrowsInvalidArgumentException()
4096
    {
4097
        $repository = $this->getRepository();
4098
4099
        $contentService = $repository->getContentService();
4100
4101
        /* BEGIN: Use Case */
4102
        // RemoteId of the "Media" page of an eZ Publish demo installation
4103
        $mediaRemoteId = 'a6e35cbcb7cd6ae4b691f3eee30cd262';
4104
4105
        $draft = $this->createContentDraftVersion1();
4106
4107
        // Load the destination object
4108
        $media = $contentService->loadContentInfoByRemoteId($mediaRemoteId);
4109
4110
        // This call will fail with a "InvalidArgumentException", because no
4111
        // relation exists between $draft and $media.
4112
        $contentService->deleteRelation(
4113
            $draft->getVersionInfo(),
4114
            $media
4115
        );
4116
        /* END: Use Case */
4117
    }
4118
4119
    /**
4120
     * Test for the createContent() method.