blob: 12cfd369eacd012bdc117b7e80e93458aacb1168 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
<?php
namespace Guzzle\Tests\Http\Exception;
use Guzzle\Http\Message\Response;
use Guzzle\Http\Message\Request;
use Guzzle\Http\Exception\RequestException;
use Guzzle\Http\Exception\BadResponseException;
class ExceptionTest extends \Guzzle\Tests\GuzzleTestCase
{
/**
* @covers Guzzle\Http\Exception\RequestException
*/
public function testRequestException()
{
$e = new RequestException('Message');
$request = new Request('GET', 'http://www.guzzle-project.com/');
$e->setRequest($request);
$this->assertEquals($request, $e->getRequest());
}
/**
* @covers Guzzle\Http\Exception\BadResponseException
*/
public function testBadResponseException()
{
$e = new BadResponseException('Message');
$response = new Response(200);
$e->setResponse($response);
$this->assertEquals($response, $e->getResponse());
}
/**
* @covers Guzzle\Http\Exception\BadResponseException::factory
*/
public function testCreatesGenericErrorExceptionOnError()
{
$request = new Request('GET', 'http://www.example.com');
$response = new Response(307);
$e = BadResponseException::factory($request, $response);
$this->assertInstanceOf('Guzzle\Http\Exception\BadResponseException', $e);
}
/**
* @covers Guzzle\Http\Exception\BadResponseException::factory
*/
public function testCreatesClientErrorExceptionOnClientError()
{
$request = new Request('GET', 'http://www.example.com');
$response = new Response(404);
$e = BadResponseException::factory($request, $response);
$this->assertInstanceOf('Guzzle\Http\Exception\ClientErrorResponseException', $e);
}
/**
* @covers Guzzle\Http\Exception\BadResponseException::factory
*/
public function testCreatesServerErrorExceptionOnServerError()
{
$request = new Request('GET', 'http://www.example.com');
$response = new Response(503);
$e = BadResponseException::factory($request, $response);
$this->assertInstanceOf('Guzzle\Http\Exception\ServerErrorResponseException', $e);
}
}
|