Skip to content

Commit

Permalink
Updated tests for HtmlHelper::textarea()
Browse files Browse the repository at this point in the history
  • Loading branch information
SilverFire committed Nov 28, 2016
1 parent 10ad620 commit 63e6509
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 4 deletions.
1 change: 0 additions & 1 deletion framework/helpers/BaseHtml.php
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,6 @@ public static function fileInput($name, $value = null, $options = [])
public static function textarea($name, $value = '', $options = [])
{
$options['name'] = $name;
// Get value, then remove from array - not needed for `renderTagAttributes` called inside the `tag` method
$doubleEncode = ArrayHelper::remove($options, 'doubleEncode', true);
return static::tag('textarea', static::encode($value, $doubleEncode), $options);
}
Expand Down
41 changes: 38 additions & 3 deletions tests/framework/helpers/HtmlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,45 @@ public function testFileInput()
$this->assertEquals('<input type="file" class="t" name="test" value="value">', Html::fileInput('test', 'value', ['class' => 't']));
}

public function testTextarea()
/**
* @return array
*/
public function textareaDataProvider()
{
return [
[
'<textarea name="test"></textarea>',
'test',
null,
[]
],
[
'<textarea class="t" name="test">value&lt;&gt;</textarea>',
'test',
'value<>',
['class' => 't']
],
[
'<textarea name="test">value&amp;lt;&amp;gt;</textarea>',
'test',
'value&lt;&gt;',
[]
],
[
'<textarea name="test">value&lt;&gt;</textarea>',
'test',
'value&lt;&gt;',
['doubleEncode' => false]
],
];
}

/**
* @dataProvider textareaDataProvider
*/
public function testTextarea($expected, $name, $value, $options)
{
$this->assertEquals('<textarea name="test"></textarea>', Html::textarea('test'));
$this->assertEquals('<textarea class="t" name="test">value&lt;&gt;</textarea>', Html::textarea('test', 'value<>', ['class' => 't']));
$this->assertEquals($expected, Html::textarea($name, $value, $options));
}

public function testRadio()
Expand Down

0 comments on commit 63e6509

Please sign in to comment.