7
7
use Illuminate \Foundation \Application ;
8
8
use Illuminate \Foundation \Bootstrap \HandleExceptions ;
9
9
use Illuminate \Log \LogManager ;
10
+ use Illuminate \Support \Str ;
10
11
use Mockery as m ;
11
12
use Monolog \Handler \NullHandler ;
12
13
use PHPUnit \Framework \TestCase ;
@@ -50,11 +51,20 @@ public function testPhpDeprecations()
50
51
$ this ->app ->instance (LogManager::class, $ logger );
51
52
52
53
$ logger ->shouldReceive ('channel ' )->with ('deprecations ' )->andReturnSelf ();
53
- $ logger ->shouldReceive ('warning ' )->with (sprintf ('%s in %s on line %s ' ,
54
- 'str_contains(): Passing null to parameter #2 ($needle) of type string is deprecated ' ,
55
- '/home/user/laravel/routes/web.php ' ,
56
- 17
57
- ));
54
+ $ logger ->shouldReceive ('warning ' )->with (
55
+ m::on (fn (string $ message ) => (bool ) preg_match (
56
+ <<<REGEXP
57
+ #ErrorException: str_contains\(\): Passing null to parameter \#2 \(\\ \$needle\) of type string is deprecated in /home/user/laravel/routes/web\.php:17
58
+ Stack trace:
59
+ \#0 .*helpers.php\(.*\): Illuminate\\\\Foundation\\\\Bootstrap\\\\HandleExceptions.*
60
+ \#1 .*HandleExceptions\.php\(.*\): with.*
61
+ \#2 .*HandleExceptions\.php\(.*\): Illuminate\\\\Foundation\\\\Bootstrap\\\\HandleExceptions->handleDeprecation.*
62
+ \#3 .*HandleExceptionsTest\.php\(.*\): Illuminate\\\\Foundation\\\\Bootstrap\\\\HandleExceptions->handleError.*
63
+ [\s\S]*#i
64
+ REGEXP ,
65
+ $ message
66
+ ))
67
+ );
58
68
59
69
$ this ->handleExceptions ->handleError (
60
70
E_DEPRECATED ,
@@ -70,11 +80,20 @@ public function testUserDeprecations()
70
80
$ this ->app ->instance (LogManager::class, $ logger );
71
81
72
82
$ logger ->shouldReceive ('channel ' )->with ('deprecations ' )->andReturnSelf ();
73
- $ logger ->shouldReceive ('warning ' )->with (sprintf ('%s in %s on line %s ' ,
74
- 'str_contains(): Passing null to parameter #2 ($needle) of type string is deprecated ' ,
75
- '/home/user/laravel/routes/web.php ' ,
76
- 17
77
- ));
83
+ $ logger ->shouldReceive ('warning ' )->with (
84
+ m::on (fn (string $ message ) => (bool ) preg_match (
85
+ <<<REGEXP
86
+ #ErrorException: str_contains\(\): Passing null to parameter \#2 \(\\ \$needle\) of type string is deprecated in /home/user/laravel/routes/web\.php:17
87
+ Stack trace:
88
+ \#0 .*helpers.php\(.*\): Illuminate\\\\Foundation\\\\Bootstrap\\\\HandleExceptions.*
89
+ \#1 .*HandleExceptions\.php\(.*\): with.*
90
+ \#2 .*HandleExceptions\.php\(.*\): Illuminate\\\\Foundation\\\\Bootstrap\\\\HandleExceptions->handleDeprecation.*
91
+ \#3 .*HandleExceptionsTest\.php\(.*\): Illuminate\\\\Foundation\\\\Bootstrap\\\\HandleExceptions->handleError.*
92
+ [\s\S]*#i
93
+ REGEXP ,
94
+ $ message
95
+ ))
96
+ );
78
97
79
98
$ this ->handleExceptions ->handleError (
80
99
E_USER_DEPRECATED ,
0 commit comments