From fbea6234478a660a81f5eeb3b241087ff98e6dec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rk=20S=C3=A1gi-Kaz=C3=A1r?= Date: Thu, 3 Mar 2016 00:54:21 +0100 Subject: [PATCH 1/2] Update integration tests --- composer.json | 4 +--- tests/AsyncClientTest.php | 5 ++--- tests/ClientTest.php | 5 ++--- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/composer.json b/composer.json index d2c8659..1420fa5 100644 --- a/composer.json +++ b/composer.json @@ -18,9 +18,7 @@ "react/stream": "^0.4.3" }, "require-dev": { - "guzzlehttp/psr7": "^1.0", - "php-http/adapter-integration-tests": "^0.3.1", - "puli/composer-plugin": "1.0.0-beta9" + "php-http/adapter-integration-tests": "^0.4" }, "autoload": { "psr-4": { diff --git a/tests/AsyncClientTest.php b/tests/AsyncClientTest.php index 6cffe42..e64d3ad 100644 --- a/tests/AsyncClientTest.php +++ b/tests/AsyncClientTest.php @@ -3,9 +3,9 @@ namespace Http\Adapter\React\Tests; use Http\Client\HttpClient; -use Http\Discovery\MessageFactoryDiscovery; use Http\Client\Tests\HttpAsyncClientTest; use Http\Adapter\React\Client; +use Http\Message\MessageFactory\GuzzleMessageFactory; /** * @author Stéphane Hulard @@ -17,7 +17,6 @@ class AsyncClientTest extends HttpAsyncClientTest */ protected function createHttpAsyncClient() { - $messageFactory = MessageFactoryDiscovery::find(); - return new Client($messageFactory); + return new Client(new GuzzleMessageFactory()); } } diff --git a/tests/ClientTest.php b/tests/ClientTest.php index d5cc526..edc998f 100644 --- a/tests/ClientTest.php +++ b/tests/ClientTest.php @@ -5,7 +5,7 @@ use Http\Client\HttpClient; use Http\Client\Tests\HttpClientTest; use Http\Adapter\React\Client; -use Http\Discovery\MessageFactoryDiscovery; +use Http\Message\MessageFactory\GuzzleMessageFactory; /** * @author Stéphane Hulard @@ -17,7 +17,6 @@ class ClientTest extends HttpClientTest */ protected function createHttpAdapter() { - $messageFactory = MessageFactoryDiscovery::find(); - return new Client($messageFactory); + return new Client(new GuzzleMessageFactory()); } } From 96b4b7ae7365cd6f3f0a9b28bf8004793b8ed32e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rk=20S=C3=A1gi-Kaz=C3=A1r?= Date: Thu, 3 Mar 2016 00:56:47 +0100 Subject: [PATCH 2/2] Add discovery support --- composer.json | 3 ++- src/Client.php | 13 +++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/composer.json b/composer.json index 1420fa5..8953432 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,8 @@ "php-http/httplug": "^1.0", "react/http-client": "^0.4.8", "react/dns": "^0.4.1", - "react/stream": "^0.4.3" + "react/stream": "^0.4.3", + "php-http/discovery": "^0.8" }, "require-dev": { "php-http/adapter-integration-tests": "^0.4" diff --git a/src/Client.php b/src/Client.php index 9a4b9b5..551340e 100644 --- a/src/Client.php +++ b/src/Client.php @@ -2,6 +2,7 @@ namespace Http\Adapter\React; +use Http\Discovery\MessageFactoryDiscovery; use Psr\Http\Message\ResponseInterface; use React\EventLoop\LoopInterface; use React\Promise\Deferred; @@ -38,7 +39,7 @@ class Client implements HttpClient, HttpAsyncClient private $loop; /** - * HttpPlug message factory. + * HTTPlug message factory. * * @var MessageFactory */ @@ -47,12 +48,12 @@ class Client implements HttpClient, HttpAsyncClient /** * Initialize the React client. * - * @param MessageFactory $messageFactory - * @param LoopInterface|null $loop React Event loop - * @param ReactClient $client React client to use + * @param MessageFactory|null $messageFactory + * @param LoopInterface|null $loop React Event loop + * @param ReactClient|null $client React client to use */ public function __construct( - MessageFactory $messageFactory, + MessageFactory $messageFactory = null, LoopInterface $loop = null, ReactClient $client = null ) { @@ -64,7 +65,7 @@ public function __construct( $this->loop = (null !== $loop) ?: ReactFactory::buildEventLoop(); $this->client = (null !== $client) ?: ReactFactory::buildHttpClient($this->loop); - $this->messageFactory = $messageFactory; + $this->messageFactory = $messageFactory ?: MessageFactoryDiscovery::find(); } /**