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.
@@ 3121-3142 (lines=22) @@
3118
     *
3119
     * @return \eZ\Publish\API\Repository\Values\Content\Content published Content
3120
     */
3121
    private function publishContentWithParentLocation($contentName, $parentLocationId)
3122
    {
3123
        $repository = $this->getRepository(false);
3124
        $locationService = $repository->getLocationService();
3125
3126
        $contentService = $repository->getContentService();
3127
        $contentTypeService = $repository->getContentTypeService();
3128
3129
        $contentCreateStruct = $contentService->newContentCreateStruct(
3130
            $contentTypeService->loadContentTypeByIdentifier('folder'),
3131
            'eng-US'
3132
        );
3133
        $contentCreateStruct->setField('name', $contentName);
3134
        $contentDraft = $contentService->createContent(
3135
            $contentCreateStruct,
3136
            [
3137
                $locationService->newLocationCreateStruct($parentLocationId),
3138
            ]
3139
        );
3140
3141
        return $contentService->publishVersion($contentDraft->versionInfo);
3142
    }
3143
3144
    /**
3145
     * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException

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

@@ 1001-1016 (lines=16) @@
998
     *
999
     * @return \eZ\Publish\API\Repository\Values\Content\Content
1000
     */
1001
    protected function createNewContentInPlaceTrashedOne(Repository $repository, $parentLocationId)
1002
    {
1003
        $contentService = $repository->getContentService();
1004
        $locationService = $repository->getLocationService();
1005
        $contentTypeService = $repository->getContentTypeService();
1006
1007
        $contentType = $contentTypeService->loadContentTypeByIdentifier('forum');
1008
        $newContent = $contentService->newContentCreateStruct($contentType, 'eng-US');
1009
        $newContent->setField('name', 'Media');
1010
1011
        $location = $locationService->newLocationCreateStruct($parentLocationId);
1012
1013
        $draftContent = $contentService->createContent($newContent, [$location]);
1014
1015
        return $contentService->publishVersion($draftContent->versionInfo);
1016
    }
1017
1018
    /**
1019
     * @param URLAliasService $urlAliasService