Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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/" }
Expand Down
3 changes: 2 additions & 1 deletion tests/FunctionalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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);
}
Expand Down
16 changes: 13 additions & 3 deletions tests/StreamingClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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();

Expand All @@ -34,29 +35,38 @@ 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');
}

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'));
}

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))));
Expand Down