|
@@ 1670-1691 (lines=22) @@
|
| 1667 |
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
| 1668 |
|
* @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testUpdateContent |
| 1669 |
|
*/ |
| 1670 |
|
public function testUpdateContentThrowsInvalidArgumentExceptionWhenFieldTypeDoesNotAccept() |
| 1671 |
|
{ |
| 1672 |
|
$repository = $this->getRepository(); |
| 1673 |
|
|
| 1674 |
|
$contentService = $repository->getContentService(); |
| 1675 |
|
|
| 1676 |
|
/* BEGIN: Use Case */ |
| 1677 |
|
$draft = $this->createContentDraftVersion1(); |
| 1678 |
|
|
| 1679 |
|
// Now create an update struct and modify some fields |
| 1680 |
|
$contentUpdateStruct = $contentService->newContentUpdateStruct(); |
| 1681 |
|
// The name field does not accept a stdClass object as its input |
| 1682 |
|
$contentUpdateStruct->setField('name', new \stdClass(), 'eng-US'); |
| 1683 |
|
|
| 1684 |
|
// Throws an InvalidArgumentException, since the value for field "name" |
| 1685 |
|
// is not accepted |
| 1686 |
|
$contentService->updateContent( |
| 1687 |
|
$draft->getVersionInfo(), |
| 1688 |
|
$contentUpdateStruct |
| 1689 |
|
); |
| 1690 |
|
/* END: Use Case */ |
| 1691 |
|
} |
| 1692 |
|
|
| 1693 |
|
/** |
| 1694 |
|
* Test for the updateContent() method. |
|
@@ 1700-1723 (lines=24) @@
|
| 1697 |
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\ContentFieldValidationException |
| 1698 |
|
* @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testUpdateContent |
| 1699 |
|
*/ |
| 1700 |
|
public function testUpdateContentWhenMandatoryFieldIsEmpty() |
| 1701 |
|
{ |
| 1702 |
|
$repository = $this->getRepository(); |
| 1703 |
|
|
| 1704 |
|
$contentService = $repository->getContentService(); |
| 1705 |
|
|
| 1706 |
|
/* BEGIN: Use Case */ |
| 1707 |
|
$draft = $this->createContentDraftVersion1(); |
| 1708 |
|
|
| 1709 |
|
// Now create an update struct and set a mandatory field to null |
| 1710 |
|
$contentUpdateStruct = $contentService->newContentUpdateStruct(); |
| 1711 |
|
$contentUpdateStruct->setField('name', null); |
| 1712 |
|
|
| 1713 |
|
// Don't set this, then the above call without languageCode will fail |
| 1714 |
|
$contentUpdateStruct->initialLanguageCode = 'eng-US'; |
| 1715 |
|
|
| 1716 |
|
// This call will fail with a "ContentFieldValidationException", because the |
| 1717 |
|
// mandatory "name" field is empty. |
| 1718 |
|
$contentService->updateContent( |
| 1719 |
|
$draft->getVersionInfo(), |
| 1720 |
|
$contentUpdateStruct |
| 1721 |
|
); |
| 1722 |
|
/* END: Use Case */ |
| 1723 |
|
} |
| 1724 |
|
|
| 1725 |
|
/** |
| 1726 |
|
* Test for the updateContent() method. |