Merge "Add type hint against LinkTarget"
[lhc/web/wiklou.git] / tests / phpunit / MediaWikiLangTestCase.php
1 <?php
2
3 /**
4 * Base class that store and restore the Language objects
5 */
6 abstract class MediaWikiLangTestCase extends MediaWikiTestCase {
7 protected function setUp() {
8 global $wgLanguageCode, $wgContLang;
9 parent::setUp();
10
11 if ( $wgLanguageCode != $wgContLang->getCode() ) {
12 throw new MWException( "Error in MediaWikiLangTestCase::setUp(): " .
13 "\$wgLanguageCode ('$wgLanguageCode') is different from " .
14 "\$wgContLang->getCode() (" . $wgContLang->getCode() . ")" );
15 }
16
17 // HACK: Call getLanguage() so the real $wgContLang is cached as the user language
18 // rather than our fake one. This is to avoid breaking other, unrelated tests.
19 RequestContext::getMain()->getLanguage();
20
21 $langCode = 'en'; # For mainpage to be 'Main Page'
22 $langObj = Language::factory( $langCode );
23
24 $this->setMwGlobals( [
25 'wgLanguageCode' => $langCode,
26 'wgLang' => $langObj,
27 'wgContLang' => $langObj,
28 ] );
29
30 MessageCache::singleton()->disable();
31 }
32 }