From fa0c39b8a7cba7dbe83741922766489ac8acb70c Mon Sep 17 00:00:00 2001 From: Arnaud Le Blanc Date: Wed, 27 May 2015 13:18:54 +0200 Subject: [PATCH 1/2] Use done() when the goal is not transformation --- src/Request.php | 2 +- tests/RequestTest.php | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/Request.php b/src/Request.php index 67ae3a1..dfbd064 100644 --- a/src/Request.php +++ b/src/Request.php @@ -57,7 +57,7 @@ public function writeHead() $this ->connect() - ->then( + ->done( function ($stream) use ($requestData, &$streamRef, &$stateRef) { $streamRef = $stream; diff --git a/tests/RequestTest.php b/tests/RequestTest.php index eb17727..9c17137 100644 --- a/tests/RequestTest.php +++ b/tests/RequestTest.php @@ -217,6 +217,25 @@ public function requestShouldEmitErrorIfConnectionEmitsError() $request->handleError(new \Exception('test')); } + /** + * @test + * @expectedException Exception + * @expectedExceptionMessage something failed + */ + public function requestDoesNotHideErrors() + { + $requestData = new RequestData('GET', 'http://www.example.com'); + $request = new Request($this->connector, $requestData); + + $this->rejectedConnectionMock(); + + $request->on('error', function () { + throw new \Exception('something failed'); + }); + + $request->end(); + } + /** @test */ public function postRequestShouldSendAPostRequest() { From bd15c8fe66b2e8c4b07d9726542bf738a7ec6088 Mon Sep 17 00:00:00 2001 From: Cees-Jan Kiewiet Date: Thu, 24 Sep 2015 16:15:32 +0200 Subject: [PATCH 2/2] Required promise ~2.2 to ensure ExtendedPromiseInterface::done() availability --- composer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/composer.json b/composer.json index e971e32..a1ca502 100644 --- a/composer.json +++ b/composer.json @@ -10,6 +10,7 @@ "react/dns": "0.4.*", "react/event-loop": "0.4.*", "react/stream": "0.4.*", + "react/promise": "~2.2", "evenement/evenement": "~2.0" }, "autoload": {