Skip to content

Instantly share code, notes, and snippets.

@romainneutron
Created January 24, 2013 11:00
Show Gist options
  • Save romainneutron/4620042 to your computer and use it in GitHub Desktop.
Save romainneutron/4620042 to your computer and use it in GitHub Desktop.
<?php
namespace Silex\Tests;
use Silex\Application;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
class ExceptionHandlerTest extends \PHPUnit_Framework_TestCase
{
public function testExceptionHandlerShouldNotCatchExceptionIfDisabled()
{
$app = new Application();
$app->match('/foo', function () {
throw new \RuntimeException('foo exception');
});
$app->error(function ($e) {
throw new \RuntimeException('foo exception handler exception');
});
$app['exception_handler']->disable();
try {
$request = Request::create('/foo');
$app->handle($request);
$this->fail('->handle() should not catch exceptions thrown from an error handler');
} catch (\RuntimeException $e) {
$this->assertEquals('foo exception', $e->getMessage());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment