mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-18 10:36:16 +00:00
Optimizing optional quotes handling in assertTags
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6786 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
14fc2ef778
commit
22781b8af5
1 changed files with 3 additions and 3 deletions
|
@ -505,20 +505,20 @@ class CakeTestCase extends UnitTestCase {
|
||||||
$explanations[] = sprintf('Regex "%s" matches', $matches[1]);
|
$explanations[] = sprintf('Regex "%s" matches', $matches[1]);
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
$quotes = true;
|
$quotes = '"';
|
||||||
if (is_numeric($attr)) {
|
if (is_numeric($attr)) {
|
||||||
$attr = $val;
|
$attr = $val;
|
||||||
$val = '.+?';
|
$val = '.+?';
|
||||||
$explanations[] = sprintf('Attribute "%s" present', $attr);
|
$explanations[] = sprintf('Attribute "%s" present', $attr);
|
||||||
} else if (!empty($val) && preg_match('/^preg\:\/(.+)\/$/i', $val, $matches)) {
|
} else if (!empty($val) && preg_match('/^preg\:\/(.+)\/$/i', $val, $matches)) {
|
||||||
$quotes = false;
|
$quotes = '"?';
|
||||||
$val = $matches[1];
|
$val = $matches[1];
|
||||||
$explanations[] = sprintf('Attribute "%s" matches "%s"', $attr, $val);
|
$explanations[] = sprintf('Attribute "%s" matches "%s"', $attr, $val);
|
||||||
} else {
|
} else {
|
||||||
$explanations[] = sprintf('Attribute "%s" == "%s"', $attr, $val);
|
$explanations[] = sprintf('Attribute "%s" == "%s"', $attr, $val);
|
||||||
$val = preg_quote($val, '/');
|
$val = preg_quote($val, '/');
|
||||||
}
|
}
|
||||||
$attrs[] = '[\s]+'.preg_quote($attr, '/').'='.ife($quotes, '"', '"?').$val.ife($quotes, '"', '"?');
|
$attrs[] = '[\s]+'.preg_quote($attr, '/').'='.$quotes.$val.$quotes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($attrs) {
|
if ($attrs) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue