Code Duplication    Length = 16-22 lines in 4 locations

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

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

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

@@ 906-926 (lines=21) @@
903
     * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocations
904
     * @expectedException \eZ\Publish\API\Repository\Exceptions\BadStateException
905
     */
906
    public function testLoadLocationsThrowsBadStateException()
907
    {
908
        $repository = $this->getRepository();
909
910
        /* BEGIN: Use Case */
911
        $contentTypeService = $repository->getContentTypeService();
912
        $contentService = $repository->getContentService();
913
        $locationService = $repository->getLocationService();
914
915
        // Create new content, which is not published
916
        $folderType = $contentTypeService->loadContentTypeByIdentifier('folder');
917
        $contentCreate = $contentService->newContentCreateStruct($folderType, 'eng-US');
918
        $contentCreate->setField('name', 'New Folder');
919
        $content = $contentService->createContent($contentCreate);
920
921
        // Throws Exception, since $content has no published version, yet
922
        $locationService->loadLocations(
923
            $content->contentInfo
924
        );
925
        /* END: Use Case */
926
    }
927
928
    /**
929
     * Test for the loadLocations() method.
@@ 3143-3164 (lines=22) @@
3140
     *
3141
     * @return \eZ\Publish\API\Repository\Values\Content\Content published Content
3142
     */
3143
    private function publishContentWithParentLocation($contentName, $parentLocationId)
3144
    {
3145
        $repository = $this->getRepository(false);
3146
        $locationService = $repository->getLocationService();
3147
3148
        $contentService = $repository->getContentService();
3149
        $contentTypeService = $repository->getContentTypeService();
3150
3151
        $contentCreateStruct = $contentService->newContentCreateStruct(
3152
            $contentTypeService->loadContentTypeByIdentifier('folder'),
3153
            'eng-US'
3154
        );
3155
        $contentCreateStruct->setField('name', $contentName);
3156
        $contentDraft = $contentService->createContent(
3157
            $contentCreateStruct,
3158
            [
3159
                $locationService->newLocationCreateStruct($parentLocationId),
3160
            ]
3161
        );
3162
3163
        return $contentService->publishVersion($contentDraft->versionInfo);
3164
    }
3165
3166
    /**
3167
     * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException

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

@@ 1056-1071 (lines=16) @@
1053
     *
1054
     * @return \eZ\Publish\API\Repository\Values\Content\Content
1055
     */
1056
    protected function createNewContentInPlaceTrashedOne(Repository $repository, $parentLocationId)
1057
    {
1058
        $contentService = $repository->getContentService();
1059
        $locationService = $repository->getLocationService();
1060
        $contentTypeService = $repository->getContentTypeService();
1061
1062
        $contentType = $contentTypeService->loadContentTypeByIdentifier('forum');
1063
        $newContent = $contentService->newContentCreateStruct($contentType, 'eng-US');
1064
        $newContent->setField('name', 'Media');
1065
1066
        $location = $locationService->newLocationCreateStruct($parentLocationId);
1067
1068
        $draftContent = $contentService->createContent($newContent, [$location]);
1069
1070
        return $contentService->publishVersion($draftContent->versionInfo);
1071
    }
1072
1073
    /**
1074
     * @param URLAliasService $urlAliasService