/** * Tests rendering the error screen. */ public function testErrorScreen() { $event = new GetResponseForExceptionEvent($this->mockKernel(), new Request(), HttpKernelInterface::MASTER_REQUEST, new NotFoundHttpException('', new PageNotFoundException())); $count = 0; $twig = $this->getMock('Twig_Environment', ['render']); $twig->expects($this->any())->method('render')->willReturnCallback(function () use(&$count) { if (0 === $count++) { throw new \Twig_Error('foo'); } }); $listener = new PrettyErrorScreenListener(true, $twig, new ConfigAdapter()); $listener->onKernelException($event); $this->assertTrue($event->hasResponse()); $response = $event->getResponse(); $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\Response', $response); $this->assertEquals(500, $response->getStatusCode()); }
/** * Tests rendering a non existing page handler. */ public function testNonExistingPageHandler() { $event = new GetResponseForExceptionEvent($this->mockKernel(), new Request(), HttpKernelInterface::MASTER_REQUEST, new AccessDeniedHttpException('', new AccessDeniedException())); $this->listener->onKernelException($event); $this->assertFalse($event->hasResponse()); }