function RestLoginHttpTest::passwordRequest
Same name and namespace in other branches
- main core/modules/rest/tests/src/Functional/RestLoginHttpTest.php \Drupal\Tests\rest\Functional\RestLoginHttpTest::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.
File
-
core/
modules/ rest/ tests/ src/ Functional/ RestLoginHttpTest.php, line 223
Class
- RestLoginHttpTest
- Tests login and password reset via direct HTTP.
Namespace
Drupal\Tests\rest\FunctionalCode
protected function passwordRequest(array $request_body, $format = 'json') : ResponseInterface {
$password_reset_url = Url::fromRoute('rest.pass')->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.