-
Notifications
You must be signed in to change notification settings - Fork 12
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 #8 from printu/fix/getStatusCode
fixed an Fatal Error when a timeout occured
- Loading branch information
Showing
3 changed files
with
46 additions
and
0 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 |
---|---|---|
|
@@ -6,7 +6,10 @@ | |
use Customerio\Exception\ServerErrorResponseException; | ||
use GuzzleHttp\Client; | ||
use GuzzleHttp\Command\Guzzle\Description; | ||
use GuzzleHttp\Exception\ConnectException; | ||
use GuzzleHttp\Message\Request; | ||
use GuzzleHttp\Subscriber\History; | ||
use GuzzleHttp\Subscriber\Mock; | ||
|
||
/** | ||
* Class ClientTest | ||
|
@@ -120,4 +123,34 @@ public function testUnsuccessfulResponse() | |
$this->assertSame($e->getResponse()->getStatusCode(), 404); | ||
} | ||
} | ||
|
||
/** | ||
* @expectedException \Customerio\Exception\CustomerioException | ||
*/ | ||
public function testTimeoutResponse() | ||
{ | ||
$history = new History(); | ||
|
||
$config['api_key'] = 'key'; | ||
$config['site_id'] = 'site_id'; | ||
|
||
$client = new \Customerio\Client($config); | ||
$httpClient = $client->getHttpClient(); | ||
|
||
$mock = new Mock(); | ||
$mock->addException( | ||
new ConnectException( | ||
'addCustomer', | ||
new Request('post', '/') | ||
) | ||
); | ||
|
||
$httpClient->getEmitter()->attach($mock); | ||
$httpClient->getEmitter()->attach($history); | ||
|
||
$client->addCustomer([ | ||
'id' => 45, | ||
'email' => '[email protected]' | ||
]); | ||
} | ||
} |