1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-02-24 15:02:28 +01:00
php-monolog/tests/Monolog/Handler/TestHandlerTest.php
Frederic G. MARAND 07aac12c72 Implement the 8 RFC3164 severity levels instead of just 6.
- constants defined for the 2 missing levels: NOTICE and EMERGENCY.
- add<level>() and <level>() convenience methods added.
- TestHandler and tests updated to account for the two extra levels.
- surjective mappings from the RFC3164 to only 6 levels changes to bijective.
- README updated accordingly.
2012-05-28 20:29:27 +02:00

57 lines
1.6 KiB
PHP

<?php
/*
* This file is part of the Monolog package.
*
* (c) Jordi Boggiano <j.boggiano@seld.be>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Monolog\Handler;
use Monolog\TestCase;
use Monolog\Logger;
/**
* @covers Monolog\Handler\TestHandler
*/
class TestHandlerTest extends TestCase
{
/**
* @dataProvider methodProvider
*/
public function testHandler($method, $level)
{
$handler = new TestHandler;
$record = $this->getRecord($level, 'test'.$method);
$this->assertFalse($handler->{'has'.$method}($record));
$this->assertFalse($handler->{'has'.$method.'Records'}());
$handler->handle($record);
$this->assertFalse($handler->{'has'.$method}('bar'));
$this->assertTrue($handler->{'has'.$method}($record));
$this->assertTrue($handler->{'has'.$method}('test'.$method));
$this->assertTrue($handler->{'has'.$method.'Records'}());
$records = $handler->getRecords();
unset($records[0]['formatted']);
$this->assertEquals(array($record), $records);
}
public function methodProvider()
{
return array(
array('Emergency', Logger::EMERGENCY),
array('Alert' , Logger::ALERT),
array('Critical' , Logger::CRITICAL),
array('Error' , Logger::ERROR),
array('Warning' , Logger::WARNING),
array('Info' , Logger::INFO),
array('Notice' , Logger::NOTICE),
array('Debug' , Logger::DEBUG),
);
}
}