@@ 1903-1918 (lines=16) @@ | ||
1900 | * @expectedExceptionMessage Argument 'password' is invalid: Password doesn't match the following 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 |
|
1901 | * @covers \eZ\Publish\API\Repository\UserService::updateUser |
|
1902 | */ |
|
1903 | public function testUpdateUserWithWeakPasswordThrowsUserPasswordValidationException() |
|
1904 | { |
|
1905 | $userService = $this->getRepository()->getUserService(); |
|
1906 | ||
1907 | $user = $this->createUserWithPassword('H@xxxiR!_1', $this->createUserWithStrongPasswordContentType()); |
|
1908 | ||
1909 | /* BEGIN: Use Case */ |
|
1910 | // Create a new update struct instance |
|
1911 | $userUpdate = $userService->newUserUpdateStruct(); |
|
1912 | $userUpdate->password = 'pass'; |
|
1913 | ||
1914 | // This call will fail with a "UserPasswordValidationException" because the |
|
1915 | // the password does not follow specified rules |
|
1916 | $userService->updateUser($user, $userUpdate); |
|
1917 | /* END: Use Case */ |
|
1918 | } |
|
1919 | ||
1920 | /** |
|
1921 | * Opposite test case for testUpdateUserWithWeakPasswordThrowsUserPasswordValidationException. |
|
@@ 1925-1940 (lines=16) @@ | ||
1922 | * |
|
1923 | * @covers \eZ\Publish\API\Repository\UserService::updateUser |
|
1924 | */ |
|
1925 | public function testUpdateUserWithStrongPassword() |
|
1926 | { |
|
1927 | $userService = $this->getRepository()->getUserService(); |
|
1928 | ||
1929 | $user = $this->createUserWithPassword('H@xxxiR!_1', $this->createUserWithStrongPasswordContentType()); |
|
1930 | ||
1931 | /* BEGIN: Use Case */ |
|
1932 | // Create a new update struct instance |
|
1933 | $userUpdate = $userService->newUserUpdateStruct(); |
|
1934 | $userUpdate->password = 'H@xxxiR!_2'; |
|
1935 | ||
1936 | $user = $userService->updateUser($user, $userUpdate); |
|
1937 | /* END: Use Case */ |
|
1938 | ||
1939 | $this->assertInstanceOf(User::class, $user); |
|
1940 | } |
|
1941 | ||
1942 | /** |
|
1943 | * Test for the loadUserGroupsOfUser() method. |