From a23a930b206c8bc504ce66ec539141a6be8a0ba6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCck?= Date: Fri, 3 Jul 2020 20:35:26 +0200 Subject: [PATCH 1/2] Update to clue/reactphp-buzz v2.9.0 --- composer.json | 2 +- src/EventSource.php | 5 ++- tests/EventSourceTest.php | 92 +++++++++++++++++++-------------------- 3 files changed, 50 insertions(+), 49 deletions(-) diff --git a/composer.json b/composer.json index 3bda530..1833cac 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ }, "require": { "php": ">=5.4", - "clue/buzz-react": "^2.5", + "clue/buzz-react": "^2.9", "evenement/evenement": "^3.0 || ^2.0" }, "require-dev": { diff --git a/src/EventSource.php b/src/EventSource.php index 6ec3c88..7e5bd02 100644 --- a/src/EventSource.php +++ b/src/EventSource.php @@ -88,7 +88,7 @@ public function __construct($url, LoopInterface $loop, Browser $browser = null) if ($browser === null) { $browser = new Browser($loop); } - $this->browser = $browser->withOptions(array('streaming' => true, 'obeySuccessCode' => false)); + $this->browser = $browser->withRejectErrorResponse(false); $this->loop = $loop; $this->url = $url; @@ -106,7 +106,8 @@ private function request() $headers['Last-Event-ID'] = $this->lastEventId; } - $this->request = $this->browser->get( + $this->request = $this->browser->requestStreaming( + 'GET', $this->url, $headers ); diff --git a/tests/EventSourceTest.php b/tests/EventSourceTest.php index 889042b..4cf8545 100644 --- a/tests/EventSourceTest.php +++ b/tests/EventSourceTest.php @@ -59,8 +59,8 @@ public function testConstructorWillSendGetRequestThroughGivenBrowser() $pending = new Promise(function () { }); $browser = $this->getMockBuilder('Clue\React\Buzz\Browser')->disableOriginalConstructor()->getMock(); - $browser->expects($this->once())->method('withOptions')->willReturnSelf(); - $browser->expects($this->once())->method('get')->with('http://example.com')->willReturn($pending); + $browser->expects($this->once())->method('withRejectErrorResponse')->with(false)->willReturnSelf(); + $browser->expects($this->once())->method('requestStreaming')->with('GET', 'http://example.com')->willReturn($pending); $es = new EventSource('http://example.com', $loop, $browser); } @@ -71,8 +71,8 @@ public function testConstructorWillSendGetRequestThroughGivenBrowserWithHttpsSch $pending = new Promise(function () { }); $browser = $this->getMockBuilder('Clue\React\Buzz\Browser')->disableOriginalConstructor()->getMock(); - $browser->expects($this->once())->method('withOptions')->willReturnSelf(); - $browser->expects($this->once())->method('get')->with('https://example.com')->willReturn($pending); + $browser->expects($this->once())->method('withRejectErrorResponse')->with(false)->willReturnSelf(); + $browser->expects($this->once())->method('requestStreaming')->with('GET', 'https://example.com')->willReturn($pending); $es = new EventSource('https://example.com', $loop, $browser); } @@ -86,8 +86,8 @@ public function testCloseWillCancelPendingGetRequest() ++$cancelled; }); $browser = $this->getMockBuilder('Clue\React\Buzz\Browser')->disableOriginalConstructor()->getMock(); - $browser->expects($this->once())->method('withOptions')->willReturnSelf(); - $browser->expects($this->once())->method('get')->with('http://example.com')->willReturn($pending); + $browser->expects($this->once())->method('withRejectErrorResponse')->willReturnSelf(); + $browser->expects($this->once())->method('requestStreaming')->willReturn($pending); $es = new EventSource('http://example.com', $loop, $browser); $es->close(); @@ -103,8 +103,8 @@ public function testCloseWillNotEmitErrorEventWhenGetRequestCancellationHandlerR throw new \RuntimeException(); }); $browser = $this->getMockBuilder('Clue\React\Buzz\Browser')->disableOriginalConstructor()->getMock(); - $browser->expects($this->once())->method('withOptions')->willReturnSelf(); - $browser->expects($this->once())->method('get')->with('http://example.com')->willReturn($pending); + $browser->expects($this->once())->method('withRejectErrorResponse')->willReturnSelf(); + $browser->expects($this->once())->method('requestStreaming')->willReturn($pending); $es = new EventSource('http://example.com', $loop, $browser); @@ -128,8 +128,8 @@ public function testConstructorWillStartGetRequestThatWillStartRetryTimerWhenGet $deferred = new Deferred(); $browser = $this->getMockBuilder('Clue\React\Buzz\Browser')->disableOriginalConstructor()->getMock(); - $browser->expects($this->once())->method('withOptions')->willReturnSelf(); - $browser->expects($this->once())->method('get')->willReturn($deferred->promise()); + $browser->expects($this->once())->method('withRejectErrorResponse')->willReturnSelf(); + $browser->expects($this->once())->method('requestStreaming')->willReturn($deferred->promise()); $es = new EventSource('http://example.com', $loop, $browser); @@ -150,8 +150,8 @@ public function testConstructorWillStartGetRequestThatWillStartRetryTimerThatWil $deferred = new Deferred(); $browser = $this->getMockBuilder('Clue\React\Buzz\Browser')->disableOriginalConstructor()->getMock(); - $browser->expects($this->once())->method('withOptions')->willReturnSelf(); - $browser->expects($this->exactly(2))->method('get')->willReturnOnConsecutiveCalls( + $browser->expects($this->once())->method('withRejectErrorResponse')->willReturnSelf(); + $browser->expects($this->exactly(2))->method('requestStreaming')->willReturnOnConsecutiveCalls( $deferred->promise(), new Promise(function () { }) ); @@ -174,8 +174,8 @@ public function testConstructorWillStartGetRequestThatWillEmitErrorWhenGetReques $deferred = new Deferred(); $browser = $this->getMockBuilder('Clue\React\Buzz\Browser')->disableOriginalConstructor()->getMock(); - $browser->expects($this->once())->method('withOptions')->willReturnSelf(); - $browser->expects($this->once())->method('get')->willReturn($deferred->promise()); + $browser->expects($this->once())->method('withRejectErrorResponse')->willReturnSelf(); + $browser->expects($this->once())->method('requestStreaming')->willReturn($deferred->promise()); $es = new EventSource('http://example.com', $loop, $browser); @@ -194,8 +194,8 @@ public function testConstructorWillStartGetRequestThatWillNotStartRetryTimerWhen $deferred = new Deferred(); $browser = $this->getMockBuilder('Clue\React\Buzz\Browser')->disableOriginalConstructor()->getMock(); - $browser->expects($this->once())->method('withOptions')->willReturnSelf(); - $browser->expects($this->once())->method('get')->with('http://example.com')->willReturn($deferred->promise()); + $browser->expects($this->once())->method('withRejectErrorResponse')->willReturnSelf(); + $browser->expects($this->once())->method('requestStreaming')->willReturn($deferred->promise()); $es = new EventSource('http://example.com', $loop, $browser); @@ -217,8 +217,8 @@ public function testCloseAfterGetRequestFromConstructorFailsWillCancelPendingRet $deferred = new Deferred(); $browser = $this->getMockBuilder('Clue\React\Buzz\Browser')->disableOriginalConstructor()->getMock(); - $browser->expects($this->once())->method('withOptions')->willReturnSelf(); - $browser->expects($this->once())->method('get')->with('http://example.com')->willReturn($deferred->promise()); + $browser->expects($this->once())->method('withRejectErrorResponse')->willReturnSelf(); + $browser->expects($this->once())->method('requestStreaming')->willReturn($deferred->promise()); $es = new EventSource('http://example.com', $loop, $browser); @@ -233,8 +233,8 @@ public function testConstructorWillReportFatalErrorWhenGetResponseResolvesWithIn $deferred = new Deferred(); $browser = $this->getMockBuilder('Clue\React\Buzz\Browser')->disableOriginalConstructor()->getMock(); - $browser->expects($this->once())->method('withOptions')->willReturnSelf(); - $browser->expects($this->once())->method('get')->with('http://example.com')->willReturn($deferred->promise()); + $browser->expects($this->once())->method('withRejectErrorResponse')->willReturnSelf(); + $browser->expects($this->once())->method('requestStreaming')->willReturn($deferred->promise()); $es = new EventSource('http://example.com', $loop, $browser); @@ -258,8 +258,8 @@ public function testConstructorWillReportFatalErrorWhenGetResponseResolvesWithIn $deferred = new Deferred(); $browser = $this->getMockBuilder('Clue\React\Buzz\Browser')->disableOriginalConstructor()->getMock(); - $browser->expects($this->once())->method('withOptions')->willReturnSelf(); - $browser->expects($this->once())->method('get')->with('http://example.com')->willReturn($deferred->promise()); + $browser->expects($this->once())->method('withRejectErrorResponse')->willReturnSelf(); + $browser->expects($this->once())->method('requestStreaming')->willReturn($deferred->promise()); $es = new EventSource('http://example.com', $loop, $browser); @@ -283,8 +283,8 @@ public function testConstructorWillReportOpenWhenGetResponseResolvesWithValidRes $deferred = new Deferred(); $browser = $this->getMockBuilder('Clue\React\Buzz\Browser')->disableOriginalConstructor()->getMock(); - $browser->expects($this->once())->method('withOptions')->willReturnSelf(); - $browser->expects($this->once())->method('get')->with('http://example.com')->willReturn($deferred->promise()); + $browser->expects($this->once())->method('withRejectErrorResponse')->willReturnSelf(); + $browser->expects($this->once())->method('requestStreaming')->willReturn($deferred->promise()); $es = new EventSource('http://example.com', $loop, $browser); @@ -306,8 +306,8 @@ public function testConstructorWillReportOpenWhenGetResponseResolvesWithValidRes $deferred = new Deferred(); $browser = $this->getMockBuilder('Clue\React\Buzz\Browser')->disableOriginalConstructor()->getMock(); - $browser->expects($this->once())->method('withOptions')->willReturnSelf(); - $browser->expects($this->once())->method('get')->with('http://example.com')->willReturn($deferred->promise()); + $browser->expects($this->once())->method('withRejectErrorResponse')->willReturnSelf(); + $browser->expects($this->once())->method('requestStreaming')->willReturn($deferred->promise()); $es = new EventSource('http://example.com', $loop, $browser); @@ -329,8 +329,8 @@ public function testConstructorWillReportOpenWhenGetResponseResolvesWithValidRes $deferred = new Deferred(); $browser = $this->getMockBuilder('Clue\React\Buzz\Browser')->disableOriginalConstructor()->getMock(); - $browser->expects($this->once())->method('withOptions')->willReturnSelf(); - $browser->expects($this->once())->method('get')->with('http://example.com')->willReturn($deferred->promise()); + $browser->expects($this->once())->method('withRejectErrorResponse')->willReturnSelf(); + $browser->expects($this->once())->method('requestStreaming')->willReturn($deferred->promise()); $es = new EventSource('http://example.com', $loop, $browser); @@ -356,8 +356,8 @@ public function testCloseResponseStreamWillStartRetryTimerWithoutErrorEvent() $deferred = new Deferred(); $browser = $this->getMockBuilder('Clue\React\Buzz\Browser')->disableOriginalConstructor()->getMock(); - $browser->expects($this->once())->method('withOptions')->willReturnSelf(); - $browser->expects($this->once())->method('get')->with('http://example.com')->willReturn($deferred->promise()); + $browser->expects($this->once())->method('withRejectErrorResponse')->willReturnSelf(); + $browser->expects($this->once())->method('requestStreaming')->willReturn($deferred->promise()); $es = new EventSource('http://example.com', $loop, $browser); @@ -382,8 +382,8 @@ public function testCloseFromOpenEventWillCloseResponseStreamAndCloseEventSource $deferred = new Deferred(); $browser = $this->getMockBuilder('Clue\React\Buzz\Browser')->disableOriginalConstructor()->getMock(); - $browser->expects($this->once())->method('withOptions')->willReturnSelf(); - $browser->expects($this->once())->method('get')->with('http://example.com')->willReturn($deferred->promise()); + $browser->expects($this->once())->method('withRejectErrorResponse')->willReturnSelf(); + $browser->expects($this->once())->method('requestStreaming')->willReturn($deferred->promise()); $es = new EventSource('http://example.com', $loop, $browser); @@ -405,8 +405,8 @@ public function testEmitMessageWithParsedDataFromEventStream() $deferred = new Deferred(); $browser = $this->getMockBuilder('Clue\React\Buzz\Browser')->disableOriginalConstructor()->getMock(); - $browser->expects($this->once())->method('withOptions')->willReturnSelf(); - $browser->expects($this->once())->method('get')->with('http://example.com')->willReturn($deferred->promise()); + $browser->expects($this->once())->method('withRejectErrorResponse')->willReturnSelf(); + $browser->expects($this->once())->method('requestStreaming')->willReturn($deferred->promise()); $es = new EventSource('http://example.com', $loop, $browser); @@ -432,8 +432,8 @@ public function testEmitMessageWithParsedIdAndDataOverMultipleRowsFromEventStrea $deferred = new Deferred(); $browser = $this->getMockBuilder('Clue\React\Buzz\Browser')->disableOriginalConstructor()->getMock(); - $browser->expects($this->once())->method('withOptions')->willReturnSelf(); - $browser->expects($this->once())->method('get')->with('http://example.com')->willReturn($deferred->promise()); + $browser->expects($this->once())->method('withRejectErrorResponse')->willReturnSelf(); + $browser->expects($this->once())->method('requestStreaming')->willReturn($deferred->promise()); $es = new EventSource('http://example.com', $loop, $browser); @@ -459,8 +459,8 @@ public function testEmitMessageWithParsedEventTypeAndDataWithTrailingWhitespaceF $deferred = new Deferred(); $browser = $this->getMockBuilder('Clue\React\Buzz\Browser')->disableOriginalConstructor()->getMock(); - $browser->expects($this->once())->method('withOptions')->willReturnSelf(); - $browser->expects($this->once())->method('get')->with('http://example.com')->willReturn($deferred->promise()); + $browser->expects($this->once())->method('withRejectErrorResponse')->willReturnSelf(); + $browser->expects($this->once())->method('requestStreaming')->willReturn($deferred->promise()); $es = new EventSource('http://example.com', $loop, $browser); @@ -485,8 +485,8 @@ public function testDoesNotEmitMessageWhenParsedEventStreamHasNoData() $deferred = new Deferred(); $browser = $this->getMockBuilder('Clue\React\Buzz\Browser')->disableOriginalConstructor()->getMock(); - $browser->expects($this->once())->method('withOptions')->willReturnSelf(); - $browser->expects($this->once())->method('get')->with('http://example.com')->willReturn($deferred->promise()); + $browser->expects($this->once())->method('withRejectErrorResponse')->willReturnSelf(); + $browser->expects($this->once())->method('requestStreaming')->willReturn($deferred->promise()); $es = new EventSource('http://example.com', $loop, $browser); @@ -510,8 +510,8 @@ public function testEmitMessageWithParsedDataAndPreviousIdWhenNotGivenAgainFromE $deferred = new Deferred(); $browser = $this->getMockBuilder('Clue\React\Buzz\Browser')->disableOriginalConstructor()->getMock(); - $browser->expects($this->once())->method('withOptions')->willReturnSelf(); - $browser->expects($this->once())->method('get')->with('http://example.com')->willReturn($deferred->promise()); + $browser->expects($this->once())->method('withRejectErrorResponse')->willReturnSelf(); + $browser->expects($this->once())->method('requestStreaming')->willReturn($deferred->promise()); $es = new EventSource('http://example.com', $loop, $browser); @@ -545,10 +545,10 @@ public function testReconnectAfterStreamClosesUsesLastEventIdFromParsedEventStre $deferred = new Deferred(); $browser = $this->getMockBuilder('Clue\React\Buzz\Browser')->disableOriginalConstructor()->getMock(); - $browser->expects($this->once())->method('withOptions')->willReturnSelf(); - $browser->expects($this->exactly(2))->method('get')->withConsecutive( - ['http://example.com', ['Accept' => 'text/event-stream', 'Cache-Control' => 'no-cache']], - ['http://example.com', ['Accept' => 'text/event-stream', 'Cache-Control' => 'no-cache', 'Last-Event-ID' => '123']] + $browser->expects($this->once())->method('withRejectErrorResponse')->willReturnSelf(); + $browser->expects($this->exactly(2))->method('requestStreaming')->withConsecutive( + ['GET', 'http://example.com', ['Accept' => 'text/event-stream', 'Cache-Control' => 'no-cache']], + ['GET', 'http://example.com', ['Accept' => 'text/event-stream', 'Cache-Control' => 'no-cache', 'Last-Event-ID' => '123']] )->willReturnOnConsecutiveCalls( $deferred->promise(), new Promise(function () { }) From d2a0860978ab89502251c94bd625d49e0e775897 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCck?= Date: Wed, 15 Jul 2020 21:15:39 +0200 Subject: [PATCH 2/2] Update to reactphp/http v1.0.0 --- README.md | 16 ++++++------ composer.json | 5 ++-- src/EventSource.php | 14 +++++----- tests/EventSourceTest.php | 54 +++++++++++++++++++-------------------- 4 files changed, 45 insertions(+), 44 deletions(-) diff --git a/README.md b/README.md index c22ff6d..6762a18 100644 --- a/README.md +++ b/README.md @@ -21,9 +21,9 @@ from any Server-Sent Events (SSE) server endpoint: ```php $loop = Factory::create(); -$es = new EventSource('https://example.com/stream.php', $loop); +$es = new Clue\React\EventSource\EventSource('https://example.com/stream.php', $loop); -$es->on('message', function (MessageEvent $message) { +$es->on('message', function (Clue\React\EventSource\MessageEvent $message) { //$data = json_decode($message->data); var_dump($message); }); @@ -48,19 +48,19 @@ registers everything with the main [`EventLoop`](https://github.com/reactphp/eve in order to handle async HTTP requests. ```php -$loop = \React\EventLoop\Factory::create(); +$loop = React\EventLoop\Factory::create(); -$es = new \Clue\React\EventSource\EventSource('https://example.com/stream.php', $loop); +$es = new Clue\React\EventSource\EventSource('https://example.com/stream.php', $loop); ``` If you need custom connector settings (DNS resolution, TLS parameters, timeouts, proxy servers etc.), you can explicitly pass a custom instance of the [`ConnectorInterface`](https://github.com/reactphp/socket#connectorinterface) -to the [`Browser`](https://github.com/clue/reactphp-buzz#browser) instance +to the [`Browser`](https://github.com/reactphp/http#browser) instance and pass it as an additional argument to the `EventSource` like this: ```php -$connector = new \React\Socket\Connector($loop, array( +$connector = new React\Socket\Connector($loop, array( 'dns' => '127.0.0.1', 'tcp' => array( 'bindto' => '192.168.10.1:0' @@ -70,9 +70,9 @@ $connector = new \React\Socket\Connector($loop, array( 'verify_peer_name' => false ) )); -$browser = new \Clue\React\Buzz\Browser($loop, $connector); +$browser = new React\Http\Browser($loop, $connector); -$es = new \Clue\React\EventSource\EventSource('https://example.com/stream.php', $loop, $browser); +$es = new Clue\React\EventSource\EventSource('https://example.com/stream.php', $loop, $browser); ``` ## Install diff --git a/composer.json b/composer.json index 1833cac..2e77766 100644 --- a/composer.json +++ b/composer.json @@ -18,8 +18,9 @@ }, "require": { "php": ">=5.4", - "clue/buzz-react": "^2.9", - "evenement/evenement": "^3.0 || ^2.0" + "evenement/evenement": "^3.0 || ^2.0", + "react/event-loop": "^1.0", + "react/http": "^1.0" }, "require-dev": { "phpunit/phpunit": "^7.0 || ^6.4 || ^5.7 || ^4.8.35" diff --git a/src/EventSource.php b/src/EventSource.php index 7e5bd02..d90f767 100644 --- a/src/EventSource.php +++ b/src/EventSource.php @@ -2,10 +2,10 @@ namespace Clue\React\EventSource; -use Clue\React\Buzz\Browser; use Evenement\EventEmitter; use Psr\Http\Message\ResponseInterface; use React\EventLoop\LoopInterface; +use React\Http\Browser; use React\Stream\ReadableStreamInterface; /** @@ -20,19 +20,19 @@ * in order to handle async HTTP requests. * * ```php - * $loop = \React\EventLoop\Factory::create(); + * $loop = React\EventLoop\Factory::create(); * - * $es = new \Clue\React\EventSource\EventSource('https://example.com/stream.php', $loop); + * $es = new Clue\React\EventSource\EventSource('https://example.com/stream.php', $loop); * ``` * * If you need custom connector settings (DNS resolution, TLS parameters, timeouts, * proxy servers etc.), you can explicitly pass a custom instance of the * [`ConnectorInterface`](https://github.com/reactphp/socket#connectorinterface) - * to the [`Browser`](https://github.com/clue/reactphp-buzz#browser) instance + * to the [`Browser`](https://github.com/reactphp/http#browser) instance * and pass it as an additional argument to the `EventSource` like this: * * ```php - * $connector = new \React\Socket\Connector($loop, array( + * $connector = new React\Socket\Connector($loop, array( * 'dns' => '127.0.0.1', * 'tcp' => array( * 'bindto' => '192.168.10.1:0' @@ -42,9 +42,9 @@ * 'verify_peer_name' => false * ) * )); - * $browser = new \Clue\React\Buzz\Browser($loop, $connector); + * $browser = new React\Http\Browser($loop, $connector); * - * $es = new \Clue\React\EventSource\EventSource('https://example.com/stream.php', $loop, $browser); + * $es = new Clue\React\EventSource\EventSource('https://example.com/stream.php', $loop, $browser); * ``` */ class EventSource extends EventEmitter diff --git a/tests/EventSourceTest.php b/tests/EventSourceTest.php index 4cf8545..da314e5 100644 --- a/tests/EventSourceTest.php +++ b/tests/EventSourceTest.php @@ -2,14 +2,14 @@ namespace Clue\Tests\React\EventSource; -use PHPUnit\Framework\TestCase; use Clue\React\EventSource\EventSource; +use PHPUnit\Framework\TestCase; use React\Promise\Promise; use React\Promise\Deferred; -use RingCentral\Psr7\Response; +use React\Http\Browser; +use React\Http\Io\ReadableBodyStream; use React\Stream\ThroughStream; -use Clue\React\Buzz\Message\ReadableBodyStream; -use Clue\React\Buzz\Browser; +use RingCentral\Psr7\Response; class EventSourceTest extends TestCase { @@ -50,7 +50,7 @@ public function testConstructorCanBeCalledWithoutBrowser() $ref->setAccessible(true); $browser = $ref->getValue($es); - $this->assertInstanceOf('Clue\React\Buzz\Browser', $browser); + $this->assertInstanceOf('React\Http\Browser', $browser); } public function testConstructorWillSendGetRequestThroughGivenBrowser() @@ -58,7 +58,7 @@ public function testConstructorWillSendGetRequestThroughGivenBrowser() $loop = $this->getMockBuilder('React\EventLoop\LoopInterface')->getMock(); $pending = new Promise(function () { }); - $browser = $this->getMockBuilder('Clue\React\Buzz\Browser')->disableOriginalConstructor()->getMock(); + $browser = $this->getMockBuilder('React\Http\Browser')->disableOriginalConstructor()->getMock(); $browser->expects($this->once())->method('withRejectErrorResponse')->with(false)->willReturnSelf(); $browser->expects($this->once())->method('requestStreaming')->with('GET', 'http://example.com')->willReturn($pending); @@ -70,7 +70,7 @@ public function testConstructorWillSendGetRequestThroughGivenBrowserWithHttpsSch $loop = $this->getMockBuilder('React\EventLoop\LoopInterface')->getMock(); $pending = new Promise(function () { }); - $browser = $this->getMockBuilder('Clue\React\Buzz\Browser')->disableOriginalConstructor()->getMock(); + $browser = $this->getMockBuilder('React\Http\Browser')->disableOriginalConstructor()->getMock(); $browser->expects($this->once())->method('withRejectErrorResponse')->with(false)->willReturnSelf(); $browser->expects($this->once())->method('requestStreaming')->with('GET', 'https://example.com')->willReturn($pending); @@ -85,7 +85,7 @@ public function testCloseWillCancelPendingGetRequest() $pending = new Promise(function () { }, function () use (&$cancelled) { ++$cancelled; }); - $browser = $this->getMockBuilder('Clue\React\Buzz\Browser')->disableOriginalConstructor()->getMock(); + $browser = $this->getMockBuilder('React\Http\Browser')->disableOriginalConstructor()->getMock(); $browser->expects($this->once())->method('withRejectErrorResponse')->willReturnSelf(); $browser->expects($this->once())->method('requestStreaming')->willReturn($pending); @@ -102,7 +102,7 @@ public function testCloseWillNotEmitErrorEventWhenGetRequestCancellationHandlerR $pending = new Promise(function () { }, function () { throw new \RuntimeException(); }); - $browser = $this->getMockBuilder('Clue\React\Buzz\Browser')->disableOriginalConstructor()->getMock(); + $browser = $this->getMockBuilder('React\Http\Browser')->disableOriginalConstructor()->getMock(); $browser->expects($this->once())->method('withRejectErrorResponse')->willReturnSelf(); $browser->expects($this->once())->method('requestStreaming')->willReturn($pending); @@ -127,7 +127,7 @@ public function testConstructorWillStartGetRequestThatWillStartRetryTimerWhenGet ); $deferred = new Deferred(); - $browser = $this->getMockBuilder('Clue\React\Buzz\Browser')->disableOriginalConstructor()->getMock(); + $browser = $this->getMockBuilder('React\Http\Browser')->disableOriginalConstructor()->getMock(); $browser->expects($this->once())->method('withRejectErrorResponse')->willReturnSelf(); $browser->expects($this->once())->method('requestStreaming')->willReturn($deferred->promise()); @@ -149,7 +149,7 @@ public function testConstructorWillStartGetRequestThatWillStartRetryTimerThatWil ); $deferred = new Deferred(); - $browser = $this->getMockBuilder('Clue\React\Buzz\Browser')->disableOriginalConstructor()->getMock(); + $browser = $this->getMockBuilder('React\Http\Browser')->disableOriginalConstructor()->getMock(); $browser->expects($this->once())->method('withRejectErrorResponse')->willReturnSelf(); $browser->expects($this->exactly(2))->method('requestStreaming')->willReturnOnConsecutiveCalls( $deferred->promise(), @@ -173,7 +173,7 @@ public function testConstructorWillStartGetRequestThatWillEmitErrorWhenGetReques ); $deferred = new Deferred(); - $browser = $this->getMockBuilder('Clue\React\Buzz\Browser')->disableOriginalConstructor()->getMock(); + $browser = $this->getMockBuilder('React\Http\Browser')->disableOriginalConstructor()->getMock(); $browser->expects($this->once())->method('withRejectErrorResponse')->willReturnSelf(); $browser->expects($this->once())->method('requestStreaming')->willReturn($deferred->promise()); @@ -193,7 +193,7 @@ public function testConstructorWillStartGetRequestThatWillNotStartRetryTimerWhen $loop = $this->getMockBuilder('React\EventLoop\LoopInterface')->getMock(); $deferred = new Deferred(); - $browser = $this->getMockBuilder('Clue\React\Buzz\Browser')->disableOriginalConstructor()->getMock(); + $browser = $this->getMockBuilder('React\Http\Browser')->disableOriginalConstructor()->getMock(); $browser->expects($this->once())->method('withRejectErrorResponse')->willReturnSelf(); $browser->expects($this->once())->method('requestStreaming')->willReturn($deferred->promise()); @@ -216,7 +216,7 @@ public function testCloseAfterGetRequestFromConstructorFailsWillCancelPendingRet $loop->expects($this->once())->method('cancelTimer')->with($timer); $deferred = new Deferred(); - $browser = $this->getMockBuilder('Clue\React\Buzz\Browser')->disableOriginalConstructor()->getMock(); + $browser = $this->getMockBuilder('React\Http\Browser')->disableOriginalConstructor()->getMock(); $browser->expects($this->once())->method('withRejectErrorResponse')->willReturnSelf(); $browser->expects($this->once())->method('requestStreaming')->willReturn($deferred->promise()); @@ -232,7 +232,7 @@ public function testConstructorWillReportFatalErrorWhenGetResponseResolvesWithIn $loop = $this->getMockBuilder('React\EventLoop\LoopInterface')->getMock(); $deferred = new Deferred(); - $browser = $this->getMockBuilder('Clue\React\Buzz\Browser')->disableOriginalConstructor()->getMock(); + $browser = $this->getMockBuilder('React\Http\Browser')->disableOriginalConstructor()->getMock(); $browser->expects($this->once())->method('withRejectErrorResponse')->willReturnSelf(); $browser->expects($this->once())->method('requestStreaming')->willReturn($deferred->promise()); @@ -257,7 +257,7 @@ public function testConstructorWillReportFatalErrorWhenGetResponseResolvesWithIn $loop = $this->getMockBuilder('React\EventLoop\LoopInterface')->getMock(); $deferred = new Deferred(); - $browser = $this->getMockBuilder('Clue\React\Buzz\Browser')->disableOriginalConstructor()->getMock(); + $browser = $this->getMockBuilder('React\Http\Browser')->disableOriginalConstructor()->getMock(); $browser->expects($this->once())->method('withRejectErrorResponse')->willReturnSelf(); $browser->expects($this->once())->method('requestStreaming')->willReturn($deferred->promise()); @@ -282,7 +282,7 @@ public function testConstructorWillReportOpenWhenGetResponseResolvesWithValidRes $loop = $this->getMockBuilder('React\EventLoop\LoopInterface')->getMock(); $deferred = new Deferred(); - $browser = $this->getMockBuilder('Clue\React\Buzz\Browser')->disableOriginalConstructor()->getMock(); + $browser = $this->getMockBuilder('React\Http\Browser')->disableOriginalConstructor()->getMock(); $browser->expects($this->once())->method('withRejectErrorResponse')->willReturnSelf(); $browser->expects($this->once())->method('requestStreaming')->willReturn($deferred->promise()); @@ -305,7 +305,7 @@ public function testConstructorWillReportOpenWhenGetResponseResolvesWithValidRes $loop = $this->getMockBuilder('React\EventLoop\LoopInterface')->getMock(); $deferred = new Deferred(); - $browser = $this->getMockBuilder('Clue\React\Buzz\Browser')->disableOriginalConstructor()->getMock(); + $browser = $this->getMockBuilder('React\Http\Browser')->disableOriginalConstructor()->getMock(); $browser->expects($this->once())->method('withRejectErrorResponse')->willReturnSelf(); $browser->expects($this->once())->method('requestStreaming')->willReturn($deferred->promise()); @@ -328,7 +328,7 @@ public function testConstructorWillReportOpenWhenGetResponseResolvesWithValidRes $loop = $this->getMockBuilder('React\EventLoop\LoopInterface')->getMock(); $deferred = new Deferred(); - $browser = $this->getMockBuilder('Clue\React\Buzz\Browser')->disableOriginalConstructor()->getMock(); + $browser = $this->getMockBuilder('React\Http\Browser')->disableOriginalConstructor()->getMock(); $browser->expects($this->once())->method('withRejectErrorResponse')->willReturnSelf(); $browser->expects($this->once())->method('requestStreaming')->willReturn($deferred->promise()); @@ -355,7 +355,7 @@ public function testCloseResponseStreamWillStartRetryTimerWithoutErrorEvent() ); $deferred = new Deferred(); - $browser = $this->getMockBuilder('Clue\React\Buzz\Browser')->disableOriginalConstructor()->getMock(); + $browser = $this->getMockBuilder('React\Http\Browser')->disableOriginalConstructor()->getMock(); $browser->expects($this->once())->method('withRejectErrorResponse')->willReturnSelf(); $browser->expects($this->once())->method('requestStreaming')->willReturn($deferred->promise()); @@ -381,7 +381,7 @@ public function testCloseFromOpenEventWillCloseResponseStreamAndCloseEventSource $loop = $this->getMockBuilder('React\EventLoop\LoopInterface')->getMock(); $deferred = new Deferred(); - $browser = $this->getMockBuilder('Clue\React\Buzz\Browser')->disableOriginalConstructor()->getMock(); + $browser = $this->getMockBuilder('React\Http\Browser')->disableOriginalConstructor()->getMock(); $browser->expects($this->once())->method('withRejectErrorResponse')->willReturnSelf(); $browser->expects($this->once())->method('requestStreaming')->willReturn($deferred->promise()); @@ -404,7 +404,7 @@ public function testEmitMessageWithParsedDataFromEventStream() $loop = $this->getMockBuilder('React\EventLoop\LoopInterface')->getMock(); $deferred = new Deferred(); - $browser = $this->getMockBuilder('Clue\React\Buzz\Browser')->disableOriginalConstructor()->getMock(); + $browser = $this->getMockBuilder('React\Http\Browser')->disableOriginalConstructor()->getMock(); $browser->expects($this->once())->method('withRejectErrorResponse')->willReturnSelf(); $browser->expects($this->once())->method('requestStreaming')->willReturn($deferred->promise()); @@ -431,7 +431,7 @@ public function testEmitMessageWithParsedIdAndDataOverMultipleRowsFromEventStrea $loop = $this->getMockBuilder('React\EventLoop\LoopInterface')->getMock(); $deferred = new Deferred(); - $browser = $this->getMockBuilder('Clue\React\Buzz\Browser')->disableOriginalConstructor()->getMock(); + $browser = $this->getMockBuilder('React\Http\Browser')->disableOriginalConstructor()->getMock(); $browser->expects($this->once())->method('withRejectErrorResponse')->willReturnSelf(); $browser->expects($this->once())->method('requestStreaming')->willReturn($deferred->promise()); @@ -458,7 +458,7 @@ public function testEmitMessageWithParsedEventTypeAndDataWithTrailingWhitespaceF $loop = $this->getMockBuilder('React\EventLoop\LoopInterface')->getMock(); $deferred = new Deferred(); - $browser = $this->getMockBuilder('Clue\React\Buzz\Browser')->disableOriginalConstructor()->getMock(); + $browser = $this->getMockBuilder('React\Http\Browser')->disableOriginalConstructor()->getMock(); $browser->expects($this->once())->method('withRejectErrorResponse')->willReturnSelf(); $browser->expects($this->once())->method('requestStreaming')->willReturn($deferred->promise()); @@ -484,7 +484,7 @@ public function testDoesNotEmitMessageWhenParsedEventStreamHasNoData() $loop = $this->getMockBuilder('React\EventLoop\LoopInterface')->getMock(); $deferred = new Deferred(); - $browser = $this->getMockBuilder('Clue\React\Buzz\Browser')->disableOriginalConstructor()->getMock(); + $browser = $this->getMockBuilder('React\Http\Browser')->disableOriginalConstructor()->getMock(); $browser->expects($this->once())->method('withRejectErrorResponse')->willReturnSelf(); $browser->expects($this->once())->method('requestStreaming')->willReturn($deferred->promise()); @@ -509,7 +509,7 @@ public function testEmitMessageWithParsedDataAndPreviousIdWhenNotGivenAgainFromE $loop = $this->getMockBuilder('React\EventLoop\LoopInterface')->getMock(); $deferred = new Deferred(); - $browser = $this->getMockBuilder('Clue\React\Buzz\Browser')->disableOriginalConstructor()->getMock(); + $browser = $this->getMockBuilder('React\Http\Browser')->disableOriginalConstructor()->getMock(); $browser->expects($this->once())->method('withRejectErrorResponse')->willReturnSelf(); $browser->expects($this->once())->method('requestStreaming')->willReturn($deferred->promise()); @@ -544,7 +544,7 @@ public function testReconnectAfterStreamClosesUsesLastEventIdFromParsedEventStre ); $deferred = new Deferred(); - $browser = $this->getMockBuilder('Clue\React\Buzz\Browser')->disableOriginalConstructor()->getMock(); + $browser = $this->getMockBuilder('React\Http\Browser')->disableOriginalConstructor()->getMock(); $browser->expects($this->once())->method('withRejectErrorResponse')->willReturnSelf(); $browser->expects($this->exactly(2))->method('requestStreaming')->withConsecutive( ['GET', 'http://example.com', ['Accept' => 'text/event-stream', 'Cache-Control' => 'no-cache']],