wiki.techinc.nl/tests/phpunit/includes/libs/HtmlArmorTest.php
Legoktm 4e35134f7a Revert "Separate MediaWiki unit and integration tests"
This reverts commit 0a2b996278.

Reason for revert: Broke postgres tests.

Change-Id: I27d8e0c807ad5f0748b9611a4f3df84cc213fbe1
2019-06-13 23:00:08 +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 )
);
}
}