-
Notifications
You must be signed in to change notification settings - Fork 0
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 #103 from cego/gusb/handle-guzzle-exception
gusb/handle-guzzle-exception
- Loading branch information
Showing
2 changed files
with
68 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
use Tests\TestCase; | ||
use GuzzleHttp\Psr7\Request; | ||
use GuzzleHttp\Psr7\Response; | ||
use Cego\RequestInsurance\HttpResponse; | ||
use GuzzleHttp\Exception\RequestException; | ||
use GuzzleHttp\Exception\BadResponseException; | ||
use GuzzleHttp\Exception\TooManyRedirectsException; | ||
|
||
class HttpResponseTest extends TestCase | ||
{ | ||
/** @test */ | ||
public function it_can_initialize_with_request_exception() | ||
{ | ||
$httpResponse = new HttpResponse(new RequestException('F', new Request('GET', 'www.notaplaceforsho.dk'))); | ||
|
||
$this->assertTrue($httpResponse->isRequestException()); | ||
} | ||
|
||
/** @test */ | ||
public function it_can_initialize_with_bad_response_exception() | ||
{ | ||
$httpResponse = new HttpResponse(new BadResponseException('F', new Request('GET', 'www.notaplaceforsho.dk'), new Response())); | ||
|
||
$this->assertTrue($httpResponse->isRequestException()); | ||
} | ||
|
||
/** @test */ | ||
public function it_can_initialize_with_too_many_redirects_exception() | ||
{ | ||
$httpResponse = new HttpResponse(new TooManyRedirectsException('F', new Request('GET', 'www.notaplaceforsho.dk'))); | ||
|
||
$this->assertTrue($httpResponse->isRequestException()); | ||
} | ||
} |