示例#1
0
 /**
  * {@inheritdoc}
  */
 public function close()
 {
     if ($this->socket instanceof \ZMQSocket && !$this->socket->isPersistent()) {
         $this->socket->disconnect($this->dsn);
     }
     $this->socket = null;
 }
 private function getContextMock($methods = array(), \ZMQSocket $socket = null)
 {
     $context = $this->getMockBuilder('\\ZMQContext')->setConstructorArgs(array(1, $socket->isPersistent()))->setMethods($methods)->getMock();
     if ($socket) {
         $context->expects($this->any())->method('getSocket')->with($this->equalTo($socket->getSocketType()), $socket->isPersistent() ? $this->isType('string') : $this->isNull(), $this->isType('callable'))->will($this->returnCallback(function ($socketType, $persistentId, $callback) use($socket) {
             call_user_func($callback, $socket);
             return $socket;
         }));
     }
     return $context;
 }