wiki.techinc.nl/tests/phpunit/includes/libs/HtmlArmorTest.php
Kunal Mehta 75160bdd3b Use MediaWikiCoversValidator for tests that don't use MediaWikiTestCase
Change-Id: I8c4de7e9c72c9969088666007b54c6fd23f6cc13
2018-01-01 08:28:02 +00:00

55 lines
962 B
PHP

<?php
/**
* @covers HtmlArmor
*/
class HtmlArmorTest extends PHPUnit_Framework_TestCase {
use MediaWikiCoversValidator;
public static function provideConstructor() {
return [
[ 'test' ],
[ null ],
[ '<em>some html!</em>' ]
];
}
/**
* @dataProvider provideConstructor
*/
public function testConstructor( $value ) {
$this->assertInstanceOf( HtmlArmor::class, new HtmlArmor( $value ) );
}
public static function provideGetHtml() {
return [
[
'foobar',
'foobar',
],
[
'<script>alert("evil!");</script>',
'&lt;script&gt;alert(&quot;evil!&quot;);&lt;/script&gt;',
],
[
new HtmlArmor( '<script>alert("evil!");</script>' ),
'<script>alert("evil!");</script>',
],
[
new HtmlArmor( null ),
null,
]
];
}
/**
* @dataProvider provideGetHtml
*/
public function testGetHtml( $input, $expected ) {
$this->assertEquals(
$expected,
HtmlArmor::getHtml( $input )
);
}
}