Permalink
Browse files

Better approach to exception handling in tests

  • Loading branch information...
1 parent fa4a27e commit cf4d355cb69ec6d9522f78df7b9ea509e78761ab @igorw committed Jun 29, 2012
Showing with 11 additions and 1 deletion.
  1. +4 −0 src/app.php
  2. +7 −1 tests/FunctionalTest.php
View
@@ -81,6 +81,10 @@
->assert('id', '[0-9a-f]{8}');
$app->error(function (Exception $e) use ($app) {
+ if (!$app['catch_exceptions']) {
+ return;
+ }
+
$code = ($e instanceof HttpException) ? $e->getStatusCode() : 500;
return new Response($app['twig']->render('error.html', array(
View
@@ -8,9 +8,13 @@ public function createApplication()
{
$app = require __DIR__.'/../src/app.php';
+ $app['catch_exceptions'] = false;
+
$app['app.storage'] = $this->getMockBuilder('Igorw\Trashbin\Storage')->disableOriginalConstructor()->getMock();
- unset($this->app['exception_handler']);
+ $app['twig.options'] = array('debug' => true);
+
+ unset($app['exception_handler']);
return $app;
}
@@ -94,6 +98,8 @@ public function testViewPaste()
public function testViewPasteWithInvalidId()
{
+ $this->app['catch_exceptions'] = true;
+
$this->app['app.storage']
->expects($this->once())
->method('get')

0 comments on commit cf4d355

Please sign in to comment.