Allowing regular expressions as part of the tag construction in assertTags()

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6725 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
mariano.iglesias 2008-04-26 14:28:00 +00:00
parent 2902969504
commit 3f0b8217ec

View file

@ -428,9 +428,12 @@ class CakeTestCase extends UnitTestCase {
* '!p'
* )
*
* You can also specify a pattern expression as part of the attribute values if you prepend the value with preg:, and
* enclose it with slashes, like so:
* array('input' => array('name', 'id' => 'preg:/FieldName\d+/'))
* You can also specify a pattern expression as part of the attribute values, or the tag being defined,
* if you prepend the value with preg: and enclose it with slashes, like so:
* array(
* array('input' => array('name', 'id' => 'preg:/FieldName\d+/')),
* 'preg:/My\s+field/'
* )
*
* Important: This function is very forgiving about whitespace and also accepts any permutation of attribute order.
*
@ -458,7 +461,12 @@ class CakeTestCase extends UnitTestCase {
$regex[] = '<[\s]*\/[\s]*'.substr($tags, 1).'[\s]*>';
continue;
}
$regex[] = preg_quote($tags, '/');
if (!empty($tags) && preg_match('/^preg\:\/(.+)\/$/i', $tags, $matches)) {
$tags = $matches[1];
} else {
$tags = preg_quote($tags, '/');
}
$regex[] = $tags;
continue;
}
foreach ($tags as $tag => $attributes) {