Index: trunk/phase3/tests/phpunit/MediaWikiLangTestCase.php |
— | — | @@ -0,0 +1,32 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * Base class that store and restore the Language objects |
| 6 | + */ |
| 7 | +class MediaWikiLangTestCase extends MediaWikiTestCase { |
| 8 | + private static $oldLang; |
| 9 | + private static $oldContLang; |
| 10 | + |
| 11 | + public function setUp() { |
| 12 | + global $wgLanguageCode, $wgLang, $wgContLang; |
| 13 | + |
| 14 | + self::$oldLang = $wgLang; |
| 15 | + self::$oldContLang = $wgContLang; |
| 16 | + |
| 17 | + if( $wgLanguageCode != $wgContLang->getCode() ) die("nooo!"); |
| 18 | + |
| 19 | + $wgLanguageCode = 'en'; # For mainpage to be 'Main Page' |
| 20 | + |
| 21 | + $wgContLang = $wgLang = Language::factory( $wgLanguageCode ); |
| 22 | + MessageCache::singleton()->disable(); |
| 23 | + } |
| 24 | + |
| 25 | + public function tearDown() { |
| 26 | + global $wgContLang, $wgLang, $wgLanguageCode; |
| 27 | + $wgLang = self::$oldLang; |
| 28 | + |
| 29 | + $wgContLang = self::$oldContLang; |
| 30 | + $wgLanguageCode = $wgContLang->getCode(); |
| 31 | + } |
| 32 | + |
| 33 | +} |
Property changes on: trunk/phase3/tests/phpunit/MediaWikiLangTestCase.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 34 | + native |
Index: trunk/phase3/tests/phpunit/includes/XmlTest.php |
— | — | @@ -1,7 +1,22 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | class XmlTest extends MediaWikiTestCase { |
| 5 | + private static $oldLang; |
5 | 6 | |
| 7 | + public function setUp() { |
| 8 | + global $wgLang, $wgLanguageCode; |
| 9 | + |
| 10 | + self::$oldLang = $wgLang; |
| 11 | + $wgLanguageCode = 'en'; |
| 12 | + $wgLang = Language::factory( $wgLanguageCode ); |
| 13 | + } |
| 14 | + |
| 15 | + public function tearDown() { |
| 16 | + global $wgContLang, $wgLanguageCode; |
| 17 | + $wgLang = self::$oldLang; |
| 18 | + $wgLanguageCode = $wgLang->getCode(); |
| 19 | + } |
| 20 | + |
6 | 21 | public function testExpandAttributes() { |
7 | 22 | $this->assertNull( Xml::expandAttributes(null), |
8 | 23 | 'Converting a null list of attributes' |
Index: trunk/phase3/tests/phpunit/includes/LanguageConverterTest.php |
— | — | @@ -1,10 +1,12 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | | -class LanguageConverterTest extends MediaWikiTestCase { |
| 4 | + |
| 5 | +class LanguageConverterTest extends MediaWikiLangTestCase { |
5 | 6 | protected $lang = null; |
6 | 7 | protected $lc = null; |
7 | 8 | |
8 | 9 | function setUp() { |
| 10 | + parent::setUp(); |
9 | 11 | global $wgMemc, $wgRequest, $wgUser, $wgContLang; |
10 | 12 | |
11 | 13 | $wgUser = new User; |
Index: trunk/phase3/tests/phpunit/includes/SampleTest.php |
— | — | @@ -1,6 +1,6 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | | -class TestSample extends MediaWikiTestCase { |
| 4 | +class TestSample extends MediaWikiLangTestCase { |
5 | 5 | |
6 | 6 | /** |
7 | 7 | * Anything that needs to happen before your tests should go here. |
Index: trunk/phase3/tests/phpunit/includes/MessageTest.php |
— | — | @@ -1,16 +1,7 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | | -class MessageTest extends MediaWikiTestCase { |
| 4 | +class MessageTest extends MediaWikiLangTestCase { |
5 | 5 | |
6 | | - function setUp() { |
7 | | - global $wgLanguageCode, $wgLang, $wgContLang; |
8 | | - |
9 | | - $wgLanguageCode = 'en'; # For mainpage to be 'Main Page' |
10 | | - //Note that a Stub Object is not enough for this test |
11 | | - $wgContLang = $wgLang = Language::factory( $wgLanguageCode ); |
12 | | - MessageCache::singleton()->disable(); |
13 | | - } |
14 | | - |
15 | 6 | function testExists() { |
16 | 7 | $this->assertTrue( wfMessage( 'mainpage' )->exists() ); |
17 | 8 | $this->assertTrue( wfMessage( 'mainpage' )->params( array() )->exists() ); |