Allowing quotes enclosing attributes to be optional when regular expression used in assertTags

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6785 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
mariano.iglesias 2008-05-10 04:26:52 +00:00
parent 697261e3da
commit 14fc2ef778

View file

@ -505,18 +505,20 @@ class CakeTestCase extends UnitTestCase {
$explanations[] = sprintf('Regex "%s" matches', $matches[1]);
continue;
} else {
$quotes = true;
if (is_numeric($attr)) {
$attr = $val;
$val = '.+?';
$explanations[] = sprintf('Attribute "%s" present', $attr);
} else if (!empty($val) && preg_match('/^preg\:\/(.+)\/$/i', $val, $matches)) {
$quotes = false;
$val = $matches[1];
$explanations[] = sprintf('Attribute "%s" matches "%s"', $attr, $val);
} else {
$explanations[] = sprintf('Attribute "%s" == "%s"', $attr, $val);
$val = preg_quote($val, '/');
}
$attrs[] = '[\s]+'.preg_quote($attr, '/').'="'.$val.'"';
$attrs[] = '[\s]+'.preg_quote($attr, '/').'='.ife($quotes, '"', '"?').$val.ife($quotes, '"', '"?');
}
}
if ($attrs) {