|
@@ 789-813 (lines=25) @@
|
| 786 |
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
| 787 |
|
* @depends eZ\Publish\API\Repository\Tests\UserServiceTest::testUpdateUserGroup |
| 788 |
|
*/ |
| 789 |
|
public function testUpdateUserGroupThrowsInvalidArgumentExceptionOnFieldTypeNotAccept() |
| 790 |
|
{ |
| 791 |
|
$repository = $this->getRepository(); |
| 792 |
|
$userService = $repository->getUserService(); |
| 793 |
|
|
| 794 |
|
/* BEGIN: Use Case */ |
| 795 |
|
$userGroup = $this->createUserGroupVersion1(); |
| 796 |
|
|
| 797 |
|
// Load the content service |
| 798 |
|
$contentService = $repository->getContentService(); |
| 799 |
|
|
| 800 |
|
// Create a content update struct and update the group name |
| 801 |
|
$contentUpdate = $contentService->newContentUpdateStruct(); |
| 802 |
|
// An object of stdClass is not accepted as a value by the field "name" |
| 803 |
|
$contentUpdate->setField('name', new \stdClass(), 'eng-US'); |
| 804 |
|
|
| 805 |
|
// Create a group update struct and set content update struct |
| 806 |
|
$groupUpdate = $userService->newUserGroupUpdateStruct(); |
| 807 |
|
$groupUpdate->contentUpdateStruct = $contentUpdate; |
| 808 |
|
|
| 809 |
|
// This call will fail with an InvalidArgumentException, because the |
| 810 |
|
// field "name" does not accept the given value |
| 811 |
|
$userService->updateUserGroup($userGroup, $groupUpdate); |
| 812 |
|
/* END: Use Case */ |
| 813 |
|
} |
| 814 |
|
|
| 815 |
|
/** |
| 816 |
|
* Test for the newUserCreateStruct() method. |
|
@@ 1784-1811 (lines=28) @@
|
| 1781 |
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\ContentFieldValidationException |
| 1782 |
|
* @depends eZ\Publish\API\Repository\Tests\UserServiceTest::testUpdateUser |
| 1783 |
|
*/ |
| 1784 |
|
public function testUpdateUserWhenMissingField() |
| 1785 |
|
{ |
| 1786 |
|
$repository = $this->getRepository(); |
| 1787 |
|
|
| 1788 |
|
$userService = $repository->getUserService(); |
| 1789 |
|
|
| 1790 |
|
/* BEGIN: Use Case */ |
| 1791 |
|
$user = $this->createUserVersion1(); |
| 1792 |
|
|
| 1793 |
|
// Get the ContentService implementation |
| 1794 |
|
$contentService = $repository->getContentService(); |
| 1795 |
|
|
| 1796 |
|
// Create a content update struct and change the remote id. |
| 1797 |
|
$contentUpdate = $contentService->newContentUpdateStruct(); |
| 1798 |
|
$contentUpdate->setField('first_name', null, 'eng-US'); |
| 1799 |
|
|
| 1800 |
|
// Create a new update struct instance |
| 1801 |
|
$userUpdate = $userService->newUserUpdateStruct(); |
| 1802 |
|
|
| 1803 |
|
// Set the content update struct. |
| 1804 |
|
$userUpdate->contentUpdateStruct = $contentUpdate; |
| 1805 |
|
|
| 1806 |
|
// This call will fail with a "ContentFieldValidationException" because the |
| 1807 |
|
// mandatory field "first_name" is set to an empty value. |
| 1808 |
|
$userService->updateUser($user, $userUpdate); |
| 1809 |
|
|
| 1810 |
|
/* END: Use Case */ |
| 1811 |
|
} |
| 1812 |
|
|
| 1813 |
|
/** |
| 1814 |
|
* Test for the updateUser() method. |
|
@@ 1820-1847 (lines=28) @@
|
| 1817 |
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
| 1818 |
|
* @depends eZ\Publish\API\Repository\Tests\UserServiceTest::testUpdateUser |
| 1819 |
|
*/ |
| 1820 |
|
public function testUpdateUserThrowsInvalidArgumentExceptionOnFieldTypeNotAccept() |
| 1821 |
|
{ |
| 1822 |
|
$repository = $this->getRepository(); |
| 1823 |
|
|
| 1824 |
|
$userService = $repository->getUserService(); |
| 1825 |
|
|
| 1826 |
|
/* BEGIN: Use Case */ |
| 1827 |
|
$user = $this->createUserVersion1(); |
| 1828 |
|
|
| 1829 |
|
// Get the ContentService implementation |
| 1830 |
|
$contentService = $repository->getContentService(); |
| 1831 |
|
|
| 1832 |
|
$contentUpdate = $contentService->newContentUpdateStruct(); |
| 1833 |
|
// An object of stdClass is not valid for the field first_name |
| 1834 |
|
$contentUpdate->setField('first_name', new \stdClass(), 'eng-US'); |
| 1835 |
|
|
| 1836 |
|
// Create a new update struct instance |
| 1837 |
|
$userUpdate = $userService->newUserUpdateStruct(); |
| 1838 |
|
|
| 1839 |
|
// Set the content update struct. |
| 1840 |
|
$userUpdate->contentUpdateStruct = $contentUpdate; |
| 1841 |
|
|
| 1842 |
|
// This call will fail with a "InvalidArgumentException" because the |
| 1843 |
|
// the field "first_name" does not accept the given value. |
| 1844 |
|
$userService->updateUser($user, $userUpdate); |
| 1845 |
|
|
| 1846 |
|
/* END: Use Case */ |
| 1847 |
|
} |
| 1848 |
|
|
| 1849 |
|
/** |
| 1850 |
|
* Test for the loadUserGroupsOfUser() method. |