SwiftMailerHandlerTest.php 954 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. namespace Monolog\Handler;
  3. use Monolog\Logger;
  4. use Monolog\TestCase;
  5. class SwiftMailerHandlerTest extends TestCase
  6. {
  7. /** @var \Swift_Mailer|\PHPUnit_Framework_MockObject_MockObject */
  8. private $mailer;
  9. public function setUp()
  10. {
  11. $this->mailer = $this
  12. ->getMockBuilder('Swift_Mailer')
  13. ->disableOriginalConstructor()
  14. ->getMock();
  15. }
  16. public function testMessageCreationIsLazyWhenUsingCallback()
  17. {
  18. $this->mailer->expects($this->never())
  19. ->method('send');
  20. $callback = function () {
  21. throw new \RuntimeException('Swift_Message creation callback should not have been called in this test');
  22. };
  23. $handler = new SwiftMailerHandler($this->mailer, $callback);
  24. $records = [
  25. $this->getRecord(Logger::DEBUG),
  26. $this->getRecord(Logger::INFO),
  27. ];
  28. $handler->handleBatch($records);
  29. }
  30. }