You are here

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

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

Overrides TokenBearerFunctionalTestBase::setUp

File

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

Class

RefreshFunctionalTest
The refresh tests.

Namespace

Drupal\Tests\simple_oauth\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
    ->post($this->url, $valid_payload);
  $body = (string) $response
    ->getBody();
  $parsed_response = Json::decode($body);
  $this->refreshToken = $parsed_response['refresh_token'];
}