Esempio n. 1
0
 /**
  * @test
  */
 public function loopShouldSendQueuedMessages()
 {
     $writeListener = function () {
     };
     $loop = $this->getMock('React\\EventLoop\\LoopInterface');
     $loop->expects($this->once())->method('addWriteStream')->with($this->isType('integer'), $writeListener);
     $socket = $this->getMockBuilder('ZMQSocket')->disableOriginalConstructor()->getMock();
     $socket->expects($this->at(0))->method('sendmulti')->with(array('foo'), \ZMQ::MODE_DONTWAIT)->will($this->returnSelf());
     $socket->expects($this->at(1))->method('sendmulti')->with(array('bar'), \ZMQ::MODE_DONTWAIT)->will($this->returnSelf());
     $buffer = new Buffer($socket, 42, $loop, $writeListener);
     $buffer->send('foo');
     $buffer->send('bar');
     $buffer->handleWriteEvent();
 }
Esempio n. 2
0
 public function end()
 {
     if ($this->closed) {
         return;
     }
     $that = $this;
     $this->buffer->on('end', function () use($that) {
         $that->close();
     });
     $this->buffer->end();
 }