| @@ 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 "([^"]*)":$/ |
|
| @@ 1056-1071 (lines=16) @@ | ||
| 1053 | * |
|
| 1054 | * @return \eZ\Publish\API\Repository\Values\Content\Content |
|
| 1055 | */ |
|
| 1056 | protected function createNewContentInPlaceTrashedOne(Repository $repository, $parentLocationId) |
|
| 1057 | { |
|
| 1058 | $contentService = $repository->getContentService(); |
|
| 1059 | $locationService = $repository->getLocationService(); |
|
| 1060 | $contentTypeService = $repository->getContentTypeService(); |
|
| 1061 | ||
| 1062 | $contentType = $contentTypeService->loadContentTypeByIdentifier('forum'); |
|
| 1063 | $newContent = $contentService->newContentCreateStruct($contentType, 'eng-US'); |
|
| 1064 | $newContent->setField('name', 'Media'); |
|
| 1065 | ||
| 1066 | $location = $locationService->newLocationCreateStruct($parentLocationId); |
|
| 1067 | ||
| 1068 | $draftContent = $contentService->createContent($newContent, [$location]); |
|
| 1069 | ||
| 1070 | return $contentService->publishVersion($draftContent->versionInfo); |
|
| 1071 | } |
|
| 1072 | ||
| 1073 | /** |
|
| 1074 | * @param URLAliasService $urlAliasService |
|
| @@ 900-920 (lines=21) @@ | ||
| 897 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocations |
|
| 898 | * @expectedException \eZ\Publish\API\Repository\Exceptions\BadStateException |
|
| 899 | */ |
|
| 900 | public function testLoadLocationsThrowsBadStateException() |
|
| 901 | { |
|
| 902 | $repository = $this->getRepository(); |
|
| 903 | ||
| 904 | /* BEGIN: Use Case */ |
|
| 905 | $contentTypeService = $repository->getContentTypeService(); |
|
| 906 | $contentService = $repository->getContentService(); |
|
| 907 | $locationService = $repository->getLocationService(); |
|
| 908 | ||
| 909 | // Create new content, which is not published |
|
| 910 | $folderType = $contentTypeService->loadContentTypeByIdentifier('folder'); |
|
| 911 | $contentCreate = $contentService->newContentCreateStruct($folderType, 'eng-US'); |
|
| 912 | $contentCreate->setField('name', 'New Folder'); |
|
| 913 | $content = $contentService->createContent($contentCreate); |
|
| 914 | ||
| 915 | // Throws Exception, since $content has no published version, yet |
|
| 916 | $locationService->loadLocations( |
|
| 917 | $content->contentInfo |
|
| 918 | ); |
|
| 919 | /* END: Use Case */ |
|
| 920 | } |
|
| 921 | ||
| 922 | /** |
|
| 923 | * Test for the loadLocations() method. |
|
| @@ 3137-3158 (lines=22) @@ | ||
| 3134 | * |
|
| 3135 | * @return \eZ\Publish\API\Repository\Values\Content\Content published Content |
|
| 3136 | */ |
|
| 3137 | private function publishContentWithParentLocation($contentName, $parentLocationId) |
|
| 3138 | { |
|
| 3139 | $repository = $this->getRepository(false); |
|
| 3140 | $locationService = $repository->getLocationService(); |
|
| 3141 | ||
| 3142 | $contentService = $repository->getContentService(); |
|
| 3143 | $contentTypeService = $repository->getContentTypeService(); |
|
| 3144 | ||
| 3145 | $contentCreateStruct = $contentService->newContentCreateStruct( |
|
| 3146 | $contentTypeService->loadContentTypeByIdentifier('folder'), |
|
| 3147 | 'eng-US' |
|
| 3148 | ); |
|
| 3149 | $contentCreateStruct->setField('name', $contentName); |
|
| 3150 | $contentDraft = $contentService->createContent( |
|
| 3151 | $contentCreateStruct, |
|
| 3152 | [ |
|
| 3153 | $locationService->newLocationCreateStruct($parentLocationId), |
|
| 3154 | ] |
|
| 3155 | ); |
|
| 3156 | ||
| 3157 | return $contentService->publishVersion($contentDraft->versionInfo); |
|
| 3158 | } |
|
| 3159 | ||
| 3160 | /** |
|
| 3161 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException |
|