MediaWiki REL1_31
HtmlArmorTest.php
Go to the documentation of this file.
1<?php
2
6class HtmlArmorTest extends PHPUnit\Framework\TestCase {
7
8 use MediaWikiCoversValidator;
9
10 public static function provideConstructor() {
11 return [
12 [ 'test' ],
13 [ null ],
14 [ '<em>some html!</em>' ]
15 ];
16 }
17
21 public function testConstructor( $value ) {
22 $this->assertInstanceOf( HtmlArmor::class, new HtmlArmor( $value ) );
23 }
24
25 public static function provideGetHtml() {
26 return [
27 [
28 'foobar',
29 'foobar',
30 ],
31 [
32 '<script>alert("evil!");</script>',
33 '&lt;script&gt;alert(&quot;evil!&quot;);&lt;/script&gt;',
34 ],
35 [
36 new HtmlArmor( '<script>alert("evil!");</script>' ),
37 '<script>alert("evil!");</script>',
38 ],
39 [
40 new HtmlArmor( null ),
41 null,
42 ]
43 ];
44 }
45
49 public function testGetHtml( $input, $expected ) {
50 $this->assertEquals(
51 $expected,
52 HtmlArmor::getHtml( $input )
53 );
54 }
55}
static provideConstructor()
testGetHtml( $input, $expected)
provideGetHtml
testConstructor( $value)
provideConstructor
static provideGetHtml()
Marks HTML that shouldn't be escaped.
Definition HtmlArmor.php:28
if(is_array($mode)) switch( $mode) $input