From 136b4db7adef2cef07878af4eb9129cb00916c1b Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 26 Aug 2009 22:46:49 -0400 Subject: [PATCH] Deprecating $escape for HtmlHelper::tag() use $attributes['escape'] instead. Test case added. --- cake/libs/view/helpers/html.php | 5 ++++- .../cases/libs/view/helpers/html.test.php | 18 ++++++------------ 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/cake/libs/view/helpers/html.php b/cake/libs/view/helpers/html.php index 3ed9ddcd8..7e98caeb2 100644 --- a/cake/libs/view/helpers/html.php +++ b/cake/libs/view/helpers/html.php @@ -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)) { diff --git a/cake/tests/cases/libs/view/helpers/html.test.php b/cake/tests/cases/libs/view/helpers/html.test.php index e6f4f745c..bb5752c4a 100644 --- a/cake/tests/cases/libs/view/helpers/html.test.php +++ b/cake/tests/cases/libs/view/helpers/html.test.php @@ -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', '', array('class' => 'class-name'), true); $this->assertTags($result, array('div' => array('class' => 'class-name'), '<text>', '/div')); + $result = $this->Html->tag('div', '', array('class' => 'class-name', 'escape' => true)); + $this->assertTags($result, array('div' => array('class' => 'class-name'), '<text>', '/div')); + $result = $this->Html->tag('div', '', 'class-name', true); $this->assertTags($result, array('div' => array('class' => 'class-name'), '<text>', '/div')); } @@ -1145,15 +1149,5 @@ class HtmlHelperTest extends CakeTestCase { $result = $this->Html->para('class-name', '', array(), true); $this->assertTags($result, array('p' => array('class' => 'class-name'), '<text>', '/p')); } -/** - * endTest method - * - * @access public - * @return void - */ - function endTest() { - ClassRegistry::flush(); - unset($this->Html); - } } ?> \ No newline at end of file