mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-11 23:54:04 +02:00
Added an abstract MailHandler class
This commit is contained in:
42
tests/Monolog/Handler/MailHandlerTest.php
Normal file
42
tests/Monolog/Handler/MailHandlerTest.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace Monolog\Handler;
|
||||
|
||||
use Monolog\Logger;
|
||||
|
||||
use Monolog\TestCase;
|
||||
|
||||
class MailHandlerTest extends TestCase
|
||||
{
|
||||
|
||||
public function testHandleBatch()
|
||||
{
|
||||
$records = $this->getMultipleRecords();
|
||||
|
||||
$formatter = $this->getMock('Monolog\Formatter\LineFormatter');
|
||||
$formatter->expects($this->exactly(count($records)))
|
||||
->method('format'); // Each record is formatted
|
||||
|
||||
$handler = $this->getMockForAbstractClass('Monolog\\Handler\\MailHandler');
|
||||
$handler->expects($this->once())
|
||||
->method('send');
|
||||
$handler->expects($this->never())
|
||||
->method('write'); // write is for individual records
|
||||
|
||||
$handler->setFormatter($formatter);
|
||||
|
||||
$handler->handleBatch($records);
|
||||
}
|
||||
|
||||
public function testHandle()
|
||||
{
|
||||
$record = $this->getRecord();
|
||||
|
||||
$handler = $this->getMockForAbstractClass('Monolog\\Handler\\MailHandler');
|
||||
$handler->expects($this->once())
|
||||
->method('write');
|
||||
|
||||
$this->assertTrue($handler->handle($record));
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user