Code Duplication    Length = 16-23 lines in 3 locations

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

@@ 848-870 (lines=23) @@
845
     * @see \eZ\Publish\API\Repository\LocationService::loadLocations()
846
     * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocations
847
     */
848
    public function testLoadLocationsThrowsBadStateException()
849
    {
850
        $this->expectException(\eZ\Publish\API\Repository\Exceptions\BadStateException::class);
851
852
        $repository = $this->getRepository();
853
854
        /* BEGIN: Use Case */
855
        $contentTypeService = $repository->getContentTypeService();
856
        $contentService = $repository->getContentService();
857
        $locationService = $repository->getLocationService();
858
859
        // Create new content, which is not published
860
        $folderType = $contentTypeService->loadContentTypeByIdentifier('folder');
861
        $contentCreate = $contentService->newContentCreateStruct($folderType, 'eng-US');
862
        $contentCreate->setField('name', 'New Folder');
863
        $content = $contentService->createContent($contentCreate);
864
865
        // Throws Exception, since $content has no published version, yet
866
        $locationService->loadLocations(
867
            $content->contentInfo
868
        );
869
        /* END: Use Case */
870
    }
871
872
    /**
873
     * Test for the loadLocations() method.
@@ 2918-2939 (lines=22) @@
2915
     *
2916
     * @return \eZ\Publish\API\Repository\Values\Content\Content published Content
2917
     */
2918
    private function publishContentWithParentLocation($contentName, $parentLocationId)
2919
    {
2920
        $repository = $this->getRepository(false);
2921
        $locationService = $repository->getLocationService();
2922
2923
        $contentService = $repository->getContentService();
2924
        $contentTypeService = $repository->getContentTypeService();
2925
2926
        $contentCreateStruct = $contentService->newContentCreateStruct(
2927
            $contentTypeService->loadContentTypeByIdentifier('folder'),
2928
            'eng-US'
2929
        );
2930
        $contentCreateStruct->setField('name', $contentName);
2931
        $contentDraft = $contentService->createContent(
2932
            $contentCreateStruct,
2933
            [
2934
                $locationService->newLocationCreateStruct($parentLocationId),
2935
            ]
2936
        );
2937
2938
        return $contentService->publishVersion($contentDraft->versionInfo);
2939
    }
2940
}
2941

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

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