9
9
use GuzzleHttp \Stream \Stream ;
10
10
use Http \Adapter \Guzzle5 \Client ;
11
11
use Http \Message \MessageFactory \GuzzleMessageFactory ;
12
+ use PHPUnit \Framework \TestCase ;
12
13
13
14
/**
14
15
* @author Tobias Nyholm <[email protected] >
15
16
*/
16
- class ExceptionTest extends \PHPUnit_Framework_TestCase
17
+ class ExceptionTest extends TestCase
17
18
{
18
19
private $ guzzleRequest ;
20
+
19
21
private $ guzzleResponse ;
20
22
21
23
public function setUp ()
@@ -37,84 +39,84 @@ protected function makeRequest(GuzzleExceptions\TransferException $exception)
37
39
public function testConnectException ()
38
40
{
39
41
// Guzzle's ConnectException should be converted to a NetworkException
40
- $ this ->setExpectedException ('Http\Client\Exception\NetworkException ' );
42
+ $ this ->expectException ('Http\Client\Exception\NetworkException ' );
41
43
$ this ->makeRequest (new GuzzleExceptions \ConnectException ('foo ' , $ this ->guzzleRequest ));
42
44
}
43
45
44
46
public function testTooManyRedirectsException ()
45
47
{
46
48
// Guzzle's TooManyRedirectsException should be converted to a RequestException
47
- $ this ->setExpectedException ('Http\Client\Exception\RequestException ' );
49
+ $ this ->expectException ('Http\Client\Exception\RequestException ' );
48
50
$ this ->makeRequest (new GuzzleExceptions \TooManyRedirectsException ('foo ' , $ this ->guzzleRequest ));
49
51
}
50
52
51
53
public function testRequestException ()
52
54
{
53
55
// Guzzle's RequestException should be converted to a HttpException
54
- $ this ->setExpectedException ('Http\Client\Exception\HttpException ' );
56
+ $ this ->expectException ('Http\Client\Exception\HttpException ' );
55
57
$ this ->makeRequest (new GuzzleExceptions \RequestException ('foo ' , $ this ->guzzleRequest , $ this ->guzzleResponse ));
56
58
}
57
59
58
60
public function testRequestExceptionWithoutResponse ()
59
61
{
60
62
// Guzzle's RequestException with no response should be converted to a RequestException
61
- $ this ->setExpectedException ('Http\Client\Exception\RequestException ' );
63
+ $ this ->expectException ('Http\Client\Exception\RequestException ' );
62
64
$ this ->makeRequest (new GuzzleExceptions \RequestException ('foo ' , $ this ->guzzleRequest ));
63
65
}
64
66
65
67
public function testBadResponseException ()
66
68
{
67
69
// Guzzle's BadResponseException should be converted to a HttpException
68
- $ this ->setExpectedException ('Http\Client\Exception\HttpException ' );
70
+ $ this ->expectException ('Http\Client\Exception\HttpException ' );
69
71
$ this ->makeRequest (new GuzzleExceptions \BadResponseException ('foo ' , $ this ->guzzleRequest , $ this ->guzzleResponse ));
70
72
}
71
73
72
74
public function testBadResponseExceptionWithoutResponse ()
73
75
{
74
76
// Guzzle's BadResponseException with no response should be converted to a RequestException
75
- $ this ->setExpectedException ('Http\Client\Exception\RequestException ' );
77
+ $ this ->expectException ('Http\Client\Exception\RequestException ' );
76
78
$ this ->makeRequest (new GuzzleExceptions \BadResponseException ('foo ' , $ this ->guzzleRequest ));
77
79
}
78
80
79
81
public function testClientException ()
80
82
{
81
83
// Guzzle's ClientException should be converted to a HttpException
82
- $ this ->setExpectedException ('Http\Client\Exception\HttpException ' );
84
+ $ this ->expectException ('Http\Client\Exception\HttpException ' );
83
85
$ this ->makeRequest (new GuzzleExceptions \ClientException ('foo ' , $ this ->guzzleRequest , $ this ->guzzleResponse ));
84
86
}
85
87
86
88
public function testClientExceptionWithoutResponse ()
87
89
{
88
90
// Guzzle's ClientException with no response should be converted to a RequestException
89
- $ this ->setExpectedException ('Http\Client\Exception\RequestException ' );
91
+ $ this ->expectException ('Http\Client\Exception\RequestException ' );
90
92
$ this ->makeRequest (new GuzzleExceptions \ClientException ('foo ' , $ this ->guzzleRequest ));
91
93
}
92
94
93
95
public function testServerException ()
94
96
{
95
97
// Guzzle's ServerException should be converted to a HttpException
96
- $ this ->setExpectedException ('Http\Client\Exception\HttpException ' );
98
+ $ this ->expectException ('Http\Client\Exception\HttpException ' );
97
99
$ this ->makeRequest (new GuzzleExceptions \ServerException ('foo ' , $ this ->guzzleRequest , $ this ->guzzleResponse ));
98
100
}
99
101
100
102
public function testServerExceptionWithoutResponse ()
101
103
{
102
104
// Guzzle's ServerException with no response should be converted to a RequestException
103
- $ this ->setExpectedException ('Http\Client\Exception\RequestException ' );
105
+ $ this ->expectException ('Http\Client\Exception\RequestException ' );
104
106
$ this ->makeRequest (new GuzzleExceptions \BadResponseException ('foo ' , $ this ->guzzleRequest ));
105
107
}
106
108
107
109
public function testTransferException ()
108
110
{
109
111
// Guzzle's TransferException should be converted to a TransferException
110
- $ this ->setExpectedException ('Http\Client\Exception\TransferException ' );
112
+ $ this ->expectException ('Http\Client\Exception\TransferException ' );
111
113
$ this ->makeRequest (new GuzzleExceptions \TransferException ('foo ' ));
112
114
}
113
115
114
116
public function testParseException ()
115
117
{
116
118
// Guzzle's ParseException should be converted to a TransferException
117
- $ this ->setExpectedException ('Http\Client\Exception\TransferException ' );
119
+ $ this ->expectException ('Http\Client\Exception\TransferException ' );
118
120
$ this ->makeRequest (new GuzzleExceptions \ParseException ('foo ' , $ this ->guzzleResponse ));
119
121
}
120
122
}
0 commit comments