/** * @expectedException \Exception */ public function testHandleExceptionGivenSubRequestShouldThrowException() { if (!class_exists('Whoops\\Run')) { $this->markTestSkipped(); } $app = new Application(); $app->handlers([new WhoopsMiddleware($app), function () { throw new \Exception('foo'); }]); $app['app.context']->request(new Request(), HttpKernelInterface::SUB_REQUEST); $app->run(); }
/** * @expectedException \LogicException */ public function testRunWithUncaughtException() { $app = new Application(); $context = $app['app.context']; $probe = $this->getMock('Durian\\Handler'); $probe->expects($this->once())->method('context')->will($this->throwException(new \LogicException())); $callback = function () use($probe) { try { yield; } catch (\RuntimeException $e) { } }; $generator = $callback(); $handler1 = $this->getMock('Durian\\Handler'); $handler1->expects($this->once())->method('__invoke')->will($this->returnValue($generator)); $handler2 = function () use($probe, $context) { $probe->context($context); }; $app->handlers([$handler1, $handler2]); $app->run(); }