tests: Wraper to set/disable $wgHTML5 in HtmlTest
authorAntoine Musso <hashar@free.fr>
Thu, 30 Aug 2012 09:56:21 +0000 (11:56 +0200)
committerAntoine Musso <hashar@free.fr>
Thu, 30 Aug 2012 10:20:31 +0000 (12:20 +0200)
Would let us easily set $wgHtml5 in our tests.

Change-Id: Iacf38c2961cbbb9cc58cd45bba34f10ee5688605

tests/phpunit/includes/HtmlTest.php

index 8b019d7..0dd85c1 100644 (file)
@@ -6,15 +6,18 @@ class HtmlTest extends MediaWikiTestCase {
        private static $oldContLang;
        private static $oldLanguageCode;
        private static $oldNamespaces;
+       private static $oldHTML5;
 
        public function setUp() {
-               global $wgLang, $wgContLang, $wgLanguageCode;
-               
+               global $wgLang, $wgContLang, $wgLanguageCode, $wgHTML5;
+
+               // Save globals
                self::$oldLang = $wgLang;
                self::$oldContLang = $wgContLang;
                self::$oldNamespaces = $wgContLang->getNamespaces();
                self::$oldLanguageCode = $wgLanguageCode;
-               
+               self::$oldHTML5 = $wgHTML5;
+
                $wgLanguageCode = 'en';
                $wgContLang = $wgLang = Language::factory( $wgLanguageCode );
 
@@ -42,14 +45,35 @@ class HtmlTest extends MediaWikiTestCase {
                        101  => 'Custom_talk',
                ) );
        }
-       
+
        public function tearDown() {
-               global $wgLang, $wgContLang, $wgLanguageCode;
+               global $wgLang, $wgContLang, $wgLanguageCode, $wgHTML5;
 
+               // Restore globals
                $wgContLang->setNamespaces( self::$oldNamespaces );
                $wgLang = self::$oldLang;
                $wgContLang = self::$oldContLang;
                $wgLanguageCode = self::$oldLanguageCode;
+               $wgHTML5 = self::$oldHTML5;
+       }
+
+       /**
+        * Wrapper to easily set $wgHTML5 = true.
+        * Original value will be restored after test completion.
+        * @todo Move to MediaWikiTestCase
+        */
+       public function enableHTML5() {
+               global $wgHTML5;
+               $wgHTML5 = true;
+       }
+       /**
+        * Wrapper to easily set $wgHTML5 = false
+        * Original value will be restored after test completion.
+        * @todo Move to MediaWikiTestCase
+        */
+       public function disableHTML5() {
+               global $wgHTML5;
+               $wgHTML5 = false;
        }
 
        public function testExpandAttributesSkipsNullAndFalse() {