summaryrefslogtreecommitdiff
path: root/tests/Unit/Models/LogEntryTest.php
diff options
context:
space:
mode:
authorIgor Scheller <igor.scheller@igorshp.de>2019-07-16 02:59:33 +0200
committerIgor Scheller <igor.scheller@igorshp.de>2019-07-16 02:59:33 +0200
commitb9cb7d57fdea7246f536204fd0f267380434aa09 (patch)
tree82e3e5a7760ed0ac2c44fccc656090bcd5a8e10f /tests/Unit/Models/LogEntryTest.php
parent6ca0e8e81afed52fa211dd4bcb117cfec9ce3b29 (diff)
Basic coverage tests of logger classes for 100% unit tests coverage
Diffstat (limited to 'tests/Unit/Models/LogEntryTest.php')
-rw-r--r--tests/Unit/Models/LogEntryTest.php43
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/Unit/Models/LogEntryTest.php b/tests/Unit/Models/LogEntryTest.php
new file mode 100644
index 00000000..0a0efa3c
--- /dev/null
+++ b/tests/Unit/Models/LogEntryTest.php
@@ -0,0 +1,43 @@
+<?php
+
+namespace Engelsystem\Test\Unit\Models;
+
+use Engelsystem\Models\LogEntry;
+use Engelsystem\Test\Unit\HasDatabase;
+use PHPUnit\Framework\TestCase;
+use Psr\Log\LogLevel;
+
+class LogEntryTest extends TestCase
+{
+ use HasDatabase;
+
+ /**
+ * @covers \Engelsystem\Models\LogEntry::filter
+ */
+ public function testFilter()
+ {
+ foreach ([
+ 'I\'m an info' => LogLevel::INFO,
+ '*Insert explosion here*' => LogLevel::EMERGENCY,
+ 'Tracing along' => LogLevel::DEBUG,
+ 'Oops' => LogLevel::ERROR,
+ 'It\'s happening' => LogLevel::INFO,
+ 'Something is wrong' => LogLevel::ERROR,
+ 'Ohi' => LogLevel::INFO,
+ ] as $message => $level) {
+ (new LogEntry(['level' => $level, 'message' => $message]))->save();
+ }
+
+ $this->assertCount(7, LogEntry::filter());
+ $this->assertCount(3, LogEntry::filter(LogLevel::INFO));
+ $this->assertCount(1, LogEntry::filter('Oops'));
+ }
+
+ /**
+ * Prepare test
+ */
+ protected function setUp(): void
+ {
+ $this->initDatabase();
+ }
+}