diff options
Diffstat (limited to 'tests/phpunit/languages/LanguageClassesTestCase.php')
-rw-r--r-- | tests/phpunit/languages/LanguageClassesTestCase.php | 58 |
1 files changed, 16 insertions, 42 deletions
diff --git a/tests/phpunit/languages/LanguageClassesTestCase.php b/tests/phpunit/languages/LanguageClassesTestCase.php index 6659dad1..632e037f 100644 --- a/tests/phpunit/languages/LanguageClassesTestCase.php +++ b/tests/phpunit/languages/LanguageClassesTestCase.php @@ -3,16 +3,7 @@ * Helping class to run tests using a clean language instance. * * This is intended for the MediaWiki language class tests under - * tests/phpunit/languages. You simply need to extends this test - * and set it up with a language code using setUpBeforeClass: - * - * @par Setting up a language: - * @code - * class LanguageFooTest extends LanguageClassesTestCase { - * public static function setUpBeforeClass() { - * self::setLang( 'Foo' ); - * } - * @endcode + * tests/phpunit/languages. * * Before each tests, a new language object is build which you * can retrieve in your test using the $this->getLang() method: @@ -28,19 +19,6 @@ * @endcode */ abstract class LanguageClassesTestCase extends MediaWikiTestCase { - - /** - * Regex used to find out the language code out of the class name - * used by setUpBeforeClass - */ - private static $reExtractLangFromClass = '/Language(.*)Test/'; - - /** - * Hold the language code we are going to use. This is extracted - * directly from the extending class. - */ - private static $LanguageClassCode; - /** * Internal language object * @@ -57,9 +35,19 @@ abstract class LanguageClassesTestCase extends MediaWikiTestCase { */ private $languageObject; - public static function setUpBeforeClass() { - $found = preg_match( self::$reExtractLangFromClass, - get_called_class(), $m ); + /** + * @return Language + */ + protected function getLang() { + return $this->languageObject; + } + + /** + * Create a new language object before each test. + */ + protected function setUp() { + parent::setUp(); + $found = preg_match( '/Language(.+)Test/', get_called_class(), $m ); if ( $found ) { # Normalize language code since classes uses underscores $m[1] = str_replace( '_', '-', $m[1] ); @@ -71,21 +59,8 @@ abstract class LanguageClassesTestCase extends MediaWikiTestCase { . "out of " . get_called_class() . " failling back to 'en'\n" ); } - // TODO: validate $m[1] which should be a valid language code - self::$LanguageClassCode = $m[1]; - } - - protected function getLang() { - return $this->languageObject; - } - - /** - * Create a new language object before each test. - */ - protected function setUp() { - parent::setUp(); - $this->languageObject = Language::factory( - self::$LanguageClassCode ); + // @todo validate $m[1] which should be a valid language code + $this->languageObject = Language::factory( $m[1] ); } /** @@ -96,5 +71,4 @@ abstract class LanguageClassesTestCase extends MediaWikiTestCase { unset( $this->languageObject ); parent::tearDown(); } - } |