* internal customisation of MediaWiki, via Messages*.php.
*/
public static function isValidBuiltInCode( $code ) {
- return preg_match( '/^[a-z0-9-]*$/', $code );
+ return preg_match( '/^[a-z0-9-_]*$/i', $code );
}
/**
'formatTimePeriod() rounding (>=1h)'
);
}
+
+ /**
+ * Test Language::isValidBuiltInCode()
+ * @dataProvider provideLanguageCodes
+ */
+ function testBuiltInCodeValidation( $code, $message = '' ) {
+ $this->assertTrue(
+ (bool) Language::isValidBuiltInCode( $code ),
+ "validating code $code $message"
+ );
+ }
+
+ function provideLanguageCodes() {
+ return array(
+ array( 'fr' , 'Two letters, minor case' ),
+ array( 'EN' , 'Two letters, upper case' ),
+ array( 'tyv' , 'Three letters' ),
+ array( 'tokipona' , 'long language code' ),
+ array( 'be_tarask', 'With underscore' ),
+ array( 'Zh_classical', 'Begin with upper case, underscore' ),
+ array( 'Be_x_old', 'With extension (two underscores)' ),
+ );
+ }
}