@@ -31,14 +31,14 @@ class HttpKernelExtensionTest extends TestCase
3131 public function testFragmentWithError ()
3232 {
3333 $ this ->expectException (\Twig \Error \RuntimeError::class);
34- $ renderer = $ this ->getFragmentHandler ($ this -> throwException ( new \Exception ('foo ' ) ));
34+ $ renderer = $ this ->getFragmentHandler (new \Exception ('foo ' ));
3535
3636 $ this ->renderTemplate ($ renderer );
3737 }
3838
3939 public function testRenderFragment ()
4040 {
41- $ renderer = $ this ->getFragmentHandler ($ this -> returnValue ( new Response ('html ' ) ));
41+ $ renderer = $ this ->getFragmentHandler (new Response ('html ' ));
4242
4343 $ response = $ this ->renderTemplate ($ renderer );
4444
@@ -87,11 +87,17 @@ public function testGenerateFragmentUri()
8787 $ this ->assertSame ('/_fragment?_hash=PP8%2FeEbn1pr27I9wmag%2FM6jYGVwUZ0l2h0vhh2OJ6CI%3D&_path=template%3Dfoo.html.twig%26_format%3Dhtml%26_locale%3Den%26_controller%3DSymfonyBundleFrameworkBundleControllerTemplateController%253A%253AtemplateAction ' , $ twig ->render ('index ' ));
8888 }
8989
90- protected function getFragmentHandler ($ return )
90+ protected function getFragmentHandler ($ returnOrException ): FragmentHandler
9191 {
9292 $ strategy = $ this ->createMock (FragmentRendererInterface::class);
9393 $ strategy ->expects ($ this ->once ())->method ('getName ' )->willReturn ('inline ' );
94- $ strategy ->expects ($ this ->once ())->method ('render ' )->will ($ return );
94+
95+ $ mocker = $ strategy ->expects ($ this ->once ())->method ('render ' );
96+ if ($ returnOrException instanceof \Exception) {
97+ $ mocker ->willThrowException ($ returnOrException );
98+ } else {
99+ $ mocker ->willReturn ($ returnOrException );
100+ }
95101
96102 $ context = $ this ->createMock (RequestStack::class);
97103
0 commit comments