1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
use Suricate\Logger; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* @SuppressWarnings("StaticAccess") |
7
|
|
|
*/ |
8
|
|
|
class LoggerTest extends \PHPUnit\Framework\TestCase |
9
|
|
|
{ |
10
|
|
|
public function testFatal() |
11
|
|
|
{ |
12
|
|
|
$message = 'log message'; |
13
|
|
|
$mock = $this->getMockBuilder(Logger::class) |
14
|
|
|
->setMethods(['log']) |
15
|
|
|
->getMock(); |
16
|
|
|
$mock |
17
|
|
|
->expects($this->once()) |
18
|
|
|
->method('log') |
19
|
|
|
->with($message, Logger::LOGLEVEL_FATAL); |
20
|
|
|
|
21
|
|
|
/** @scrutinizer ignore-call */ |
22
|
|
|
$mock->fatal($message); |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
public function testError() |
26
|
|
|
{ |
27
|
|
|
$message = 'log message'; |
28
|
|
|
$mock = $this->getMockBuilder(Logger::class) |
29
|
|
|
->setMethods(['log']) |
30
|
|
|
->getMock(); |
31
|
|
|
$mock |
32
|
|
|
->expects($this->once()) |
33
|
|
|
->method('log') |
34
|
|
|
->with($message, Logger::LOGLEVEL_ERROR); |
35
|
|
|
|
36
|
|
|
/** @scrutinizer ignore-call */ |
37
|
|
|
$mock->error($message); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
public function testWarn() |
41
|
|
|
{ |
42
|
|
|
$message = 'log message'; |
43
|
|
|
$mock = $this->getMockBuilder(Logger::class) |
44
|
|
|
->setMethods(['log']) |
45
|
|
|
->getMock(); |
46
|
|
|
$mock |
47
|
|
|
->expects($this->once()) |
48
|
|
|
->method('log') |
49
|
|
|
->with($message, Logger::LOGLEVEL_WARN); |
50
|
|
|
|
51
|
|
|
/** @scrutinizer ignore-call */ |
52
|
|
|
$mock->warn($message); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
public function testInfo() |
56
|
|
|
{ |
57
|
|
|
$message = 'log message'; |
58
|
|
|
$mock = $this->getMockBuilder(Logger::class) |
59
|
|
|
->setMethods(['log']) |
60
|
|
|
->getMock(); |
61
|
|
|
$mock |
62
|
|
|
->expects($this->once()) |
63
|
|
|
->method('log') |
64
|
|
|
->with($message, Logger::LOGLEVEL_INFO); |
65
|
|
|
|
66
|
|
|
/** @scrutinizer ignore-call */ |
67
|
|
|
$mock->info($message); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
public function testDebug() |
71
|
|
|
{ |
72
|
|
|
$message = 'log message'; |
73
|
|
|
$mock = $this->getMockBuilder(Logger::class) |
74
|
|
|
->setMethods(['log']) |
75
|
|
|
->getMock(); |
76
|
|
|
$mock |
77
|
|
|
->expects($this->once()) |
78
|
|
|
->method('log') |
79
|
|
|
->with($message, Logger::LOGLEVEL_DEBUG); |
80
|
|
|
|
81
|
|
|
/** @scrutinizer ignore-call */ |
82
|
|
|
$mock->debug($message); |
83
|
|
|
} |
84
|
|
|
} |
85
|
|
|
|