|
5 | 5 | use Clue\Redis\Protocol\Model\IntegerReply; |
6 | 6 | use Clue\Redis\Protocol\Model\BulkReply; |
7 | 7 | use Clue\Redis\Protocol\Model\ErrorReply; |
| 8 | +use Clue\Redis\Protocol\Model\StatusReply; |
8 | 9 |
|
9 | 10 | class ClientTest extends TestCase |
10 | 11 | { |
@@ -91,6 +92,52 @@ public function testPingPong() |
91 | 92 | $promise->then($this->expectCallableOnce('PONG')); |
92 | 93 | } |
93 | 94 |
|
| 95 | + /** |
| 96 | + * @expectedException UnderflowException |
| 97 | + */ |
| 98 | + public function testInvalidMonitor() |
| 99 | + { |
| 100 | + $this->client->handleMessage(new StatusReply('+1409171800.312243 [0 127.0.0.1:58542] "ping"')); |
| 101 | + } |
| 102 | + |
| 103 | + public function testMonitor() |
| 104 | + { |
| 105 | + $this->serializer->expects($this->once())->method('getRequestMessage')->with($this->equalTo('monitor')); |
| 106 | + |
| 107 | + $promise = $this->client->monitor(); |
| 108 | + |
| 109 | + $this->client->handleMessage(new StatusReply('OK')); |
| 110 | + |
| 111 | + $this->expectPromiseResolve($promise); |
| 112 | + $promise->then($this->expectCallableOnce('OK')); |
| 113 | + |
| 114 | + return $this->client; |
| 115 | + } |
| 116 | + |
| 117 | + /** |
| 118 | + * @depends testMonitor |
| 119 | + * @param StreamingClient $client |
| 120 | + */ |
| 121 | + public function testMonitorEvent(StreamingClient $client) |
| 122 | + { |
| 123 | + $client->on('monitor', $this->expectCallableOnce()); |
| 124 | + |
| 125 | + $client->handleMessage(new StatusReply('1409171800.312243 [0 127.0.0.1:58542] "ping"')); |
| 126 | + } |
| 127 | + |
| 128 | + /** |
| 129 | + * @depends testMonitor |
| 130 | + * @param StreamingClient $client |
| 131 | + */ |
| 132 | + public function testMonitorPing(StreamingClient $client) |
| 133 | + { |
| 134 | + $client->on('monitor', $this->expectCallableOnce()); |
| 135 | + |
| 136 | + $client->ping(); |
| 137 | + $client->handleMessage(new StatusReply('1409171800.312243 [0 127.0.0.1:58542] "ping"')); |
| 138 | + $client->handleMessage(new StatusReply('PONG')); |
| 139 | + } |
| 140 | + |
94 | 141 | public function testErrorReply() |
95 | 142 | { |
96 | 143 | $promise = $this->client->invalid(); |
|
0 commit comments