2
2
3
3
namespace Tests \Email ;
4
4
5
+ use GuzzleHttp \Exception \ServerException ;
5
6
use GuzzleHttp \Handler \MockHandler ;
6
7
use GuzzleHttp \HandlerStack ;
7
8
use GuzzleHttp \Psr7 \Response ;
@@ -103,7 +104,7 @@ public function testGetMessagesSuccess(): void
103
104
], $ response ->successResponse ->toArray ()['messages ' ][1 ]);
104
105
}
105
106
106
- public function testCreate400Error (): void
107
+ public function testGetMessages400Error (): void
107
108
{
108
109
$ error = [
109
110
'error ' => [
@@ -130,7 +131,7 @@ public function testCreate400Error(): void
130
131
$ this ->assertEquals ($ error , $ response ->errorResponse ->toArray ());
131
132
}
132
133
133
- public function testCreate429Error (): void
134
+ public function testGetMessages429Error (): void
134
135
{
135
136
$ error = [
136
137
'error ' => [
@@ -156,4 +157,18 @@ public function testCreate429Error(): void
156
157
$ this ->assertNull ($ response ->successResponse );
157
158
$ this ->assertEquals ($ error , $ response ->errorResponse ->toArray ());
158
159
}
160
+
161
+ public function testGetMessages502Error (): void
162
+ {
163
+ $ this ->expectException (ServerException::class);
164
+
165
+ $ mock = new MockHandler ([
166
+ new Response (502 , [], 'Bad Gateway ' )
167
+ ]);
168
+ $ handlerStack = HandlerStack::create ($ mock );
169
+ $ guzzleClient = new \GuzzleHttp \Client (['handler ' => $ handlerStack ]);
170
+ $ client = new Client ($ guzzleClient , new RateLimitReader (), 'test-api-key ' );
171
+
172
+ $ client ->getMessages ('test@example.com ' );
173
+ }
159
174
}
0 commit comments