function UserLoginHttpTest::getResultValue

Same name in other branches
  1. 8.9.x core/modules/user/tests/src/Functional/UserLoginHttpTest.php \Drupal\Tests\user\Functional\UserLoginHttpTest::getResultValue()
  2. 10 core/modules/user/tests/src/Functional/UserLoginHttpTest.php \Drupal\Tests\user\Functional\UserLoginHttpTest::getResultValue()
  3. 11.x 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.

1 call to UserLoginHttpTest::getResultValue()
UserLoginHttpTest::assertHttpResponseWithMessage in core/modules/user/tests/src/Functional/UserLoginHttpTest.php
Checks a response for status code and message.

File

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

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};
    }
}

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