public function getTests() {
$fixturesDir = realpath($this
->getFixturesDir());
$tests = array();
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($fixturesDir), RecursiveIteratorIterator::LEAVES_ONLY) as $file) {
if (!preg_match('/\\.test$/', $file)) {
continue;
}
$test = file_get_contents($file
->getRealpath());
if (preg_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[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];
$templates = $this
->parseTemplates($match[3]);
$exception = false;
preg_match_all('/--DATA--(.*?)(?:--CONFIG--(.*?))?--EXPECT--(.*?)(?=\\-\\-DATA\\-\\-|$)/s', $test, $outputs, PREG_SET_ORDER);
}
else {
throw new InvalidArgumentException(sprintf('Test "%s" is not valid.', str_replace($fixturesDir . '/', '', $file)));
}
$tests[] = array(
str_replace($fixturesDir . '/', '', $file),
$message,
$condition,
$templates,
$exception,
$outputs,
);
}
return $tests;
}