Code Duplication    Length = 22-23 lines in 2 locations

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

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