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:
committed by
Haralan Dobrev
parent
01a2ac25a2
commit
08b577c657
@@ -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()
|
||||
|
Reference in New Issue
Block a user