private function createHandler($token = 'myToken', $room = 'room1', $name = 'Monolog', $notify = false, $host = 'api.hipchat.com', $version = 'v1') { $constructorArgs = array($token, $room, $name, $notify, Logger::DEBUG, true, true, 'text', $host, $version); $this->res = fopen('php://memory', 'a'); $this->handler = $this->getMock('\\Monolog\\Handler\\HipChatHandler', array('fsockopen', 'streamSetTimeout', 'closeSocket'), $constructorArgs); $reflectionProperty = new \ReflectionProperty('\\Monolog\\Handler\\SocketHandler', 'connectionString'); $reflectionProperty->setAccessible(true); $reflectionProperty->setValue($this->handler, 'localhost:1234'); $this->handler->expects($this->any())->method('fsockopen')->will($this->returnValue($this->res)); $this->handler->expects($this->any())->method('streamSetTimeout')->will($this->returnValue(true)); $this->handler->expects($this->any())->method('closeSocket')->will($this->returnValue(true)); $this->handler->setFormatter($this->getIdentityFormatter()); }