', '<abc>'],
['alert(":-)");', 'alert(":-)");'],
['alert(\':-)\');', 'alert(':-)');'],
];
}
/**
* @dataProvider encodeProvider
*/
public function testEncode($string, $expected)
{
$this->assertSame($expected, HtmlHelper::encode($string));
}
public function voidTagInvalidArgumentProvider()
{
return [
[1, []],
[false, []],
];
}
/**
* @dataProvider voidTagInvalidArgumentProvider
* @expectedException \InvalidArgumentException
*/
public function testVoidTagInvalidArgument($name, $attributes)
{
HtmlHelper::voidTag($name, $attributes);
}
public function voidTagProvider()
{
return [
['tag', [], ''],
['void', ['a' => '1'], ''],
['void', ['a' => ''], ''],
['void', ['a' => 1], ''],
['void', ['a' => '1', 'b' => '2'], ''],
['void', ['b' => '1', 'a' => '2'], ''],
['void', ['a' => null, 'b' => '2'], ''],
['void', ['a' => true], ''],
['void', ['a' => true, 'b' => '2'], ''],
['void', ['a' => false], ''],
['void', ['a' => false, 'b' => '2'], ''],
['script', ['type' => 'text/javascript'], ''],
['img', ['ondrag' => 'alert(":-)")'], ''],
['img', ['ondrag' => "alert(':-)')"], ''],
[null, [], null],
[null, ['attr' => 'v'], null],
];
}
/**
* @dataProvider voidTagProvider
*/
public function testVoidTag($name, $attributes, $expected_tag)
{
$this->assertSame($expected_tag, HtmlHelper::voidTag($name, $attributes));
}
public function testVoidTagNoAttributes()
{
$this->assertSame('', HtmlHelper::voidTag('tag'));
}
public function startTagInvalidArgumentProvider()
{
return [
[1, []],
[false, []],
];
}
/**
* @dataProvider startTagInvalidArgumentProvider
* @expectedException \InvalidArgumentException
*/
public function testStartTagInvalidArgument($name, $attributes)
{
HtmlHelper::startTag($name, $attributes);
}
public function startTagProvider()
{
return [
['tag', [], ''],
['start', ['a' => '1'], ''],
['start', ['a' => ''], ''],
['start', ['a' => 1], ''],
['start', ['a' => '1', 'b' => '2'], ''],
['start', ['b' => '1', 'a' => '2'], ''],
['start', ['a' => null, 'b' => '2'], ''],
['start', ['a' => true], ''],
['start', ['a' => true, 'b' => '2'], ''],
['start', ['a' => false], ''],
['start', ['a' => false, 'b' => '2'], ''],
['script', ['type' => 'text/javascript'], '