Code Duplication    Length = 16-22 lines in 4 locations

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/TrashServiceTest.php 1 location

@@ 956-971 (lines=16) @@
953
     *
954
     * @return \eZ\Publish\API\Repository\Values\Content\Content
955
     */
956
    protected function createNewContentInPlaceTrashedOne(Repository $repository, $parentLocationId)
957
    {
958
        $contentService = $repository->getContentService();
959
        $locationService = $repository->getLocationService();
960
        $contentTypeService = $repository->getContentTypeService();
961
962
        $contentType = $contentTypeService->loadContentTypeByIdentifier('forum');
963
        $newContent = $contentService->newContentCreateStruct($contentType, 'eng-US');
964
        $newContent->setField('name', 'Media');
965
966
        $location = $locationService->newLocationCreateStruct($parentLocationId);
967
968
        $draftContent = $contentService->createContent($newContent, [$location]);
969
970
        return $contentService->publishVersion($draftContent->versionInfo);
971
    }
972
973
    /**
974
     * @param URLAliasService $urlAliasService

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

@@ 907-927 (lines=21) @@
904
     * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocations
905
     * @expectedException \eZ\Publish\API\Repository\Exceptions\BadStateException
906
     */
907
    public function testLoadLocationsThrowsBadStateException()
908
    {
909
        $repository = $this->getRepository();
910
911
        /* BEGIN: Use Case */
912
        $contentTypeService = $repository->getContentTypeService();
913
        $contentService = $repository->getContentService();
914
        $locationService = $repository->getLocationService();
915
916
        // Create new content, which is not published
917
        $folderType = $contentTypeService->loadContentTypeByIdentifier('folder');
918
        $contentCreate = $contentService->newContentCreateStruct($folderType, 'eng-US');
919
        $contentCreate->setField('name', 'New Folder');
920
        $content = $contentService->createContent($contentCreate);
921
922
        // Throws Exception, since $content has no published version, yet
923
        $locationService->loadLocations(
924
            $content->contentInfo
925
        );
926
        /* END: Use Case */
927
    }
928
929
    /**
930
     * Test for the loadLocations() method.
@@ 3039-3060 (lines=22) @@
3036
     *
3037
     * @return \eZ\Publish\API\Repository\Values\Content\Content published Content
3038
     */
3039
    private function publishContentWithParentLocation($contentName, $parentLocationId)
3040
    {
3041
        $repository = $this->getRepository(false);
3042
        $locationService = $repository->getLocationService();
3043
3044
        $contentService = $repository->getContentService();
3045
        $contentTypeService = $repository->getContentTypeService();
3046
3047
        $contentCreateStruct = $contentService->newContentCreateStruct(
3048
            $contentTypeService->loadContentTypeByIdentifier('folder'),
3049
            'eng-US'
3050
        );
3051
        $contentCreateStruct->setField('name', $contentName);
3052
        $contentDraft = $contentService->createContent(
3053
            $contentCreateStruct,
3054
            [
3055
                $locationService->newLocationCreateStruct($parentLocationId),
3056
            ]
3057
        );
3058
3059
        return $contentService->publishVersion($contentDraft->versionInfo);
3060
    }
3061
3062
    /**
3063
     * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException