wiki.techinc.nl/tests/phpunit/MediaWikiLangTestCase.php
Daimona Eaytoy 1c6e872bd4 Replace usages of deprecated MWException
Use SPL exceptions instead when the exception is unchecked.

Bug: T328220
Change-Id: Ia1e5edc2ef3269a44b670262b78b305d07559829
2023-06-06 17:05:32 +02:00

30 lines
843 B
PHP

<?php
use MediaWiki\MediaWikiServices;
/**
* Base class that store and restore the Language objects
*/
abstract class MediaWikiLangTestCase extends MediaWikiIntegrationTestCase {
/**
* The annotation causes this to be called immediately before setUp()
* @before
*/
final protected function mediaWikiLangSetUp(): void {
global $wgLanguageCode;
$services = MediaWikiServices::getInstance();
$contLang = $services->getContentLanguage();
if ( $wgLanguageCode != $contLang->getCode() ) {
throw new RuntimeException( "Error in " . __METHOD__ . ': ' .
"\$wgLanguageCode ('$wgLanguageCode') is different from content language code (" .
$contLang->getCode() . ")" );
}
$this->setUserLang( 'en' );
// For mainpage to be 'Main Page'
$this->setContentLang( 'en' );
$services->getMessageCache()->disable();
}
}