|
@@ 1394-1415 (lines=22) @@
|
| 1391 |
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
| 1392 |
|
* @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testUpdateContent |
| 1393 |
|
*/ |
| 1394 |
|
public function testUpdateContentThrowsInvalidArgumentExceptionWhenFieldTypeDoesNotAccept() |
| 1395 |
|
{ |
| 1396 |
|
$repository = $this->getRepository(); |
| 1397 |
|
|
| 1398 |
|
$contentService = $repository->getContentService(); |
| 1399 |
|
|
| 1400 |
|
/* BEGIN: Use Case */ |
| 1401 |
|
$draft = $this->createContentDraftVersion1(); |
| 1402 |
|
|
| 1403 |
|
// Now create an update struct and modify some fields |
| 1404 |
|
$contentUpdateStruct = $contentService->newContentUpdateStruct(); |
| 1405 |
|
// The name field does not accept a stdClass object as its input |
| 1406 |
|
$contentUpdateStruct->setField('name', new \stdClass(), 'eng-US'); |
| 1407 |
|
|
| 1408 |
|
// Throws an InvalidArgumentException, since the value for field "name" |
| 1409 |
|
// is not accepted |
| 1410 |
|
$contentService->updateContent( |
| 1411 |
|
$draft->getVersionInfo(), |
| 1412 |
|
$contentUpdateStruct |
| 1413 |
|
); |
| 1414 |
|
/* END: Use Case */ |
| 1415 |
|
} |
| 1416 |
|
|
| 1417 |
|
/** |
| 1418 |
|
* Test for the updateContent() method. |
|
@@ 1424-1447 (lines=24) @@
|
| 1421 |
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\ContentValidationException |
| 1422 |
|
* @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testUpdateContent |
| 1423 |
|
*/ |
| 1424 |
|
public function testUpdateContentThrowsContentValidationExceptionWhenMandatoryFieldIsEmpty() |
| 1425 |
|
{ |
| 1426 |
|
$repository = $this->getRepository(); |
| 1427 |
|
|
| 1428 |
|
$contentService = $repository->getContentService(); |
| 1429 |
|
|
| 1430 |
|
/* BEGIN: Use Case */ |
| 1431 |
|
$draft = $this->createContentDraftVersion1(); |
| 1432 |
|
|
| 1433 |
|
// Now create an update struct and set a mandatory field to null |
| 1434 |
|
$contentUpdateStruct = $contentService->newContentUpdateStruct(); |
| 1435 |
|
$contentUpdateStruct->setField('name', null); |
| 1436 |
|
|
| 1437 |
|
// Don't set this, then the above call without languageCode will fail |
| 1438 |
|
$contentUpdateStruct->initialLanguageCode = 'eng-US'; |
| 1439 |
|
|
| 1440 |
|
// This call will fail with a "ContentValidationException", because the |
| 1441 |
|
// mandatory "name" field is empty. |
| 1442 |
|
$contentService->updateContent( |
| 1443 |
|
$draft->getVersionInfo(), |
| 1444 |
|
$contentUpdateStruct |
| 1445 |
|
); |
| 1446 |
|
/* END: Use Case */ |
| 1447 |
|
} |
| 1448 |
|
|
| 1449 |
|
/** |
| 1450 |
|
* Test for the updateContent() method. |