Code Duplication    Length = 16-23 lines in 3 locations

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

@@ 827-849 (lines=23) @@
824
     * @see \eZ\Publish\API\Repository\LocationService::loadLocations()
825
     * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocations
826
     */
827
    public function testLoadLocationsThrowsBadStateException()
828
    {
829
        $this->expectException(\eZ\Publish\API\Repository\Exceptions\BadStateException::class);
830
831
        $repository = $this->getRepository();
832
833
        /* BEGIN: Use Case */
834
        $contentTypeService = $repository->getContentTypeService();
835
        $contentService = $repository->getContentService();
836
        $locationService = $repository->getLocationService();
837
838
        // Create new content, which is not published
839
        $folderType = $contentTypeService->loadContentTypeByIdentifier('folder');
840
        $contentCreate = $contentService->newContentCreateStruct($folderType, 'eng-US');
841
        $contentCreate->setField('name', 'New Folder');
842
        $content = $contentService->createContent($contentCreate);
843
844
        // Throws Exception, since $content has no published version, yet
845
        $locationService->loadLocations(
846
            $content->contentInfo
847
        );
848
        /* END: Use Case */
849
    }
850
851
    /**
852
     * Test for the loadLocations() method.
@@ 2896-2917 (lines=22) @@
2893
     *
2894
     * @return \eZ\Publish\API\Repository\Values\Content\Content published Content
2895
     */
2896
    private function publishContentWithParentLocation($contentName, $parentLocationId)
2897
    {
2898
        $repository = $this->getRepository(false);
2899
        $locationService = $repository->getLocationService();
2900
2901
        $contentService = $repository->getContentService();
2902
        $contentTypeService = $repository->getContentTypeService();
2903
2904
        $contentCreateStruct = $contentService->newContentCreateStruct(
2905
            $contentTypeService->loadContentTypeByIdentifier('folder'),
2906
            'eng-US'
2907
        );
2908
        $contentCreateStruct->setField('name', $contentName);
2909
        $contentDraft = $contentService->createContent(
2910
            $contentCreateStruct,
2911
            [
2912
                $locationService->newLocationCreateStruct($parentLocationId),
2913
            ]
2914
        );
2915
2916
        return $contentService->publishVersion($contentDraft->versionInfo);
2917
    }
2918
}
2919

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

@@ 930-945 (lines=16) @@
927
     *
928
     * @return \eZ\Publish\API\Repository\Values\Content\Content
929
     */
930
    protected function createNewContentInPlaceTrashedOne(Repository $repository, $parentLocationId)
931
    {
932
        $contentService = $repository->getContentService();
933
        $locationService = $repository->getLocationService();
934
        $contentTypeService = $repository->getContentTypeService();
935
936
        $contentType = $contentTypeService->loadContentTypeByIdentifier('forum');
937
        $newContent = $contentService->newContentCreateStruct($contentType, 'eng-US');
938
        $newContent->setField('name', 'Media');
939
940
        $location = $locationService->newLocationCreateStruct($parentLocationId);
941
942
        $draftContent = $contentService->createContent($newContent, [$location]);
943
944
        return $contentService->publishVersion($draftContent->versionInfo);
945
    }
946
947
    /**
948
     * @param URLAliasService $urlAliasService