Code Duplication    Length = 22-34 lines in 2 locations

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

@@ 3570-3591 (lines=22) @@
3567
     * @see \eZ\Publish\API\Repository\ContentService::createContentDraft()
3568
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testAddRelationSetsExpectedRelations
3569
     */
3570
    public function testCreateContentDraftWithRelations()
3571
    {
3572
        $repository = $this->getRepository();
3573
3574
        $contentService = $repository->getContentService();
3575
3576
        // RemoteId of the "Media" content of an eZ Publish demo installation
3577
        $mediaRemoteId = 'a6e35cbcb7cd6ae4b691f3eee30cd262';
3578
        $draft = $this->createContentDraftVersion1();
3579
        $media = $contentService->loadContentInfoByRemoteId($mediaRemoteId);
3580
3581
        // Create relation between new content object and "Media" page
3582
        $contentService->addRelation(
3583
            $draft->getVersionInfo(),
3584
            $media
3585
        );
3586
3587
        $content = $contentService->publishVersion($draft->versionInfo);
3588
        $newDraft = $contentService->createContentDraft($content->contentInfo);
3589
3590
        return $contentService->loadRelations($newDraft->getVersionInfo());
3591
    }
3592
3593
    /**
3594
     * Test for the createContentDraft() method.
@@ 4152-4185 (lines=34) @@
4149
     * @expectedException \eZ\Publish\API\Repository\Exceptions\BadStateException
4150
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testDeleteRelation
4151
     */
4152
    public function testDeleteRelationThrowsBadStateException()
4153
    {
4154
        $repository = $this->getRepository();
4155
4156
        $contentService = $repository->getContentService();
4157
4158
        /* BEGIN: Use Case */
4159
        // RemoteId of the "Media" page of an eZ Publish demo installation
4160
        $mediaRemoteId = 'a6e35cbcb7cd6ae4b691f3eee30cd262';
4161
4162
        $content = $this->createContentVersion1();
4163
4164
        // Load the destination object
4165
        $media = $contentService->loadContentInfoByRemoteId($mediaRemoteId);
4166
4167
        // Create a new draft
4168
        $draftVersion2 = $contentService->createContentDraft($content->contentInfo);
4169
4170
        // Add a relation
4171
        $contentService->addRelation($draftVersion2->getVersionInfo(), $media);
4172
4173
        // Publish new version
4174
        $contentVersion2 = $contentService->publishVersion(
4175
            $draftVersion2->getVersionInfo()
4176
        );
4177
4178
        // This call will fail with a "BadStateException", because content is
4179
        // published and not a draft.
4180
        $contentService->deleteRelation(
4181
            $contentVersion2->getVersionInfo(),
4182
            $media
4183
        );
4184
        /* END: Use Case */
4185
    }
4186
4187
    /**
4188
     * Test for the deleteRelation() method.