|
@@ 744-768 (lines=25) @@
|
| 741 |
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
| 742 |
|
* @depends eZ\Publish\API\Repository\Tests\UserServiceTest::testUpdateUserGroup |
| 743 |
|
*/ |
| 744 |
|
public function testUpdateUserGroupThrowsInvalidArgumentExceptionOnFieldTypeNotAccept() |
| 745 |
|
{ |
| 746 |
|
$repository = $this->getRepository(); |
| 747 |
|
$userService = $repository->getUserService(); |
| 748 |
|
|
| 749 |
|
/* BEGIN: Use Case */ |
| 750 |
|
$userGroup = $this->createUserGroupVersion1(); |
| 751 |
|
|
| 752 |
|
// Load the content service |
| 753 |
|
$contentService = $repository->getContentService(); |
| 754 |
|
|
| 755 |
|
// Create a content update struct and update the group name |
| 756 |
|
$contentUpdate = $contentService->newContentUpdateStruct(); |
| 757 |
|
// An object of stdClass is not accepted as a value by the field "name" |
| 758 |
|
$contentUpdate->setField('name', new \stdClass(), 'eng-US'); |
| 759 |
|
|
| 760 |
|
// Create a group update struct and set content update struct |
| 761 |
|
$groupUpdate = $userService->newUserGroupUpdateStruct(); |
| 762 |
|
$groupUpdate->contentUpdateStruct = $contentUpdate; |
| 763 |
|
|
| 764 |
|
// This call will fail with an InvalidArgumentException, because the |
| 765 |
|
// field "name" does not accept the given value |
| 766 |
|
$userService->updateUserGroup($userGroup, $groupUpdate); |
| 767 |
|
/* END: Use Case */ |
| 768 |
|
} |
| 769 |
|
|
| 770 |
|
/** |
| 771 |
|
* Test for the newUserCreateStruct() method. |
|
@@ 1869-1896 (lines=28) @@
|
| 1866 |
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\ContentFieldValidationException |
| 1867 |
|
* @depends eZ\Publish\API\Repository\Tests\UserServiceTest::testUpdateUser |
| 1868 |
|
*/ |
| 1869 |
|
public function testUpdateUserWhenMissingField() |
| 1870 |
|
{ |
| 1871 |
|
$repository = $this->getRepository(); |
| 1872 |
|
|
| 1873 |
|
$userService = $repository->getUserService(); |
| 1874 |
|
|
| 1875 |
|
/* BEGIN: Use Case */ |
| 1876 |
|
$user = $this->createUserVersion1(); |
| 1877 |
|
|
| 1878 |
|
// Get the ContentService implementation |
| 1879 |
|
$contentService = $repository->getContentService(); |
| 1880 |
|
|
| 1881 |
|
// Create a content update struct and change the remote id. |
| 1882 |
|
$contentUpdate = $contentService->newContentUpdateStruct(); |
| 1883 |
|
$contentUpdate->setField('first_name', null, 'eng-US'); |
| 1884 |
|
|
| 1885 |
|
// Create a new update struct instance |
| 1886 |
|
$userUpdate = $userService->newUserUpdateStruct(); |
| 1887 |
|
|
| 1888 |
|
// Set the content update struct. |
| 1889 |
|
$userUpdate->contentUpdateStruct = $contentUpdate; |
| 1890 |
|
|
| 1891 |
|
// This call will fail with a "ContentFieldValidationException" because the |
| 1892 |
|
// mandatory field "first_name" is set to an empty value. |
| 1893 |
|
$userService->updateUser($user, $userUpdate); |
| 1894 |
|
|
| 1895 |
|
/* END: Use Case */ |
| 1896 |
|
} |
| 1897 |
|
|
| 1898 |
|
/** |
| 1899 |
|
* Test for the updateUser() method. |
|
@@ 1905-1932 (lines=28) @@
|
| 1902 |
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
| 1903 |
|
* @depends eZ\Publish\API\Repository\Tests\UserServiceTest::testUpdateUser |
| 1904 |
|
*/ |
| 1905 |
|
public function testUpdateUserThrowsInvalidArgumentExceptionOnFieldTypeNotAccept() |
| 1906 |
|
{ |
| 1907 |
|
$repository = $this->getRepository(); |
| 1908 |
|
|
| 1909 |
|
$userService = $repository->getUserService(); |
| 1910 |
|
|
| 1911 |
|
/* BEGIN: Use Case */ |
| 1912 |
|
$user = $this->createUserVersion1(); |
| 1913 |
|
|
| 1914 |
|
// Get the ContentService implementation |
| 1915 |
|
$contentService = $repository->getContentService(); |
| 1916 |
|
|
| 1917 |
|
$contentUpdate = $contentService->newContentUpdateStruct(); |
| 1918 |
|
// An object of stdClass is not valid for the field first_name |
| 1919 |
|
$contentUpdate->setField('first_name', new \stdClass(), 'eng-US'); |
| 1920 |
|
|
| 1921 |
|
// Create a new update struct instance |
| 1922 |
|
$userUpdate = $userService->newUserUpdateStruct(); |
| 1923 |
|
|
| 1924 |
|
// Set the content update struct. |
| 1925 |
|
$userUpdate->contentUpdateStruct = $contentUpdate; |
| 1926 |
|
|
| 1927 |
|
// This call will fail with a "InvalidArgumentException" because the |
| 1928 |
|
// the field "first_name" does not accept the given value. |
| 1929 |
|
$userService->updateUser($user, $userUpdate); |
| 1930 |
|
|
| 1931 |
|
/* END: Use Case */ |
| 1932 |
|
} |
| 1933 |
|
|
| 1934 |
|
/** |
| 1935 |
|
* Test updating a user throwing UserPasswordValidationException when password doesn't follow specified rules. |