1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-08-11 07:34:12 +02:00

Add plain text message support

This commit is contained in:
gkedzierski
2014-06-15 16:35:40 +02:00
parent 83ebdc1f32
commit efd9a2065c
2 changed files with 37 additions and 12 deletions

View File

@@ -54,7 +54,7 @@ class SlackHandlerTest extends TestCase
fseek($this->res, 0);
$content = fread($this->res, 1024);
$this->assertRegexp('/token=myToken&channel=channel1&username=Monolog&attachments=.*$/', $content);
$this->assertRegexp('/token=myToken&channel=channel1&username=Monolog&text=&attachments=.*$/', $content);
}
/**
@@ -70,6 +70,16 @@ class SlackHandlerTest extends TestCase
$this->assertRegexp('/color%22%3A%22'.$expectedColor.'/', $content);
}
public function testWriteContentWithPlainTextMessage()
{
$this->createHandler('myToken', 'channel1', 'Monolog', false);
$this->handler->handle($this->getRecord(Logger::CRITICAL, 'test1'));
fseek($this->res, 0);
$content = fread($this->res, 1024);
$this->assertRegexp('/text=test1/', $content);
}
public function provideLevelColors()
{
return array(
@@ -84,9 +94,9 @@ class SlackHandlerTest extends TestCase
);
}
private function createHandler($token = 'myToken', $channel = 'channel1', $username = 'Monolog')
private function createHandler($token = 'myToken', $channel = 'channel1', $username = 'Monolog', $useAttachment = true)
{
$constructorArgs = array($token, $channel, $username, Logger::DEBUG);
$constructorArgs = array($token, $channel, $username, Logger::DEBUG, true, $useAttachment);
$this->res = fopen('php://memory', 'a');
$this->handler = $this->getMock(
'\Monolog\Handler\SlackHandler',