Completed
Push — master ( 2eebbc...f22af2 )
by Dmitry
01:57
created

testDoNotPrintingInStdOutWithoutVerboseFlag()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 2
1
<?php
2
/**
3
 * @author Dmitry Gladyshev <[email protected]>
4
 */
5
6
namespace Rucaptcha\Test;
7
8
9
use PHPUnit\Framework\TestCase;
10
use Psr\Log\LogLevel;
11
use Rucaptcha\Logger;
12
13
class LoggerTest extends TestCase
14
{
15
    /**
16
     * @dataProvider providerLevelMessages
17
     */
18
    public function testPrintingLogInStdOutIfVerboseFlag($level, $message)
19
    {
20
        $logger = new Logger;
21
        $logger->verbose = true;
22
23
        $logger->log($level, $message);
24
25
        $this->expectOutputRegex("#\[{$level}\]\s{$message}#ui");
26
    }
27
28
    /**
29
     * @dataProvider providerLevelMessages
30
     */
31
    public function testDoNotPrintingInStdOutWithoutVerboseFlag($level, $message)
32
    {
33
        $logger = new Logger;
34
        $logger->verbose = false;
35
        $logger->log($level, $message);
36
        $this->expectOutputString('');
37
    }
38
39
    public function providerLevelMessages()
40
    {
41
        return [
42
            [LogLevel::ALERT, 'hello, i am the Log Entry!'],
43
            [LogLevel::CRITICAL, 'hello, i am the Log Entry!'],
44
            [LogLevel::EMERGENCY, 'hello, i am the Log Entry!'],
45
            [LogLevel::DEBUG, 'hello, i am the Log Entry!'],
46
            [LogLevel::ERROR, 'hello, i am the Log Entry!'],
47
            [LogLevel::INFO, 'hello, i am the Log Entry!'],
48
            [LogLevel::WARNING, 'hello, i am the Log Entry!']
49
        ];
50
    }
51
}