1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-08-05 04:37:38 +02:00

bugfix: use custom hipchat server in buildHeader method

This commit is contained in:
louis
2014-12-30 11:20:31 +01:00
committed by louis
parent 46825bdb95
commit 2ae33f7382

View File

@@ -35,6 +35,18 @@ class HipChatHandlerTest extends TestCase
return $content; return $content;
} }
public function testWriteCustomHostHeader()
{
$this->createHandler('myToken', 'room1', 'Monolog', false, 'hipchat.foo.bar');
$this->handler->handle($this->getRecord(Logger::CRITICAL, 'test1'));
fseek($this->res, 0);
$content = fread($this->res, 1024);
$this->assertRegexp('/POST \/v1\/rooms\/message\?format=json&auth_token=.* HTTP\/1.1\\r\\nHost: hipchat.foo.bar\\r\\nContent-Type: application\/x-www-form-urlencoded\\r\\nContent-Length: \d{2,4}\\r\\n\\r\\n/', $content);
return $content;
}
/** /**
* @depends testWriteHeader * @depends testWriteHeader
*/ */
@@ -129,9 +141,9 @@ class HipChatHandlerTest extends TestCase
); );
} }
private function createHandler($token = 'myToken', $room = 'room1', $name = 'Monolog', $notify = false) private function createHandler($token = 'myToken', $room = 'room1', $name = 'Monolog', $notify = false, $host = 'api.hipchat.com')
{ {
$constructorArgs = array($token, $room, $name, $notify, Logger::DEBUG); $constructorArgs = array($token, $room, $name, $notify, Logger::DEBUG, true, true, 'text', $host);
$this->res = fopen('php://memory', 'a'); $this->res = fopen('php://memory', 'a');
$this->handler = $this->getMock( $this->handler = $this->getMock(
'\Monolog\Handler\HipChatHandler', '\Monolog\Handler\HipChatHandler',