Deprecating $escape for HtmlHelper::tag() use $attributes['escape'] instead. Test case added.

This commit is contained in:
mark_story 2009-08-26 22:46:49 -04:00
parent 56d2423bc3
commit 136b4db7ad
2 changed files with 10 additions and 13 deletions

View file

@ -708,7 +708,10 @@ class HtmlHelper extends AppHelper {
* @access public
*/
function tag($name, $text = null, $attributes = array(), $escape = false) {
if ($escape) {
if ($escape || isset($attributes['escape']) && $attributes['escape']) {
if (is_array($attributes)) {
unset($attributes['escape']);
}
$text = h($text);
}
if (!is_array($attributes)) {

View file

@ -123,16 +123,17 @@ class HtmlHelperTest extends CakeTestCase {
}
/**
* tearDown method
* endTest method
*
* @access public
* @return void
*/
function tearDown() {
function endTest() {
Configure::write('App.encoding', $this->_appEncoding);
Configure::write('Asset', $this->_asset);
Configure::write('debug', $this->_debug);
ClassRegistry::flush();
unset($this->Html);
}
/**
@ -1108,6 +1109,9 @@ class HtmlHelperTest extends CakeTestCase {
$result = $this->Html->tag('div', '<text>', array('class' => 'class-name'), true);
$this->assertTags($result, array('div' => array('class' => 'class-name'), '&lt;text&gt;', '/div'));
$result = $this->Html->tag('div', '<text>', array('class' => 'class-name', 'escape' => true));
$this->assertTags($result, array('div' => array('class' => 'class-name'), '&lt;text&gt;', '/div'));
$result = $this->Html->tag('div', '<text>', 'class-name', true);
$this->assertTags($result, array('div' => array('class' => 'class-name'), '&lt;text&gt;', '/div'));
}
@ -1145,15 +1149,5 @@ class HtmlHelperTest extends CakeTestCase {
$result = $this->Html->para('class-name', '<text>', array(), true);
$this->assertTags($result, array('p' => array('class' => 'class-name'), '&lt;text&gt;', '/p'));
}
/**
* endTest method
*
* @access public
* @return void
*/
function endTest() {
ClassRegistry::flush();
unset($this->Html);
}
}
?>