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

Signed-off-by: Mark Story <mark@mark-story.com>
This commit is contained in:
Phally 2009-10-28 19:14:50 +01:00 committed by mark_story
parent 02f9275e20
commit bb92a47ddb
2 changed files with 54 additions and 0 deletions

View file

@ -164,6 +164,57 @@ class CakeTestCaseTest extends CakeTestCase {
}
/**
* 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

View file

@ -586,6 +586,9 @@ class CakeTestCase extends UnitTestCase {
}
$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());