From: Antoine Musso Date: Thu, 30 Aug 2012 09:56:21 +0000 (+0200) Subject: tests: Wraper to set/disable $wgHTML5 in HtmlTest X-Git-Tag: 1.31.0-rc.0~22533 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22articles%22%2C%22id_article=%24id_article%22%29%20.%20%22?a=commitdiff_plain;h=9fd8cf88f0b7b999c75bbef7bda832c32e498cea;p=lhc%2Fweb%2Fwiklou.git tests: Wraper to set/disable $wgHTML5 in HtmlTest Would let us easily set $wgHtml5 in our tests. Change-Id: Iacf38c2961cbbb9cc58cd45bba34f10ee5688605 --- diff --git a/tests/phpunit/includes/HtmlTest.php b/tests/phpunit/includes/HtmlTest.php index 8b019d78e6..0dd85c19e3 100644 --- a/tests/phpunit/includes/HtmlTest.php +++ b/tests/phpunit/includes/HtmlTest.php @@ -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() {