| @@ 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 |
|
| @@ 873-895 (lines=23) @@ | ||
| 870 | * @see \eZ\Publish\API\Repository\LocationService::loadLocations() |
|
| 871 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocations |
|
| 872 | */ |
|
| 873 | public function testLoadLocationsThrowsBadStateException() |
|
| 874 | { |
|
| 875 | $this->expectException(\eZ\Publish\API\Repository\Exceptions\BadStateException::class); |
|
| 876 | ||
| 877 | $repository = $this->getRepository(); |
|
| 878 | ||
| 879 | /* BEGIN: Use Case */ |
|
| 880 | $contentTypeService = $repository->getContentTypeService(); |
|
| 881 | $contentService = $repository->getContentService(); |
|
| 882 | $locationService = $repository->getLocationService(); |
|
| 883 | ||
| 884 | // Create new content, which is not published |
|
| 885 | $folderType = $contentTypeService->loadContentTypeByIdentifier('folder'); |
|
| 886 | $contentCreate = $contentService->newContentCreateStruct($folderType, 'eng-US'); |
|
| 887 | $contentCreate->setField('name', 'New Folder'); |
|
| 888 | $content = $contentService->createContent($contentCreate); |
|
| 889 | ||
| 890 | // Throws Exception, since $content has no published version, yet |
|
| 891 | $locationService->loadLocations( |
|
| 892 | $content->contentInfo |
|
| 893 | ); |
|
| 894 | /* END: Use Case */ |
|
| 895 | } |
|
| 896 | ||
| 897 | /** |
|
| 898 | * Test for the loadLocations() method. |
|
| @@ 2943-2964 (lines=22) @@ | ||
| 2940 | * |
|
| 2941 | * @return \eZ\Publish\API\Repository\Values\Content\Content published Content |
|
| 2942 | */ |
|
| 2943 | private function publishContentWithParentLocation($contentName, $parentLocationId) |
|
| 2944 | { |
|
| 2945 | $repository = $this->getRepository(false); |
|
| 2946 | $locationService = $repository->getLocationService(); |
|
| 2947 | ||
| 2948 | $contentService = $repository->getContentService(); |
|
| 2949 | $contentTypeService = $repository->getContentTypeService(); |
|
| 2950 | ||
| 2951 | $contentCreateStruct = $contentService->newContentCreateStruct( |
|
| 2952 | $contentTypeService->loadContentTypeByIdentifier('folder'), |
|
| 2953 | 'eng-US' |
|
| 2954 | ); |
|
| 2955 | $contentCreateStruct->setField('name', $contentName); |
|
| 2956 | $contentDraft = $contentService->createContent( |
|
| 2957 | $contentCreateStruct, |
|
| 2958 | [ |
|
| 2959 | $locationService->newLocationCreateStruct($parentLocationId), |
|
| 2960 | ] |
|
| 2961 | ); |
|
| 2962 | ||
| 2963 | return $contentService->publishVersion($contentDraft->versionInfo); |
|
| 2964 | } |
|
| 2965 | } |
|
| 2966 | ||