From 3f0b8217ec671ed834ef3ff49e53ce0fae0e2b96 Mon Sep 17 00:00:00 2001 From: "mariano.iglesias" Date: Sat, 26 Apr 2008 14:28:00 +0000 Subject: [PATCH] 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 --- cake/tests/lib/cake_test_case.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/cake/tests/lib/cake_test_case.php b/cake/tests/lib/cake_test_case.php index b31a1338a..1eb37bb09 100644 --- a/cake/tests/lib/cake_test_case.php +++ b/cake/tests/lib/cake_test_case.php @@ -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) {