1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-08-13 16:44:23 +02:00

Update SlackHandler tests && allow SlackRecord formatter change after construction

This commit is contained in:
Anton Nizhegorodov
2016-11-13 23:42:09 +02:00
committed by Haralan Dobrev
parent 01a2ac25a2
commit 08b577c657
4 changed files with 39 additions and 5 deletions

View File

@@ -181,12 +181,24 @@ class SlackRecordTest extends TestCase
->method('format')
->will($this->returnCallback(function ($record) { return $record['message'] . 'test'; }));
$formatter2 = $this->createMock(FormatterInterface::class);
$formatter2
->expects($this->any())
->method('format')
->will($this->returnCallback(function ($record) { return $record['message'] . 'test1'; }));
$message = 'Test message';
$record = new SlackRecord($this->channel, 'Monolog', false, null, false, false, $formatter);
$data = $record->getSlackData($this->getRecord(Logger::WARNING, $message));
$this->assertArrayHasKey('text', $data);
$this->assertSame($message . 'test', $data['text']);
$record->setFormatter($formatter2);
$data = $record->getSlackData($this->getRecord(Logger::WARNING, $message));
$this->assertArrayHasKey('text', $data);
$this->assertSame($message . 'test1', $data['text']);
}
public function testAddsFallbackAndTextToAttachment()