From 3f962ba89ee968f30b1a07ae33aa777e20646198 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 3 Apr 2012 08:49:35 +0200 Subject: [PATCH] enhance error reporting in Twig unit tests --- test/Twig/Tests/integrationTest.php | 14 +++++++++++++- 1 files changed, 13 insertions(+), 1 deletions(-) diff --git a/test/Twig/Tests/integrationTest.php b/test/Twig/Tests/integrationTest.php index 2045097..4a41b2e 100644 --- a/test/Twig/Tests/integrationTest.php +++ b/test/Twig/Tests/integrationTest.php @@ -84,12 +84,24 @@ class Twig_Tests_IntegrationTest extends PHPUnit_Framework_TestCase throw $e; } - throw new Twig_Error($e->getMessage().' (in '.$file.')'); + throw new Twig_Error(sprintf('%s: %s', get_class($e), $e->getMessage()), -1, $file, $e); } try { $output = trim($template->render(eval($match[1].';')), "\n "); } catch (Exception $e) { + if (false !== $exception) { + $this->assertEquals(trim($exception), trim(sprintf('%s: %s', get_class($e), $e->getMessage()))); + + return; + } + + if ($e instanceof Twig_Error_Syntax) { + $e->setTemplateFile($file); + } else { + $e = new Twig_Error(sprintf('%s: %s', get_class($e), $e->getMessage()), -1, $file, $e); + } + $output = trim(sprintf('%s: %s', get_class($e), $e->getMessage())); } $expected = trim($match[3], "\n "); -- 1.7.2.5