Test Failed
Push — main ( a69ba7...42e76b )
by ANDREY
02:16
created

ConsoleLoggerTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
namespace Tests;
5
6
use PHPUnit\Framework\TestCase;
7
use VPA\Logger\ConsoleLogger;
8
9
10
class ConsoleLoggerTest extends TestCase
11
{
12
    private ConsoleLogger $logger;
13
14
    public function setUp(): void
15
    {
16
        parent::setUp();
17
        $this->logger = new ConsoleLogger();
18
    }
19
20
    public function testInitClass()
21
    {
22
        $this->assertTrue($this->logger instanceof ConsoleLogger);
23
    }
24
25
    public function testEmergency()
26
    {
27
        ob_start();
28
        $this->logger->emergency("testEmergency {Interpolation}",['Interpolation'=>'InterpolationEmergency']);
29
        $capture = ob_get_clean();
30
        $this->assertTrue(strpos($capture, "0;35") !== false);
31
        $this->assertTrue(strpos($capture, "testEmergency") !== false);
32
        $this->assertTrue(strpos($capture, "InterpolationEmergency") !== false);
33
    }
34
35
    public function testAlert()
36
    {
37
        ob_start();
38
        $this->logger->alert("testAlert {Interpolation}",['Interpolation'=>'InterpolationAlert']);
39
        $capture = ob_get_clean();
40
        $this->assertTrue(strpos($capture, "1;31") !== false);
41
        $this->assertTrue(strpos($capture, "testAlert") !== false);
42
        $this->assertTrue(strpos($capture, "InterpolationAlert") !== false);
43
    }
44
45
    public function testCritical()
46
    {
47
        ob_start();
48
        $this->logger->critical("testCritical {Interpolation}",['Interpolation'=>'InterpolationCritical']);
49
        $capture = ob_get_clean();
50
        $this->assertTrue(strpos($capture, "0;31") !== false);
51
        $this->assertTrue(strpos($capture, "testCritical") !== false);
52
        $this->assertTrue(strpos($capture, "InterpolationCritical") !== false);
53
    }
54
55
    public function testError()
56
    {
57
        ob_start();
58
        $this->logger->error("testError {Interpolation}",['Interpolation'=>'InterpolationError']);
59
        $capture = ob_get_clean();
60
        $this->assertTrue(strpos($capture, "0;31") !== false);
61
        $this->assertTrue(strpos($capture, "testError") !== false);
62
        $this->assertTrue(strpos($capture, "InterpolationError") !== false);
63
    }
64
65
    public function testWarning()
66
    {
67
        ob_start();
68
        $this->logger->warning("testWarning {Interpolation}",['Interpolation'=>'InterpolationWarning']);
69
        $capture = ob_get_clean();
70
        $this->assertTrue(strpos($capture, "1;37") !== false);
71
        $this->assertTrue(strpos($capture, "testWarning") !== false);
72
        $this->assertTrue(strpos($capture, "InterpolationWarning") !== false);
73
    }
74
75
    public function testNotice()
76
    {
77
        ob_start();
78
        $this->logger->notice("testNotice {Interpolation}",['Interpolation'=>'InterpolationNotice']);
79
        $capture = ob_get_clean();
80
        $this->assertTrue(strpos($capture, "1;33") !== false);
81
        $this->assertTrue(strpos($capture, "testNotice") !== false);
82
        $this->assertTrue(strpos($capture, "InterpolationNotice") !== false);
83
    }
84
85
    public function testInfo()
86
    {
87
        ob_start();
88
        $this->logger->info("testInfo {Interpolation}",['Interpolation'=>'InterpolationInfo']);
89
        $capture = ob_get_clean();
90
        $this->assertTrue(strpos($capture, "0;32") !== false);
91
        $this->assertTrue(strpos($capture, "testInfo") !== false);
92
        $this->assertTrue(strpos($capture, "InterpolationInfo") !== false);
93
    }
94
95
    public function testDebug()
96
    {
97
        ob_start();
98
        $this->logger->debug("testDebug {Interpolation}",['Interpolation'=>'InterpolationDebug']);
99
        $capture = ob_get_clean();
100
        $this->assertTrue(strpos($capture, "1;34") !== false);
101
        $this->assertTrue(strpos($capture, "testDebug") !== false);
102
        $this->assertTrue(strpos($capture, "InterpolationDebug") !== false);
103
    }
104
105
    public function testTable()
106
    {
107
        ob_start();
108
        $this->logger->table("testTable {Interpolation}",['Interpolation'=>'InterpolationTable']);
109
        $capture = ob_get_clean();
110
        $this->assertTrue(strpos($capture, "1;37") !== false);
111
        $this->assertTrue(strpos($capture, "testTable") !== false);
112
        $this->assertTrue(strpos($capture, "InterpolationTable") !== false);
113
    }
114
115
116
}