MailHandlerTest.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. /*
  3. * This file is part of the Monolog package.
  4. *
  5. * (c) Jordi Boggiano <j.boggiano@seld.be>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Monolog\Handler;
  11. use Monolog\Logger;
  12. use Monolog\TestCase;
  13. class MailHandlerTest extends TestCase
  14. {
  15. public function testHandleBatch()
  16. {
  17. $records = $this->getMultipleRecords();
  18. $formatter = $this->getMock('Monolog\Formatter\LineFormatter');
  19. $formatter->expects($this->exactly(count($records)))
  20. ->method('format'); // Each record is formatted
  21. $handler = $this->getMockForAbstractClass('Monolog\\Handler\\MailHandler');
  22. $handler->expects($this->once())
  23. ->method('send');
  24. $handler->expects($this->never())
  25. ->method('write'); // write is for individual records
  26. $handler->setFormatter($formatter);
  27. $handler->handleBatch($records);
  28. }
  29. public function testHandle()
  30. {
  31. $record = $this->getRecord();
  32. $handler = $this->getMockForAbstractClass('Monolog\\Handler\\MailHandler');
  33. $handler->expects($this->once())
  34. ->method('send');
  35. $handler->handle($record);
  36. }
  37. }