Code Duplication    Length = 22-23 lines in 2 locations

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

@@ 3593-3614 (lines=22) @@
3590
     * @expectedException \eZ\Publish\API\Repository\Exceptions\BadStateException
3591
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testAddRelation
3592
     */
3593
    public function testAddRelationThrowsBadStateException()
3594
    {
3595
        $repository = $this->getRepository();
3596
3597
        $contentService = $repository->getContentService();
3598
3599
        /* BEGIN: Use Case */
3600
        // RemoteId of the "Media" page of an eZ Publish demo installation
3601
        $mediaRemoteId = 'a6e35cbcb7cd6ae4b691f3eee30cd262';
3602
3603
        $content = $this->createContentVersion1();
3604
3605
        $media = $contentService->loadContentInfoByRemoteId($mediaRemoteId);
3606
3607
        // This call will fail with a "BadStateException", because content is
3608
        // published and not a draft.
3609
        $contentService->addRelation(
3610
            $content->getVersionInfo(),
3611
            $media
3612
        );
3613
        /* END: Use Case */
3614
    }
3615
3616
    /**
3617
     * Test for the loadRelations() method.
@@ 4157-4179 (lines=23) @@
4154
     * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException
4155
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testDeleteRelation
4156
     */
4157
    public function testDeleteRelationThrowsInvalidArgumentException()
4158
    {
4159
        $repository = $this->getRepository();
4160
4161
        $contentService = $repository->getContentService();
4162
4163
        /* BEGIN: Use Case */
4164
        // RemoteId of the "Media" page of an eZ Publish demo installation
4165
        $mediaRemoteId = 'a6e35cbcb7cd6ae4b691f3eee30cd262';
4166
4167
        $draft = $this->createContentDraftVersion1();
4168
4169
        // Load the destination object
4170
        $media = $contentService->loadContentInfoByRemoteId($mediaRemoteId);
4171
4172
        // This call will fail with a "InvalidArgumentException", because no
4173
        // relation exists between $draft and $media.
4174
        $contentService->deleteRelation(
4175
            $draft->getVersionInfo(),
4176
            $media
4177
        );
4178
        /* END: Use Case */
4179
    }
4180
4181
    /**
4182
     * Test for the createContent() method.