mirror of
https://github.com/Seldaek/monolog.git
synced 2025-07-30 18:00:17 +02:00
Refactored ErrorLogHandler to use constantes for types
- Create tests for ErrorLogHandler; - Remove types 1, 2 and 3 in favor of specific handlers.
This commit is contained in:
43
tests/Monolog/Handler/ErrorLogHandlerTest.php
Normal file
43
tests/Monolog/Handler/ErrorLogHandlerTest.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace Monolog\Handler;
|
||||
|
||||
use Monolog\TestCase;
|
||||
use Monolog\Logger;
|
||||
|
||||
function error_log()
|
||||
{
|
||||
$GLOBALS['error_log'] = func_get_args();
|
||||
}
|
||||
|
||||
class ErrorLogHandlerTest extends TestCase
|
||||
{
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$GLOBALS['error_log'] = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Monolog\Handler\ErrorLogHandler::__construct
|
||||
* @expectedException InvalidArgumentException
|
||||
* @expectedExceptionMessage The given message type "42" is not supported
|
||||
*/
|
||||
public function testShouldNotAcceptAnInvalidTypeOnContructor()
|
||||
{
|
||||
new ErrorLogHandler(42);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Monolog\Handler\ErrorLogHandler::write
|
||||
*/
|
||||
public function testShouldLogMessagesUsingErrorLogFuncion()
|
||||
{
|
||||
$type = ErrorLogHandler::OPERATING_SYSTEM;
|
||||
$handler = new ErrorLogHandler($type);
|
||||
$handler->handle($this->getRecord(Logger::ERROR));
|
||||
|
||||
$this->assertStringMatchesFormat('[%s] test.ERROR: test [] []', $GLOBALS['error_log'][0]);
|
||||
$this->assertSame($GLOBALS['error_log'][1], $type);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user