|
@@ 249-273 (lines=25) @@
|
| 246 |
|
* @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testNewLocationCreateStruct |
| 247 |
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
| 248 |
|
*/ |
| 249 |
|
public function testCreateLocationThrowsInvalidArgumentExceptionContentAlreadyBelowParent() |
| 250 |
|
{ |
| 251 |
|
$repository = $this->getRepository(); |
| 252 |
|
|
| 253 |
|
$contentId = $this->generateId('object', 11); |
| 254 |
|
$parentLocationId = $this->generateId('location', 5); |
| 255 |
|
/* BEGIN: Use Case */ |
| 256 |
|
// $contentId is the ID of an existing content object |
| 257 |
|
// $parentLocationId is the ID of an existing location which already |
| 258 |
|
// has the content assigned to one of its descendant locations |
| 259 |
|
$contentService = $repository->getContentService(); |
| 260 |
|
$locationService = $repository->getLocationService(); |
| 261 |
|
|
| 262 |
|
// ContentInfo for "How to use eZ Publish" |
| 263 |
|
$contentInfo = $contentService->loadContentInfo($contentId); |
| 264 |
|
|
| 265 |
|
$locationCreate = $locationService->newLocationCreateStruct($parentLocationId); |
| 266 |
|
|
| 267 |
|
// Throws exception, since content is already located at "/1/2/107/110/" |
| 268 |
|
$locationService->createLocation( |
| 269 |
|
$contentInfo, |
| 270 |
|
$locationCreate |
| 271 |
|
); |
| 272 |
|
/* END: Use Case */ |
| 273 |
|
} |
| 274 |
|
|
| 275 |
|
/** |
| 276 |
|
* Test for the createLocation() method. |
|
@@ 282-306 (lines=25) @@
|
| 279 |
|
* @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testNewLocationCreateStruct |
| 280 |
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
| 281 |
|
*/ |
| 282 |
|
public function testCreateLocationThrowsInvalidArgumentExceptionParentIsSubLocationOfContent() |
| 283 |
|
{ |
| 284 |
|
$repository = $this->getRepository(); |
| 285 |
|
|
| 286 |
|
$contentId = $this->generateId('object', 4); |
| 287 |
|
$parentLocationId = $this->generateId('location', 12); |
| 288 |
|
/* BEGIN: Use Case */ |
| 289 |
|
// $contentId is the ID of an existing content object |
| 290 |
|
// $parentLocationId is the ID of an existing location which is below a |
| 291 |
|
// location that is assigned to the content |
| 292 |
|
$contentService = $repository->getContentService(); |
| 293 |
|
$locationService = $repository->getLocationService(); |
| 294 |
|
|
| 295 |
|
// ContentInfo for "How to use eZ Publish" |
| 296 |
|
$contentInfo = $contentService->loadContentInfo($contentId); |
| 297 |
|
|
| 298 |
|
$locationCreate = $locationService->newLocationCreateStruct($parentLocationId); |
| 299 |
|
|
| 300 |
|
// Throws exception, since content is already located at "/1/2/" |
| 301 |
|
$locationService->createLocation( |
| 302 |
|
$contentInfo, |
| 303 |
|
$locationCreate |
| 304 |
|
); |
| 305 |
|
/* END: Use Case */ |
| 306 |
|
} |
| 307 |
|
|
| 308 |
|
/** |
| 309 |
|
* Test for the createLocation() method. |
|
@@ 315-339 (lines=25) @@
|
| 312 |
|
* @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testNewLocationCreateStruct |
| 313 |
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
| 314 |
|
*/ |
| 315 |
|
public function testCreateLocationThrowsInvalidArgumentExceptionRemoteIdExists() |
| 316 |
|
{ |
| 317 |
|
$repository = $this->getRepository(); |
| 318 |
|
|
| 319 |
|
$contentId = $this->generateId('object', 41); |
| 320 |
|
$parentLocationId = $this->generateId('location', 5); |
| 321 |
|
/* BEGIN: Use Case */ |
| 322 |
|
// $contentId is the ID of an existing content object |
| 323 |
|
$contentService = $repository->getContentService(); |
| 324 |
|
$locationService = $repository->getLocationService(); |
| 325 |
|
|
| 326 |
|
// ContentInfo for "How to use eZ Publish" |
| 327 |
|
$contentInfo = $contentService->loadContentInfo($contentId); |
| 328 |
|
|
| 329 |
|
$locationCreate = $locationService->newLocationCreateStruct($parentLocationId); |
| 330 |
|
// This remote ID already exists |
| 331 |
|
$locationCreate->remoteId = 'f3e90596361e31d496d4026eb624c983'; |
| 332 |
|
|
| 333 |
|
// Throws exception, since remote ID is already in use |
| 334 |
|
$locationService->createLocation( |
| 335 |
|
$contentInfo, |
| 336 |
|
$locationCreate |
| 337 |
|
); |
| 338 |
|
/* END: Use Case */ |
| 339 |
|
} |
| 340 |
|
|
| 341 |
|
/** |
| 342 |
|
* Test for the createLocation() method. |