|
@@ 167-191 (lines=25) @@
|
| 164 |
|
* @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testNewLocationCreateStruct |
| 165 |
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
| 166 |
|
*/ |
| 167 |
|
public function testCreateLocationThrowsInvalidArgumentExceptionContentAlreadyBelowParent() |
| 168 |
|
{ |
| 169 |
|
$repository = $this->getRepository(); |
| 170 |
|
|
| 171 |
|
$contentId = $this->generateId('object', 11); |
| 172 |
|
$parentLocationId = $this->generateId('location', 5); |
| 173 |
|
/* BEGIN: Use Case */ |
| 174 |
|
// $contentId is the ID of an existing content object |
| 175 |
|
// $parentLocationId is the ID of an existing location which already |
| 176 |
|
// has the content assigned to one of its descendant locations |
| 177 |
|
$contentService = $repository->getContentService(); |
| 178 |
|
$locationService = $repository->getLocationService(); |
| 179 |
|
|
| 180 |
|
// ContentInfo for "How to use eZ Publish" |
| 181 |
|
$contentInfo = $contentService->loadContentInfo($contentId); |
| 182 |
|
|
| 183 |
|
$locationCreate = $locationService->newLocationCreateStruct($parentLocationId); |
| 184 |
|
|
| 185 |
|
// Throws exception, since content is already located at "/1/2/107/110/" |
| 186 |
|
$locationService->createLocation( |
| 187 |
|
$contentInfo, |
| 188 |
|
$locationCreate |
| 189 |
|
); |
| 190 |
|
/* END: Use Case */ |
| 191 |
|
} |
| 192 |
|
|
| 193 |
|
/** |
| 194 |
|
* Test for the createLocation() method. |
|
@@ 200-224 (lines=25) @@
|
| 197 |
|
* @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testNewLocationCreateStruct |
| 198 |
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
| 199 |
|
*/ |
| 200 |
|
public function testCreateLocationThrowsInvalidArgumentExceptionParentIsSubLocationOfContent() |
| 201 |
|
{ |
| 202 |
|
$repository = $this->getRepository(); |
| 203 |
|
|
| 204 |
|
$contentId = $this->generateId('object', 4); |
| 205 |
|
$parentLocationId = $this->generateId('location', 12); |
| 206 |
|
/* BEGIN: Use Case */ |
| 207 |
|
// $contentId is the ID of an existing content object |
| 208 |
|
// $parentLocationId is the ID of an existing location which is below a |
| 209 |
|
// location that is assigned to the content |
| 210 |
|
$contentService = $repository->getContentService(); |
| 211 |
|
$locationService = $repository->getLocationService(); |
| 212 |
|
|
| 213 |
|
// ContentInfo for "How to use eZ Publish" |
| 214 |
|
$contentInfo = $contentService->loadContentInfo($contentId); |
| 215 |
|
|
| 216 |
|
$locationCreate = $locationService->newLocationCreateStruct($parentLocationId); |
| 217 |
|
|
| 218 |
|
// Throws exception, since content is already located at "/1/2/" |
| 219 |
|
$locationService->createLocation( |
| 220 |
|
$contentInfo, |
| 221 |
|
$locationCreate |
| 222 |
|
); |
| 223 |
|
/* END: Use Case */ |
| 224 |
|
} |
| 225 |
|
|
| 226 |
|
/** |
| 227 |
|
* Test for the createLocation() method. |
|
@@ 233-257 (lines=25) @@
|
| 230 |
|
* @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testNewLocationCreateStruct |
| 231 |
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
| 232 |
|
*/ |
| 233 |
|
public function testCreateLocationThrowsInvalidArgumentExceptionRemoteIdExists() |
| 234 |
|
{ |
| 235 |
|
$repository = $this->getRepository(); |
| 236 |
|
|
| 237 |
|
$contentId = $this->generateId('object', 41); |
| 238 |
|
$parentLocationId = $this->generateId('location', 5); |
| 239 |
|
/* BEGIN: Use Case */ |
| 240 |
|
// $contentId is the ID of an existing content object |
| 241 |
|
$contentService = $repository->getContentService(); |
| 242 |
|
$locationService = $repository->getLocationService(); |
| 243 |
|
|
| 244 |
|
// ContentInfo for "How to use eZ Publish" |
| 245 |
|
$contentInfo = $contentService->loadContentInfo($contentId); |
| 246 |
|
|
| 247 |
|
$locationCreate = $locationService->newLocationCreateStruct($parentLocationId); |
| 248 |
|
// This remote ID already exists |
| 249 |
|
$locationCreate->remoteId = 'f3e90596361e31d496d4026eb624c983'; |
| 250 |
|
|
| 251 |
|
// Throws exception, since remote ID is already in use |
| 252 |
|
$locationService->createLocation( |
| 253 |
|
$contentInfo, |
| 254 |
|
$locationCreate |
| 255 |
|
); |
| 256 |
|
/* END: Use Case */ |
| 257 |
|
} |
| 258 |
|
|
| 259 |
|
/** |
| 260 |
|
* Test for the createLocation() method. |