Predis\Protocol\Text\CompositeProtocolProcessor::write PHP Méthode

write() public méthode

public write ( Predis\Connection\CompositeConnectionInterface $connection, Predis\Command\CommandInterface $command )
$connection Predis\Connection\CompositeConnectionInterface
$command Predis\Command\CommandInterface
    public function write(CompositeConnectionInterface $connection, CommandInterface $command)
    {
        $connection->writeBuffer($this->serializer->serialize($command));
    }

Usage Example

 /**
  * @group disconnected
  */
 public function testConnectionWrite()
 {
     $serialized = "*1\r\n\$4\r\nPING\r\n";
     $command = $this->getMock('Predis\\Command\\CommandInterface');
     $connection = $this->getMock('Predis\\Connection\\CompositeConnectionInterface');
     $serializer = $this->getMock('Predis\\Protocol\\RequestSerializerInterface');
     $protocol = new CompositeProtocolProcessor($serializer);
     $connection->expects($this->once())->method('writeBuffer')->with($this->equalTo($serialized));
     $serializer->expects($this->once())->method('serialize')->with($command)->will($this->returnValue($serialized));
     $protocol->write($connection, $command);
 }