1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-08-16 10:04:14 +02:00
This commit is contained in:
Jordi Boggiano
2016-05-26 20:54:06 +01:00
parent 85e43a5e7b
commit f200e79879
115 changed files with 1138 additions and 1123 deletions

View File

@@ -66,10 +66,10 @@ class IntrospectionProcessorTest extends TestCase
public function testLevelTooLow()
{
$input = array(
$input = [
'level' => Logger::DEBUG,
'extra' => array(),
);
'extra' => [],
];
$expected = $input;
@@ -81,18 +81,18 @@ class IntrospectionProcessorTest extends TestCase
public function testLevelEqual()
{
$input = array(
$input = [
'level' => Logger::CRITICAL,
'extra' => array(),
);
'extra' => [],
];
$expected = $input;
$expected['extra'] = array(
$expected['extra'] = [
'file' => null,
'line' => null,
'class' => 'ReflectionMethod',
'function' => 'invokeArgs',
);
];
$processor = new IntrospectionProcessor(Logger::CRITICAL);
$actual = $processor($input);
@@ -102,18 +102,18 @@ class IntrospectionProcessorTest extends TestCase
public function testLevelHigher()
{
$input = array(
$input = [
'level' => Logger::EMERGENCY,
'extra' => array(),
);
'extra' => [],
];
$expected = $input;
$expected['extra'] = array(
$expected['extra'] = [
'file' => null,
'line' => null,
'class' => 'ReflectionMethod',
'function' => 'invokeArgs',
);
];
$processor = new IntrospectionProcessor(Logger::CRITICAL);
$actual = $processor($input);

View File

@@ -20,24 +20,24 @@ class PsrLogMessageProcessorTest extends \PHPUnit_Framework_TestCase
{
$proc = new PsrLogMessageProcessor;
$message = $proc(array(
$message = $proc([
'message' => '{foo}',
'context' => array('foo' => $val),
));
'context' => ['foo' => $val],
]);
$this->assertEquals($expected, $message['message']);
}
public function getPairs()
{
return array(
array('foo', 'foo'),
array('3', '3'),
array(3, '3'),
array(null, ''),
array(true, '1'),
array(false, ''),
array(new \stdClass, '[object stdClass]'),
array(array(), '[array]'),
);
return [
['foo', 'foo'],
['3', '3'],
[3, '3'],
[null, ''],
[true, '1'],
[false, ''],
[new \stdClass, '[object stdClass]'],
[[], '[array]'],
];
}
}

View File

@@ -20,7 +20,7 @@ class TagProcessorTest extends TestCase
*/
public function testProcessor()
{
$tags = array(1, 2, 3);
$tags = [1, 2, 3];
$processor = new TagProcessor($tags);
$record = $processor($this->getRecord());
@@ -32,18 +32,18 @@ class TagProcessorTest extends TestCase
*/
public function testProcessorTagModification()
{
$tags = array(1, 2, 3);
$tags = [1, 2, 3];
$processor = new TagProcessor($tags);
$record = $processor($this->getRecord());
$this->assertEquals($tags, $record['extra']['tags']);
$processor->setTags(array('a', 'b'));
$processor->setTags(['a', 'b']);
$record = $processor($this->getRecord());
$this->assertEquals(array('a', 'b'), $record['extra']['tags']);
$this->assertEquals(['a', 'b'], $record['extra']['tags']);
$processor->addTags(array('a', 'c', 'foo' => 'bar'));
$processor->addTags(['a', 'c', 'foo' => 'bar']);
$record = $processor($this->getRecord());
$this->assertEquals(array('a', 'b', 'a', 'c', 'foo' => 'bar'), $record['extra']['tags']);
$this->assertEquals(['a', 'b', 'a', 'c', 'foo' => 'bar'], $record['extra']['tags']);
}
}

View File

@@ -17,14 +17,14 @@ class WebProcessorTest extends TestCase
{
public function testProcessor()
{
$server = array(
$server = [
'REQUEST_URI' => 'A',
'REMOTE_ADDR' => 'B',
'REQUEST_METHOD' => 'C',
'HTTP_REFERER' => 'D',
'SERVER_NAME' => 'F',
'UNIQUE_ID' => 'G',
);
];
$processor = new WebProcessor($server);
$record = $processor($this->getRecord());
@@ -38,10 +38,10 @@ class WebProcessorTest extends TestCase
public function testProcessorDoNothingIfNoRequestUri()
{
$server = array(
$server = [
'REMOTE_ADDR' => 'B',
'REQUEST_METHOD' => 'C',
);
];
$processor = new WebProcessor($server);
$record = $processor($this->getRecord());
$this->assertEmpty($record['extra']);
@@ -49,12 +49,12 @@ class WebProcessorTest extends TestCase
public function testProcessorReturnNullIfNoHttpReferer()
{
$server = array(
$server = [
'REQUEST_URI' => 'A',
'REMOTE_ADDR' => 'B',
'REQUEST_METHOD' => 'C',
'SERVER_NAME' => 'F',
);
];
$processor = new WebProcessor($server);
$record = $processor($this->getRecord());
$this->assertNull($record['extra']['referrer']);
@@ -62,12 +62,12 @@ class WebProcessorTest extends TestCase
public function testProcessorDoesNotAddUniqueIdIfNotPresent()
{
$server = array(
$server = [
'REQUEST_URI' => 'A',
'REMOTE_ADDR' => 'B',
'REQUEST_METHOD' => 'C',
'SERVER_NAME' => 'F',
);
];
$processor = new WebProcessor($server);
$record = $processor($this->getRecord());
$this->assertFalse(isset($record['extra']['unique_id']));
@@ -75,32 +75,32 @@ class WebProcessorTest extends TestCase
public function testProcessorAddsOnlyRequestedExtraFields()
{
$server = array(
$server = [
'REQUEST_URI' => 'A',
'REMOTE_ADDR' => 'B',
'REQUEST_METHOD' => 'C',
'SERVER_NAME' => 'F',
);
];
$processor = new WebProcessor($server, array('url', 'http_method'));
$processor = new WebProcessor($server, ['url', 'http_method']);
$record = $processor($this->getRecord());
$this->assertSame(array('url' => 'A', 'http_method' => 'C'), $record['extra']);
$this->assertSame(['url' => 'A', 'http_method' => 'C'], $record['extra']);
}
public function testProcessorConfiguringOfExtraFields()
{
$server = array(
$server = [
'REQUEST_URI' => 'A',
'REMOTE_ADDR' => 'B',
'REQUEST_METHOD' => 'C',
'SERVER_NAME' => 'F',
);
];
$processor = new WebProcessor($server, array('url' => 'REMOTE_ADDR'));
$processor = new WebProcessor($server, ['url' => 'REMOTE_ADDR']);
$record = $processor($this->getRecord());
$this->assertSame(array('url' => 'B'), $record['extra']);
$this->assertSame(['url' => 'B'], $record['extra']);
}
/**