/**
  * @group disconnected
  */
 public function testConnectionRead()
 {
     $serialized = "*1\r\n\$4\r\nPING\r\n";
     $connection = $this->getMock('Predis\\Connection\\ComposableConnectionInterface');
     $reader = $this->getMock('Predis\\Protocol\\ResponseReaderInterface');
     $protocol = new ComposableTextProtocol();
     $protocol->setReader($reader);
     $reader->expects($this->once())->method('read')->with($connection)->will($this->returnValue('bulk'));
     $this->assertSame('bulk', $protocol->read($connection));
 }
示例#2
0
 /**
  * @group disconnected
  */
 public function testReadResponse()
 {
     $reader = new TextResponseReader();
     $protocol = new ComposableTextProtocol();
     $protocol->setReader($reader);
     $connection = $this->getMock('Predis\\Connection\\ComposableConnectionInterface');
     $connection->expects($this->at(0))->method('readLine')->will($this->returnValue("+OK"));
     $connection->expects($this->at(1))->method('readLine')->will($this->returnValue("-ERR error message"));
     $connection->expects($this->at(2))->method('readLine')->will($this->returnValue(":2"));
     $connection->expects($this->at(3))->method('readLine')->will($this->returnValue("\$-1"));
     $connection->expects($this->at(4))->method('readLine')->will($this->returnValue("*-1"));
     $this->assertTrue($reader->read($connection));
     $this->assertEquals("ERR error message", $reader->read($connection));
     $this->assertSame(2, $reader->read($connection));
     $this->assertNull($reader->read($connection));
     $this->assertNull($reader->read($connection));
 }