You are here

protected function OAuth2ClientTest::getToken in OAuth2 Client 8

Get and return a token from the given test client.

3 calls to OAuth2ClientTest::getToken()
OAuth2ClientTest::clientCredentialsFlow in tests/src/Functional/OAuth2ClientTest.php
Test the client-credentials flow.
OAuth2ClientTest::serverSideFlow in tests/src/Functional/OAuth2ClientTest.php
Test the server-side flow.
OAuth2ClientTest::userPasswordFlow in tests/src/Functional/OAuth2ClientTest.php
Test the user-password flow.

File

tests/src/Functional/OAuth2ClientTest.php, line 48

Class

OAuth2ClientTest
Test OAuth2 Client.

Namespace

Drupal\Tests\oauth2_client\Functional

Code

protected function getToken($client) {
  $result = $this
    ->drupalGet('oauth2/test/' . $client);
  $this
    ->assertSession()
    ->responseMatches('/^access_token: /');
  $token = str_replace('access_token: ', '', $result);
  $token = trim($token);
  $this
    ->assertNotEquals('', $token, 'Token is not empty.');
  return $token;
}