|
@@ 699-723 (lines=25) @@
|
| 696 |
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
| 697 |
|
* @depends eZ\Publish\API\Repository\Tests\UserServiceTest::testUpdateUserGroup |
| 698 |
|
*/ |
| 699 |
|
public function testUpdateUserGroupThrowsInvalidArgumentExceptionOnFieldTypeNotAccept() |
| 700 |
|
{ |
| 701 |
|
$repository = $this->getRepository(); |
| 702 |
|
$userService = $repository->getUserService(); |
| 703 |
|
|
| 704 |
|
/* BEGIN: Use Case */ |
| 705 |
|
$userGroup = $this->createUserGroupVersion1(); |
| 706 |
|
|
| 707 |
|
// Load the content service |
| 708 |
|
$contentService = $repository->getContentService(); |
| 709 |
|
|
| 710 |
|
// Create a content update struct and update the group name |
| 711 |
|
$contentUpdate = $contentService->newContentUpdateStruct(); |
| 712 |
|
// An object of stdClass is not accepted as a value by the field "name" |
| 713 |
|
$contentUpdate->setField('name', new \stdClass(), 'eng-US'); |
| 714 |
|
|
| 715 |
|
// Create a group update struct and set content update struct |
| 716 |
|
$groupUpdate = $userService->newUserGroupUpdateStruct(); |
| 717 |
|
$groupUpdate->contentUpdateStruct = $contentUpdate; |
| 718 |
|
|
| 719 |
|
// This call will fail with an InvalidArgumentException, because the |
| 720 |
|
// field "name" does not accept the given value |
| 721 |
|
$userService->updateUserGroup($userGroup, $groupUpdate); |
| 722 |
|
/* END: Use Case */ |
| 723 |
|
} |
| 724 |
|
|
| 725 |
|
/** |
| 726 |
|
* Test for the newUserCreateStruct() method. |
|
@@ 1749-1776 (lines=28) @@
|
| 1746 |
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\ContentFieldValidationException |
| 1747 |
|
* @depends eZ\Publish\API\Repository\Tests\UserServiceTest::testUpdateUser |
| 1748 |
|
*/ |
| 1749 |
|
public function testUpdateUserWhenMissingField() |
| 1750 |
|
{ |
| 1751 |
|
$repository = $this->getRepository(); |
| 1752 |
|
|
| 1753 |
|
$userService = $repository->getUserService(); |
| 1754 |
|
|
| 1755 |
|
/* BEGIN: Use Case */ |
| 1756 |
|
$user = $this->createUserVersion1(); |
| 1757 |
|
|
| 1758 |
|
// Get the ContentService implementation |
| 1759 |
|
$contentService = $repository->getContentService(); |
| 1760 |
|
|
| 1761 |
|
// Create a content update struct and change the remote id. |
| 1762 |
|
$contentUpdate = $contentService->newContentUpdateStruct(); |
| 1763 |
|
$contentUpdate->setField('first_name', null, 'eng-US'); |
| 1764 |
|
|
| 1765 |
|
// Create a new update struct instance |
| 1766 |
|
$userUpdate = $userService->newUserUpdateStruct(); |
| 1767 |
|
|
| 1768 |
|
// Set the content update struct. |
| 1769 |
|
$userUpdate->contentUpdateStruct = $contentUpdate; |
| 1770 |
|
|
| 1771 |
|
// This call will fail with a "ContentFieldValidationException" because the |
| 1772 |
|
// mandatory field "first_name" is set to an empty value. |
| 1773 |
|
$userService->updateUser($user, $userUpdate); |
| 1774 |
|
|
| 1775 |
|
/* END: Use Case */ |
| 1776 |
|
} |
| 1777 |
|
|
| 1778 |
|
/** |
| 1779 |
|
* Test for the updateUser() method. |
|
@@ 1785-1812 (lines=28) @@
|
| 1782 |
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
| 1783 |
|
* @depends eZ\Publish\API\Repository\Tests\UserServiceTest::testUpdateUser |
| 1784 |
|
*/ |
| 1785 |
|
public function testUpdateUserThrowsInvalidArgumentExceptionOnFieldTypeNotAccept() |
| 1786 |
|
{ |
| 1787 |
|
$repository = $this->getRepository(); |
| 1788 |
|
|
| 1789 |
|
$userService = $repository->getUserService(); |
| 1790 |
|
|
| 1791 |
|
/* BEGIN: Use Case */ |
| 1792 |
|
$user = $this->createUserVersion1(); |
| 1793 |
|
|
| 1794 |
|
// Get the ContentService implementation |
| 1795 |
|
$contentService = $repository->getContentService(); |
| 1796 |
|
|
| 1797 |
|
$contentUpdate = $contentService->newContentUpdateStruct(); |
| 1798 |
|
// An object of stdClass is not valid for the field first_name |
| 1799 |
|
$contentUpdate->setField('first_name', new \stdClass(), 'eng-US'); |
| 1800 |
|
|
| 1801 |
|
// Create a new update struct instance |
| 1802 |
|
$userUpdate = $userService->newUserUpdateStruct(); |
| 1803 |
|
|
| 1804 |
|
// Set the content update struct. |
| 1805 |
|
$userUpdate->contentUpdateStruct = $contentUpdate; |
| 1806 |
|
|
| 1807 |
|
// This call will fail with a "InvalidArgumentException" because the |
| 1808 |
|
// the field "first_name" does not accept the given value. |
| 1809 |
|
$userService->updateUser($user, $userUpdate); |
| 1810 |
|
|
| 1811 |
|
/* END: Use Case */ |
| 1812 |
|
} |
| 1813 |
|
|
| 1814 |
|
/** |
| 1815 |
|
* Test for the loadUserGroupsOfUser() method. |