You are here

protected function OAuth2ServerTest::assertTokenResponse in OAuth2 Server 8

Same name and namespace in other branches
  1. 2.0.x tests/src/Functional/OAuth2ServerTest.php \Drupal\Tests\oauth2_server\Functional\OAuth2ServerTest::assertTokenResponse()

Assert that the given token response has the expected values.

Parameters

array|object $payload: The response payload (either an object decoded from a json string or the prepared query string as array).

bool $has_refresh_token: A boolean indicating whether this response should have a refresh token.

9 calls to OAuth2ServerTest::assertTokenResponse()
OAuth2ServerTest::testAuthorizationCodeGrantType in tests/src/Functional/OAuth2ServerTest.php
Tests the "Authorization code" grant type.
OAuth2ServerTest::testClientCredentialsGrantType in tests/src/Functional/OAuth2ServerTest.php
Tests the "Client credentials" grant type.
OAuth2ServerTest::testCryptoTokens in tests/src/Functional/OAuth2ServerTest.php
Tests crypto tokens.
OAuth2ServerTest::testImplicitFlow in tests/src/Functional/OAuth2ServerTest.php
Tests the implicit flow.
OAuth2ServerTest::testJwtBearerGrantType in tests/src/Functional/OAuth2ServerTest.php
Tests the "JWT bearer" grant type.

... See full list

File

tests/src/Functional/OAuth2ServerTest.php, line 648

Class

OAuth2ServerTest
The OAuth2 Server admin test case.

Namespace

Drupal\Tests\oauth2_server\Functional

Code

protected function assertTokenResponse($payload, $has_refresh_token = TRUE) {

  // Make sure we have an array.
  $payload = (array) $payload;
  $this
    ->assertArrayHasKey('access_token', $payload, 'The "access token" value is present in the return values');
  $this
    ->assertArrayHasKey('expires_in', $payload, 'The "expires_in" value is present in the return values');
  $this
    ->assertArrayHasKey('token_type', $payload, 'The "token_type" value is present in the return values');
  $this
    ->assertArrayHasKey('scope', $payload, 'The "scope" value is present in the return values');
  if ($has_refresh_token) {
    $this
      ->assertArrayHasKey('refresh_token', $payload, 'The "refresh_token" value is present in the return values');
  }
}