public function delete(AccessToken $accessToken)
 {
     if (!isset($this->accessTokens[$accessToken->getToken()])) {
         throw new AccessTokenNotFound($accessToken->getToken());
     }
     unset($this->accessTokens[$accessToken->getToken()]);
 }
 public function testAuthorizationServerWithClientCredentialsGrantType()
 {
     $client = new Client('client_test_id', 'secret', [], ['client_credentials']);
     $clientStorage = $this->getMockBuilder(ClientStorage::class)->getMock();
     $clientStorage->expects($this->any())->method('findById')->with('client_test_id')->willReturn($client);
     $accessTokenStorage = $this->getMockBuilder(AccessTokenStorage::class)->getMock();
     $accessToken = new AccessToken('access_token_test', 3600, $client->getId(), 'borisguery');
     $accessTokenStorage->expects($this->any())->method('findByToken')->with($accessToken->getToken())->willReturn($accessToken->getToken());
     $refreshTokenStorage = $this->getMockBuilder(RefreshTokenStorage::class)->getMock();
     $refreshToken = new RefreshToken('refresh_token_test');
     $refreshTokenStorage->expects($this->any())->method('findByToken')->with($refreshToken->getToken())->willReturn($refreshToken->getToken());
     $tokenGenerator = $this->getMockBuilder(TokenGenerator::class)->getMock();
     $tokenGenerator->expects($this->any())->method('generate')->willReturn($accessToken->getToken());
     $configuration = (new AuthorizationServerConfigurationBuilder())->setAccessTokenStorage($accessTokenStorage)->setClientStorage($clientStorage)->setRefreshStorage($refreshTokenStorage)->setAccessTokenGenerator($tokenGenerator)->alwaysRequireAClient(true)->alwaysGenerateARefreshToken(true)->addGrantType(new ClientCredentialsGrantType(new ClientAuthenticator($clientStorage)))->build()->getAuthorizationServerConfiguration();
     $resourceServer = new AuthorizationServer($configuration);
     $inputDataBag = new InputDataBag(['grant_type' => 'client_credentials', 'client_id' => 'client_test_id', 'client_secret' => 'secret']);
     $attemptResult = $resourceServer->requestAccessToken(new TokenRequestAttempt($inputDataBag->getGrantType(), $inputDataBag));
     $this->assertInstanceOf(SuccessfulTokenRequestAttemptResult::class, $attemptResult);
     $this->assertTrue($attemptResult->getGrantDecision()->isAllowed());
     $this->assertEquals(GrantError::NONE, $attemptResult->getGrantDecision()->getError()->getError());
 }
 public function delete(AccessToken $accessToken)
 {
     $this->dbalConnection->delete($this->tableConfiguration->getAccessTokenTableName(), ['access_token' => $accessToken->getToken()]);
 }