summaryrefslogtreecommitdiff
path: root/tests/phpunit/MediaWikiLangTestCase.php
blob: 783f03158d94bc53b345a065d21d622de9d10ad0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php

/**
 * Base class that store and restore the Language objects
 */
abstract class MediaWikiLangTestCase extends MediaWikiTestCase {
	private static $oldLang;
	private static $oldContLang;

	public function setUp() {
		global $wgLanguageCode, $wgLang, $wgContLang;

		self::$oldLang = $wgLang;
		self::$oldContLang = $wgContLang;

		if( $wgLanguageCode != $wgContLang->getCode() ) {
			throw new MWException("Error in MediaWikiLangTestCase::setUp(): " .
				"\$wgLanguageCode ('$wgLanguageCode') is different from " .
				"\$wgContLang->getCode() (" . $wgContLang->getCode() . ")" );
		}

		$wgLanguageCode = 'en'; # For mainpage to be 'Main Page'

		$wgContLang = $wgLang = Language::factory( $wgLanguageCode );
		MessageCache::singleton()->disable();
	}

	public function tearDown() {
		global $wgContLang, $wgLang, $wgLanguageCode;
		$wgLang = self::$oldLang;

		$wgContLang = self::$oldContLang;
		$wgLanguageCode = $wgContLang->getCode();
		self::$oldContLang = self::$oldLang = null;
	}

}