public function testCloseDoesNotClosePersistentSocket()
 {
     $this->setMockHandler();
     $this->handler->setPersistent(true);
     $this->writeRecord('Hello world');
     $this->assertTrue(is_resource($this->res));
     $this->handler->close();
     $this->assertTrue(is_resource($this->res));
 }
 private function setMockHandler(array $methods = array())
 {
     $this->res = fopen('php://memory', 'a');
     $defaultMethods = array('fsockopen', 'pfsockopen', 'streamSetTimeout');
     $newMethods = array_diff($methods, $defaultMethods);
     $finalMethods = array_merge($defaultMethods, $newMethods);
     $this->handler = $this->getMock('\\Monolog\\Handler\\SocketHandler', $finalMethods, array('localhost:1234'));
     if (!in_array('fsockopen', $methods)) {
         $this->handler->expects($this->any())->method('fsockopen')->will($this->returnValue($this->res));
     }
     if (!in_array('pfsockopen', $methods)) {
         $this->handler->expects($this->any())->method('pfsockopen')->will($this->returnValue($this->res));
     }
     if (!in_array('streamSetTimeout', $methods)) {
         $this->handler->expects($this->any())->method('streamSetTimeout')->will($this->returnValue(true));
     }
     $this->handler->setFormatter($this->getIdentityFormatter());
 }