', ], [ 'star', [ 'tag' => 'i', 'prefix' => 'my-icon icon-', ], '', ], ]; } /** * @dataProvider dataProviderIcon * * @param $name * @param $options * @param $expectedHtml */ public function testIcon($name, array $options, $expectedHtml) { $this->assertEquals($expectedHtml, Html::icon($name, $options)); } /** * @return array */ public function dataProviderStaticControl() { return [ [ 'foo', [], '

foo

' ], [ '', [], '

<html>

' ], [ '', [ 'encode' => false ], '

' ], ]; } /** * @dataProvider dataProviderStaticControl * * @param string $value * @param array $options * @param string $expectedHtml */ public function testStaticControl($value, array $options, $expectedHtml) { $this->assertEquals($expectedHtml, Html::staticControl($value, $options)); } public function testRadioList() { $this->assertEquals('
', Html::radioList('test')); $dataItems = [ 'value1' => 'text1', 'value2' => 'text2', ]; $expected = <<<'EOD'
EOD; $this->assertEqualsWithoutLE($expected, Html::radioList('test', ['value2'], $dataItems)); $expected = <<<'EOD'
0 1
EOD; $this->assertEqualsWithoutLE($expected, Html::radioList('test', ['value2'], $dataItems, [ 'item' => function ($index, $label, $name, $checked, $value) { return $index . Html::label($label . ' ' . Html::radio($name, $checked, ['value' => $value])); }, ])); $expected = <<<'EOD'
EOD; $this->assertEqualsWithoutLE($expected, Html::radioList('test', [], ['value' => 'label&'])); $expected = <<<'EOD'
EOD; $this->assertEqualsWithoutLE($expected, Html::radioList('test', [], ['value' => 'label&'], ['encode' => false])); } public function testCheckboxList() { $this->assertEquals('
', Html::checkboxList('test')); $dataItems = [ 'value1' => 'text1', 'value2' => 'text2', ]; $expected = <<<'EOD'
EOD; $this->assertEqualsWithoutLE($expected, Html::checkboxList('test', ['value2'], $dataItems)); $expected = <<<'EOD'
0 1
EOD; $this->assertEqualsWithoutLE($expected, Html::checkboxList('test', ['value2'], $dataItems, [ 'item' => function ($index, $label, $name, $checked, $value) { return $index . Html::label($label . ' ' . Html::checkbox($name, $checked, ['value' => $value])); }, ])); $expected = <<<'EOD'
EOD; $this->assertEqualsWithoutLE($expected, Html::checkboxList('test', 'value', ['value' => 'label&'])); $expected = <<<'EOD'
EOD; $this->assertEqualsWithoutLE($expected, Html::checkboxList('test', 'value', ['value' => 'label&'], ['encode' => false])); } }