25 ->getMockBuilder(
'Swift_Mailer')
26 ->disableOriginalConstructor()
32 $this->mailer->expects($this->never())
35 $callback =
function () {
36 throw new \RuntimeException(
'Swift_Message creation callback should not have been called in this test');
50 $expectedMessage = new \Swift_Message();
51 $this->mailer->expects($this->once())
53 ->with($this->callback(
function ($value) use ($expectedMessage) {
54 return $value instanceof \Swift_Message
55 && $value->getSubject() ===
'Emergency' 56 && $value === $expectedMessage;
60 $callback =
function ($content,
array $records) use ($expectedMessage) {
61 $subject = count(
$records) > 0 ?
'Emergency' :
'Normal';
62 $expectedMessage->setSubject($subject);
64 return $expectedMessage;
78 $messageTemplate = new \Swift_Message();
79 $messageTemplate->setSubject(
'Alert: %level_name% %message%');
80 $receivedMessage = null;
82 $this->mailer->expects($this->once())
84 ->with($this->callback(
function ($value) use (&$receivedMessage) {
85 $receivedMessage = $value;
96 $this->assertEquals(
'Alert: EMERGENCY test', $receivedMessage->getSubject());
101 $messageTemplate = \Swift_Message::newInstance();
104 $method = new \ReflectionMethod(
'Monolog\Handler\SwiftMailerHandler',
'buildMessage');
105 $method->setAccessible(
true);
106 $method->invokeArgs($handler,
array($messageTemplate,
array()));
108 $builtMessage1 = $method->invoke($handler, $messageTemplate,
array());
109 $builtMessage2 = $method->invoke($handler, $messageTemplate,
array());
111 $this->assertFalse($builtMessage1->getId() === $builtMessage2->getId(),
'Two different messages have the same id');
const DEBUG
Detailed debug information.
testMessageCreationIsLazyWhenUsingCallback()
testMessageCanBeCustomizedGivenLoggedData()
getRecord($level=Logger::WARNING, $message='test', $context=array())
testMessageSubjectFormatting()
testMessageHaveUniqueId()
const EMERGENCY
Urgent alert.
Create styles array
The data for the language used.
SwiftMailerHandler uses Swift_Mailer to send the emails.
const INFO
Interesting events.