Code Duplication    Length = 16-23 lines in 3 locations

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

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

@@ 913-935 (lines=23) @@
910
     * @see \eZ\Publish\API\Repository\LocationService::loadLocations()
911
     * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocations
912
     */
913
    public function testLoadLocationsThrowsBadStateException()
914
    {
915
        $this->expectException(\eZ\Publish\API\Repository\Exceptions\BadStateException::class);
916
917
        $repository = $this->getRepository();
918
919
        /* BEGIN: Use Case */
920
        $contentTypeService = $repository->getContentTypeService();
921
        $contentService = $repository->getContentService();
922
        $locationService = $repository->getLocationService();
923
924
        // Create new content, which is not published
925
        $folderType = $contentTypeService->loadContentTypeByIdentifier('folder');
926
        $contentCreate = $contentService->newContentCreateStruct($folderType, 'eng-US');
927
        $contentCreate->setField('name', 'New Folder');
928
        $content = $contentService->createContent($contentCreate);
929
930
        // Throws Exception, since $content has no published version, yet
931
        $locationService->loadLocations(
932
            $content->contentInfo
933
        );
934
        /* END: Use Case */
935
    }
936
937
    /**
938
     * Test for the loadLocations() method.
@@ 3094-3115 (lines=22) @@
3091
     *
3092
     * @return \eZ\Publish\API\Repository\Values\Content\Content published Content
3093
     */
3094
    private function publishContentWithParentLocation($contentName, $parentLocationId)
3095
    {
3096
        $repository = $this->getRepository(false);
3097
        $locationService = $repository->getLocationService();
3098
3099
        $contentService = $repository->getContentService();
3100
        $contentTypeService = $repository->getContentTypeService();
3101
3102
        $contentCreateStruct = $contentService->newContentCreateStruct(
3103
            $contentTypeService->loadContentTypeByIdentifier('folder'),
3104
            'eng-US'
3105
        );
3106
        $contentCreateStruct->setField('name', $contentName);
3107
        $contentDraft = $contentService->createContent(
3108
            $contentCreateStruct,
3109
            [
3110
                $locationService->newLocationCreateStruct($parentLocationId),
3111
            ]
3112
        );
3113
3114
        return $contentService->publishVersion($contentDraft->versionInfo);
3115
    }
3116
3117
    /**
3118
     * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException