summaryrefslogtreecommitdiffstats
path: root/tests/Monolog/Formatter/GelfMessageFormatterTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Monolog/Formatter/GelfMessageFormatterTest.php')
-rw-r--r--tests/Monolog/Formatter/GelfMessageFormatterTest.php78
1 files changed, 39 insertions, 39 deletions
diff --git a/tests/Monolog/Formatter/GelfMessageFormatterTest.php b/tests/Monolog/Formatter/GelfMessageFormatterTest.php
index 4a24761..39eeaf7 100644
--- a/tests/Monolog/Formatter/GelfMessageFormatterTest.php
+++ b/tests/Monolog/Formatter/GelfMessageFormatterTest.php
@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
/*
* This file is part of the Monolog package.
@@ -13,12 +13,12 @@ namespace Monolog\Formatter;
use Monolog\Logger;
-class GelfMessageFormatterTest extends \PHPUnit_Framework_TestCase
+class GelfMessageFormatterTest extends \PHPUnit\Framework\TestCase
{
public function setUp()
{
if (!class_exists('\Gelf\Message')) {
- $this->markTestSkipped("graylog2/gelf-php or mlehner/gelf-php is not installed");
+ $this->markTestSkipped("graylog2/gelf-php is not installed");
}
}
@@ -28,15 +28,15 @@ class GelfMessageFormatterTest extends \PHPUnit_Framework_TestCase
public function testDefaultFormatter()
{
$formatter = new GelfMessageFormatter();
- $record = array(
+ $record = [
'level' => Logger::ERROR,
'level_name' => 'ERROR',
'channel' => 'meh',
- 'context' => array(),
- 'datetime' => new \DateTime("@0"),
- 'extra' => array(),
+ 'context' => [],
+ 'datetime' => new \DateTimeImmutable("@0"),
+ 'extra' => [],
'message' => 'log',
- );
+ ];
$message = $formatter->format($record);
@@ -63,15 +63,15 @@ class GelfMessageFormatterTest extends \PHPUnit_Framework_TestCase
public function testFormatWithFileAndLine()
{
$formatter = new GelfMessageFormatter();
- $record = array(
+ $record = [
'level' => Logger::ERROR,
'level_name' => 'ERROR',
'channel' => 'meh',
- 'context' => array('from' => 'logger'),
- 'datetime' => new \DateTime("@0"),
- 'extra' => array('file' => 'test', 'line' => 14),
+ 'context' => ['from' => 'logger'],
+ 'datetime' => new \DateTimeImmutable("@0"),
+ 'extra' => ['file' => 'test', 'line' => 14],
'message' => 'log',
- );
+ ];
$message = $formatter->format($record);
@@ -87,10 +87,10 @@ class GelfMessageFormatterTest extends \PHPUnit_Framework_TestCase
public function testFormatInvalidFails()
{
$formatter = new GelfMessageFormatter();
- $record = array(
+ $record = [
'level' => Logger::ERROR,
'level_name' => 'ERROR',
- );
+ ];
$formatter->format($record);
}
@@ -101,15 +101,15 @@ class GelfMessageFormatterTest extends \PHPUnit_Framework_TestCase
public function testFormatWithContext()
{
$formatter = new GelfMessageFormatter();
- $record = array(
+ $record = [
'level' => Logger::ERROR,
'level_name' => 'ERROR',
'channel' => 'meh',
- 'context' => array('from' => 'logger'),
- 'datetime' => new \DateTime("@0"),
- 'extra' => array('key' => 'pair'),
+ 'context' => ['from' => 'logger'],
+ 'datetime' => new \DateTimeImmutable("@0"),
+ 'extra' => ['key' => 'pair'],
'message' => 'log',
- );
+ ];
$message = $formatter->format($record);
@@ -138,19 +138,19 @@ class GelfMessageFormatterTest extends \PHPUnit_Framework_TestCase
public function testFormatWithContextContainingException()
{
$formatter = new GelfMessageFormatter();
- $record = array(
+ $record = [
'level' => Logger::ERROR,
'level_name' => 'ERROR',
'channel' => 'meh',
- 'context' => array('from' => 'logger', 'exception' => array(
+ 'context' => ['from' => 'logger', 'exception' => [
'class' => '\Exception',
'file' => '/some/file/in/dir.php:56',
- 'trace' => array('/some/file/1.php:23', '/some/file/2.php:3'),
- )),
- 'datetime' => new \DateTime("@0"),
- 'extra' => array(),
+ 'trace' => ['/some/file/1.php:23', '/some/file/2.php:3'],
+ ]],
+ 'datetime' => new \DateTimeImmutable("@0"),
+ 'extra' => [],
'message' => 'log',
- );
+ ];
$message = $formatter->format($record);
@@ -166,15 +166,15 @@ class GelfMessageFormatterTest extends \PHPUnit_Framework_TestCase
public function testFormatWithExtra()
{
$formatter = new GelfMessageFormatter();
- $record = array(
+ $record = [
'level' => Logger::ERROR,
'level_name' => 'ERROR',
'channel' => 'meh',
- 'context' => array('from' => 'logger'),
- 'datetime' => new \DateTime("@0"),
- 'extra' => array('key' => 'pair'),
+ 'context' => ['from' => 'logger'],
+ 'datetime' => new \DateTimeImmutable("@0"),
+ 'extra' => ['key' => 'pair'],
'message' => 'log',
- );
+ ];
$message = $formatter->format($record);
@@ -200,15 +200,15 @@ class GelfMessageFormatterTest extends \PHPUnit_Framework_TestCase
public function testFormatWithLargeData()
{
$formatter = new GelfMessageFormatter();
- $record = array(
+ $record = [
'level' => Logger::ERROR,
'level_name' => 'ERROR',
'channel' => 'meh',
- 'context' => array('exception' => str_repeat(' ', 32767)),
- 'datetime' => new \DateTime("@0"),
- 'extra' => array('key' => str_repeat(' ', 32767)),
- 'message' => 'log'
- );
+ 'context' => ['exception' => str_repeat(' ', 32767)],
+ 'datetime' => new \DateTimeImmutable("@0"),
+ 'extra' => ['key' => str_repeat(' ', 32767)],
+ 'message' => 'log',
+ ];
$message = $formatter->format($record);
$messageArray = $message->toArray();
@@ -216,7 +216,7 @@ class GelfMessageFormatterTest extends \PHPUnit_Framework_TestCase
$length = 200;
foreach ($messageArray as $key => $value) {
- if (!in_array($key, array('level', 'timestamp'))) {
+ if (!in_array($key, ['level', 'timestamp']) && is_string($value)) {
$length += strlen($value);
}
}