|
@@ 1858-1873 (lines=16) @@
|
| 1855 |
|
* @expectedExceptionMessage Argument 'password' is invalid: Password doesn't match the fallowing rules: User password must be at least 8 characters long, User password must include at least one upper case letter, User password must include at least one number, User password must include at least one special character |
| 1856 |
|
* @covers \eZ\Publish\API\Repository\UserService::updateUser |
| 1857 |
|
*/ |
| 1858 |
|
public function testUpdateUserWithWeakPasswordThrowsUserPasswordValidationException() |
| 1859 |
|
{ |
| 1860 |
|
$userService = $this->getRepository()->getUserService(); |
| 1861 |
|
|
| 1862 |
|
$user = $this->createUserWithPassword('H@xxxiR!_1', $this->createUserWithStrongPasswordContentType()); |
| 1863 |
|
|
| 1864 |
|
/* BEGIN: Use Case */ |
| 1865 |
|
// Create a new update struct instance |
| 1866 |
|
$userUpdate = $userService->newUserUpdateStruct(); |
| 1867 |
|
$userUpdate->password = 'pass'; |
| 1868 |
|
|
| 1869 |
|
// This call will fail with a "UserPasswordValidationException" because the |
| 1870 |
|
// the password does not follow specified rules |
| 1871 |
|
$userService->updateUser($user, $userUpdate); |
| 1872 |
|
/* END: Use Case */ |
| 1873 |
|
} |
| 1874 |
|
|
| 1875 |
|
/** |
| 1876 |
|
* Opposite test case for testUpdateUserWithWeakPasswordThrowsUserPasswordValidationException. |
|
@@ 1880-1895 (lines=16) @@
|
| 1877 |
|
* |
| 1878 |
|
* @covers \eZ\Publish\API\Repository\UserService::updateUser |
| 1879 |
|
*/ |
| 1880 |
|
public function testUpdateUserWithStrongPassword() |
| 1881 |
|
{ |
| 1882 |
|
$userService = $this->getRepository()->getUserService(); |
| 1883 |
|
|
| 1884 |
|
$user = $this->createUserWithPassword('H@xxxiR!_1', $this->createUserWithStrongPasswordContentType()); |
| 1885 |
|
|
| 1886 |
|
/* BEGIN: Use Case */ |
| 1887 |
|
// Create a new update struct instance |
| 1888 |
|
$userUpdate = $userService->newUserUpdateStruct(); |
| 1889 |
|
$userUpdate->password = 'H@xxxiR!_2'; |
| 1890 |
|
|
| 1891 |
|
$user = $userService->updateUser($user, $userUpdate); |
| 1892 |
|
/* END: Use Case */ |
| 1893 |
|
|
| 1894 |
|
$this->assertInstanceOf(User::class, $user); |
| 1895 |
|
} |
| 1896 |
|
|
| 1897 |
|
/** |
| 1898 |
|
* Test for the loadUserGroupsOfUser() method. |