Code Duplication    Length = 16-22 lines in 4 locations

eZ/Publish/API/Repository/Tests/TrashServiceTest.php 1 location

@@ 866-881 (lines=16) @@
863
     *
864
     * @return \eZ\Publish\API\Repository\Values\Content\Content
865
     */
866
    protected function createNewContentInPlaceTrashedOne(Repository $repository, $parentLocationId)
867
    {
868
        $contentService = $repository->getContentService();
869
        $locationService = $repository->getLocationService();
870
        $contentTypeService = $repository->getContentTypeService();
871
872
        $contentType = $contentTypeService->loadContentTypeByIdentifier('forum');
873
        $newContent = $contentService->newContentCreateStruct($contentType, 'eng-US');
874
        $newContent->setField('name', 'Media');
875
876
        $location = $locationService->newLocationCreateStruct($parentLocationId);
877
878
        $draftContent = $contentService->createContent($newContent, [$location]);
879
880
        return $contentService->publishVersion($draftContent->versionInfo);
881
    }
882
883
    /**
884
     * @param URLAliasService $urlAliasService

eZ/Bundle/EzPublishCoreBundle/Features/Context/QueryControllerContext.php 1 location

@@ 99-120 (lines=22) @@
96
    /**
97
     * @return Content
98
     */
99
    private function createFolder()
100
    {
101
        $repository = $this->getRepository();
102
        $contentService = $repository->getContentService();
103
        $contentTypeService = $repository->getContentTypeService();
104
        $locationService = $repository->getLocationService();
105
106
        $struct = $contentService->newContentCreateStruct(
107
            $contentTypeService->loadContentTypeByIdentifier('folder'),
108
            'eng-GB'
109
        );
110
111
        $struct->setField('name', uniqid('Query Controller BDD ', true));
112
113
        $contentDraft = $contentService->createContent(
114
            $struct,
115
            [$locationService->newLocationCreateStruct(2)]
116
        );
117
        $contentService->publishVersion($contentDraft->versionInfo);
118
119
        return $contentService->loadContent($contentDraft->id);
120
    }
121
122
    /**
123
     * @Given /^a LocationChildren QueryType defined in "([^"]*)":$/

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

@@ 739-759 (lines=21) @@
736
     * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocations
737
     * @expectedException \eZ\Publish\API\Repository\Exceptions\BadStateException
738
     */
739
    public function testLoadLocationsThrowsBadStateException()
740
    {
741
        $repository = $this->getRepository();
742
743
        /* BEGIN: Use Case */
744
        $contentTypeService = $repository->getContentTypeService();
745
        $contentService = $repository->getContentService();
746
        $locationService = $repository->getLocationService();
747
748
        // Create new content, which is not published
749
        $folderType = $contentTypeService->loadContentTypeByIdentifier('folder');
750
        $contentCreate = $contentService->newContentCreateStruct($folderType, 'eng-US');
751
        $contentCreate->setField('name', 'New Folder');
752
        $content = $contentService->createContent($contentCreate);
753
754
        // Throws Exception, since $content has no published version, yet
755
        $locationService->loadLocations(
756
            $content->contentInfo
757
        );
758
        /* END: Use Case */
759
    }
760
761
    /**
762
     * Test for the loadLocations() method.
@@ 2753-2774 (lines=22) @@
2750
     *
2751
     * @return \eZ\Publish\API\Repository\Values\Content\Content published Content
2752
     */
2753
    private function publishContentWithParentLocation($contentName, $parentLocationId)
2754
    {
2755
        $repository = $this->getRepository(false);
2756
        $locationService = $repository->getLocationService();
2757
2758
        $contentService = $repository->getContentService();
2759
        $contentTypeService = $repository->getContentTypeService();
2760
2761
        $contentCreateStruct = $contentService->newContentCreateStruct(
2762
            $contentTypeService->loadContentTypeByIdentifier('folder'),
2763
            'eng-US'
2764
        );
2765
        $contentCreateStruct->setField('name', $contentName);
2766
        $contentDraft = $contentService->createContent(
2767
            $contentCreateStruct,
2768
            [
2769
                $locationService->newLocationCreateStruct($parentLocationId),
2770
            ]
2771
        );
2772
2773
        return $contentService->publishVersion($contentDraft->versionInfo);
2774
    }
2775
}
2776