Code Duplication    Length = 13-23 lines in 3 locations

eZ/Publish/Core/Repository/Tests/Service/Integration/ContentBase.php 1 location

@@ 2420-2432 (lines=13) @@
2417
     * @covers \eZ\Publish\Core\Repository\ContentService::addRelation
2418
     * @expectedException \eZ\Publish\API\Repository\Exceptions\BadStateException
2419
     */
2420
    public function testAddRelationThrowsBadStateException()
2421
    {
2422
        $contentService = $this->repository->getContentService();
2423
        list($contentDraft, $contentType) = $this->createTestContent();
2424
        $publishedContent = $contentService->publishVersion($contentDraft->versionInfo);
2425
2426
        $mediaContentInfo = $contentService->loadContentInfoByRemoteId('a6e35cbcb7cd6ae4b691f3eee30cd262');
2427
2428
        $contentService->addRelation(
2429
            $publishedContent->getVersionInfo(),
2430
            $mediaContentInfo
2431
        );
2432
    }
2433
2434
    /**
2435
     * Test for the deleteRelation() method.

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

@@ 3005-3026 (lines=22) @@
3002
     * @expectedException \eZ\Publish\API\Repository\Exceptions\BadStateException
3003
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testAddRelation
3004
     */
3005
    public function testAddRelationThrowsBadStateException()
3006
    {
3007
        $repository = $this->getRepository();
3008
3009
        $contentService = $repository->getContentService();
3010
3011
        /* BEGIN: Use Case */
3012
        // RemoteId of the "Media" page of an eZ Publish demo installation
3013
        $mediaRemoteId = 'a6e35cbcb7cd6ae4b691f3eee30cd262';
3014
3015
        $content = $this->createContentVersion1();
3016
3017
        $media = $contentService->loadContentInfoByRemoteId($mediaRemoteId);
3018
3019
        // This call will fail with a "BadStateException", because content is
3020
        // published and not a draft.
3021
        $contentService->addRelation(
3022
            $content->getVersionInfo(),
3023
            $media
3024
        );
3025
        /* END: Use Case */
3026
    }
3027
3028
    /**
3029
     * Test for the loadRelations() method.
@@ 3569-3591 (lines=23) @@
3566
     * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException
3567
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testDeleteRelation
3568
     */
3569
    public function testDeleteRelationThrowsInvalidArgumentException()
3570
    {
3571
        $repository = $this->getRepository();
3572
3573
        $contentService = $repository->getContentService();
3574
3575
        /* BEGIN: Use Case */
3576
        // RemoteId of the "Media" page of an eZ Publish demo installation
3577
        $mediaRemoteId = 'a6e35cbcb7cd6ae4b691f3eee30cd262';
3578
3579
        $draft = $this->createContentDraftVersion1();
3580
3581
        // Load the destination object
3582
        $media = $contentService->loadContentInfoByRemoteId($mediaRemoteId);
3583
3584
        // This call will fail with a "InvalidArgumentException", because no
3585
        // relation exists between $draft and $media.
3586
        $contentService->deleteRelation(
3587
            $draft->getVersionInfo(),
3588
            $media
3589
        );
3590
        /* END: Use Case */
3591
    }
3592
3593
    /**
3594
     * Test for the createContent() method.