|
@@ 208-232 (lines=25) @@
|
| 205 |
|
* @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testNewLocationCreateStruct |
| 206 |
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
| 207 |
|
*/ |
| 208 |
|
public function testCreateLocationThrowsInvalidArgumentExceptionContentAlreadyBelowParent() |
| 209 |
|
{ |
| 210 |
|
$repository = $this->getRepository(); |
| 211 |
|
|
| 212 |
|
$contentId = $this->generateId('object', 11); |
| 213 |
|
$parentLocationId = $this->generateId('location', 5); |
| 214 |
|
/* BEGIN: Use Case */ |
| 215 |
|
// $contentId is the ID of an existing content object |
| 216 |
|
// $parentLocationId is the ID of an existing location which already |
| 217 |
|
// has the content assigned to one of its descendant locations |
| 218 |
|
$contentService = $repository->getContentService(); |
| 219 |
|
$locationService = $repository->getLocationService(); |
| 220 |
|
|
| 221 |
|
// ContentInfo for "How to use eZ Publish" |
| 222 |
|
$contentInfo = $contentService->loadContentInfo($contentId); |
| 223 |
|
|
| 224 |
|
$locationCreate = $locationService->newLocationCreateStruct($parentLocationId); |
| 225 |
|
|
| 226 |
|
// Throws exception, since content is already located at "/1/2/107/110/" |
| 227 |
|
$locationService->createLocation( |
| 228 |
|
$contentInfo, |
| 229 |
|
$locationCreate |
| 230 |
|
); |
| 231 |
|
/* END: Use Case */ |
| 232 |
|
} |
| 233 |
|
|
| 234 |
|
/** |
| 235 |
|
* Test for the createLocation() method. |
|
@@ 241-265 (lines=25) @@
|
| 238 |
|
* @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testNewLocationCreateStruct |
| 239 |
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
| 240 |
|
*/ |
| 241 |
|
public function testCreateLocationThrowsInvalidArgumentExceptionParentIsSubLocationOfContent() |
| 242 |
|
{ |
| 243 |
|
$repository = $this->getRepository(); |
| 244 |
|
|
| 245 |
|
$contentId = $this->generateId('object', 4); |
| 246 |
|
$parentLocationId = $this->generateId('location', 12); |
| 247 |
|
/* BEGIN: Use Case */ |
| 248 |
|
// $contentId is the ID of an existing content object |
| 249 |
|
// $parentLocationId is the ID of an existing location which is below a |
| 250 |
|
// location that is assigned to the content |
| 251 |
|
$contentService = $repository->getContentService(); |
| 252 |
|
$locationService = $repository->getLocationService(); |
| 253 |
|
|
| 254 |
|
// ContentInfo for "How to use eZ Publish" |
| 255 |
|
$contentInfo = $contentService->loadContentInfo($contentId); |
| 256 |
|
|
| 257 |
|
$locationCreate = $locationService->newLocationCreateStruct($parentLocationId); |
| 258 |
|
|
| 259 |
|
// Throws exception, since content is already located at "/1/2/" |
| 260 |
|
$locationService->createLocation( |
| 261 |
|
$contentInfo, |
| 262 |
|
$locationCreate |
| 263 |
|
); |
| 264 |
|
/* END: Use Case */ |
| 265 |
|
} |
| 266 |
|
|
| 267 |
|
/** |
| 268 |
|
* Test for the createLocation() method. |
|
@@ 274-298 (lines=25) @@
|
| 271 |
|
* @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testNewLocationCreateStruct |
| 272 |
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
| 273 |
|
*/ |
| 274 |
|
public function testCreateLocationThrowsInvalidArgumentExceptionRemoteIdExists() |
| 275 |
|
{ |
| 276 |
|
$repository = $this->getRepository(); |
| 277 |
|
|
| 278 |
|
$contentId = $this->generateId('object', 41); |
| 279 |
|
$parentLocationId = $this->generateId('location', 5); |
| 280 |
|
/* BEGIN: Use Case */ |
| 281 |
|
// $contentId is the ID of an existing content object |
| 282 |
|
$contentService = $repository->getContentService(); |
| 283 |
|
$locationService = $repository->getLocationService(); |
| 284 |
|
|
| 285 |
|
// ContentInfo for "How to use eZ Publish" |
| 286 |
|
$contentInfo = $contentService->loadContentInfo($contentId); |
| 287 |
|
|
| 288 |
|
$locationCreate = $locationService->newLocationCreateStruct($parentLocationId); |
| 289 |
|
// This remote ID already exists |
| 290 |
|
$locationCreate->remoteId = 'f3e90596361e31d496d4026eb624c983'; |
| 291 |
|
|
| 292 |
|
// Throws exception, since remote ID is already in use |
| 293 |
|
$locationService->createLocation( |
| 294 |
|
$contentInfo, |
| 295 |
|
$locationCreate |
| 296 |
|
); |
| 297 |
|
/* END: Use Case */ |
| 298 |
|
} |
| 299 |
|
|
| 300 |
|
/** |
| 301 |
|
* Test for the createLocation() method. |