From 3694d4b2bf241e59c1720a01c7f4f951e7794e0a Mon Sep 17 00:00:00 2001 From: Arnaud Le Blanc Date: Mon, 20 Aug 2012 20:27:57 +0200 Subject: [PATCH] allow --EXCEPTION-- tests to have a --DATA-- block --- test/Twig/Tests/integrationTest.php | 12 +++++++++--- 1 files changed, 9 insertions(+), 3 deletions(-) diff --git a/test/Twig/Tests/integrationTest.php b/test/Twig/Tests/integrationTest.php index b905b56..3171758 100644 --- a/test/Twig/Tests/integrationTest.php +++ b/test/Twig/Tests/integrationTest.php @@ -31,12 +31,12 @@ class Twig_Tests_IntegrationTest extends PHPUnit_Framework_TestCase $test = file_get_contents($file->getRealpath()); if (preg_match('/ - --TEST--\s*(.*?)\s*(?:--CONDITION--\s*(.*))?\s*((?:--TEMPLATE(?:\(.*?\))?--(?:.*))+)\s*--EXCEPTION--\s*(.*)/sx', $test, $match)) { + --TEST--\s*(.*?)\s*(?:--CONDITION--\s*(.*))?\s*((?:--TEMPLATE(?:\(.*?\))?--(?:.*?))+)\s*(?:--DATA--\s*(.*))?\s*--EXCEPTION--\s*(.*)/sx', $test, $match)) { $message = $match[1]; $condition = $match[2]; $templates = $this->parseTemplates($match[3]); - $exception = $match[4]; - $outputs = array(null, array(), null, ''); + $exception = $match[5]; + $outputs = array(array(null, $match[4], null, '')); } elseif (preg_match('/--TEST--\s*(.*?)\s*(?:--CONDITION--\s*(.*))?\s*((?:--TEMPLATE(?:\(.*?\))?--(?:.*?))+)--DATA--.*?--EXPECT--.*/s', $test, $match)) { $message = $match[1]; $condition = $match[2]; @@ -114,6 +114,12 @@ class Twig_Tests_IntegrationTest extends PHPUnit_Framework_TestCase $output = trim(sprintf('%s: %s', get_class($e), $e->getMessage())); } + + if (false !== $exception) { + list($class, ) = explode(':', $exception); + $this->assertThat(NULL, new PHPUnit_Framework_Constraint_Exception($class)); + } + $expected = trim($match[3], "\n "); if ($expected != $output) { -- 1.7.2.5