mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-30 08:21:05 +02:00
Merge remote-tracking branch 'upstream/master' into couchdb
This commit is contained in:
@@ -86,11 +86,8 @@ class LineFormatterTest extends \PHPUnit_Framework_TestCase
|
||||
'extra' => array('foo' => new TestFoo, 'bar' => new TestBar, 'baz' => array(), 'res' => fopen('php://memory', 'rb')),
|
||||
'message' => 'foobar',
|
||||
));
|
||||
if (version_compare(PHP_VERSION, '5.4.0', '>=')) {
|
||||
$this->assertEquals('['.date('Y-m-d').'] meh.ERROR: foobar [] {"foo":"[object] (Monolog\\\\Formatter\\\\TestFoo: {\\"foo\\":\\"foo\\"})","bar":"[object] (Monolog\\\\Formatter\\\\TestBar: {})","baz":[],"res":"[resource]"}'."\n", $message);
|
||||
} else {
|
||||
$this->assertEquals('['.date('Y-m-d').'] meh.ERROR: foobar [] {"foo":"[object] (Monolog\\Formatter\\TestFoo: {"foo":"foo"})","bar":"[object] (Monolog\\Formatter\\TestBar: {})","baz":[],"res":"[resource]"}'."\n", $message);
|
||||
}
|
||||
|
||||
$this->assertEquals('['.date('Y-m-d').'] meh.ERROR: foobar [] {"foo":"[object] (Monolog\\\\Formatter\\\\TestFoo: {\\"foo\\":\\"foo\\"})","bar":"[object] (Monolog\\\\Formatter\\\\TestBar: {})","baz":[],"res":"[resource]"}'."\n", $message);
|
||||
}
|
||||
|
||||
public function testBatchFormat()
|
||||
|
@@ -36,6 +36,7 @@ class BufferHandlerTest extends TestCase
|
||||
|
||||
/**
|
||||
* @covers Monolog\Handler\BufferHandler::close
|
||||
* @covers Monolog\Handler\BufferHandler::flush
|
||||
*/
|
||||
public function testDestructPropagatesRecords()
|
||||
{
|
||||
@@ -65,6 +66,36 @@ class BufferHandlerTest extends TestCase
|
||||
$this->assertFalse($test->hasDebugRecords());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Monolog\Handler\BufferHandler::handle
|
||||
*/
|
||||
public function testHandleBufferLimitWithFlushOnOverflow()
|
||||
{
|
||||
$test = new TestHandler();
|
||||
$handler = new BufferHandler($test, 3, Logger::DEBUG, true, true);
|
||||
|
||||
// send two records
|
||||
$handler->handle($this->getRecord(Logger::DEBUG));
|
||||
$handler->handle($this->getRecord(Logger::DEBUG));
|
||||
$handler->handle($this->getRecord(Logger::DEBUG));
|
||||
$this->assertFalse($test->hasDebugRecords());
|
||||
$this->assertCount(0, $test->getRecords());
|
||||
|
||||
// overflow
|
||||
$handler->handle($this->getRecord(Logger::INFO));
|
||||
$this->assertTrue($test->hasDebugRecords());
|
||||
$this->assertCount(3, $test->getRecords());
|
||||
|
||||
// should buffer again
|
||||
$handler->handle($this->getRecord(Logger::WARNING));
|
||||
$this->assertCount(3, $test->getRecords());
|
||||
|
||||
$handler->close();
|
||||
$this->assertCount(5, $test->getRecords());
|
||||
$this->assertTrue($test->hasWarningRecords());
|
||||
$this->assertTrue($test->hasInfoRecords());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Monolog\Handler\BufferHandler::handle
|
||||
*/
|
||||
@@ -81,4 +112,19 @@ class BufferHandlerTest extends TestCase
|
||||
$this->assertTrue($test->hasInfoRecords());
|
||||
$this->assertFalse($test->hasDebugRecords());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Monolog\Handler\BufferHandler::flush
|
||||
*/
|
||||
public function testFlush()
|
||||
{
|
||||
$test = new TestHandler();
|
||||
$handler = new BufferHandler($test, 0);
|
||||
$handler->handle($this->getRecord(Logger::DEBUG));
|
||||
$handler->handle($this->getRecord(Logger::INFO));
|
||||
$handler->flush();
|
||||
$this->assertTrue($test->hasInfoRecords());
|
||||
$this->assertTrue($test->hasDebugRecords());
|
||||
$this->assertFalse($test->hasWarningRecords());
|
||||
}
|
||||
}
|
||||
|
@@ -10,6 +10,7 @@
|
||||
*/
|
||||
|
||||
namespace Monolog\Handler;
|
||||
use Monolog\Logger;
|
||||
|
||||
class SyslogHandlerTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
@@ -26,6 +27,9 @@ class SyslogHandlerTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$handler = new SyslogHandler('test', 'user');
|
||||
$this->assertInstanceOf('Monolog\Handler\SyslogHandler', $handler);
|
||||
|
||||
$handler = new SyslogHandler('test', LOG_USER, Logger::DEBUG, true, LOG_PERROR);
|
||||
$this->assertInstanceOf('Monolog\Handler\SyslogHandler', $handler);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -25,6 +25,23 @@ class LoggerTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals('foo', $logger->getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Monolog\Logger::getLevelName
|
||||
*/
|
||||
public function testGetLevelName()
|
||||
{
|
||||
$this->assertEquals('ERROR', Logger::getLevelName(Logger::ERROR));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Monolog\Logger::getLevelName
|
||||
* @expectedException InvalidArgumentException
|
||||
*/
|
||||
public function testGetLevelNameThrows()
|
||||
{
|
||||
Logger::getLevelName(5);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Monolog\Logger::__construct
|
||||
*/
|
||||
|
Reference in New Issue
Block a user