From 63e650952b314a9b5b2faaaed4f1b1b18f38686d Mon Sep 17 00:00:00 2001 From: SilverFire - Dmitry Naumenko Date: Tue, 29 Nov 2016 00:05:55 +0200 Subject: [PATCH] Updated tests for HtmlHelper::textarea() --- framework/helpers/BaseHtml.php | 1 - tests/framework/helpers/HtmlTest.php | 41 +++++++++++++++++++++++++++++++++--- 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/framework/helpers/BaseHtml.php b/framework/helpers/BaseHtml.php index d28d67a..92b7b28 100644 --- a/framework/helpers/BaseHtml.php +++ b/framework/helpers/BaseHtml.php @@ -670,7 +670,6 @@ class BaseHtml 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); } diff --git a/tests/framework/helpers/HtmlTest.php b/tests/framework/helpers/HtmlTest.php index 969e297..a83b4dd 100644 --- a/tests/framework/helpers/HtmlTest.php +++ b/tests/framework/helpers/HtmlTest.php @@ -213,10 +213,45 @@ class HtmlTest extends TestCase $this->assertEquals('', Html::fileInput('test', 'value', ['class' => 't'])); } - public function testTextarea() + /** + * @return array + */ + public function textareaDataProvider() + { + return [ + [ + '', + 'test', + null, + [] + ], + [ + '', + 'test', + 'value<>', + ['class' => 't'] + ], + [ + '', + 'test', + 'value<>', + [] + ], + [ + '', + 'test', + 'value<>', + ['doubleEncode' => false] + ], + ]; + } + + /** + * @dataProvider textareaDataProvider + */ + public function testTextarea($expected, $name, $value, $options) { - $this->assertEquals('', Html::textarea('test')); - $this->assertEquals('', Html::textarea('test', 'value<>', ['class' => 't'])); + $this->assertEquals($expected, Html::textarea($name, $value, $options)); } public function testRadio()