|
@@ 354-368 (lines=15) @@
|
| 351 |
|
* @see \eZ\Publish\API\Repository\ContentService::createContent() |
| 352 |
|
* @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContent |
| 353 |
|
*/ |
| 354 |
|
public function testCreateContentThrowsInvalidArgumentExceptionOnFieldTypeNotAccept() |
| 355 |
|
{ |
| 356 |
|
/* BEGIN: Use Case */ |
| 357 |
|
$contentTypeService = $this->getRepository()->getContentTypeService(); |
| 358 |
|
|
| 359 |
|
$contentType = $contentTypeService->loadContentTypeByIdentifier('forum'); |
| 360 |
|
|
| 361 |
|
$contentCreate = $this->contentService->newContentCreateStruct($contentType, 'eng-US'); |
| 362 |
|
// The name field does only accept strings and null as its values |
| 363 |
|
$contentCreate->setField('name', new \stdClass()); |
| 364 |
|
|
| 365 |
|
$this->expectException(APIInvalidArgumentException::class); |
| 366 |
|
$draft = $this->contentService->createContent($contentCreate); |
| 367 |
|
/* END: Use Case */ |
| 368 |
|
} |
| 369 |
|
|
| 370 |
|
/** |
| 371 |
|
* Test for the createContent() method. |
|
@@ 401-415 (lines=15) @@
|
| 398 |
|
* @see \eZ\Publish\API\Repository\ContentService::createContent() |
| 399 |
|
* @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContent |
| 400 |
|
*/ |
| 401 |
|
public function testCreateContentRequiredFieldMissing() |
| 402 |
|
{ |
| 403 |
|
/* BEGIN: Use Case */ |
| 404 |
|
$contentTypeService = $this->getRepository()->getContentTypeService(); |
| 405 |
|
$contentType = $contentTypeService->loadContentTypeByIdentifier('forum'); |
| 406 |
|
|
| 407 |
|
$contentCreate1 = $this->contentService->newContentCreateStruct($contentType, 'eng-US'); |
| 408 |
|
// Required field "name" is not set |
| 409 |
|
|
| 410 |
|
$this->expectException(ContentFieldValidationException::class); |
| 411 |
|
|
| 412 |
|
// Throws a ContentFieldValidationException, since a required field is missing |
| 413 |
|
$draft = $this->contentService->createContent($contentCreate1); |
| 414 |
|
/* END: Use Case */ |
| 415 |
|
} |
| 416 |
|
|
| 417 |
|
/** |
| 418 |
|
* Test for the createContent() method. |