diff options
author | gkedzierski <greg@gregkedzierski.com> | 2014-06-15 15:55:24 +0200 |
---|---|---|
committer | gkedzierski <greg@gregkedzierski.com> | 2014-06-15 16:17:43 +0200 |
commit | 83ebdc1f32872ffa9179b902f9d2c266ca23ea00 (patch) | |
tree | 7059d185a16a8f795fabd60491884ca6f878c8d3 /tests/Monolog/Handler/SlackHandlerTest.php | |
parent | 20844b94ffe2d2e8c0f963ec3ae7dbd5fa8f2f11 (diff) | |
download | monolog-83ebdc1f32872ffa9179b902f9d2c266ca23ea00.zip monolog-83ebdc1f32872ffa9179b902f9d2c266ca23ea00.tar.gz monolog-83ebdc1f32872ffa9179b902f9d2c266ca23ea00.tar.bz2 |
Add colors to attachments based on level
Diffstat (limited to 'tests/Monolog/Handler/SlackHandlerTest.php')
-rw-r--r-- | tests/Monolog/Handler/SlackHandlerTest.php | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/tests/Monolog/Handler/SlackHandlerTest.php b/tests/Monolog/Handler/SlackHandlerTest.php index e813210..58fb624 100644 --- a/tests/Monolog/Handler/SlackHandlerTest.php +++ b/tests/Monolog/Handler/SlackHandlerTest.php @@ -45,16 +45,43 @@ class SlackHandlerTest extends TestCase $content = fread($this->res, 1024); $this->assertRegexp('/POST \/api\/chat.postMessage HTTP\/1.1\\r\\nHost: slack.com\\r\\nContent-Type: application\/x-www-form-urlencoded\\r\\nContent-Length: \d{2,4}\\r\\n\\r\\n/', $content); + } - return $content; + public function testWriteContent() + { + $this->createHandler(); + $this->handler->handle($this->getRecord(Logger::CRITICAL, 'test1')); + fseek($this->res, 0); + $content = fread($this->res, 1024); + + $this->assertRegexp('/token=myToken&channel=channel1&username=Monolog&attachments=.*$/', $content); } /** - * @depends testWriteHeader + * @dataProvider provideLevelColors */ - public function testWriteContent($content) + public function testWriteContentWithColors($level, $expectedColor) { - $this->assertRegexp('/token=myToken&channel=channel1&username=Monolog&attachments=.*$/', $content); + $this->createHandler(); + $this->handler->handle($this->getRecord($level, 'test1')); + fseek($this->res, 0); + $content = fread($this->res, 1024); + + $this->assertRegexp('/color%22%3A%22'.$expectedColor.'/', $content); + } + + public function provideLevelColors() + { + return array( + array(Logger::DEBUG, '%23e3e4e6'), // escaped #e3e4e6 + array(Logger::INFO, 'good'), + array(Logger::NOTICE, 'good'), + array(Logger::WARNING, 'warning'), + array(Logger::ERROR, 'danger'), + array(Logger::CRITICAL, 'danger'), + array(Logger::ALERT, 'danger'), + array(Logger::EMERGENCY,'danger'), + ); } private function createHandler($token = 'myToken', $channel = 'channel1', $username = 'Monolog') |