diff options
author | Yaco <franco@reevo.org> | 2020-06-04 11:01:00 -0300 |
---|---|---|
committer | Yaco <franco@reevo.org> | 2020-06-04 11:01:00 -0300 |
commit | fc7369835258467bf97eb64f184b93691f9a9fd5 (patch) | |
tree | daabd60089d2dd76d9f5fb416b005fbe159c799d /www/wiki/tests/phpunit/includes/libs/HtmlArmorTest.php |
first commit
Diffstat (limited to 'www/wiki/tests/phpunit/includes/libs/HtmlArmorTest.php')
-rw-r--r-- | www/wiki/tests/phpunit/includes/libs/HtmlArmorTest.php | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/www/wiki/tests/phpunit/includes/libs/HtmlArmorTest.php b/www/wiki/tests/phpunit/includes/libs/HtmlArmorTest.php new file mode 100644 index 00000000..c5e87e4e --- /dev/null +++ b/www/wiki/tests/phpunit/includes/libs/HtmlArmorTest.php @@ -0,0 +1,55 @@ +<?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>', + '<script>alert("evil!");</script>', + ], + [ + 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 ) + ); + } +} |