|
@@ 302-320 (lines=19) @@
|
| 299 |
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
| 300 |
|
* @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContent |
| 301 |
|
*/ |
| 302 |
|
public function testCreateContentThrowsInvalidArgumentExceptionOnFieldTypeNotAccept() |
| 303 |
|
{ |
| 304 |
|
$repository = $this->getRepository(); |
| 305 |
|
|
| 306 |
|
/* BEGIN: Use Case */ |
| 307 |
|
$contentTypeService = $repository->getContentTypeService(); |
| 308 |
|
$contentService = $repository->getContentService(); |
| 309 |
|
|
| 310 |
|
$contentType = $contentTypeService->loadContentTypeByIdentifier('forum'); |
| 311 |
|
|
| 312 |
|
$contentCreate = $contentService->newContentCreateStruct($contentType, 'eng-US'); |
| 313 |
|
// The name field does only accept strings and null as its values |
| 314 |
|
$contentCreate->setField('name', new \stdClass()); |
| 315 |
|
|
| 316 |
|
// Throws InvalidArgumentException since the name field is filled |
| 317 |
|
// improperly |
| 318 |
|
$draft = $contentService->createContent($contentCreate); |
| 319 |
|
/* END: Use Case */ |
| 320 |
|
} |
| 321 |
|
|
| 322 |
|
/** |
| 323 |
|
* Test for the createContent() method. |
|
@@ 357-374 (lines=18) @@
|
| 354 |
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\ContentValidationException |
| 355 |
|
* @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContent |
| 356 |
|
*/ |
| 357 |
|
public function testCreateContentThrowsContentValidationException() |
| 358 |
|
{ |
| 359 |
|
$repository = $this->getRepository(); |
| 360 |
|
|
| 361 |
|
/* BEGIN: Use Case */ |
| 362 |
|
$contentTypeService = $repository->getContentTypeService(); |
| 363 |
|
$contentService = $repository->getContentService(); |
| 364 |
|
|
| 365 |
|
$contentType = $contentTypeService->loadContentTypeByIdentifier('forum'); |
| 366 |
|
|
| 367 |
|
$contentCreate1 = $contentService->newContentCreateStruct($contentType, 'eng-US'); |
| 368 |
|
// Required field "name" is not set |
| 369 |
|
|
| 370 |
|
// Throws a ContentValidationException, since a required field is |
| 371 |
|
// missing |
| 372 |
|
$draft = $contentService->createContent($contentCreate1); |
| 373 |
|
/* END: Use Case */ |
| 374 |
|
} |
| 375 |
|
|
| 376 |
|
/** |
| 377 |
|
* Test for the createContent() method. |