public function testAccessTokenGranted()
 {
     # obtain a device code
     $controller = new Controller();
     $response = new Response();
     $request = new Request(['response_type' => 'device_code', 'client_id' => 'x']);
     $response_data = $controller->generate_code($request, $response);
     $data = json_decode($response_data->getContent());
     $this->assertObjectNotHasAttribute('error', $data);
     $device_code = $data->device_code;
     # simulate the access token being granted
     Cache::set($device_code, ['status' => 'complete', 'token_response' => ['access_token' => 'abc123', 'expires_in' => 600, 'custom' => 'foo']]);
     # check the status of the device code
     $request = new Request(['grant_type' => 'authorization_code', 'client_id' => 'x', 'code' => $device_code]);
     $response_data = $controller->access_token($request, $response);
     $data = json_decode($response_data->getContent());
     $this->assertObjectNotHasAttribute('error', $data);
     $this->assertEquals('abc123', $data->access_token);
     $this->assertEquals(600, $data->expires_in);
     $this->assertEquals('foo', $data->custom);
 }