mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
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:
parent
697261e3da
commit
14fc2ef778
1 changed files with 3 additions and 1 deletions
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue