tests: Complete test coverage of HtmlArmor
authorKunal Mehta <legoktm@member.fsf.org>
Thu, 28 Dec 2017 03:22:51 +0000 (19:22 -0800)
committerKunal Mehta <legoktm@member.fsf.org>
Thu, 28 Dec 2017 08:56:12 +0000 (00:56 -0800)
Change-Id: I3c50ea56721226ddb37bcf4778a7d71e9b56d0f7

tests/phpunit/includes/libs/HtmlArmorTest.php

index 5f176e0..0e9469a 100644 (file)
@@ -5,7 +5,22 @@
  */
 class HtmlArmorTest extends PHPUnit_Framework_TestCase {
 
-       public static function provideHtmlArmor() {
+       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',
@@ -19,13 +34,17 @@ class HtmlArmorTest extends PHPUnit_Framework_TestCase {
                                new HtmlArmor( '<script>alert("evil!");</script>' ),
                                '<script>alert("evil!");</script>',
                        ],
+                       [
+                               new HtmlArmor( null ),
+                               null,
+                       ]
                ];
        }
 
        /**
-        * @dataProvider provideHtmlArmor
+        * @dataProvider provideGetHtml
         */
-       public function testHtmlArmor( $input, $expected ) {
+       public function testGetHtml( $input, $expected ) {
                $this->assertEquals(
                        $expected,
                        HtmlArmor::getHtml( $input )