|
@@ 1571-1592 (lines=22) @@
|
| 1568 |
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
| 1569 |
|
* @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testUpdateContent |
| 1570 |
|
*/ |
| 1571 |
|
public function testUpdateContentThrowsInvalidArgumentExceptionWhenFieldTypeDoesNotAccept() |
| 1572 |
|
{ |
| 1573 |
|
$repository = $this->getRepository(); |
| 1574 |
|
|
| 1575 |
|
$contentService = $repository->getContentService(); |
| 1576 |
|
|
| 1577 |
|
/* BEGIN: Use Case */ |
| 1578 |
|
$draft = $this->createContentDraftVersion1(); |
| 1579 |
|
|
| 1580 |
|
// Now create an update struct and modify some fields |
| 1581 |
|
$contentUpdateStruct = $contentService->newContentUpdateStruct(); |
| 1582 |
|
// The name field does not accept a stdClass object as its input |
| 1583 |
|
$contentUpdateStruct->setField('name', new \stdClass(), 'eng-US'); |
| 1584 |
|
|
| 1585 |
|
// Throws an InvalidArgumentException, since the value for field "name" |
| 1586 |
|
// is not accepted |
| 1587 |
|
$contentService->updateContent( |
| 1588 |
|
$draft->getVersionInfo(), |
| 1589 |
|
$contentUpdateStruct |
| 1590 |
|
); |
| 1591 |
|
/* END: Use Case */ |
| 1592 |
|
} |
| 1593 |
|
|
| 1594 |
|
/** |
| 1595 |
|
* Test for the updateContent() method. |
|
@@ 1601-1624 (lines=24) @@
|
| 1598 |
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\ContentFieldValidationException |
| 1599 |
|
* @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testUpdateContent |
| 1600 |
|
*/ |
| 1601 |
|
public function testUpdateContentWhenMandatoryFieldIsEmpty() |
| 1602 |
|
{ |
| 1603 |
|
$repository = $this->getRepository(); |
| 1604 |
|
|
| 1605 |
|
$contentService = $repository->getContentService(); |
| 1606 |
|
|
| 1607 |
|
/* BEGIN: Use Case */ |
| 1608 |
|
$draft = $this->createContentDraftVersion1(); |
| 1609 |
|
|
| 1610 |
|
// Now create an update struct and set a mandatory field to null |
| 1611 |
|
$contentUpdateStruct = $contentService->newContentUpdateStruct(); |
| 1612 |
|
$contentUpdateStruct->setField('name', null); |
| 1613 |
|
|
| 1614 |
|
// Don't set this, then the above call without languageCode will fail |
| 1615 |
|
$contentUpdateStruct->initialLanguageCode = 'eng-US'; |
| 1616 |
|
|
| 1617 |
|
// This call will fail with a "ContentFieldValidationException", because the |
| 1618 |
|
// mandatory "name" field is empty. |
| 1619 |
|
$contentService->updateContent( |
| 1620 |
|
$draft->getVersionInfo(), |
| 1621 |
|
$contentUpdateStruct |
| 1622 |
|
); |
| 1623 |
|
/* END: Use Case */ |
| 1624 |
|
} |
| 1625 |
|
|
| 1626 |
|
/** |
| 1627 |
|
* Test for the updateContent() method. |