From 7aeb2fcf4fe19ba2768a84bde55bb8e5659ddf56 Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Fri, 9 Aug 2013 09:21:41 -0400 Subject: [PATCH] Fixed test breaks. --- framework/yii/helpers/HtmlBase.php | 14 +++++---- tests/unit/framework/helpers/HtmlTest.php | 50 +++++++++++++++++++++++-------- 2 files changed, 46 insertions(+), 18 deletions(-) diff --git a/framework/yii/helpers/HtmlBase.php b/framework/yii/helpers/HtmlBase.php index f368b97..d6ee2b5 100644 --- a/framework/yii/helpers/HtmlBase.php +++ b/framework/yii/helpers/HtmlBase.php @@ -761,9 +761,10 @@ class HtmlBase if ($formatter !== null) { $lines[] = call_user_func($formatter, $index, $label, $name, $checked, $value); } else { - $checkbox = static::checkbox($name, $checked, array('value' => $value)); - $content = static::label($checkbox . ' ' . ($encode ? static::encode($label) : $label)); - $lines[] = static::tag('div', $content, array('class' => 'checkbox')); + $lines[] = static::checkbox($name, $checked, array( + 'value' => $value, + 'label' => $encode ? static::encode($label) : $label, + )); } $index++; } @@ -819,9 +820,10 @@ class HtmlBase if ($formatter !== null) { $lines[] = call_user_func($formatter, $index, $label, $name, $checked, $value); } else { - $radio = static::radio($name, $checked, array('value' => $value)); - $content = static::label($radio . ' ' . ($encode ? static::encode($label) : $label)); - $lines[] = static::tag('div', $content, array('class' => 'radio')); + $lines[] = static::radio($name, $checked, array( + 'value' => $value, + 'label' => $encode ? static::encode($label) : $label, + )); } $index++; } diff --git a/tests/unit/framework/helpers/HtmlTest.php b/tests/unit/framework/helpers/HtmlTest.php index 2fb3b75..b041903 100644 --- a/tests/unit/framework/helpers/HtmlTest.php +++ b/tests/unit/framework/helpers/HtmlTest.php @@ -210,6 +210,19 @@ class HtmlTest extends TestCase $this->assertEquals('', Html::radio('test')); $this->assertEquals('', Html::radio('test', true, array('class' => 'a', 'value' => null))); $this->assertEquals('', Html::radio('test', true, array('class' => 'a' , 'uncheck' => '0', 'value' => 2))); + + $this->assertEquals('
', Html::radio('test', true, array( + 'class' => 'a', + 'value' => null, + 'label' => 'ccc', + 'labelOptions' => array('class' =>'bbb'), + ))); + $this->assertEquals('
', Html::radio('test', true, array( + 'class' => 'a', + 'uncheck' => '0', + 'label' => 'ccc', + 'value' => 2, + ))); } public function testCheckbox() @@ -217,6 +230,19 @@ class HtmlTest extends TestCase $this->assertEquals('', Html::checkbox('test')); $this->assertEquals('', Html::checkbox('test', true, array('class' => 'a', 'value' => null))); $this->assertEquals('', Html::checkbox('test', true, array('class' => 'a', 'uncheck' => '0', 'value' => 2))); + + $this->assertEquals('
', Html::checkbox('test', true, array( + 'class' => 'a', + 'value' => null, + 'label' => 'ccc', + 'labelOptions' => array('class' =>'bbb'), + ))); + $this->assertEquals('
', Html::checkbox('test', true, array( + 'class' => 'a', + 'uncheck' => '0', + 'label' => 'ccc', + 'value' => 2, + ))); } public function testDropDownList() @@ -299,20 +325,20 @@ EOD; $this->assertEquals('', Html::checkboxList('test')); $expected = << text1 - +
+
EOD; $this->assertEqualsWithoutLE($expected, Html::checkboxList('test', array('value2'), $this->getDataItems())); $expected = << text1<> - +
+
EOD; $this->assertEqualsWithoutLE($expected, Html::checkboxList('test', array('value2'), $this->getDataItems2())); $expected = <<
- +

+
EOD; $this->assertEqualsWithoutLE($expected, Html::checkboxList('test', array('value2'), $this->getDataItems(), array( 'separator' => "
\n", @@ -335,20 +361,20 @@ EOD; $this->assertEquals('', Html::radioList('test')); $expected = << text1 - +
+
EOD; $this->assertEqualsWithoutLE($expected, Html::radioList('test', array('value2'), $this->getDataItems())); $expected = << text1<> - +
+
EOD; $this->assertEqualsWithoutLE($expected, Html::radioList('test', array('value2'), $this->getDataItems2())); $expected = <<
- +

+
EOD; $this->assertEqualsWithoutLE($expected, Html::radioList('test', array('value2'), $this->getDataItems(), array( 'separator' => "
\n",