Permalink
Browse files

Deprecating $escape for HtmlHelper::tag() use $attributes['escape'] i…

…nstead. Test case added.
  • Loading branch information...
1 parent 56d2423 commit 136b4db7adef2cef07878af4eb9129cb00916c1b @markstory markstory committed Aug 27, 2009
Showing with 10 additions and 13 deletions.
  1. +4 −1 cake/libs/view/helpers/html.php
  2. +6 −12 cake/tests/cases/libs/view/helpers/html.test.php
@@ -708,7 +708,10 @@ function tableCells($data, $oddTrOptions = null, $evenTrOptions = null, $useCoun
* @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)) {
@@ -123,16 +123,17 @@ function startTest() {
}
/**
- * 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 @@ function testTag() {
$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 @@ function testPara() {
$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);
- }
}
?>

0 comments on commit 136b4db

Please sign in to comment.