| @@ 267-295 (lines=29) @@ | ||
| 264 | * @dataProvider dataProviderForOutOfRangeLocationPriority |
|
| 265 | * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
|
| 266 | */ |
|
| 267 | public function testCreateLocationThrowsInvalidArgumentExceptionPriorityIsOutOfRange($priority) |
|
| 268 | { |
|
| 269 | $repository = $this->getRepository(); |
|
| 270 | ||
| 271 | $contentId = $this->generateId('object', 41); |
|
| 272 | $parentLocationId = $this->generateId('location', 5); |
|
| 273 | /* BEGIN: Use Case */ |
|
| 274 | // $contentId is the ID of an existing content object |
|
| 275 | // $parentLocationId is the ID of an existing location |
|
| 276 | $contentService = $repository->getContentService(); |
|
| 277 | $locationService = $repository->getLocationService(); |
|
| 278 | ||
| 279 | // ContentInfo for "How to use eZ Publish" |
|
| 280 | $contentInfo = $contentService->loadContentInfo($contentId); |
|
| 281 | ||
| 282 | $locationCreate = $locationService->newLocationCreateStruct($parentLocationId); |
|
| 283 | $locationCreate->priority = $priority; |
|
| 284 | $locationCreate->hidden = true; |
|
| 285 | $locationCreate->remoteId = 'sindelfingen'; |
|
| 286 | $locationCreate->sortField = Location::SORT_FIELD_NODE_ID; |
|
| 287 | $locationCreate->sortOrder = Location::SORT_ORDER_DESC; |
|
| 288 | ||
| 289 | // Throws exception, since priority is out of range |
|
| 290 | $locationService->createLocation( |
|
| 291 | $contentInfo, |
|
| 292 | $locationCreate |
|
| 293 | ); |
|
| 294 | /* END: Use Case */ |
|
| 295 | } |
|
| 296 | ||
| 297 | public function dataProviderForOutOfRangeLocationPriority() |
|
| 298 | { |
|
| @@ 32-63 (lines=32) @@ | ||
| 29 | * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException |
|
| 30 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testCreateLocation |
|
| 31 | */ |
|
| 32 | public function testCreateLocationThrowsUnauthorizedException() |
|
| 33 | { |
|
| 34 | $repository = $this->getRepository(); |
|
| 35 | ||
| 36 | $editorsGroupId = $this->generateId('group', 13); |
|
| 37 | ||
| 38 | /* BEGIN: Use Case */ |
|
| 39 | $contentService = $repository->getContentService(); |
|
| 40 | $locationService = $repository->getLocationService(); |
|
| 41 | ||
| 42 | $user = $this->createUserVersion1(); |
|
| 43 | ||
| 44 | // ContentInfo for "Editors" user group |
|
| 45 | $contentInfo = $contentService->loadContentInfo($editorsGroupId); |
|
| 46 | ||
| 47 | // Set current user to newly created user |
|
| 48 | $repository->setCurrentUser($user); |
|
| 49 | ||
| 50 | $locationCreate = $locationService->newLocationCreateStruct(1); |
|
| 51 | $locationCreate->priority = 23; |
|
| 52 | $locationCreate->hidden = true; |
|
| 53 | $locationCreate->remoteId = 'sindelfingen'; |
|
| 54 | $locationCreate->sortField = Location::SORT_FIELD_NODE_ID; |
|
| 55 | $locationCreate->sortOrder = Location::SORT_ORDER_DESC; |
|
| 56 | ||
| 57 | // This call will fail with an "UnauthorizedException" |
|
| 58 | $locationService->createLocation( |
|
| 59 | $contentInfo, |
|
| 60 | $locationCreate |
|
| 61 | ); |
|
| 62 | /* END: Use Case */ |
|
| 63 | } |
|
| 64 | ||
| 65 | /** |
|
| 66 | * Test for the createLocation() method. Tests a case when user doesn't have content/manage_locations policy for the new location ID. |
|