| @@ 100-121 (lines=22) @@ | ||
| 97 | /** |
|
| 98 | * @return Content |
|
| 99 | */ |
|
| 100 | private function createFolder() |
|
| 101 | { |
|
| 102 | $repository = $this->getRepository(); |
|
| 103 | $contentService = $repository->getContentService(); |
|
| 104 | $contentTypeService = $repository->getContentTypeService(); |
|
| 105 | $locationService = $repository->getLocationService(); |
|
| 106 | ||
| 107 | $struct = $contentService->newContentCreateStruct( |
|
| 108 | $contentTypeService->loadContentTypeByIdentifier('folder'), |
|
| 109 | 'eng-GB' |
|
| 110 | ); |
|
| 111 | ||
| 112 | $struct->setField('name', uniqid('Query Controller BDD ', true)); |
|
| 113 | ||
| 114 | $contentDraft = $contentService->createContent( |
|
| 115 | $struct, |
|
| 116 | [$locationService->newLocationCreateStruct(2)] |
|
| 117 | ); |
|
| 118 | $contentService->publishVersion($contentDraft->versionInfo); |
|
| 119 | ||
| 120 | return $contentService->loadContent($contentDraft->id); |
|
| 121 | } |
|
| 122 | ||
| 123 | /** |
|
| 124 | * @Given /^a LocationChildren QueryType defined in "([^"]*)":$/ |
|
| @@ 905-925 (lines=21) @@ | ||
| 902 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocations |
|
| 903 | * @expectedException \eZ\Publish\API\Repository\Exceptions\BadStateException |
|
| 904 | */ |
|
| 905 | public function testLoadLocationsThrowsBadStateException() |
|
| 906 | { |
|
| 907 | $repository = $this->getRepository(); |
|
| 908 | ||
| 909 | /* BEGIN: Use Case */ |
|
| 910 | $contentTypeService = $repository->getContentTypeService(); |
|
| 911 | $contentService = $repository->getContentService(); |
|
| 912 | $locationService = $repository->getLocationService(); |
|
| 913 | ||
| 914 | // Create new content, which is not published |
|
| 915 | $folderType = $contentTypeService->loadContentTypeByIdentifier('folder'); |
|
| 916 | $contentCreate = $contentService->newContentCreateStruct($folderType, 'eng-US'); |
|
| 917 | $contentCreate->setField('name', 'New Folder'); |
|
| 918 | $content = $contentService->createContent($contentCreate); |
|
| 919 | ||
| 920 | // Throws Exception, since $content has no published version, yet |
|
| 921 | $locationService->loadLocations( |
|
| 922 | $content->contentInfo |
|
| 923 | ); |
|
| 924 | /* END: Use Case */ |
|
| 925 | } |
|
| 926 | ||
| 927 | /** |
|
| 928 | * Test for the loadLocations() method. |
|
| @@ 3080-3101 (lines=22) @@ | ||
| 3077 | * |
|
| 3078 | * @return \eZ\Publish\API\Repository\Values\Content\Content published Content |
|
| 3079 | */ |
|
| 3080 | private function publishContentWithParentLocation($contentName, $parentLocationId) |
|
| 3081 | { |
|
| 3082 | $repository = $this->getRepository(false); |
|
| 3083 | $locationService = $repository->getLocationService(); |
|
| 3084 | ||
| 3085 | $contentService = $repository->getContentService(); |
|
| 3086 | $contentTypeService = $repository->getContentTypeService(); |
|
| 3087 | ||
| 3088 | $contentCreateStruct = $contentService->newContentCreateStruct( |
|
| 3089 | $contentTypeService->loadContentTypeByIdentifier('folder'), |
|
| 3090 | 'eng-US' |
|
| 3091 | ); |
|
| 3092 | $contentCreateStruct->setField('name', $contentName); |
|
| 3093 | $contentDraft = $contentService->createContent( |
|
| 3094 | $contentCreateStruct, |
|
| 3095 | [ |
|
| 3096 | $locationService->newLocationCreateStruct($parentLocationId), |
|
| 3097 | ] |
|
| 3098 | ); |
|
| 3099 | ||
| 3100 | return $contentService->publishVersion($contentDraft->versionInfo); |
|
| 3101 | } |
|
| 3102 | ||
| 3103 | /** |
|
| 3104 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException |
|
| @@ 1061-1076 (lines=16) @@ | ||
| 1058 | * |
|
| 1059 | * @return \eZ\Publish\API\Repository\Values\Content\Content |
|
| 1060 | */ |
|
| 1061 | protected function createNewContentInPlaceTrashedOne(Repository $repository, $parentLocationId) |
|
| 1062 | { |
|
| 1063 | $contentService = $repository->getContentService(); |
|
| 1064 | $locationService = $repository->getLocationService(); |
|
| 1065 | $contentTypeService = $repository->getContentTypeService(); |
|
| 1066 | ||
| 1067 | $contentType = $contentTypeService->loadContentTypeByIdentifier('forum'); |
|
| 1068 | $newContent = $contentService->newContentCreateStruct($contentType, 'eng-US'); |
|
| 1069 | $newContent->setField('name', 'Media'); |
|
| 1070 | ||
| 1071 | $location = $locationService->newLocationCreateStruct($parentLocationId); |
|
| 1072 | ||
| 1073 | $draftContent = $contentService->createContent($newContent, [$location]); |
|
| 1074 | ||
| 1075 | return $contentService->publishVersion($draftContent->versionInfo); |
|
| 1076 | } |
|
| 1077 | ||
| 1078 | /** |
|
| 1079 | * @param URLAliasService $urlAliasService |
|