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

Add ability to use formatter in email subject lines

This commit is contained in:
Jordi Boggiano
2016-04-12 18:05:41 +01:00
parent 1fa91efc3b
commit a754edc64c
5 changed files with 63 additions and 1 deletions

View File

@@ -96,4 +96,16 @@ class NativeMailerHandlerTest extends TestCase
$this->assertSame("From: $from\r\nContent-type: text/plain; charset=utf-8\r\n", $params[3]);
$this->assertSame('', $params[4]);
}
public function testMessageSubjectFormatting()
{
$mailer = new NativeMailerHandler('to@example.org', 'Alert: %level_name% %message%', 'from@example.org');
$mailer->handle($this->getRecord(Logger::ERROR, "Foo\nBar\r\n\r\nBaz"));
$this->assertNotEmpty($GLOBALS['mail']);
$this->assertInternalType('array', $GLOBALS['mail']);
$this->assertArrayHasKey('0', $GLOBALS['mail']);
$params = $GLOBALS['mail'][0];
$this->assertCount(5, $params);
$this->assertSame('Alert: ERROR Foo Bar Baz', $params[1]);
}
}