Code Duplication    Length = 22-23 lines in 2 locations

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

@@ 3423-3444 (lines=22) @@
3420
     * @expectedException \eZ\Publish\API\Repository\Exceptions\BadStateException
3421
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testAddRelation
3422
     */
3423
    public function testAddRelationThrowsBadStateException()
3424
    {
3425
        $repository = $this->getRepository();
3426
3427
        $contentService = $repository->getContentService();
3428
3429
        /* BEGIN: Use Case */
3430
        // RemoteId of the "Media" page of an eZ Publish demo installation
3431
        $mediaRemoteId = 'a6e35cbcb7cd6ae4b691f3eee30cd262';
3432
3433
        $content = $this->createContentVersion1();
3434
3435
        $media = $contentService->loadContentInfoByRemoteId($mediaRemoteId);
3436
3437
        // This call will fail with a "BadStateException", because content is
3438
        // published and not a draft.
3439
        $contentService->addRelation(
3440
            $content->getVersionInfo(),
3441
            $media
3442
        );
3443
        /* END: Use Case */
3444
    }
3445
3446
    /**
3447
     * Test for the loadRelations() method.
@@ 3987-4009 (lines=23) @@
3984
     * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException
3985
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testDeleteRelation
3986
     */
3987
    public function testDeleteRelationThrowsInvalidArgumentException()
3988
    {
3989
        $repository = $this->getRepository();
3990
3991
        $contentService = $repository->getContentService();
3992
3993
        /* BEGIN: Use Case */
3994
        // RemoteId of the "Media" page of an eZ Publish demo installation
3995
        $mediaRemoteId = 'a6e35cbcb7cd6ae4b691f3eee30cd262';
3996
3997
        $draft = $this->createContentDraftVersion1();
3998
3999
        // Load the destination object
4000
        $media = $contentService->loadContentInfoByRemoteId($mediaRemoteId);
4001
4002
        // This call will fail with a "InvalidArgumentException", because no
4003
        // relation exists between $draft and $media.
4004
        $contentService->deleteRelation(
4005
            $draft->getVersionInfo(),
4006
            $media
4007
        );
4008
        /* END: Use Case */
4009
    }
4010
4011
    /**
4012
     * Test for the createContent() method.