Adding support for pattern based attribute values in assertTags()

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6723 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
mariano.iglesias 2008-04-26 13:44:02 +00:00
parent db2c2c02d1
commit fae3b0386a

View file

@ -428,6 +428,10 @@ 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+/'))
*
* Important: This function is very forgiving about whitespace and also accepts any permutation of attribute order.
*
* @param string $string An HTML/XHTML/XML string
@ -464,6 +468,8 @@ class CakeTestCase extends UnitTestCase {
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, '/');
}