-
Notifications
You must be signed in to change notification settings - Fork 296
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #819 from google/fix/818-refresh-errors
Properly handle refresh token response errors
- Loading branch information
Showing
4 changed files
with
60 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
/** | ||
* Fake HTTP Client | ||
* | ||
* @package Google\Site_Kit\Tests | ||
* @copyright 2019 Google LLC | ||
* @license https://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0 | ||
* @link https://sitekit.withgoogle.com | ||
*/ | ||
|
||
namespace Google\Site_Kit\Tests; | ||
|
||
use Google\Site_Kit_Dependencies\GuzzleHttp\Client; | ||
use Google\Site_Kit_Dependencies\GuzzleHttp\Message\RequestInterface; | ||
use Google\Site_Kit_Dependencies\GuzzleHttp\Message\Response; | ||
|
||
/** | ||
* Class FakeHttpClient | ||
*/ | ||
class FakeHttpClient extends Client { | ||
/** | ||
* Handler function for overriding requests. | ||
* | ||
* @var callable | ||
*/ | ||
protected $request_handler; | ||
|
||
/** | ||
* Sets the handler for all requests. | ||
* | ||
* @param callable $handler | ||
*/ | ||
public function set_request_handler( callable $handler ) { | ||
$this->request_handler = $handler; | ||
} | ||
|
||
/** | ||
* @param RequestInterface $request | ||
* | ||
* @return \Google\Site_Kit_Dependencies\GuzzleHttp\Message\ResponseInterface | ||
*/ | ||
public function send( RequestInterface $request ) { | ||
if ( $this->request_handler ) { | ||
return call_user_func( $this->request_handler, $request ); | ||
} | ||
|
||
return new Response( 200 ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters