Fix scope on all /phpunit test methods
[lhc/web/wiklou.git] / tests / phpunit / includes / HtmlTest.php
index 9e3d3a4..1c62d03 100644 (file)
@@ -37,7 +37,6 @@ class HtmlTest extends MediaWikiTestCase {
                        'wgLanguageCode' => $langCode,
                        'wgContLang' => $langObj,
                        'wgLang' => $langObj,
-                       'wgHtml5' => true,
                        'wgWellFormedXml' => false,
                ) );
        }
@@ -70,6 +69,31 @@ class HtmlTest extends MediaWikiTestCase {
                );
        }
 
+       public function dataXmlMimeType() {
+               return array(
+                       // ( $mimetype, $isXmlMimeType )
+                       # HTML is not an XML MimeType
+                       array( 'text/html', false ),
+                       # XML is an XML MimeType
+                       array( 'text/xml', true ),
+                       array( 'application/xml', true ),
+                       # XHTML is an XML MimeType
+                       array( 'application/xhtml+xml', true ),
+                       # Make sure other +xml MimeTypes are supported
+                       # SVG is another random MimeType even though we don't use it
+                       array( 'image/svg+xml', true ),
+                       # Complete random other MimeTypes are not XML
+                       array( 'text/plain', false ),
+               );
+       }
+
+       /**
+        * @dataProvider dataXmlMimeType
+        */
+       public function testXmlMimeType( $mimetype, $isXmlMimeType ) {
+               $this->assertEquals( $isXmlMimeType, Html::isXmlMimeType( $mimetype ) );
+       }
+
        public function testExpandAttributesSkipsNullAndFalse() {
 
                ### EMPTY ########
@@ -117,14 +141,6 @@ class HtmlTest extends MediaWikiTestCase {
                        Html::expandAttributes( array( 'selected' => true ) ),
                        'Boolean attributes have empty string value when value is true (wgWellFormedXml)'
                );
-
-               $this->setMwGlobals( 'wgHtml5', false );
-
-               $this->assertEquals(
-                       ' selected="selected"',
-                       Html::expandAttributes( array( 'selected' => true ) ),
-                       'Boolean attributes have their key as value when value is true (wgWellFormedXml, wgHTML5 = false)'
-               );
        }
 
        /**
@@ -234,7 +250,7 @@ class HtmlTest extends MediaWikiTestCase {
         * Test feature added by r96188, let pass attributes values as
         * a PHP array. Restricted to class,rel, accesskey.
         */
-       function testExpandAttributesSpaceSeparatedAttributesWithBoolean() {
+       public function testExpandAttributesSpaceSeparatedAttributesWithBoolean() {
                $this->assertEquals(
                        ' class="booltrue one"',
                        Html::expandAttributes( array( 'class' => array(
@@ -258,7 +274,7 @@ class HtmlTest extends MediaWikiTestCase {
         *
         * Feature added by r96188
         */
-       function testValueIsAuthoritativeInSpaceSeparatedAttributesArrays() {
+       public function testValueIsAuthoritativeInSpaceSeparatedAttributesArrays() {
                $this->assertEquals(
                        ' class=""',
                        Html::expandAttributes( array( 'class' => array(
@@ -269,7 +285,7 @@ class HtmlTest extends MediaWikiTestCase {
                );
        }
 
-       function testNamespaceSelector() {
+       public function testNamespaceSelector() {
                $this->assertEquals(
                        '<select id=namespace name=namespace>' . "\n" .
                                '<option value=0>(Main)</option>' . "\n" .
@@ -348,7 +364,7 @@ class HtmlTest extends MediaWikiTestCase {
                );
        }
 
-       function testCanFilterOutNamespaces() {
+       public function testCanFilterOutNamespaces() {
                $this->assertEquals(
                        '<select id=namespace name=namespace>' . "\n" .
                                '<option value=2>User</option>' . "\n" .
@@ -370,7 +386,7 @@ class HtmlTest extends MediaWikiTestCase {
                );
        }
 
-       function testCanDisableANamespaces() {
+       public function testCanDisableANamespaces() {
                $this->assertEquals(
                        '<select id=namespace name=namespace>' . "\n" .
                                '<option disabled value=0>(Main)</option>' . "\n" .
@@ -400,7 +416,7 @@ class HtmlTest extends MediaWikiTestCase {
        /**
         * @dataProvider provideHtml5InputTypes
         */
-       function testHtmlElementAcceptsNewHtml5TypesInHtml5Mode( $HTML5InputType ) {
+       public function testHtmlElementAcceptsNewHtml5TypesInHtml5Mode( $HTML5InputType ) {
                $this->assertEquals(
                        '<input type=' . $HTML5InputType . '>',
                        Html::element( 'input', array( 'type' => $HTML5InputType ) ),
@@ -432,6 +448,7 @@ class HtmlTest extends MediaWikiTestCase {
                foreach ( $types as $type ) {
                        $cases[] = array( $type );
                }
+
                return $cases;
        }
 
@@ -440,7 +457,7 @@ class HtmlTest extends MediaWikiTestCase {
         * @covers Html::dropDefaults
         * @dataProvider provideElementsWithAttributesHavingDefaultValues
         */
-       function testDropDefaults( $expected, $element, $attribs, $message = '' ) {
+       public function testDropDefaults( $expected, $element, $attribs, $message = '' ) {
                $this->assertEquals( $expected, Html::element( $element, $attribs ), $message );
        }
 
@@ -596,6 +613,7 @@ class HtmlTest extends MediaWikiTestCase {
                                isset( $case[3] ) ? $case[3] : ''
                        );
                }
+
                return $ret;
        }
 
@@ -610,5 +628,4 @@ class HtmlTest extends MediaWikiTestCase {
                        'Allow special case "step=any".'
                );
        }
-
 }