|
@@ 1631-1652 (lines=22) @@
|
| 1628 |
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
| 1629 |
|
* @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testUpdateContent |
| 1630 |
|
*/ |
| 1631 |
|
public function testUpdateContentThrowsInvalidArgumentExceptionWhenFieldTypeDoesNotAccept() |
| 1632 |
|
{ |
| 1633 |
|
$repository = $this->getRepository(); |
| 1634 |
|
|
| 1635 |
|
$contentService = $repository->getContentService(); |
| 1636 |
|
|
| 1637 |
|
/* BEGIN: Use Case */ |
| 1638 |
|
$draft = $this->createContentDraftVersion1(); |
| 1639 |
|
|
| 1640 |
|
// Now create an update struct and modify some fields |
| 1641 |
|
$contentUpdateStruct = $contentService->newContentUpdateStruct(); |
| 1642 |
|
// The name field does not accept a stdClass object as its input |
| 1643 |
|
$contentUpdateStruct->setField('name', new \stdClass(), 'eng-US'); |
| 1644 |
|
|
| 1645 |
|
// Throws an InvalidArgumentException, since the value for field "name" |
| 1646 |
|
// is not accepted |
| 1647 |
|
$contentService->updateContent( |
| 1648 |
|
$draft->getVersionInfo(), |
| 1649 |
|
$contentUpdateStruct |
| 1650 |
|
); |
| 1651 |
|
/* END: Use Case */ |
| 1652 |
|
} |
| 1653 |
|
|
| 1654 |
|
/** |
| 1655 |
|
* Test for the updateContent() method. |
|
@@ 1661-1684 (lines=24) @@
|
| 1658 |
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\ContentFieldValidationException |
| 1659 |
|
* @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testUpdateContent |
| 1660 |
|
*/ |
| 1661 |
|
public function testUpdateContentWhenMandatoryFieldIsEmpty() |
| 1662 |
|
{ |
| 1663 |
|
$repository = $this->getRepository(); |
| 1664 |
|
|
| 1665 |
|
$contentService = $repository->getContentService(); |
| 1666 |
|
|
| 1667 |
|
/* BEGIN: Use Case */ |
| 1668 |
|
$draft = $this->createContentDraftVersion1(); |
| 1669 |
|
|
| 1670 |
|
// Now create an update struct and set a mandatory field to null |
| 1671 |
|
$contentUpdateStruct = $contentService->newContentUpdateStruct(); |
| 1672 |
|
$contentUpdateStruct->setField('name', null); |
| 1673 |
|
|
| 1674 |
|
// Don't set this, then the above call without languageCode will fail |
| 1675 |
|
$contentUpdateStruct->initialLanguageCode = 'eng-US'; |
| 1676 |
|
|
| 1677 |
|
// This call will fail with a "ContentFieldValidationException", because the |
| 1678 |
|
// mandatory "name" field is empty. |
| 1679 |
|
$contentService->updateContent( |
| 1680 |
|
$draft->getVersionInfo(), |
| 1681 |
|
$contentUpdateStruct |
| 1682 |
|
); |
| 1683 |
|
/* END: Use Case */ |
| 1684 |
|
} |
| 1685 |
|
|
| 1686 |
|
/** |
| 1687 |
|
* Test for the updateContent() method. |