]> scripts.mit.edu Git - autoinstalls/mediawiki.git/blob - tests/phpunit/includes/libs/HtmlArmorTest.php
MediaWiki 1.30.2-scripts2
[autoinstalls/mediawiki.git] / tests / phpunit / includes / libs / HtmlArmorTest.php
1 <?php
2
3 /**
4  * @covers HtmlArmor
5  */
6 class HtmlArmorTest extends PHPUnit_Framework_TestCase {
7
8         public static function provideHtmlArmor() {
9                 return [
10                         [
11                                 'foobar',
12                                 'foobar',
13                         ],
14                         [
15                                 '<script>alert("evil!");</script>',
16                                 '&lt;script&gt;alert(&quot;evil!&quot;);&lt;/script&gt;',
17                         ],
18                         [
19                                 new HtmlArmor( '<script>alert("evil!");</script>' ),
20                                 '<script>alert("evil!");</script>',
21                         ],
22                 ];
23         }
24
25         /**
26          * @dataProvider provideHtmlArmor
27          */
28         public function testHtmlArmor( $input, $expected ) {
29                 $this->assertEquals(
30                         $expected,
31                         HtmlArmor::getHtml( $input )
32                 );
33         }
34 }