LoggerTest   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 20
c 1
b 0
f 0
dl 0
loc 45
rs 10
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A testHasEntriesWithInvalidLevel() 0 6 1
A testHasEntries() 0 10 1
A testGetEntries() 0 10 1
A getSubjectUnderTest() 0 3 1
A testGetEntriesWithInvalidLevel() 0 6 1
1
<?php
2
3
/**
4
 * This file is part of the sweetrdf/InMemoryStoreSqlite package and licensed under
5
 * the terms of the GPL-2 license.
6
 *
7
 * (c) Konrad Abicht <[email protected]>
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12
13
namespace Tests\Unit\Log;
14
15
use Exception;
16
use sweetrdf\InMemoryStoreSqlite\Log\Logger;
17
use Tests\TestCase;
18
19
class LoggerTest extends TestCase
20
{
21
    private function getSubjectUnderTest(): Logger
22
    {
23
        return new Logger();
24
    }
25
26
    public function testGetEntriesWithInvalidLevel()
27
    {
28
        $this->expectException(Exception::class);
29
        $this->expectExceptionMessage('Level invalid not set');
30
31
        $this->getSubjectUnderTest()->getEntries('invalid');
32
    }
33
34
    public function testGetEntries()
35
    {
36
        $sut = $this->getSubjectUnderTest();
37
38
        $sut->error('error1');
39
        $sut->warning('warning1');
40
41
        $this->assertEquals(2, \count($sut->getEntries()));
42
        $this->assertEquals(1, \count($sut->getEntries('error')));
43
        $this->assertEquals(1, \count($sut->getEntries('warning')));
44
    }
45
46
    public function testHasEntriesWithInvalidLevel()
47
    {
48
        $this->expectException(Exception::class);
49
        $this->expectExceptionMessage('Level invalid not set');
50
51
        $this->getSubjectUnderTest()->hasEntries('invalid');
52
    }
53
54
    public function testHasEntries()
55
    {
56
        $sut = $this->getSubjectUnderTest();
57
58
        $sut->error('error1');
59
        $sut->warning('warning1');
60
61
        $this->assertTrue($sut->hasEntries('error'));
62
        $this->assertTrue($sut->hasEntries('warning'));
63
        $this->assertTrue($sut->hasEntries());
64
    }
65
}
66