protected function OAuth2ServerTestCase::assertTokenResponse in OAuth2 Server 7
Assert that the given token response has the expected values.
Parameters
$response: The response (either an object decoded from a json string or the query string taken from the url in case of the implicit flow).
$has_refresh_token: A boolean indicating whether this response should have a refresh token.
9 calls to OAuth2ServerTestCase::assertTokenResponse()
- OAuth2ServerTestCase::testAuthorizationCodeGrantType in tests/
oauth2_server.test - Tests the "Authorization code" grant type.
- OAuth2ServerTestCase::testClientCredentialsGrantType in tests/
oauth2_server.test - Tests the "Client credentials" grant type.
- OAuth2ServerTestCase::testCryptoTokens in tests/
oauth2_server.test - Tests crypto tokens.
- OAuth2ServerTestCase::testImplicitFlow in tests/
oauth2_server.test - Tests the implicit flow.
- OAuth2ServerTestCase::testJwtBearerGrantType in tests/
oauth2_server.test - Tests the "JWT bearer" grant type.
File
- tests/
oauth2_server.test, line 849 - OAuth2 tests.
Class
- OAuth2ServerTestCase
- Test basic API.
Code
protected function assertTokenResponse($response, $has_refresh_token = TRUE) {
// Make sure we have an array.
$response = (array) $response;
$this
->assertTrue(array_key_exists('access_token', $response), 'The "access token" value is present in the return values');
$this
->assertTrue(array_key_exists('expires_in', $response), 'The "expires_in" value is present in the return values');
$this
->assertTrue(array_key_exists('token_type', $response), 'The "token_type" value is present in the return values');
$this
->assertTrue(array_key_exists('scope', $response), 'The "scope" value is present in the return values');
if ($has_refresh_token) {
$this
->assertTrue(array_key_exists('refresh_token', $response), 'The "refresh_token" value is present in the return values');
}
}