@@ -59,8 +59,8 @@ public function testConstructorWillSendGetRequestThroughGivenBrowser()
5959
6060 $ pending = new Promise (function () { });
6161 $ browser = $ this ->getMockBuilder ('Clue\React\Buzz\Browser ' )->disableOriginalConstructor ()->getMock ();
62- $ browser ->expects ($ this ->once ())->method ('withOptions ' )->willReturnSelf ();
63- $ browser ->expects ($ this ->once ())->method ('get ' )->with ('http://example.com ' )->willReturn ($ pending );
62+ $ browser ->expects ($ this ->once ())->method ('withRejectErrorResponse ' )-> with ( false )->willReturnSelf ();
63+ $ browser ->expects ($ this ->once ())->method ('requestStreaming ' )->with (' GET ' , 'http://example.com ' )->willReturn ($ pending );
6464
6565 $ es = new EventSource ('http://example.com ' , $ loop , $ browser );
6666 }
@@ -71,8 +71,8 @@ public function testConstructorWillSendGetRequestThroughGivenBrowserWithHttpsSch
7171
7272 $ pending = new Promise (function () { });
7373 $ browser = $ this ->getMockBuilder ('Clue\React\Buzz\Browser ' )->disableOriginalConstructor ()->getMock ();
74- $ browser ->expects ($ this ->once ())->method ('withOptions ' )->willReturnSelf ();
75- $ browser ->expects ($ this ->once ())->method ('get ' )->with ('https://example.com ' )->willReturn ($ pending );
74+ $ browser ->expects ($ this ->once ())->method ('withRejectErrorResponse ' )-> with ( false )->willReturnSelf ();
75+ $ browser ->expects ($ this ->once ())->method ('requestStreaming ' )->with (' GET ' , 'https://example.com ' )->willReturn ($ pending );
7676
7777 $ es = new EventSource ('https://example.com ' , $ loop , $ browser );
7878 }
@@ -86,8 +86,8 @@ public function testCloseWillCancelPendingGetRequest()
8686 ++$ cancelled ;
8787 });
8888 $ browser = $ this ->getMockBuilder ('Clue\React\Buzz\Browser ' )->disableOriginalConstructor ()->getMock ();
89- $ browser ->expects ($ this ->once ())->method ('withOptions ' )->willReturnSelf ();
90- $ browser ->expects ($ this ->once ())->method ('get ' )-> with ( ' http://example.com ' )->willReturn ($ pending );
89+ $ browser ->expects ($ this ->once ())->method ('withRejectErrorResponse ' )->willReturnSelf ();
90+ $ browser ->expects ($ this ->once ())->method ('requestStreaming ' )->willReturn ($ pending );
9191
9292 $ es = new EventSource ('http://example.com ' , $ loop , $ browser );
9393 $ es ->close ();
@@ -103,8 +103,8 @@ public function testCloseWillNotEmitErrorEventWhenGetRequestCancellationHandlerR
103103 throw new \RuntimeException ();
104104 });
105105 $ browser = $ this ->getMockBuilder ('Clue\React\Buzz\Browser ' )->disableOriginalConstructor ()->getMock ();
106- $ browser ->expects ($ this ->once ())->method ('withOptions ' )->willReturnSelf ();
107- $ browser ->expects ($ this ->once ())->method ('get ' )-> with ( ' http://example.com ' )->willReturn ($ pending );
106+ $ browser ->expects ($ this ->once ())->method ('withRejectErrorResponse ' )->willReturnSelf ();
107+ $ browser ->expects ($ this ->once ())->method ('requestStreaming ' )->willReturn ($ pending );
108108
109109 $ es = new EventSource ('http://example.com ' , $ loop , $ browser );
110110
@@ -128,8 +128,8 @@ public function testConstructorWillStartGetRequestThatWillStartRetryTimerWhenGet
128128
129129 $ deferred = new Deferred ();
130130 $ browser = $ this ->getMockBuilder ('Clue\React\Buzz\Browser ' )->disableOriginalConstructor ()->getMock ();
131- $ browser ->expects ($ this ->once ())->method ('withOptions ' )->willReturnSelf ();
132- $ browser ->expects ($ this ->once ())->method ('get ' )->willReturn ($ deferred ->promise ());
131+ $ browser ->expects ($ this ->once ())->method ('withRejectErrorResponse ' )->willReturnSelf ();
132+ $ browser ->expects ($ this ->once ())->method ('requestStreaming ' )->willReturn ($ deferred ->promise ());
133133
134134 $ es = new EventSource ('http://example.com ' , $ loop , $ browser );
135135
@@ -150,8 +150,8 @@ public function testConstructorWillStartGetRequestThatWillStartRetryTimerThatWil
150150
151151 $ deferred = new Deferred ();
152152 $ browser = $ this ->getMockBuilder ('Clue\React\Buzz\Browser ' )->disableOriginalConstructor ()->getMock ();
153- $ browser ->expects ($ this ->once ())->method ('withOptions ' )->willReturnSelf ();
154- $ browser ->expects ($ this ->exactly (2 ))->method ('get ' )->willReturnOnConsecutiveCalls (
153+ $ browser ->expects ($ this ->once ())->method ('withRejectErrorResponse ' )->willReturnSelf ();
154+ $ browser ->expects ($ this ->exactly (2 ))->method ('requestStreaming ' )->willReturnOnConsecutiveCalls (
155155 $ deferred ->promise (),
156156 new Promise (function () { })
157157 );
@@ -174,8 +174,8 @@ public function testConstructorWillStartGetRequestThatWillEmitErrorWhenGetReques
174174
175175 $ deferred = new Deferred ();
176176 $ browser = $ this ->getMockBuilder ('Clue\React\Buzz\Browser ' )->disableOriginalConstructor ()->getMock ();
177- $ browser ->expects ($ this ->once ())->method ('withOptions ' )->willReturnSelf ();
178- $ browser ->expects ($ this ->once ())->method ('get ' )->willReturn ($ deferred ->promise ());
177+ $ browser ->expects ($ this ->once ())->method ('withRejectErrorResponse ' )->willReturnSelf ();
178+ $ browser ->expects ($ this ->once ())->method ('requestStreaming ' )->willReturn ($ deferred ->promise ());
179179
180180 $ es = new EventSource ('http://example.com ' , $ loop , $ browser );
181181
@@ -194,8 +194,8 @@ public function testConstructorWillStartGetRequestThatWillNotStartRetryTimerWhen
194194
195195 $ deferred = new Deferred ();
196196 $ browser = $ this ->getMockBuilder ('Clue\React\Buzz\Browser ' )->disableOriginalConstructor ()->getMock ();
197- $ browser ->expects ($ this ->once ())->method ('withOptions ' )->willReturnSelf ();
198- $ browser ->expects ($ this ->once ())->method ('get ' )-> with ( ' http://example.com ' )->willReturn ($ deferred ->promise ());
197+ $ browser ->expects ($ this ->once ())->method ('withRejectErrorResponse ' )->willReturnSelf ();
198+ $ browser ->expects ($ this ->once ())->method ('requestStreaming ' )->willReturn ($ deferred ->promise ());
199199
200200 $ es = new EventSource ('http://example.com ' , $ loop , $ browser );
201201
@@ -217,8 +217,8 @@ public function testCloseAfterGetRequestFromConstructorFailsWillCancelPendingRet
217217
218218 $ deferred = new Deferred ();
219219 $ browser = $ this ->getMockBuilder ('Clue\React\Buzz\Browser ' )->disableOriginalConstructor ()->getMock ();
220- $ browser ->expects ($ this ->once ())->method ('withOptions ' )->willReturnSelf ();
221- $ browser ->expects ($ this ->once ())->method ('get ' )-> with ( ' http://example.com ' )->willReturn ($ deferred ->promise ());
220+ $ browser ->expects ($ this ->once ())->method ('withRejectErrorResponse ' )->willReturnSelf ();
221+ $ browser ->expects ($ this ->once ())->method ('requestStreaming ' )->willReturn ($ deferred ->promise ());
222222
223223 $ es = new EventSource ('http://example.com ' , $ loop , $ browser );
224224
@@ -233,8 +233,8 @@ public function testConstructorWillReportFatalErrorWhenGetResponseResolvesWithIn
233233
234234 $ deferred = new Deferred ();
235235 $ browser = $ this ->getMockBuilder ('Clue\React\Buzz\Browser ' )->disableOriginalConstructor ()->getMock ();
236- $ browser ->expects ($ this ->once ())->method ('withOptions ' )->willReturnSelf ();
237- $ browser ->expects ($ this ->once ())->method ('get ' )-> with ( ' http://example.com ' )->willReturn ($ deferred ->promise ());
236+ $ browser ->expects ($ this ->once ())->method ('withRejectErrorResponse ' )->willReturnSelf ();
237+ $ browser ->expects ($ this ->once ())->method ('requestStreaming ' )->willReturn ($ deferred ->promise ());
238238
239239 $ es = new EventSource ('http://example.com ' , $ loop , $ browser );
240240
@@ -258,8 +258,8 @@ public function testConstructorWillReportFatalErrorWhenGetResponseResolvesWithIn
258258
259259 $ deferred = new Deferred ();
260260 $ browser = $ this ->getMockBuilder ('Clue\React\Buzz\Browser ' )->disableOriginalConstructor ()->getMock ();
261- $ browser ->expects ($ this ->once ())->method ('withOptions ' )->willReturnSelf ();
262- $ browser ->expects ($ this ->once ())->method ('get ' )-> with ( ' http://example.com ' )->willReturn ($ deferred ->promise ());
261+ $ browser ->expects ($ this ->once ())->method ('withRejectErrorResponse ' )->willReturnSelf ();
262+ $ browser ->expects ($ this ->once ())->method ('requestStreaming ' )->willReturn ($ deferred ->promise ());
263263
264264 $ es = new EventSource ('http://example.com ' , $ loop , $ browser );
265265
@@ -283,8 +283,8 @@ public function testConstructorWillReportOpenWhenGetResponseResolvesWithValidRes
283283
284284 $ deferred = new Deferred ();
285285 $ browser = $ this ->getMockBuilder ('Clue\React\Buzz\Browser ' )->disableOriginalConstructor ()->getMock ();
286- $ browser ->expects ($ this ->once ())->method ('withOptions ' )->willReturnSelf ();
287- $ browser ->expects ($ this ->once ())->method ('get ' )-> with ( ' http://example.com ' )->willReturn ($ deferred ->promise ());
286+ $ browser ->expects ($ this ->once ())->method ('withRejectErrorResponse ' )->willReturnSelf ();
287+ $ browser ->expects ($ this ->once ())->method ('requestStreaming ' )->willReturn ($ deferred ->promise ());
288288
289289 $ es = new EventSource ('http://example.com ' , $ loop , $ browser );
290290
@@ -306,8 +306,8 @@ public function testConstructorWillReportOpenWhenGetResponseResolvesWithValidRes
306306
307307 $ deferred = new Deferred ();
308308 $ browser = $ this ->getMockBuilder ('Clue\React\Buzz\Browser ' )->disableOriginalConstructor ()->getMock ();
309- $ browser ->expects ($ this ->once ())->method ('withOptions ' )->willReturnSelf ();
310- $ browser ->expects ($ this ->once ())->method ('get ' )-> with ( ' http://example.com ' )->willReturn ($ deferred ->promise ());
309+ $ browser ->expects ($ this ->once ())->method ('withRejectErrorResponse ' )->willReturnSelf ();
310+ $ browser ->expects ($ this ->once ())->method ('requestStreaming ' )->willReturn ($ deferred ->promise ());
311311
312312 $ es = new EventSource ('http://example.com ' , $ loop , $ browser );
313313
@@ -329,8 +329,8 @@ public function testConstructorWillReportOpenWhenGetResponseResolvesWithValidRes
329329
330330 $ deferred = new Deferred ();
331331 $ browser = $ this ->getMockBuilder ('Clue\React\Buzz\Browser ' )->disableOriginalConstructor ()->getMock ();
332- $ browser ->expects ($ this ->once ())->method ('withOptions ' )->willReturnSelf ();
333- $ browser ->expects ($ this ->once ())->method ('get ' )-> with ( ' http://example.com ' )->willReturn ($ deferred ->promise ());
332+ $ browser ->expects ($ this ->once ())->method ('withRejectErrorResponse ' )->willReturnSelf ();
333+ $ browser ->expects ($ this ->once ())->method ('requestStreaming ' )->willReturn ($ deferred ->promise ());
334334
335335 $ es = new EventSource ('http://example.com ' , $ loop , $ browser );
336336
@@ -356,8 +356,8 @@ public function testCloseResponseStreamWillStartRetryTimerWithoutErrorEvent()
356356
357357 $ deferred = new Deferred ();
358358 $ browser = $ this ->getMockBuilder ('Clue\React\Buzz\Browser ' )->disableOriginalConstructor ()->getMock ();
359- $ browser ->expects ($ this ->once ())->method ('withOptions ' )->willReturnSelf ();
360- $ browser ->expects ($ this ->once ())->method ('get ' )-> with ( ' http://example.com ' )->willReturn ($ deferred ->promise ());
359+ $ browser ->expects ($ this ->once ())->method ('withRejectErrorResponse ' )->willReturnSelf ();
360+ $ browser ->expects ($ this ->once ())->method ('requestStreaming ' )->willReturn ($ deferred ->promise ());
361361
362362 $ es = new EventSource ('http://example.com ' , $ loop , $ browser );
363363
@@ -382,8 +382,8 @@ public function testCloseFromOpenEventWillCloseResponseStreamAndCloseEventSource
382382
383383 $ deferred = new Deferred ();
384384 $ browser = $ this ->getMockBuilder ('Clue\React\Buzz\Browser ' )->disableOriginalConstructor ()->getMock ();
385- $ browser ->expects ($ this ->once ())->method ('withOptions ' )->willReturnSelf ();
386- $ browser ->expects ($ this ->once ())->method ('get ' )-> with ( ' http://example.com ' )->willReturn ($ deferred ->promise ());
385+ $ browser ->expects ($ this ->once ())->method ('withRejectErrorResponse ' )->willReturnSelf ();
386+ $ browser ->expects ($ this ->once ())->method ('requestStreaming ' )->willReturn ($ deferred ->promise ());
387387
388388 $ es = new EventSource ('http://example.com ' , $ loop , $ browser );
389389
@@ -405,8 +405,8 @@ public function testEmitMessageWithParsedDataFromEventStream()
405405
406406 $ deferred = new Deferred ();
407407 $ browser = $ this ->getMockBuilder ('Clue\React\Buzz\Browser ' )->disableOriginalConstructor ()->getMock ();
408- $ browser ->expects ($ this ->once ())->method ('withOptions ' )->willReturnSelf ();
409- $ browser ->expects ($ this ->once ())->method ('get ' )-> with ( ' http://example.com ' )->willReturn ($ deferred ->promise ());
408+ $ browser ->expects ($ this ->once ())->method ('withRejectErrorResponse ' )->willReturnSelf ();
409+ $ browser ->expects ($ this ->once ())->method ('requestStreaming ' )->willReturn ($ deferred ->promise ());
410410
411411 $ es = new EventSource ('http://example.com ' , $ loop , $ browser );
412412
@@ -432,8 +432,8 @@ public function testEmitMessageWithParsedIdAndDataOverMultipleRowsFromEventStrea
432432
433433 $ deferred = new Deferred ();
434434 $ browser = $ this ->getMockBuilder ('Clue\React\Buzz\Browser ' )->disableOriginalConstructor ()->getMock ();
435- $ browser ->expects ($ this ->once ())->method ('withOptions ' )->willReturnSelf ();
436- $ browser ->expects ($ this ->once ())->method ('get ' )-> with ( ' http://example.com ' )->willReturn ($ deferred ->promise ());
435+ $ browser ->expects ($ this ->once ())->method ('withRejectErrorResponse ' )->willReturnSelf ();
436+ $ browser ->expects ($ this ->once ())->method ('requestStreaming ' )->willReturn ($ deferred ->promise ());
437437
438438 $ es = new EventSource ('http://example.com ' , $ loop , $ browser );
439439
@@ -459,8 +459,8 @@ public function testEmitMessageWithParsedEventTypeAndDataWithTrailingWhitespaceF
459459
460460 $ deferred = new Deferred ();
461461 $ browser = $ this ->getMockBuilder ('Clue\React\Buzz\Browser ' )->disableOriginalConstructor ()->getMock ();
462- $ browser ->expects ($ this ->once ())->method ('withOptions ' )->willReturnSelf ();
463- $ browser ->expects ($ this ->once ())->method ('get ' )-> with ( ' http://example.com ' )->willReturn ($ deferred ->promise ());
462+ $ browser ->expects ($ this ->once ())->method ('withRejectErrorResponse ' )->willReturnSelf ();
463+ $ browser ->expects ($ this ->once ())->method ('requestStreaming ' )->willReturn ($ deferred ->promise ());
464464
465465 $ es = new EventSource ('http://example.com ' , $ loop , $ browser );
466466
@@ -485,8 +485,8 @@ public function testDoesNotEmitMessageWhenParsedEventStreamHasNoData()
485485
486486 $ deferred = new Deferred ();
487487 $ browser = $ this ->getMockBuilder ('Clue\React\Buzz\Browser ' )->disableOriginalConstructor ()->getMock ();
488- $ browser ->expects ($ this ->once ())->method ('withOptions ' )->willReturnSelf ();
489- $ browser ->expects ($ this ->once ())->method ('get ' )-> with ( ' http://example.com ' )->willReturn ($ deferred ->promise ());
488+ $ browser ->expects ($ this ->once ())->method ('withRejectErrorResponse ' )->willReturnSelf ();
489+ $ browser ->expects ($ this ->once ())->method ('requestStreaming ' )->willReturn ($ deferred ->promise ());
490490
491491 $ es = new EventSource ('http://example.com ' , $ loop , $ browser );
492492
@@ -510,8 +510,8 @@ public function testEmitMessageWithParsedDataAndPreviousIdWhenNotGivenAgainFromE
510510
511511 $ deferred = new Deferred ();
512512 $ browser = $ this ->getMockBuilder ('Clue\React\Buzz\Browser ' )->disableOriginalConstructor ()->getMock ();
513- $ browser ->expects ($ this ->once ())->method ('withOptions ' )->willReturnSelf ();
514- $ browser ->expects ($ this ->once ())->method ('get ' )-> with ( ' http://example.com ' )->willReturn ($ deferred ->promise ());
513+ $ browser ->expects ($ this ->once ())->method ('withRejectErrorResponse ' )->willReturnSelf ();
514+ $ browser ->expects ($ this ->once ())->method ('requestStreaming ' )->willReturn ($ deferred ->promise ());
515515
516516 $ es = new EventSource ('http://example.com ' , $ loop , $ browser );
517517
@@ -545,10 +545,10 @@ public function testReconnectAfterStreamClosesUsesLastEventIdFromParsedEventStre
545545
546546 $ deferred = new Deferred ();
547547 $ browser = $ this ->getMockBuilder ('Clue\React\Buzz\Browser ' )->disableOriginalConstructor ()->getMock ();
548- $ browser ->expects ($ this ->once ())->method ('withOptions ' )->willReturnSelf ();
549- $ browser ->expects ($ this ->exactly (2 ))->method ('get ' )->withConsecutive (
550- ['http://example.com ' , ['Accept ' => 'text/event-stream ' , 'Cache-Control ' => 'no-cache ' ]],
551- ['http://example.com ' , ['Accept ' => 'text/event-stream ' , 'Cache-Control ' => 'no-cache ' , 'Last-Event-ID ' => '123 ' ]]
548+ $ browser ->expects ($ this ->once ())->method ('withRejectErrorResponse ' )->willReturnSelf ();
549+ $ browser ->expects ($ this ->exactly (2 ))->method ('requestStreaming ' )->withConsecutive (
550+ ['GET ' , ' http://example.com ' , ['Accept ' => 'text/event-stream ' , 'Cache-Control ' => 'no-cache ' ]],
551+ ['GET ' , ' http://example.com ' , ['Accept ' => 'text/event-stream ' , 'Cache-Control ' => 'no-cache ' , 'Last-Event-ID ' => '123 ' ]]
552552 )->willReturnOnConsecutiveCalls (
553553 $ deferred ->promise (),
554554 new Promise (function () { })
0 commit comments