CakeTestCase::assertTags() now allows regular expressions for an entire attribute / attribute set

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6744 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
mariano.iglesias 2008-05-01 19:35:12 +00:00
parent 2aff396611
commit c585658c27

View file

@ -477,15 +477,19 @@ class CakeTestCase extends UnitTestCase {
} }
$attrs = array(); $attrs = array();
foreach ($attributes as $attr => $val) { foreach ($attributes as $attr => $val) {
if (is_numeric($attr)) { if (is_numeric($attr) && preg_match('/^preg\:\/(.+)\/$/i', $val, $matches)) {
$attr = $val; $attrs[] = $matches[1];
$val = '.*?';
} else if (!empty($val) && preg_match('/^preg\:\/(.+)\/$/i', $val, $matches)) {
$val = $matches[1];
} else { } else {
$val = preg_quote($val, '/'); if (is_numeric($attr)) {
$attr = $val;
$val = '.*?';
} else if (!empty($val) && preg_match('/^preg\:\/(.+)\/$/i', $val, $matches)) {
$val = $matches[1];
} else {
$val = preg_quote($val, '/');
}
$attrs[] = '[\s]+'.preg_quote($attr, '/').'="'.$val.'"';
} }
$attrs[] = '[\s]+'.preg_quote($attr, '/').'="'.$val.'"';
} }
if ($attrs) { if ($attrs) {
$permutations = $this->__array_permute($attrs); $permutations = $this->__array_permute($attrs);