Passed
Branch extract-store (f24e42)
by Konrad
04:37
created

LoggerTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Importance

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

5 Methods

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