Permalink
Browse files

Added support for numeric values in expectation of assertTags().

Signed-off-by: Mark Story <mark@mark-story.com>
  • Loading branch information...
1 parent 02f9275 commit bb92a47ddbd8191544f6ce8457a3c98041a60f91 @Phally Phally committed with markstory Oct 28, 2009
Showing with 54 additions and 0 deletions.
  1. +51 −0 cake/tests/cases/libs/cake_test_case.test.php
  2. +3 −0 cake/tests/lib/cake_test_case.php
@@ -164,6 +164,57 @@ function testAssertGoodTags() {
}
/**
+ * testNumericValuesInExpectationForAssertTags
+ *
+ * @access public
+ * @return void
+ */
+
+ function testNumericValuesInExpectationForAssertTags() {
+ $value = 220985;
+
+ $input = '<p><strong>' . $value . '</strong></p>';
+ $pattern = array(
+ 'p' => array(),
+ 'strong' => array(),
+ $value,
+ '/strong',
+ '/p'
+ );
+ $this->assertTrue($this->Case->assertTags($input, $pattern));
+
+ $input = '<p><strong>' . $value . '</strong></p><p><strong>' . $value . '</strong></p>';
+ $pattern = array(
+ array('p' => array()),
+ array('strong' => array()),
+ $value,
+ '/strong',
+ '/p',
+ array('p' => array()),
+ array('strong' => array()),
+ $value,
+ '/strong',
+ '/p',
+ );
+ $this->assertTrue($this->Case->assertTags($input, $pattern));
+
+ $input = '<p><strong>' . $value . '</strong></p><p id="' . $value . '"><strong>' . $value . '</strong></p>';
+ $pattern = array(
+ array('p' => array()),
+ array('strong' => array()),
+ $value,
+ '/strong',
+ '/p',
+ array('p' => array('id' => $value)),
+ array('strong' => array()),
+ $value,
+ '/strong',
+ '/p',
+ );
+ $this->assertTrue($this->Case->assertTags($input, $pattern));
+ }
+
+ /**
* testBadAssertTags
*
* @access public
@@ -586,6 +586,9 @@ function assertTags($string, $expected, $fullDebug = false) {
}
$i = 0;
foreach ($normalized as $tags) {
+ if (!is_array($tags)) {
+ $tags = (string)$tags;
+ }
$i++;
if (is_string($tags) && $tags{0} == '<') {
$tags = array(substr($tags, 1) => array());

0 comments on commit bb92a47

Please sign in to comment.