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

Changed the tests for the abstract handlers to use a mock instead of the TestHandler

This commit is contained in:
Christophe Coevoet
2011-08-29 15:00:42 +02:00
parent 10e5ecd409
commit 8c094aa3b3
2 changed files with 31 additions and 14 deletions

View File

@@ -22,7 +22,7 @@ class AbstractProcessingHandlerTest extends TestCase
*/
public function testHandleLowerLevelMessage()
{
$handler = new TestHandler(Logger::WARNING, true);
$handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractProcessingHandler', array(Logger::WARNING, true));
$this->assertFalse($handler->handle($this->getRecord(Logger::DEBUG)));
}
@@ -31,7 +31,7 @@ class AbstractProcessingHandlerTest extends TestCase
*/
public function testHandleBubbling()
{
$handler = new TestHandler(Logger::DEBUG, true);
$handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractProcessingHandler', array(Logger::DEBUG, true));
$this->assertFalse($handler->handle($this->getRecord()));
}
@@ -40,7 +40,7 @@ class AbstractProcessingHandlerTest extends TestCase
*/
public function testHandleNotBubbling()
{
$handler = new TestHandler(Logger::DEBUG, false);
$handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractProcessingHandler', array(Logger::DEBUG, false));
$this->assertTrue($handler->handle($this->getRecord()));
}
@@ -49,7 +49,7 @@ class AbstractProcessingHandlerTest extends TestCase
*/
public function testHandleIsFalseWhenNotHandled()
{
$handler = new TestHandler(Logger::WARNING, false);
$handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractProcessingHandler', array(Logger::WARNING, false));
$this->assertTrue($handler->handle($this->getRecord()));
$this->assertFalse($handler->handle($this->getRecord(Logger::DEBUG)));
}
@@ -59,14 +59,20 @@ class AbstractProcessingHandlerTest extends TestCase
*/
public function testProcessRecord()
{
$handler = new TestHandler();
$handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractProcessingHandler');
$handler->pushProcessor(new WebProcessor(array(
'REQUEST_URI' => '',
'REQUEST_METHOD' => '',
'REMOTE_ADDR' => '',
)));
$handledRecord = null;
$handler->expects($this->once())
->method('write')
->will($this->returnCallback(function($record) use (&$handledRecord){
$handledRecord = $record;
}))
;
$handler->handle($this->getRecord());
list($record) = $handler->getRecords();
$this->assertEquals(3, count($record['extra']));
$this->assertEquals(3, count($handledRecord['extra']));
}
}