You are here

protected function RefreshFunctionalTest::setUp in Simple OAuth (OAuth2) & OpenID Connect 8.2

Same name and namespace in other branches
  1. 8.3 simple_oauth_extras/tests/src/Functional/RefreshFunctionalTest.php \Drupal\Tests\simple_oauth_extras\Functional\RefreshFunctionalTest::setUp()

Overrides TokenBearerFunctionalTestBase::setUp

File

simple_oauth_extras/tests/src/Functional/RefreshFunctionalTest.php, line 27

Class

RefreshFunctionalTest
@group simple_oauth_extras

Namespace

Drupal\Tests\simple_oauth_extras\Functional

Code

protected function setUp() {
  parent::setUp();
  $this->scope = 'authenticated';
  $valid_payload = [
    'grant_type' => 'password',
    'client_id' => $this->client
      ->uuid(),
    'client_secret' => $this->clientSecret,
    'username' => $this->user
      ->getAccountName(),
    'password' => $this->user->pass_raw,
    'scope' => $this->scope,
  ];
  $response = $this
    ->request('POST', $this->url, [
    'form_params' => $valid_payload,
  ]);
  $body = $response
    ->getBody()
    ->getContents();
  $parsed_response = Json::decode($body);
  $this->refreshToken = $parsed_response['refresh_token'];
}