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

LoggerTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 39
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testPrintingLogInStdOutIfVerboseFlag() 0 9 1
A testDoNotPrintingInStdOutWithoutVerboseFlag() 0 7 1
A providerLevelMessages() 0 12 1
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
}