@@ -154,6 +154,7 @@ public function testCanParseServerErrorsAndThrowException(): void
154154 */
155155 public function testCanHandleRateLimitRequests (): void
156156 {
157+ $ start = microtime (true );
157158 $ rate = $ this ->getResponse ('ratelimit ' );
158159 $ rate2 = $ this ->getResponse ('ratelimit ' );
159160 $ success = $ this ->getResponse ('send-success ' );
@@ -173,6 +174,7 @@ public function testCanHandleRateLimitRequests(): void
173174
174175 $ response = $ this ->smsClient ->send (new SMS ($ args ['to ' ], $ args ['from ' ], $ args ['text ' ]));
175176 $ sentData = $ response ->current ();
177+ $ end = microtime (true );
176178
177179 $ this ->assertCount (1 , $ response );
178180 $ this ->assertSame ($ args ['to ' ], $ sentData ->getTo ());
@@ -181,6 +183,7 @@ public function testCanHandleRateLimitRequests(): void
181183 $ this ->assertSame ("12345 " , $ sentData ->getNetwork ());
182184 $ this ->assertSame ("3.14159265 " , $ sentData ->getRemainingBalance ());
183185 $ this ->assertSame (0 , $ sentData ->getStatus ());
186+ $ this ->assertGreaterThanOrEqual (2 , $ end - $ start );
184187 }
185188
186189 /**
@@ -219,6 +222,44 @@ public function testCanHandleRateLimitRequestsWithNoDeclaredTimeout(): void
219222 $ this ->assertSame (0 , $ sentData ->getStatus ());
220223 }
221224
225+ /**
226+ * @throws ClientExceptionInterface
227+ * @throws Client\Exception\Exception
228+ */
229+ public function testCanHandleAPIRateLimitRequests (): void
230+ {
231+ $ start = microtime (true );
232+ $ rate = $ this ->getResponse ('mt-limit ' );
233+ $ rate2 = $ this ->getResponse ('mt-limit ' );
234+ $ success = $ this ->getResponse ('send-success ' );
235+ $ args = [
236+ 'to ' => '447700900000 ' ,
237+ 'from ' => '1105551334 ' ,
238+ 'text ' => 'test message '
239+ ];
240+
241+ $ this ->vonageClient ->send (Argument::that (function (Request $ request ) use ($ args ) {
242+ $ this ->assertRequestJsonBodyContains ('to ' , $ args ['to ' ], $ request );
243+ $ this ->assertRequestJsonBodyContains ('from ' , $ args ['from ' ], $ request );
244+ $ this ->assertRequestJsonBodyContains ('text ' , $ args ['text ' ], $ request );
245+
246+ return true ;
247+ }))->willReturn ($ rate , $ rate2 , $ success );
248+
249+ $ response = $ this ->smsClient ->send (new SMS ($ args ['to ' ], $ args ['from ' ], $ args ['text ' ]));
250+ $ sentData = $ response ->current ();
251+ $ end = microtime (true );
252+
253+ $ this ->assertCount (1 , $ response );
254+ $ this ->assertSame ($ args ['to ' ], $ sentData ->getTo ());
255+ $ this ->assertSame ('0A0000000123ABCD1 ' , $ sentData ->getMessageId ());
256+ $ this ->assertSame ("0.03330000 " , $ sentData ->getMessagePrice ());
257+ $ this ->assertSame ("12345 " , $ sentData ->getNetwork ());
258+ $ this ->assertSame ("3.14159265 " , $ sentData ->getRemainingBalance ());
259+ $ this ->assertSame (0 , $ sentData ->getStatus ());
260+ $ this ->assertGreaterThanOrEqual (2 , $ end - $ start );
261+ }
262+
222263 /**
223264 * @throws ClientExceptionInterface
224265 * @throws Client\Exception\Exception
0 commit comments