diff options
Diffstat (limited to 'tests/Monolog/Processor')
-rw-r--r-- | tests/Monolog/Processor/GitProcessorTest.php | 4 | ||||
-rw-r--r-- | tests/Monolog/Processor/IntrospectionProcessorTest.php | 30 | ||||
-rw-r--r-- | tests/Monolog/Processor/MemoryPeakUsageProcessorTest.php | 4 | ||||
-rw-r--r-- | tests/Monolog/Processor/MemoryUsageProcessorTest.php | 4 | ||||
-rw-r--r-- | tests/Monolog/Processor/MercurialProcessorTest.php | 7 | ||||
-rw-r--r-- | tests/Monolog/Processor/ProcessIdProcessorTest.php | 4 | ||||
-rw-r--r-- | tests/Monolog/Processor/PsrLogMessageProcessorTest.php | 47 | ||||
-rw-r--r-- | tests/Monolog/Processor/TagProcessorTest.php | 16 | ||||
-rw-r--r-- | tests/Monolog/Processor/UidProcessorTest.php | 4 | ||||
-rw-r--r-- | tests/Monolog/Processor/WebProcessorTest.php | 36 |
10 files changed, 87 insertions, 69 deletions
diff --git a/tests/Monolog/Processor/GitProcessorTest.php b/tests/Monolog/Processor/GitProcessorTest.php index 5adb505..0059e6d 100644 --- a/tests/Monolog/Processor/GitProcessorTest.php +++ b/tests/Monolog/Processor/GitProcessorTest.php @@ -1,4 +1,4 @@ -<?php +<?php declare(strict_types=1); /* * This file is part of the Monolog package. @@ -11,7 +11,7 @@ namespace Monolog\Processor; -use Monolog\TestCase; +use Monolog\Test\TestCase; class GitProcessorTest extends TestCase { diff --git a/tests/Monolog/Processor/IntrospectionProcessorTest.php b/tests/Monolog/Processor/IntrospectionProcessorTest.php index 0dd411d..5f5d9ae 100644 --- a/tests/Monolog/Processor/IntrospectionProcessorTest.php +++ b/tests/Monolog/Processor/IntrospectionProcessorTest.php @@ -1,4 +1,4 @@ -<?php +<?php declare(strict_types=1); /* * This file is part of the Monolog package. @@ -27,7 +27,7 @@ function tester($handler, $record) namespace Monolog\Processor; use Monolog\Logger; -use Monolog\TestCase; +use Monolog\Test\TestCase; use Monolog\Handler\TestHandler; class IntrospectionProcessorTest extends TestCase @@ -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); diff --git a/tests/Monolog/Processor/MemoryPeakUsageProcessorTest.php b/tests/Monolog/Processor/MemoryPeakUsageProcessorTest.php index eb66614..cd80527 100644 --- a/tests/Monolog/Processor/MemoryPeakUsageProcessorTest.php +++ b/tests/Monolog/Processor/MemoryPeakUsageProcessorTest.php @@ -1,4 +1,4 @@ -<?php +<?php declare(strict_types=1); /* * This file is part of the Monolog package. @@ -11,7 +11,7 @@ namespace Monolog\Processor; -use Monolog\TestCase; +use Monolog\Test\TestCase; class MemoryPeakUsageProcessorTest extends TestCase { diff --git a/tests/Monolog/Processor/MemoryUsageProcessorTest.php b/tests/Monolog/Processor/MemoryUsageProcessorTest.php index 4692dbf..a4809cb 100644 --- a/tests/Monolog/Processor/MemoryUsageProcessorTest.php +++ b/tests/Monolog/Processor/MemoryUsageProcessorTest.php @@ -1,4 +1,4 @@ -<?php +<?php declare(strict_types=1); /* * This file is part of the Monolog package. @@ -11,7 +11,7 @@ namespace Monolog\Processor; -use Monolog\TestCase; +use Monolog\Test\TestCase; class MemoryUsageProcessorTest extends TestCase { diff --git a/tests/Monolog/Processor/MercurialProcessorTest.php b/tests/Monolog/Processor/MercurialProcessorTest.php index 11f2b35..9028e41 100644 --- a/tests/Monolog/Processor/MercurialProcessorTest.php +++ b/tests/Monolog/Processor/MercurialProcessorTest.php @@ -1,9 +1,9 @@ -<?php +<?php declare(strict_types=1); /* * This file is part of the Monolog package. * - * (c) Jonathan A. Schweder <jonathanschweder@gmail.com> + * (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. @@ -11,7 +11,7 @@ namespace Monolog\Processor; -use Monolog\TestCase; +use Monolog\Test\TestCase; class MercurialProcessorTest extends TestCase { @@ -27,6 +27,7 @@ class MercurialProcessorTest extends TestCase } if ($result != 0) { $this->markTestSkipped('hg is missing'); + return; } diff --git a/tests/Monolog/Processor/ProcessIdProcessorTest.php b/tests/Monolog/Processor/ProcessIdProcessorTest.php index 458d2a3..ec39e8e 100644 --- a/tests/Monolog/Processor/ProcessIdProcessorTest.php +++ b/tests/Monolog/Processor/ProcessIdProcessorTest.php @@ -1,4 +1,4 @@ -<?php +<?php declare(strict_types=1); /* * This file is part of the Monolog package. @@ -11,7 +11,7 @@ namespace Monolog\Processor; -use Monolog\TestCase; +use Monolog\Test\TestCase; class ProcessIdProcessorTest extends TestCase { diff --git a/tests/Monolog/Processor/PsrLogMessageProcessorTest.php b/tests/Monolog/Processor/PsrLogMessageProcessorTest.php index 029a0c0..5071d89 100644 --- a/tests/Monolog/Processor/PsrLogMessageProcessorTest.php +++ b/tests/Monolog/Processor/PsrLogMessageProcessorTest.php @@ -1,4 +1,4 @@ -<?php +<?php declare(strict_types=1); /* * This file is part of the Monolog package. @@ -11,7 +11,7 @@ namespace Monolog\Processor; -class PsrLogMessageProcessorTest extends \PHPUnit_Framework_TestCase +class PsrLogMessageProcessorTest extends \PHPUnit\Framework\TestCase { /** * @dataProvider getPairs @@ -20,24 +20,41 @@ 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 testCustomDateFormat() + { + $format = "Y-m-d"; + $date = new \DateTime(); + + $proc = new PsrLogMessageProcessor($format); + + $message = $proc([ + 'message' => '{foo}', + 'context' => ['foo' => $date], + ]); + $this->assertEquals($date->format($format), $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]'), - ); + $date = new \DateTime(); + + return [ + ['foo', 'foo'], + ['3', '3'], + [3, '3'], + [null, ''], + [true, '1'], + [false, ''], + [$date, $date->format(PsrLogMessageProcessor::SIMPLE_DATE)], + [new \stdClass, '[object stdClass]'], + [[], '[array]'], + ]; } } diff --git a/tests/Monolog/Processor/TagProcessorTest.php b/tests/Monolog/Processor/TagProcessorTest.php index 0d860c6..da84378 100644 --- a/tests/Monolog/Processor/TagProcessorTest.php +++ b/tests/Monolog/Processor/TagProcessorTest.php @@ -1,4 +1,4 @@ -<?php +<?php declare(strict_types=1); /* * This file is part of the Monolog package. @@ -11,7 +11,7 @@ namespace Monolog\Processor; -use Monolog\TestCase; +use Monolog\Test\TestCase; class TagProcessorTest extends TestCase { @@ -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']); } } diff --git a/tests/Monolog/Processor/UidProcessorTest.php b/tests/Monolog/Processor/UidProcessorTest.php index 5d13058..927d564 100644 --- a/tests/Monolog/Processor/UidProcessorTest.php +++ b/tests/Monolog/Processor/UidProcessorTest.php @@ -1,4 +1,4 @@ -<?php +<?php declare(strict_types=1); /* * This file is part of the Monolog package. @@ -11,7 +11,7 @@ namespace Monolog\Processor; -use Monolog\TestCase; +use Monolog\Test\TestCase; class UidProcessorTest extends TestCase { diff --git a/tests/Monolog/Processor/WebProcessorTest.php b/tests/Monolog/Processor/WebProcessorTest.php index 4105baf..6da6ab8 100644 --- a/tests/Monolog/Processor/WebProcessorTest.php +++ b/tests/Monolog/Processor/WebProcessorTest.php @@ -1,4 +1,4 @@ -<?php +<?php declare(strict_types=1); /* * This file is part of the Monolog package. @@ -11,20 +11,20 @@ namespace Monolog\Processor; -use Monolog\TestCase; +use Monolog\Test\TestCase; 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']); } /** |