2019-07-16 02:59:33 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Engelsystem\Test\Unit\Models;
|
|
|
|
|
|
|
|
use Engelsystem\Models\LogEntry;
|
|
|
|
use Psr\Log\LogLevel;
|
|
|
|
|
2020-05-11 19:57:25 +02:00
|
|
|
class LogEntryTest extends ModelTest
|
2019-07-16 02:59:33 +02:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @covers \Engelsystem\Models\LogEntry::filter
|
|
|
|
*/
|
|
|
|
public function testFilter(): void
|
|
|
|
{
|
2019-11-10 23:26:23 +01:00
|
|
|
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
|
|
|
|
) {
|
2019-07-16 02:59:33 +02:00
|
|
|
(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'));
|
|
|
|
}
|
|
|
|
}
|