public function testAccessTokenSetExpiresDirect()
 {
     $token = new AccessToken('testToken', 'bearer', ['expires' => 500]);
     $this->assertTrue($token->isExpired());
     $token = new AccessToken('testToken', 'bearer', ['expires' => time() + 500]);
     $this->assertFalse($token->isExpired());
 }
 /**
  * Set the refresh token.
  *
  * @param AccessToken|string $refreshToken The refresh token
  *
  * @return self
  */
 public function setRefreshToken($refreshToken)
 {
     if (!$this->accessToken instanceof AccessToken) {
         throw new \InvalidArgumentException('Unable to update the refresh token. You have never set first the access token.');
     }
     if (is_string($refreshToken)) {
         $refreshToken = new AccessToken($refreshToken, 'refresh_token');
     } elseif (!$refreshToken instanceof AccessToken) {
         throw new \InvalidArgumentException('Invalid refresh token');
     }
     $this->accessToken->setRefreshToken($refreshToken);
     if ($this->refreshTokenGrantType instanceof RefreshTokenGrantTypeInterface) {
         $this->refreshTokenGrantType->setRefreshToken($refreshToken->getToken());
     }
     return $this;
 }
 /**
  * @param AccessToken $refreshToken
  *
  * @return self
  */
 public function setRefreshToken(AccessToken $refreshToken)
 {
     if ($refreshToken->getType() != 'refresh_token') {
         throw new InvalidArgumentException('Expected AccessToken to be "refresh_token" type, got "%s"', $refreshToken->getType());
     }
     $this->refreshToken = $refreshToken;
     return $this;
 }