123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- <?php
- namespace Predis\Protocol\Text;
- use PredisTestCase;
- class ResponseMultiBulkHandlerTest extends PredisTestCase
- {
-
- public function testMultiBulk()
- {
- $handler = new ResponseMultiBulkHandler();
- $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface');
- $connection->expects($this->once())
- ->method('getProtocol')
- ->will($this->returnValue(new ComposableTextProtocol()));
- $connection->expects($this->at(1))
- ->method('readLine')
- ->will($this->returnValue("$3"));
- $connection->expects($this->at(2))
- ->method('readBytes')
- ->will($this->returnValue("foo\r\n"));
- $connection->expects($this->at(3))
- ->method('readLine')
- ->will($this->returnValue("$3"));
- $connection->expects($this->at(4))
- ->method('readBytes')
- ->will($this->returnValue("bar\r\n"));
- $this->assertSame(array('foo', 'bar'), $handler->handle($connection, '2'));
- }
-
- public function testNull()
- {
- $handler = new ResponseMultiBulkHandler();
- $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface');
- $connection->expects($this->never())->method('readLine');
- $connection->expects($this->never())->method('readBytes');
- $this->assertNull($handler->handle($connection, '-1'));
- }
-
- public function testInvalid()
- {
- $handler = new ResponseMultiBulkHandler();
- $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface');
- $connection->expects($this->never())->method('readLine');
- $connection->expects($this->never())->method('readBytes');
- $handler->handle($connection, 'invalid');
- }
- }
|