|
@@ 314-332 (lines=19) @@
|
| 311 |
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
| 312 |
|
* @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContent |
| 313 |
|
*/ |
| 314 |
|
public function testCreateContentThrowsInvalidArgumentExceptionOnFieldTypeNotAccept() |
| 315 |
|
{ |
| 316 |
|
$repository = $this->getRepository(); |
| 317 |
|
|
| 318 |
|
/* BEGIN: Use Case */ |
| 319 |
|
$contentTypeService = $repository->getContentTypeService(); |
| 320 |
|
$contentService = $repository->getContentService(); |
| 321 |
|
|
| 322 |
|
$contentType = $contentTypeService->loadContentTypeByIdentifier('forum'); |
| 323 |
|
|
| 324 |
|
$contentCreate = $contentService->newContentCreateStruct($contentType, 'eng-US'); |
| 325 |
|
// The name field does only accept strings and null as its values |
| 326 |
|
$contentCreate->setField('name', new \stdClass()); |
| 327 |
|
|
| 328 |
|
// Throws InvalidArgumentException since the name field is filled |
| 329 |
|
// improperly |
| 330 |
|
$draft = $contentService->createContent($contentCreate); |
| 331 |
|
/* END: Use Case */ |
| 332 |
|
} |
| 333 |
|
|
| 334 |
|
/** |
| 335 |
|
* Test for the createContent() method. |
|
@@ 369-386 (lines=18) @@
|
| 366 |
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\ContentFieldValidationException |
| 367 |
|
* @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContent |
| 368 |
|
*/ |
| 369 |
|
public function testCreateContentRequiredFieldMissing() |
| 370 |
|
{ |
| 371 |
|
$repository = $this->getRepository(); |
| 372 |
|
|
| 373 |
|
/* BEGIN: Use Case */ |
| 374 |
|
$contentTypeService = $repository->getContentTypeService(); |
| 375 |
|
$contentService = $repository->getContentService(); |
| 376 |
|
|
| 377 |
|
$contentType = $contentTypeService->loadContentTypeByIdentifier('forum'); |
| 378 |
|
|
| 379 |
|
$contentCreate1 = $contentService->newContentCreateStruct($contentType, 'eng-US'); |
| 380 |
|
// Required field "name" is not set |
| 381 |
|
|
| 382 |
|
// Throws a ContentFieldValidationException, since a required field is |
| 383 |
|
// missing |
| 384 |
|
$draft = $contentService->createContent($contentCreate1); |
| 385 |
|
/* END: Use Case */ |
| 386 |
|
} |
| 387 |
|
|
| 388 |
|
/** |
| 389 |
|
* Test for the createContent() method. |