Code Duplication    Length = 22-23 lines in 2 locations

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

@@ 3408-3429 (lines=22) @@
3405
     * @expectedException \eZ\Publish\API\Repository\Exceptions\BadStateException
3406
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testAddRelation
3407
     */
3408
    public function testAddRelationThrowsBadStateException()
3409
    {
3410
        $repository = $this->getRepository();
3411
3412
        $contentService = $repository->getContentService();
3413
3414
        /* BEGIN: Use Case */
3415
        // RemoteId of the "Media" page of an eZ Publish demo installation
3416
        $mediaRemoteId = 'a6e35cbcb7cd6ae4b691f3eee30cd262';
3417
3418
        $content = $this->createContentVersion1();
3419
3420
        $media = $contentService->loadContentInfoByRemoteId($mediaRemoteId);
3421
3422
        // This call will fail with a "BadStateException", because content is
3423
        // published and not a draft.
3424
        $contentService->addRelation(
3425
            $content->getVersionInfo(),
3426
            $media
3427
        );
3428
        /* END: Use Case */
3429
    }
3430
3431
    /**
3432
     * Test for the loadRelations() method.
@@ 3972-3994 (lines=23) @@
3969
     * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException
3970
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testDeleteRelation
3971
     */
3972
    public function testDeleteRelationThrowsInvalidArgumentException()
3973
    {
3974
        $repository = $this->getRepository();
3975
3976
        $contentService = $repository->getContentService();
3977
3978
        /* BEGIN: Use Case */
3979
        // RemoteId of the "Media" page of an eZ Publish demo installation
3980
        $mediaRemoteId = 'a6e35cbcb7cd6ae4b691f3eee30cd262';
3981
3982
        $draft = $this->createContentDraftVersion1();
3983
3984
        // Load the destination object
3985
        $media = $contentService->loadContentInfoByRemoteId($mediaRemoteId);
3986
3987
        // This call will fail with a "InvalidArgumentException", because no
3988
        // relation exists between $draft and $media.
3989
        $contentService->deleteRelation(
3990
            $draft->getVersionInfo(),
3991
            $media
3992
        );
3993
        /* END: Use Case */
3994
    }
3995
3996
    /**
3997
     * Test for the createContent() method.