13
13
14
14
use PHPUnit \Framework \TestCase ;
15
15
use Psr \Log \LoggerInterface ;
16
- use Symfony \Component \EventDispatcher \EventDispatcher ;
17
16
use Symfony \Component \ErrorHandler \Exception \FlattenException ;
17
+ use Symfony \Component \EventDispatcher \EventDispatcher ;
18
18
use Symfony \Component \HttpFoundation \Request ;
19
19
use Symfony \Component \HttpFoundation \Response ;
20
20
use Symfony \Component \HttpKernel \Controller \ArgumentResolver ;
@@ -158,12 +158,11 @@ public function testCSPHeaderIsRemoved()
158
158
$ this ->assertFalse ($ dispatcher ->hasListeners (KernelEvents::RESPONSE ), 'CSP removal listener has been removed ' );
159
159
}
160
160
161
- public function testOnControllerArguments ()
161
+ /**
162
+ * @dataProvider controllerProvider
163
+ */
164
+ public function testOnControllerArguments (callable $ controller )
162
165
{
163
- $ controller = function (FlattenException $ exception ) {
164
- return new Response ('OK: ' .$ exception ->getMessage ());
165
- };
166
-
167
166
$ listener = new ErrorListener ($ controller , $ this ->createMock (LoggerInterface::class), true );
168
167
169
168
$ kernel = $ this ->createMock (HttpKernelInterface::class);
@@ -181,6 +180,23 @@ public function testOnControllerArguments()
181
180
182
181
$ this ->assertSame ('OK: foo ' , $ event ->getResponse ()->getContent ());
183
182
}
183
+
184
+ public function controllerProvider ()
185
+ {
186
+ yield [function (FlattenException $ exception ) {
187
+ return new Response ('OK: ' .$ exception ->getMessage ());
188
+ }];
189
+
190
+ yield [function ($ exception ) {
191
+ $ this ->assertInstanceOf (FlattenException::class, $ exception );
192
+
193
+ return new Response ('OK: ' .$ exception ->getMessage ());
194
+ }];
195
+
196
+ yield [function (\Throwable $ exception ) {
197
+ return new Response ('OK: ' .$ exception ->getMessage ());
198
+ }];
199
+ }
184
200
}
185
201
186
202
class TestLogger extends Logger implements DebugLoggerInterface
0 commit comments