You are here

public function ExceptionListenerTest::testSubRequestFormat in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/http-kernel/Tests/EventListener/ExceptionListenerTest.php \Symfony\Component\HttpKernel\Tests\EventListener\ExceptionListenerTest::testSubRequestFormat()

File

vendor/symfony/http-kernel/Tests/EventListener/ExceptionListenerTest.php, line 104

Class

ExceptionListenerTest
ExceptionListenerTest.

Namespace

Symfony\Component\HttpKernel\Tests\EventListener

Code

public function testSubRequestFormat() {
  $listener = new ExceptionListener('foo', $this
    ->getMock('Psr\\Log\\LoggerInterface'));
  $kernel = $this
    ->getMock('Symfony\\Component\\HttpKernel\\HttpKernelInterface');
  $kernel
    ->expects($this
    ->once())
    ->method('handle')
    ->will($this
    ->returnCallback(function (Request $request) {
    return new Response($request
      ->getRequestFormat());
  }));
  $request = Request::create('/');
  $request
    ->setRequestFormat('xml');
  $event = new GetResponseForExceptionEvent($kernel, $request, 'foo', new \Exception('foo'));
  $listener
    ->onKernelException($event);
  $response = $event
    ->getResponse();
  $this
    ->assertEquals('xml', $response
    ->getContent());
}