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 '));
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

@@ 723-743 (lines=21) @@
720
     * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocations
721
     * @expectedException \eZ\Publish\API\Repository\Exceptions\BadStateException
722
     */
723
    public function testLoadLocationsThrowsBadStateException()
724
    {
725
        $repository = $this->getRepository();
726
727
        /* BEGIN: Use Case */
728
        $contentTypeService = $repository->getContentTypeService();
729
        $contentService = $repository->getContentService();
730
        $locationService = $repository->getLocationService();
731
732
        // Create new content, which is not published
733
        $folderType = $contentTypeService->loadContentTypeByIdentifier('folder');
734
        $contentCreate = $contentService->newContentCreateStruct($folderType, 'eng-US');
735
        $contentCreate->setField('name', 'New Folder');
736
        $content = $contentService->createContent($contentCreate);
737
738
        // Throws Exception, since $content has no published version, yet
739
        $locationService->loadLocations(
740
            $content->contentInfo
741
        );
742
        /* END: Use Case */
743
    }
744
745
    /**
746
     * Test for the loadLocations() method.
@@ 2484-2505 (lines=22) @@
2481
     *
2482
     * @return \eZ\Publish\API\Repository\Values\Content\Content published Content
2483
     */
2484
    private function publishContentWithParentLocation($contentName, $parentLocationId)
2485
    {
2486
        $repository = $this->getRepository(false);
2487
        $locationService = $repository->getLocationService();
2488
2489
        $contentService = $repository->getContentService();
2490
        $contentTypeService = $repository->getContentTypeService();
2491
2492
        $contentCreateStruct = $contentService->newContentCreateStruct(
2493
            $contentTypeService->loadContentTypeByIdentifier('folder'),
2494
            'eng-US'
2495
        );
2496
        $contentCreateStruct->setField('name', $contentName);
2497
        $contentDraft = $contentService->createContent(
2498
            $contentCreateStruct,
2499
            [
2500
                $locationService->newLocationCreateStruct($parentLocationId),
2501
            ]
2502
        );
2503
2504
        return $contentService->publishVersion($contentDraft->versionInfo);
2505
    }
2506
}
2507

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

@@ 841-856 (lines=16) @@
838
     *
839
     * @return \eZ\Publish\API\Repository\Values\Content\Content
840
     */
841
    protected function createNewContentInPlaceTrashedOne(Repository $repository, $parentLocationId)
842
    {
843
        $contentService = $repository->getContentService();
844
        $locationService = $repository->getLocationService();
845
        $contentTypeService = $repository->getContentTypeService();
846
847
        $contentType = $contentTypeService->loadContentTypeByIdentifier('forum');
848
        $newContent = $contentService->newContentCreateStruct($contentType, 'eng-US');
849
        $newContent->setField('name', 'Media');
850
851
        $location = $locationService->newLocationCreateStruct($parentLocationId);
852
853
        $draftContent = $contentService->createContent($newContent, [$location]);
854
855
        return $contentService->publishVersion($draftContent->versionInfo);
856
    }
857
858
    /**
859
     * @param URLAliasService $urlAliasService