|
@@ 365-383 (lines=19) @@
|
| 362 |
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
| 363 |
|
* @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContent |
| 364 |
|
*/ |
| 365 |
|
public function testCreateContentThrowsInvalidArgumentExceptionOnFieldTypeNotAccept() |
| 366 |
|
{ |
| 367 |
|
$repository = $this->getRepository(); |
| 368 |
|
|
| 369 |
|
/* BEGIN: Use Case */ |
| 370 |
|
$contentTypeService = $repository->getContentTypeService(); |
| 371 |
|
$contentService = $repository->getContentService(); |
| 372 |
|
|
| 373 |
|
$contentType = $contentTypeService->loadContentTypeByIdentifier('forum'); |
| 374 |
|
|
| 375 |
|
$contentCreate = $contentService->newContentCreateStruct($contentType, 'eng-US'); |
| 376 |
|
// The name field does only accept strings and null as its values |
| 377 |
|
$contentCreate->setField('name', new \stdClass()); |
| 378 |
|
|
| 379 |
|
// Throws InvalidArgumentException since the name field is filled |
| 380 |
|
// improperly |
| 381 |
|
$draft = $contentService->createContent($contentCreate); |
| 382 |
|
/* END: Use Case */ |
| 383 |
|
} |
| 384 |
|
|
| 385 |
|
/** |
| 386 |
|
* Test for the createContent() method. |
|
@@ 420-437 (lines=18) @@
|
| 417 |
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\ContentFieldValidationException |
| 418 |
|
* @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContent |
| 419 |
|
*/ |
| 420 |
|
public function testCreateContentRequiredFieldMissing() |
| 421 |
|
{ |
| 422 |
|
$repository = $this->getRepository(); |
| 423 |
|
|
| 424 |
|
/* BEGIN: Use Case */ |
| 425 |
|
$contentTypeService = $repository->getContentTypeService(); |
| 426 |
|
$contentService = $repository->getContentService(); |
| 427 |
|
|
| 428 |
|
$contentType = $contentTypeService->loadContentTypeByIdentifier('forum'); |
| 429 |
|
|
| 430 |
|
$contentCreate1 = $contentService->newContentCreateStruct($contentType, 'eng-US'); |
| 431 |
|
// Required field "name" is not set |
| 432 |
|
|
| 433 |
|
// Throws a ContentFieldValidationException, since a required field is |
| 434 |
|
// missing |
| 435 |
|
$draft = $contentService->createContent($contentCreate1); |
| 436 |
|
/* END: Use Case */ |
| 437 |
|
} |
| 438 |
|
|
| 439 |
|
/** |
| 440 |
|
* Test for the createContent() method. |