summaryrefslogtreecommitdiff
path: root/tests/Feature/Logger
diff options
context:
space:
mode:
authorIgor Scheller <igor.scheller@igorshp.de>2017-09-19 20:40:48 +0200
committerIgor Scheller <igor.scheller@igorshp.de>2017-09-19 20:40:48 +0200
commitc35c4ccbf39a5910530d6cf9b4f5dba45dbf82b0 (patch)
treea133c50db81fe942505c3c332bd916312975ef2d /tests/Feature/Logger
parentc57dfc631caf98df46ac014812f962863f0bfa61 (diff)
Refactoring: Logger test cleanup
Diffstat (limited to 'tests/Feature/Logger')
-rw-r--r--tests/Feature/Logger/EngelsystemLoggerTest.php72
1 files changed, 43 insertions, 29 deletions
diff --git a/tests/Feature/Logger/EngelsystemLoggerTest.php b/tests/Feature/Logger/EngelsystemLoggerTest.php
index 3b6572f5..63a01318 100644
--- a/tests/Feature/Logger/EngelsystemLoggerTest.php
+++ b/tests/Feature/Logger/EngelsystemLoggerTest.php
@@ -29,23 +29,6 @@ class EngelsystemLoggerTest extends TestCase
}
/**
- * @dataProvider provideLogLevels
- * @param string $level
- */
- public function testAllLevels($level)
- {
- $logger = $this->getLogger();
-
- LogEntries_clear_all();
-
- $logger->log($level, 'First log message');
- $logger->{$level}('Second log message');
-
- $entries = LogEntries();
- $this->assertCount(2, $entries);
- }
-
- /**
* @return string[]
*/
public function provideLogLevels()
@@ -62,6 +45,23 @@ class EngelsystemLoggerTest extends TestCase
];
}
+ /**
+ * @dataProvider provideLogLevels
+ * @param string $level
+ */
+ public function testAllLevels($level)
+ {
+ $logger = $this->getLogger();
+
+ LogEntries_clear_all();
+
+ $logger->log($level, 'First log message');
+ $logger->{$level}('Second log message');
+
+ $entries = LogEntries();
+ $this->assertCount(2, $entries);
+ }
+
public function testContextReplacement()
{
$logger = $this->getLogger();
@@ -72,21 +72,35 @@ class EngelsystemLoggerTest extends TestCase
$entry = $this->getLastEntry();
$this->assertEquals('My username is Foo', $entry['message']);
$this->assertEquals(LogLevel::INFO, $entry['level']);
+ }
- foreach (
- [
- ['Data and {context}', []],
- ['Data and ', ['context' => null]],
- ['Data and {context}', ['context' => new \stdClass()]],
- ] as $data
- ) {
- list($result, $context) = $data;
+ /**
+ * @return string[]
+ */
+ public function provideContextReplaceValues()
+ {
+ return [
+ ['Data and {context}', [], 'Data and {context}'],
+ ['Data and {context}', ['context' => null], 'Data and '],
+ ['Data and {context}', ['context' => new \stdClass()], 'Data and {context}'],
+ ['Some user asked: {question}', ['question' => 'Foo?'], 'Some user asked: Foo?'],
+ ];
+ }
- $logger->log(LogLevel::INFO, 'Data and {context}', $context);
+ /**
+ * @dataProvider provideContextReplaceValues
+ *
+ * @param string $message
+ * @param string[] $context
+ * @param string $expected
+ */
+ public function testContextReplaceValues($message, $context, $expected)
+ {
+ $logger = $this->getLogger();
+ $logger->log(LogLevel::INFO, $message, $context);
- $entry = $this->getLastEntry();
- $this->assertEquals($result, $entry['message']);
- }
+ $entry = $this->getLastEntry();
+ $this->assertEquals($expected, $entry['message']);
}
public function testContextToString()