public function testRevokeAccess() { $accessToken = "ACCESS_TOKEN"; $refreshToken = "REFRESH_TOKEN"; $accessToken2 = "ACCESS_TOKEN_2"; $token = ""; $client = $this->getClient(); $response = $this->getMock("Postman_Google_Http_Request", array(), array('')); $response->expects($this->any())->method('getResponseHttpCode')->will($this->returnValue(200)); $io = $this->getMock("Postman_Google_IO_Stream", array(), array($client)); $io->expects($this->any())->method('makeRequest')->will($this->returnCallback(function ($request) use(&$token, $response) { $elements = array(); parse_str($request->getPostBody(), $elements); $token = isset($elements['token']) ? $elements['token'] : null; return $response; })); $client->setIo($io); // Test with access token. $oauth = new Postman_Google_Auth_OAuth2($client); $oauth->setAccessToken(json_encode(array('access_token' => $accessToken, 'created' => time(), 'expires_in' => '3600'))); $this->assertTrue($oauth->revokeToken()); $this->assertEquals($accessToken, $token); // Test with refresh token. $oauth = new Postman_Google_Auth_OAuth2($client); $oauth->setAccessToken(json_encode(array('access_token' => $accessToken, 'refresh_token' => $refreshToken, 'created' => time(), 'expires_in' => '3600'))); $this->assertTrue($oauth->revokeToken()); $this->assertEquals($refreshToken, $token); // Test with passed in token. $this->assertTrue($oauth->revokeToken($accessToken2)); $this->assertEquals($accessToken2, $token); }