Code Duplication    Length = 22-23 lines in 2 locations

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

@@ 3378-3399 (lines=22) @@
3375
     * @expectedException \eZ\Publish\API\Repository\Exceptions\BadStateException
3376
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testAddRelation
3377
     */
3378
    public function testAddRelationThrowsBadStateException()
3379
    {
3380
        $repository = $this->getRepository();
3381
3382
        $contentService = $repository->getContentService();
3383
3384
        /* BEGIN: Use Case */
3385
        // RemoteId of the "Media" page of an eZ Publish demo installation
3386
        $mediaRemoteId = 'a6e35cbcb7cd6ae4b691f3eee30cd262';
3387
3388
        $content = $this->createContentVersion1();
3389
3390
        $media = $contentService->loadContentInfoByRemoteId($mediaRemoteId);
3391
3392
        // This call will fail with a "BadStateException", because content is
3393
        // published and not a draft.
3394
        $contentService->addRelation(
3395
            $content->getVersionInfo(),
3396
            $media
3397
        );
3398
        /* END: Use Case */
3399
    }
3400
3401
    /**
3402
     * Test for the loadRelations() method.
@@ 3942-3964 (lines=23) @@
3939
     * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException
3940
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testDeleteRelation
3941
     */
3942
    public function testDeleteRelationThrowsInvalidArgumentException()
3943
    {
3944
        $repository = $this->getRepository();
3945
3946
        $contentService = $repository->getContentService();
3947
3948
        /* BEGIN: Use Case */
3949
        // RemoteId of the "Media" page of an eZ Publish demo installation
3950
        $mediaRemoteId = 'a6e35cbcb7cd6ae4b691f3eee30cd262';
3951
3952
        $draft = $this->createContentDraftVersion1();
3953
3954
        // Load the destination object
3955
        $media = $contentService->loadContentInfoByRemoteId($mediaRemoteId);
3956
3957
        // This call will fail with a "InvalidArgumentException", because no
3958
        // relation exists between $draft and $media.
3959
        $contentService->deleteRelation(
3960
            $draft->getVersionInfo(),
3961
            $media
3962
        );
3963
        /* END: Use Case */
3964
    }
3965
3966
    /**
3967
     * Test for the createContent() method.