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