1<?php 2 3use MediaWiki\MediaWikiServices; 4 5/** 6 * Base class that store and restore the Language objects 7 */ 8abstract class MediaWikiLangTestCase extends MediaWikiIntegrationTestCase { 9 /** 10 * The annotation causes this to be called immediately before setUp() 11 * @before 12 */ 13 final protected function mediaWikiLangSetUp(): void { 14 global $wgLanguageCode; 15 16 $services = MediaWikiServices::getInstance(); 17 $contLang = $services->getContentLanguage(); 18 if ( $wgLanguageCode != $contLang->getCode() ) { 19 throw new MWException( "Error in MediaWikiLangTestCase::setUp(): " . 20 "\$wgLanguageCode ('$wgLanguageCode') is different from content language code (" . 21 $contLang->getCode() . ")" ); 22 } 23 24 $this->setUserLang( 'en' ); 25 // For mainpage to be 'Main Page' 26 $this->setContentLang( 'en' ); 27 28 $services->getMessageCache()->disable(); 29 } 30} 31