@@ -166,4 +166,53 @@ public function getProviderTypes()
166
166
array (HttpKernelInterface::SUB_REQUEST ),
167
167
);
168
168
}
169
+
170
+ public function testExceptionInSubRequestsDoesNotMangleOutputBuffers ()
171
+ {
172
+ $ request = new Request ();
173
+
174
+ $ container = $ this ->getMock ('Symfony \\Component \\DependencyInjection \\ContainerInterface ' );
175
+ $ container
176
+ ->expects ($ this ->at (0 ))
177
+ ->method ('getParameter ' )
178
+ ->with ($ this ->equalTo ('kernel.debug ' ))
179
+ ->will ($ this ->returnValue (false ))
180
+ ;
181
+ $ container
182
+ ->expects ($ this ->at (1 ))
183
+ ->method ('has ' )
184
+ ->with ($ this ->equalTo ('esi ' ))
185
+ ->will ($ this ->returnValue (false ))
186
+ ;
187
+ $ container
188
+ ->expects ($ this ->at (2 ))
189
+ ->method ('get ' )
190
+ ->with ($ this ->equalTo ('request ' ))
191
+ ->will ($ this ->returnValue ($ request ))
192
+ ;
193
+
194
+ $ dispatcher = new EventDispatcher ();
195
+ $ resolver = $ this ->getMock ('Symfony \\Component \\HttpKernel \\Controller \\ControllerResolverInterface ' );
196
+ $ resolver ->expects ($ this ->once ())
197
+ ->method ('getController ' )
198
+ ->will ($ this ->returnValue (function () {
199
+ ob_start ();
200
+ echo 'bar ' ;
201
+ throw new \RuntimeException ();
202
+ }));
203
+ $ resolver ->expects ($ this ->once ())
204
+ ->method ('getArguments ' )
205
+ ->will ($ this ->returnValue (array ()));
206
+
207
+ $ kernel = new HttpKernel ($ dispatcher , $ container , $ resolver );
208
+
209
+ // simulate a main request with output buffering
210
+ ob_start ();
211
+ echo 'Foo ' ;
212
+
213
+ // simulate a sub-request with output buffering and an exception
214
+ $ kernel ->render ('/ ' );
215
+
216
+ $ this ->assertEquals ('Foo ' , ob_get_clean ());
217
+ }
169
218
}
0 commit comments