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 ;
19
20
@@ -38,84 +39,84 @@ protected function makeRequest(GuzzleExceptions\TransferException $exception)
38
39
public function testConnectException ()
39
40
{
40
41
// Guzzle's ConnectException should be converted to a NetworkException
41
- $ this ->setExpectedException ('Http\Client\Exception\NetworkException ' );
42
+ $ this ->expectException ('Http\Client\Exception\NetworkException ' );
42
43
$ this ->makeRequest (new GuzzleExceptions \ConnectException ('foo ' , $ this ->guzzleRequest ));
43
44
}
44
45
45
46
public function testTooManyRedirectsException ()
46
47
{
47
48
// Guzzle's TooManyRedirectsException should be converted to a RequestException
48
- $ this ->setExpectedException ('Http\Client\Exception\RequestException ' );
49
+ $ this ->expectException ('Http\Client\Exception\RequestException ' );
49
50
$ this ->makeRequest (new GuzzleExceptions \TooManyRedirectsException ('foo ' , $ this ->guzzleRequest ));
50
51
}
51
52
52
53
public function testRequestException ()
53
54
{
54
55
// Guzzle's RequestException should be converted to a HttpException
55
- $ this ->setExpectedException ('Http\Client\Exception\HttpException ' );
56
+ $ this ->expectException ('Http\Client\Exception\HttpException ' );
56
57
$ this ->makeRequest (new GuzzleExceptions \RequestException ('foo ' , $ this ->guzzleRequest , $ this ->guzzleResponse ));
57
58
}
58
59
59
60
public function testRequestExceptionWithoutResponse ()
60
61
{
61
62
// Guzzle's RequestException with no response should be converted to a RequestException
62
- $ this ->setExpectedException ('Http\Client\Exception\RequestException ' );
63
+ $ this ->expectException ('Http\Client\Exception\RequestException ' );
63
64
$ this ->makeRequest (new GuzzleExceptions \RequestException ('foo ' , $ this ->guzzleRequest ));
64
65
}
65
66
66
67
public function testBadResponseException ()
67
68
{
68
69
// Guzzle's BadResponseException should be converted to a HttpException
69
- $ this ->setExpectedException ('Http\Client\Exception\HttpException ' );
70
+ $ this ->expectException ('Http\Client\Exception\HttpException ' );
70
71
$ this ->makeRequest (new GuzzleExceptions \BadResponseException ('foo ' , $ this ->guzzleRequest , $ this ->guzzleResponse ));
71
72
}
72
73
73
74
public function testBadResponseExceptionWithoutResponse ()
74
75
{
75
76
// Guzzle's BadResponseException with no response should be converted to a RequestException
76
- $ this ->setExpectedException ('Http\Client\Exception\RequestException ' );
77
+ $ this ->expectException ('Http\Client\Exception\RequestException ' );
77
78
$ this ->makeRequest (new GuzzleExceptions \BadResponseException ('foo ' , $ this ->guzzleRequest ));
78
79
}
79
80
80
81
public function testClientException ()
81
82
{
82
83
// Guzzle's ClientException should be converted to a HttpException
83
- $ this ->setExpectedException ('Http\Client\Exception\HttpException ' );
84
+ $ this ->expectException ('Http\Client\Exception\HttpException ' );
84
85
$ this ->makeRequest (new GuzzleExceptions \ClientException ('foo ' , $ this ->guzzleRequest , $ this ->guzzleResponse ));
85
86
}
86
87
87
88
public function testClientExceptionWithoutResponse ()
88
89
{
89
90
// Guzzle's ClientException with no response should be converted to a RequestException
90
- $ this ->setExpectedException ('Http\Client\Exception\RequestException ' );
91
+ $ this ->expectException ('Http\Client\Exception\RequestException ' );
91
92
$ this ->makeRequest (new GuzzleExceptions \ClientException ('foo ' , $ this ->guzzleRequest ));
92
93
}
93
94
94
95
public function testServerException ()
95
96
{
96
97
// Guzzle's ServerException should be converted to a HttpException
97
- $ this ->setExpectedException ('Http\Client\Exception\HttpException ' );
98
+ $ this ->expectException ('Http\Client\Exception\HttpException ' );
98
99
$ this ->makeRequest (new GuzzleExceptions \ServerException ('foo ' , $ this ->guzzleRequest , $ this ->guzzleResponse ));
99
100
}
100
101
101
102
public function testServerExceptionWithoutResponse ()
102
103
{
103
104
// Guzzle's ServerException with no response should be converted to a RequestException
104
- $ this ->setExpectedException ('Http\Client\Exception\RequestException ' );
105
+ $ this ->expectException ('Http\Client\Exception\RequestException ' );
105
106
$ this ->makeRequest (new GuzzleExceptions \BadResponseException ('foo ' , $ this ->guzzleRequest ));
106
107
}
107
108
108
109
public function testTransferException ()
109
110
{
110
111
// Guzzle's TransferException should be converted to a TransferException
111
- $ this ->setExpectedException ('Http\Client\Exception\TransferException ' );
112
+ $ this ->expectException ('Http\Client\Exception\TransferException ' );
112
113
$ this ->makeRequest (new GuzzleExceptions \TransferException ('foo ' ));
113
114
}
114
115
115
116
public function testParseException ()
116
117
{
117
118
// Guzzle's ParseException should be converted to a TransferException
118
- $ this ->setExpectedException ('Http\Client\Exception\TransferException ' );
119
+ $ this ->expectException ('Http\Client\Exception\TransferException ' );
119
120
$ this ->makeRequest (new GuzzleExceptions \ParseException ('foo ' , $ this ->guzzleResponse ));
120
121
}
121
122
}
0 commit comments