function UserLoginHttpTest::passwordRequest

Same name in other branches
  1. 8.9.x core/modules/user/tests/src/Functional/UserLoginHttpTest.php \Drupal\Tests\user\Functional\UserLoginHttpTest::passwordRequest()
  2. 10 core/modules/user/tests/src/Functional/UserLoginHttpTest.php \Drupal\Tests\user\Functional\UserLoginHttpTest::passwordRequest()
  3. 11.x core/modules/user/tests/src/Functional/UserLoginHttpTest.php \Drupal\Tests\user\Functional\UserLoginHttpTest::passwordRequest()

Executes a password HTTP request for a given serialization format.

Parameters

array $request_body: The request body.

string $format: The format to use to make the request.

Return value

\Psr\Http\Message\ResponseInterface The HTTP response.

1 call to UserLoginHttpTest::passwordRequest()
UserLoginHttpTest::doTestPasswordReset in core/modules/user/tests/src/Functional/UserLoginHttpTest.php
Do password reset testing for given format and account.

File

core/modules/user/tests/src/Functional/UserLoginHttpTest.php, line 219

Class

UserLoginHttpTest
Tests login and password reset via direct HTTP.

Namespace

Drupal\Tests\user\Functional

Code

protected function passwordRequest(array $request_body, $format = 'json') {
    $password_reset_url = Url::fromRoute('user.pass.http')->setRouteParameter('_format', $format)
        ->setAbsolute();
    $result = \Drupal::httpClient()->post($password_reset_url->toString(), [
        'body' => $this->serializer
            ->encode($request_body, $format),
        'headers' => [
            'Accept' => "application/{$format}",
        ],
        'http_errors' => FALSE,
        'cookies' => $this->cookies,
    ]);
    return $result;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.