Code Duplication    Length = 22-23 lines in 2 locations

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

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