You are here

public function ContainerAwareHttpKernelTest::testHandleRestoresThePreviousRequestOnException in Zircon Profile 8

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

@dataProvider getProviderTypes

File

vendor/symfony/http-kernel/Tests/DependencyInjection/ContainerAwareHttpKernelTest.php, line 81

Class

ContainerAwareHttpKernelTest
@group legacy

Namespace

Symfony\Component\HttpKernel\Tests\DependencyInjection

Code

public function testHandleRestoresThePreviousRequestOnException($type) {
  $request = new Request();
  $expected = new \Exception();
  $controller = function () use ($expected) {
    throw $expected;
  };
  $container = $this
    ->getMock('Symfony\\Component\\DependencyInjection\\ContainerInterface');
  $this
    ->expectsEnterScopeOnce($container)
    ->expectsLeaveScopeOnce($container)
    ->expectsSetRequestWithAt($container, $request, 3)
    ->expectsSetRequestWithAt($container, null, 4);
  $dispatcher = new EventDispatcher();
  $resolver = $this
    ->getMock('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface');
  $resolver = $this
    ->getResolverMockFor($controller, $request);
  $stack = new RequestStack();
  $kernel = new ContainerAwareHttpKernel($dispatcher, $container, $resolver, $stack);
  try {
    $kernel
      ->handle($request, $type);
    $this
      ->fail('->handle() suppresses the controller exception');
  } catch (\PHPUnit_Framework_Exception $e) {
    throw $e;
  } catch (\Exception $e) {
    $this
      ->assertSame($expected, $e, '->handle() throws the controller exception');
  }
}