2
2
3
3
use Monolog \Handler \StreamHandler ;
4
4
use Monolog \Logger ;
5
+ use PHPUnit \Framework \TestCase ;
5
6
use Superbalist \Monolog \Formatter \GoogleCloudJsonFormatter ;
6
7
7
- class GoogleCloudLoggerTest extends PHPUnit_Framework_TestCase
8
+ class GoogleCloudLoggerTest extends TestCase
8
9
{
9
10
/**
10
11
* @var Logger
@@ -15,15 +16,15 @@ class GoogleCloudLoggerTest extends PHPUnit_Framework_TestCase
15
16
/**
16
17
* Setup before test runs
17
18
*/
18
- public static function setUpBeforeClass ()
19
+ public static function setUpBeforeClass (): void
19
20
{
20
21
touch (static ::$ logfileOutput );
21
22
}
22
23
23
24
/**
24
25
* Test setup
25
26
*/
26
- public function setUp ()
27
+ public function setUp (): void
27
28
{
28
29
$ handler = new StreamHandler (static ::$ logfileOutput , Logger::DEBUG );
29
30
$ handler ->setFormatter (new GoogleCloudJsonFormatter ());
@@ -34,7 +35,7 @@ public function setUp()
34
35
/**
35
36
* Cleanup
36
37
*/
37
- public function tearDown ()
38
+ public function tearDown (): void
38
39
{
39
40
file_put_contents (static ::$ logfileOutput , '' );
40
41
unset($ this ->log );
@@ -43,7 +44,7 @@ public function tearDown()
43
44
/**
44
45
* Cleanup after all tests ran
45
46
*/
46
- public static function tearDownAfterClass ()
47
+ public static function tearDownAfterClass (): void
47
48
{
48
49
unlink (static ::$ logfileOutput );
49
50
}
@@ -55,7 +56,7 @@ public function it_should_log_a_debug_in_the_expected_format()
55
56
{
56
57
$ dt = $ this ->getDateTimeforTest ();
57
58
58
- $ this ->log ->addDebug ('Test Debug Occurred ' );
59
+ $ this ->log ->debug ('Test Debug Occurred ' );
59
60
60
61
$ expected = '{"message":"Test Debug Occurred","severity":"DEBUG","timestamp":{"seconds": '
61
62
. $ dt ->getTimestamp () . ',"nanos":0},"channel":"test-channel"} ' . "\n" ;
@@ -70,7 +71,7 @@ public function it_should_log_an_info_in_the_expected_format()
70
71
{
71
72
$ dt = $ this ->getDateTimeforTest ();
72
73
73
- $ this ->log ->addInfo ('Test Info Occurred ' );
74
+ $ this ->log ->info ('Test Info Occurred ' );
74
75
75
76
$ expected = '{"message":"Test Info Occurred","severity":"INFO","timestamp":{"seconds": '
76
77
. $ dt ->getTimestamp () . ',"nanos":0},"channel":"test-channel"} ' . "\n" ;
@@ -85,7 +86,7 @@ public function it_should_log_a_notice_in_the_expected_format()
85
86
{
86
87
$ dt = $ this ->getDateTimeforTest ();
87
88
88
- $ this ->log ->addNotice ('Test Notice Occurred ' );
89
+ $ this ->log ->notice ('Test Notice Occurred ' );
89
90
90
91
$ expected = '{"message":"Test Notice Occurred","severity":"NOTICE","timestamp":{"seconds": '
91
92
. $ dt ->getTimestamp () . ',"nanos":0},"channel":"test-channel"} ' . "\n" ;
@@ -100,7 +101,7 @@ public function it_should_log_a_warning_in_the_expected_format()
100
101
{
101
102
$ dt = $ this ->getDateTimeforTest ();
102
103
103
- $ this ->log ->addWarning ('Test Warning Occurred ' );
104
+ $ this ->log ->warning ('Test Warning Occurred ' );
104
105
105
106
$ expected = '{"message":"Test Warning Occurred","severity":"WARNING","timestamp":{"seconds": '
106
107
. $ dt ->getTimestamp () . ',"nanos":0},"channel":"test-channel"} ' . "\n" ;
@@ -115,7 +116,7 @@ public function it_should_log_an_error_in_the_expected_format()
115
116
{
116
117
$ dt = $ this ->getDateTimeforTest ();
117
118
118
- $ this ->log ->addError ('Test Error Occurred ' );
119
+ $ this ->log ->error ('Test Error Occurred ' );
119
120
120
121
$ expected = '{"message":"Test Error Occurred","severity":"ERROR","timestamp":{"seconds": ' . $ dt ->getTimestamp ()
121
122
. ',"nanos":0},"channel":"test-channel"} ' . "\n" ;
@@ -130,7 +131,7 @@ public function it_should_log_a_critical_in_the_expected_format()
130
131
{
131
132
$ dt = $ this ->getDateTimeforTest ();
132
133
133
- $ this ->log ->addCritical ('Test Critical Occurred ' );
134
+ $ this ->log ->critical ('Test Critical Occurred ' );
134
135
135
136
$ expected = '{"message":"Test Critical Occurred","severity":"CRITICAL","timestamp":{"seconds": '
136
137
. $ dt ->getTimestamp () . ',"nanos":0},"channel":"test-channel"} ' . "\n" ;
@@ -145,7 +146,7 @@ public function it_should_log_an_alert_in_the_expected_format()
145
146
{
146
147
$ dt = $ this ->getDateTimeforTest ();
147
148
148
- $ this ->log ->addAlert ('Test Alert Occurred ' );
149
+ $ this ->log ->alert ('Test Alert Occurred ' );
149
150
150
151
$ expected = '{"message":"Test Alert Occurred","severity":"ALERT","timestamp":{"seconds": '
151
152
. $ dt ->getTimestamp () . ',"nanos":0},"channel":"test-channel"} ' . "\n" ;
@@ -160,7 +161,7 @@ public function it_should_log_an_emergency_in_the_expected_format()
160
161
{
161
162
$ dt = $ this ->getDateTimeforTest ();
162
163
163
- $ this ->log ->addEmergency ('Test Emergency Occurred ' );
164
+ $ this ->log ->emergency ('Test Emergency Occurred ' );
164
165
165
166
$ expected = '{"message":"Test Emergency Occurred","severity":"EMERGENCY","timestamp":{"seconds": '
166
167
. $ dt ->getTimestamp () . ',"nanos":0},"channel":"test-channel"} ' . "\n" ;
0 commit comments