From: Arnaud Le Blanc Date: Mon, 20 Aug 2012 18:27:57 +0000 (+0200) Subject: allow --EXCEPTION-- tests to have a --DATA-- block X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=3694d4b2bf241e59c1720a01c7f4f951e7794e0a;p=web%2Fkonrad%2Ftwig.git allow --EXCEPTION-- tests to have a --DATA-- block --- 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) {