diff options
author | Igor Scheller <igor.scheller@igorshp.de> | 2018-08-31 01:55:05 +0200 |
---|---|---|
committer | Igor Scheller <igor.scheller@igorshp.de> | 2018-08-31 03:24:54 +0200 |
commit | ac48332166ce28fcb1a2fc130c7f5adbc760e42d (patch) | |
tree | 1ff076a6a1c5a35b4ad73477d60cbcb77ebfd922 /tests/Feature/Model/LogEntryTest.php | |
parent | 9d9aa71eb736885f23c069a75c7a047b06434178 (diff) |
Models: Added LogEntry model
Diffstat (limited to 'tests/Feature/Model/LogEntryTest.php')
-rw-r--r-- | tests/Feature/Model/LogEntryTest.php | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/tests/Feature/Model/LogEntryTest.php b/tests/Feature/Model/LogEntryTest.php new file mode 100644 index 00000000..25b35676 --- /dev/null +++ b/tests/Feature/Model/LogEntryTest.php @@ -0,0 +1,56 @@ +<?php + +namespace Engelsystem\Test\Feature\Model; + +use Engelsystem\Models\LogEntry; +use PHPUnit\Framework\TestCase; +use Psr\Log\LogLevel; + +class LogEntryTest extends TestCase +{ + /** + * @covers \Engelsystem\Models\LogEntry::filter + */ + public function testFilter() + { + foreach ([ + 'Lorem Ipsum' => LogLevel::INFO, + 'Some test content' => LogLevel::ERROR, + 'Foo bar bartz!' => LogLevel::INFO, + 'Someone did something?' => LogLevel::NOTICE, + 'This is a Test!' => LogLevel::INFO, + 'I\'m verbose notice!' => LogLevel::DEBUG, + 'The newest stuff!!' => LogLevel::ERROR, + ] as $message => $level) { + $entry = new LogEntry(['level' => $level, 'message' => $message]); + $entry->save(); + } + + $model = new LogEntry(); + + $return = $model->filter(); + $this->assertCount(7, $return); + + /** @var LogEntry $first */ + $first = $return->first(); + + $this->assertEquals('The newest stuff!!', $first->message); + + $return = $model->filter(LogLevel::INFO); + $this->assertCount(3, $return); + + $return = $model->filter('notice'); + $this->assertCount(2, $return); + + $return = $model->filter('bartz'); + $this->assertCount(1, $return); + } + + /** + * This method is called before a test is executed. + */ + public function setUp() + { + LogEntry::query()->truncate(); + } +} |