@@ 911-933 (lines=23) @@ | ||
908 | * @see \eZ\Publish\API\Repository\LocationService::loadLocations() |
|
909 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocations |
|
910 | */ |
|
911 | public function testLoadLocationsThrowsBadStateException() |
|
912 | { |
|
913 | $this->expectException(\eZ\Publish\API\Repository\Exceptions\BadStateException::class); |
|
914 | ||
915 | $repository = $this->getRepository(); |
|
916 | ||
917 | /* BEGIN: Use Case */ |
|
918 | $contentTypeService = $repository->getContentTypeService(); |
|
919 | $contentService = $repository->getContentService(); |
|
920 | $locationService = $repository->getLocationService(); |
|
921 | ||
922 | // Create new content, which is not published |
|
923 | $folderType = $contentTypeService->loadContentTypeByIdentifier('folder'); |
|
924 | $contentCreate = $contentService->newContentCreateStruct($folderType, 'eng-US'); |
|
925 | $contentCreate->setField('name', 'New Folder'); |
|
926 | $content = $contentService->createContent($contentCreate); |
|
927 | ||
928 | // Throws Exception, since $content has no published version, yet |
|
929 | $locationService->loadLocations( |
|
930 | $content->contentInfo |
|
931 | ); |
|
932 | /* END: Use Case */ |
|
933 | } |
|
934 | ||
935 | /** |
|
936 | * Test for the loadLocations() method. |
|
@@ 3092-3113 (lines=22) @@ | ||
3089 | * |
|
3090 | * @return \eZ\Publish\API\Repository\Values\Content\Content published Content |
|
3091 | */ |
|
3092 | private function publishContentWithParentLocation($contentName, $parentLocationId) |
|
3093 | { |
|
3094 | $repository = $this->getRepository(false); |
|
3095 | $locationService = $repository->getLocationService(); |
|
3096 | ||
3097 | $contentService = $repository->getContentService(); |
|
3098 | $contentTypeService = $repository->getContentTypeService(); |
|
3099 | ||
3100 | $contentCreateStruct = $contentService->newContentCreateStruct( |
|
3101 | $contentTypeService->loadContentTypeByIdentifier('folder'), |
|
3102 | 'eng-US' |
|
3103 | ); |
|
3104 | $contentCreateStruct->setField('name', $contentName); |
|
3105 | $contentDraft = $contentService->createContent( |
|
3106 | $contentCreateStruct, |
|
3107 | [ |
|
3108 | $locationService->newLocationCreateStruct($parentLocationId), |
|
3109 | ] |
|
3110 | ); |
|
3111 | ||
3112 | return $contentService->publishVersion($contentDraft->versionInfo); |
|
3113 | } |
|
3114 | ||
3115 | /** |
|
3116 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException |
@@ 1006-1021 (lines=16) @@ | ||
1003 | * |
|
1004 | * @return \eZ\Publish\API\Repository\Values\Content\Content |
|
1005 | */ |
|
1006 | protected function createNewContentInPlaceTrashedOne(Repository $repository, $parentLocationId) |
|
1007 | { |
|
1008 | $contentService = $repository->getContentService(); |
|
1009 | $locationService = $repository->getLocationService(); |
|
1010 | $contentTypeService = $repository->getContentTypeService(); |
|
1011 | ||
1012 | $contentType = $contentTypeService->loadContentTypeByIdentifier('forum'); |
|
1013 | $newContent = $contentService->newContentCreateStruct($contentType, 'eng-US'); |
|
1014 | $newContent->setField('name', 'Media'); |
|
1015 | ||
1016 | $location = $locationService->newLocationCreateStruct($parentLocationId); |
|
1017 | ||
1018 | $draftContent = $contentService->createContent($newContent, [$location]); |
|
1019 | ||
1020 | return $contentService->publishVersion($draftContent->versionInfo); |
|
1021 | } |
|
1022 | ||
1023 | /** |
|
1024 | * @param URLAliasService $urlAliasService |