protected function UserLoginHttpTest::doTestPasswordReset in Drupal 9
Same name and namespace in other branches
- 8 core/modules/user/tests/src/Functional/UserLoginHttpTest.php \Drupal\Tests\user\Functional\UserLoginHttpTest::doTestPasswordReset()
Do password reset testing for given format and account.
Parameters
string $format: Serialization format.
\Drupal\user\UserInterface $account: Test account.
1 call to UserLoginHttpTest::doTestPasswordReset()
- UserLoginHttpTest::testPasswordReset in core/
modules/ user/ tests/ src/ Functional/ UserLoginHttpTest.php - Tests user password reset.
File
- core/
modules/ user/ tests/ src/ Functional/ UserLoginHttpTest.php, line 521
Class
- UserLoginHttpTest
- Tests login and password reset via direct HTTP.
Namespace
Drupal\Tests\user\FunctionalCode
protected function doTestPasswordReset($format, $account) {
$response = $this
->passwordRequest([], $format);
$this
->assertHttpResponseWithMessage($response, 400, 'Missing credentials.name or credentials.mail', $format);
$response = $this
->passwordRequest([
'name' => 'dramallama',
], $format);
$this
->assertHttpResponseWithMessage($response, 400, 'Unrecognized username or email address.', $format);
$response = $this
->passwordRequest([
'mail' => 'llama@drupal.org',
], $format);
$this
->assertHttpResponseWithMessage($response, 400, 'Unrecognized username or email address.', $format);
$account
->block()
->save();
$response = $this
->passwordRequest([
'name' => $account
->getAccountName(),
], $format);
$this
->assertHttpResponseWithMessage($response, 400, 'The user has not been activated or is blocked.', $format);
$response = $this
->passwordRequest([
'mail' => $account
->getEmail(),
], $format);
$this
->assertHttpResponseWithMessage($response, 400, 'The user has not been activated or is blocked.', $format);
$account
->activate()
->save();
$response = $this
->passwordRequest([
'name' => $account
->getAccountName(),
], $format);
$this
->assertEquals(200, $response
->getStatusCode());
$this
->loginFromResetEmail();
$this
->drupalLogout();
$response = $this
->passwordRequest([
'mail' => $account
->getEmail(),
], $format);
$this
->assertEquals(200, $response
->getStatusCode());
$this
->loginFromResetEmail();
$this
->drupalLogout();
}