You are here

protected function UserLoginHttpTest::getResultValue in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/user/tests/src/Functional/UserLoginHttpTest.php \Drupal\Tests\user\Functional\UserLoginHttpTest::getResultValue()
  2. 9 core/modules/user/tests/src/Functional/UserLoginHttpTest.php \Drupal\Tests\user\Functional\UserLoginHttpTest::getResultValue()

Gets a value for a given key from the response.

Parameters

\Psr\Http\Message\ResponseInterface $response: The response object.

string $key: The key for the value.

string $format: The encoded format.

Return value

mixed The value for the key.

File

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

Class

UserLoginHttpTest
Tests login and password reset via direct HTTP.

Namespace

Drupal\Tests\user\Functional

Code

protected function getResultValue(ResponseInterface $response, $key, $format) {
  $decoded = $this->serializer
    ->decode((string) $response
    ->getBody(), $format);
  if (is_array($decoded)) {
    return $decoded[$key];
  }
  else {
    return $decoded->{$key};
  }
}