summaryrefslogtreecommitdiff
path: root/tests/Feature/Logger/EngelsystemLoggerTest.php
diff options
context:
space:
mode:
authorIgor Scheller <igor.scheller@igorshp.de>2019-04-24 10:45:00 +0200
committermsquare <msquare@notrademark.de>2019-04-25 17:56:06 +0200
commitc74fa7955d9392aea954c2e45ed4137fb2bebcbe (patch)
tree034c93b4b3ccc31e6cc9c27dd87f139569c10c72 /tests/Feature/Logger/EngelsystemLoggerTest.php
parentb74835a0968c35ad9a0955dd8b5e2f3cf9b72a56 (diff)
phpunit: Upgrade to version 8, fixed tests, formatting
Use `dms/phpunit-arraysubset-asserts` after `assertArraySubset` got deprecated
Diffstat (limited to 'tests/Feature/Logger/EngelsystemLoggerTest.php')
-rw-r--r--tests/Feature/Logger/EngelsystemLoggerTest.php25
1 files changed, 21 insertions, 4 deletions
diff --git a/tests/Feature/Logger/EngelsystemLoggerTest.php b/tests/Feature/Logger/EngelsystemLoggerTest.php
index 9ec078a3..cb7e18f3 100644
--- a/tests/Feature/Logger/EngelsystemLoggerTest.php
+++ b/tests/Feature/Logger/EngelsystemLoggerTest.php
@@ -8,10 +8,12 @@ use Engelsystem\Test\Feature\ApplicationFeatureTest;
use Psr\Log\InvalidArgumentException;
use Psr\Log\LoggerInterface;
use Psr\Log\LogLevel;
+use stdClass;
class EngelsystemLoggerTest extends ApplicationFeatureTest
{
/**
+ * @covers \Engelsystem\Logger\EngelsystemLogger::__construct
* @return LoggerInterface
*/
public function getLogger()
@@ -20,6 +22,9 @@ class EngelsystemLoggerTest extends ApplicationFeatureTest
return new EngelsystemLogger($logEntry);
}
+ /**
+ * @covers \Engelsystem\Logger\EngelsystemLogger::__construct
+ */
public function testImplements()
{
$this->assertInstanceOf(LoggerInterface::class, $this->getLogger());
@@ -43,6 +48,7 @@ class EngelsystemLoggerTest extends ApplicationFeatureTest
}
/**
+ * @covers \Engelsystem\Models\LogEntry
* @dataProvider provideLogLevels
* @param string $level
*/
@@ -58,6 +64,9 @@ class EngelsystemLoggerTest extends ApplicationFeatureTest
$this->assertCount(2, $entries);
}
+ /**
+ * @covers \Engelsystem\Logger\EngelsystemLogger::log
+ */
public function testContextReplacement()
{
LogEntry::query()->truncate();
@@ -78,12 +87,13 @@ class EngelsystemLoggerTest extends ApplicationFeatureTest
return [
['Data and {context}', [], 'Data and {context}'],
['Data and {context}', ['context' => null], 'Data and '],
- ['Data and {context}', ['context' => new \stdClass()], 'Data and {context}'],
+ ['Data and {context}', ['context' => new stdClass()], 'Data and {context}'],
['Some user asked: {question}', ['question' => 'Foo?'], 'Some user asked: Foo?'],
];
}
/**
+ * @covers \Engelsystem\Logger\EngelsystemLogger::log
* @dataProvider provideContextReplaceValues
*
* @param string $message
@@ -99,6 +109,9 @@ class EngelsystemLoggerTest extends ApplicationFeatureTest
$this->assertEquals($expected, $entry['message']);
}
+ /**
+ * @covers \Engelsystem\Logger\EngelsystemLogger::log
+ */
public function testContextToString()
{
LogEntry::query()->truncate();
@@ -119,19 +132,20 @@ class EngelsystemLoggerTest extends ApplicationFeatureTest
}
/**
- * @expectedException InvalidArgumentException
+ * @covers \Engelsystem\Logger\EngelsystemLogger::log
*/
public function testThrowExceptionOnInvalidLevel()
{
$logger = $this->getLogger();
+ $this->expectException(InvalidArgumentException::class);
$logger->log('This log level should never be defined', 'Some message');
}
/**
* @return array
*/
- public function getLastEntry()
+ protected function getLastEntry()
{
$entries = LogEntry::all();
$entry = $entries->last();
@@ -139,7 +153,10 @@ class EngelsystemLoggerTest extends ApplicationFeatureTest
return $entry;
}
- public function tearDown()
+ /**
+ * Cleanup
+ */
+ protected function tearDown(): void
{
LogEntry::query()->truncate();
}