diff --git a/composer.json b/composer.json index d8f9bad..497cdf2 100644 --- a/composer.json +++ b/composer.json @@ -12,11 +12,11 @@ ], "require": { "php": ">=5.3", - "react/event-loop": "0.3.*|0.4.*", - "react/promise": "^2.0 || ^1.1", - "react/socket": "^0.7", "clue/redis-protocol": "0.3.*", - "evenement/evenement": "~1.0|~2.0" + "evenement/evenement": "^3.0 || ^2.0 || ^1.0", + "react/event-loop": "^1.0 || ^0.5 || ^0.4 || ^0.3", + "react/promise": "^2.0 || ^1.1", + "react/socket": "^1.0 || ^0.8 || ^0.7" }, "autoload": { "psr-4": { "Clue\\React\\Redis\\": "src/" } diff --git a/tests/FunctionalTest.php b/tests/FunctionalTest.php index 6cdd8a6..379c2cf 100644 --- a/tests/FunctionalTest.php +++ b/tests/FunctionalTest.php @@ -5,6 +5,7 @@ use Clue\React\Redis\StreamingClient; use React\Promise\Deferred; use React\Stream\Stream; +use React\Stream\DuplexResourceStream; class FunctionalTest extends TestCase { @@ -161,7 +162,7 @@ protected function createClientResponse($response) fwrite($fp, $response); fseek($fp, 0); - $stream = new Stream($fp, $this->loop); + $stream = class_exists('React\Stream\DuplexResourceStream') ? new DuplexResourceStream($fp, $this->loop) : new Stream($fp, $this->loop); return new StreamingClient($stream); } diff --git a/tests/StreamingClientTest.php b/tests/StreamingClientTest.php index 120723d..58a5fc5 100644 --- a/tests/StreamingClientTest.php +++ b/tests/StreamingClientTest.php @@ -7,6 +7,7 @@ use Clue\Redis\Protocol\Model\ErrorReply; use Clue\Redis\Protocol\Model\MultiBulkReply; use Clue\React\Redis\Client; +use React\Stream\ThroughStream; class StreamingClientTest extends TestCase { @@ -17,7 +18,7 @@ class StreamingClientTest extends TestCase public function setUp() { - $this->stream = $this->getMockBuilder('React\Stream\Stream')->disableOriginalConstructor()->setMethods(array('write', 'close', 'resume', 'pause'))->getMock(); + $this->stream = $this->getMockBuilder('React\Stream\DuplexStreamInterface')->getMock(); $this->parser = $this->getMockBuilder('Clue\Redis\Protocol\Parser\ParserInterface')->getMock(); $this->serializer = $this->getMockBuilder('Clue\Redis\Protocol\Serializer\SerializerInterface')->getMock(); @@ -34,13 +35,16 @@ public function testSending() public function testClosingClientEmitsEvent() { - //$this->client->on('close', $this->expectCallableOnce()); + $this->client->on('close', $this->expectCallableOnce()); $this->client->close(); } public function testClosingStreamClosesClient() { + $this->stream = new ThroughStream(); + $this->client = new StreamingClient($this->stream, $this->parser, $this->serializer); + $this->client->on('close', $this->expectCallableOnce()); $this->stream->emit('close'); @@ -48,8 +52,11 @@ public function testClosingStreamClosesClient() public function testReceiveParseErrorEmitsErrorEvent() { + $this->stream = new ThroughStream(); + $this->client = new StreamingClient($this->stream, $this->parser, $this->serializer); + $this->client->on('error', $this->expectCallableOnce()); - //$this->client->on('close', $this->expectCallableOnce()); + $this->client->on('close', $this->expectCallableOnce()); $this->parser->expects($this->once())->method('pushIncoming')->with($this->equalTo('message'))->will($this->throwException(new ParserException())); $this->stream->emit('data', array('message')); @@ -57,6 +64,9 @@ public function testReceiveParseErrorEmitsErrorEvent() public function testReceiveThrowMessageEmitsErrorEvent() { + $this->stream = new ThroughStream(); + $this->client = new StreamingClient($this->stream, $this->parser, $this->serializer); + $this->client->on('error', $this->expectCallableOnce()); $this->parser->expects($this->once())->method('pushIncoming')->with($this->equalTo('message'))->will($this->returnValue(array(new IntegerReply(2))));