Note that this method generates an esi:include tag only when both the standalone
option is set to true and the request has ESI capability (@see Symfony\Component\HttpKernel\HttpCache\ESI).
Available options:
* attributes: An array of request attributes (only when the first argument is a controller)
* query: An array of request query parameters (only when the first argument is a controller)
* ignore_errors: true to return an empty string in case of an error
* alt: an alternative controller to execute in case of an error (can be a controller, a URI, or an array with the controller, the attributes, and the query arguments)
* standalone: whether to generate an esi:include tag or not when ESI is supported
* comment: a comment to add when returning an esi:include tag
public function testExceptionInSubRequestsDoesNotMangleOutputBuffers() { if (version_compare(phpversion(), '5.3.3', '<')) { $this->markTestSkipped('Test fails with PHP 5.3.2 due to https://bugs.php.net/bug.php?id=50563'); } $request = new Request(); $container = $this->getMock('Symfony\\Component\\DependencyInjection\\ContainerInterface'); $container->expects($this->at(0))->method('getParameter')->with($this->equalTo('kernel.debug'))->will($this->returnValue(false)); $container->expects($this->at(1))->method('has')->with($this->equalTo('esi'))->will($this->returnValue(false)); $container->expects($this->at(2))->method('get')->with($this->equalTo('request'))->will($this->returnValue($request)); $dispatcher = new EventDispatcher(); $resolver = $this->getMock('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface'); $resolver->expects($this->once())->method('getController')->will($this->returnValue(function () { ob_start(); echo 'bar'; throw new \RuntimeException(); })); $resolver->expects($this->once())->method('getArguments')->will($this->returnValue(array())); $kernel = new HttpKernel($dispatcher, $container, $resolver); // simulate a main request with output buffering ob_start(); echo 'Foo'; // simulate a sub-request with output buffering and an exception $kernel->render('/'); $this->assertEquals('Foo', ob_get_clean()); }
/** * @expectedException \InvalidArgumentException */ public function testRenderOnlyAllowScalarAttributes() { $dispatcher = new EventDispatcher(); $resolver = $this->getMock('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface'); $container = $this->getMock('Symfony\\Component\\DependencyInjection\\ContainerInterface'); $kernel = new HttpKernel($dispatcher, $container, $resolver); $kernel->render('/', array('attributes' => array('foo' => array('bar' => new \stdClass())))); }