Permalink
Browse files

allow --EXCEPTION-- tests to have a --DATA-- block

  • Loading branch information...
arnaud-lb committed Aug 20, 2012
1 parent 3e4057b commit 3694d4b2bf241e59c1720a01c7f4f951e7794e0a
Showing with 9 additions and 3 deletions.
  1. +9 −3 test/Twig/Tests/integrationTest.php
@@ -31,12 +31,12 @@ public function getTests()
$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 @@ public function testIntegration($file, $message, $condition, $templates, $except
$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) {

0 comments on commit 3694d4b

Please sign in to comment.