@@ -101,9 +101,14 @@ public function testNotice()
101
101
$ this ->fail ('ErrorException expected ' );
102
102
} catch (\ErrorException $ exception ) {
103
103
// if an exception is thrown, the test passed
104
- $ this ->assertEquals (E_NOTICE , $ exception ->getSeverity ());
104
+ if (\PHP_VERSION_ID < 80000 ) {
105
+ $ this ->assertEquals (E_NOTICE , $ exception ->getSeverity ());
106
+ $ this ->assertRegExp ('/^Notice: Undefined variable: (foo|bar)/ ' , $ exception ->getMessage ());
107
+ } else {
108
+ $ this ->assertEquals (E_WARNING , $ exception ->getSeverity ());
109
+ $ this ->assertRegExp ('/^Warning: Undefined variable \$(foo|bar)/ ' , $ exception ->getMessage ());
110
+ }
105
111
$ this ->assertEquals (__FILE__ , $ exception ->getFile ());
106
- $ this ->assertRegExp ('/^Notice: Undefined variable: (foo|bar)/ ' , $ exception ->getMessage ());
107
112
108
113
$ trace = $ exception ->getTrace ();
109
114
@@ -247,11 +252,17 @@ public function testHandleError()
247
252
248
253
$ line = null ;
249
254
$ logArgCheck = function ($ level , $ message , $ context ) use (&$ line ) {
250
- $ this ->assertEquals ('Notice: Undefined variable: undefVar ' , $ message );
251
255
$ this ->assertArrayHasKey ('exception ' , $ context );
252
256
$ exception = $ context ['exception ' ];
257
+
258
+ if (\PHP_VERSION_ID < 80000 ) {
259
+ $ this ->assertEquals ('Notice: Undefined variable: undefVar ' , $ message );
260
+ $ this ->assertSame (E_NOTICE , $ exception ->getSeverity ());
261
+ } else {
262
+ $ this ->assertEquals ('Warning: Undefined variable $undefVar ' , $ message );
263
+ $ this ->assertSame (E_WARNING , $ exception ->getSeverity ());
264
+ }
253
265
$ this ->assertInstanceOf (SilencedErrorContext::class, $ exception );
254
- $ this ->assertSame (E_NOTICE , $ exception ->getSeverity ());
255
266
$ this ->assertSame (__FILE__ , $ exception ->getFile ());
256
267
$ this ->assertSame ($ line , $ exception ->getLine ());
257
268
$ this ->assertNotEmpty ($ exception ->getTrace ());
@@ -265,8 +276,13 @@ public function testHandleError()
265
276
;
266
277
267
278
$ handler = ErrorHandler::register ();
268
- $ handler ->setDefaultLogger ($ logger , E_NOTICE );
269
- $ handler ->screamAt (E_NOTICE );
279
+ if (\PHP_VERSION_ID < 80000 ) {
280
+ $ handler ->setDefaultLogger ($ logger , E_NOTICE );
281
+ $ handler ->screamAt (E_NOTICE );
282
+ } else {
283
+ $ handler ->setDefaultLogger ($ logger , E_WARNING );
284
+ $ handler ->screamAt (E_WARNING );
285
+ }
270
286
unset($ undefVar );
271
287
$ line = __LINE__ + 1 ;
272
288
@$ undefVar ++;
0 commit comments