Index: trunk/phase3/tests/phpunit/languages/LanguageTest.php |
— | — | @@ -58,4 +58,27 @@ |
59 | 59 | 'formatTimePeriod() rounding (>=1h)' |
60 | 60 | ); |
61 | 61 | } |
| 62 | + |
| 63 | + /** |
| 64 | + * Test Language::isValidBuiltInCode() |
| 65 | + * @dataProvider provideLanguageCodes |
| 66 | + */ |
| 67 | + function testBuiltInCodeValidation( $code, $message = '' ) { |
| 68 | + $this->assertTrue( |
| 69 | + (bool) Language::isValidBuiltInCode( $code ), |
| 70 | + "validating code $code $message" |
| 71 | + ); |
| 72 | + } |
| 73 | + |
| 74 | + function provideLanguageCodes() { |
| 75 | + return array( |
| 76 | + array( 'fr' , 'Two letters, minor case' ), |
| 77 | + array( 'EN' , 'Two letters, upper case' ), |
| 78 | + array( 'tyv' , 'Three letters' ), |
| 79 | + array( 'tokipona' , 'long language code' ), |
| 80 | + array( 'be_tarask', 'With underscore' ), |
| 81 | + array( 'Zh_classical', 'Begin with upper case, underscore' ), |
| 82 | + array( 'Be_x_old', 'With extension (two underscores)' ), |
| 83 | + ); |
| 84 | + } |
62 | 85 | } |
Index: trunk/phase3/languages/Language.php |
— | — | @@ -215,7 +215,7 @@ |
216 | 216 | * internal customisation of MediaWiki, via Messages*.php. |
217 | 217 | */ |
218 | 218 | public static function isValidBuiltInCode( $code ) { |
219 | | - return preg_match( '/^[a-z0-9-]*$/', $code ); |
| 219 | + return preg_match( '/^[a-z0-9-_]*$/i', $code ); |
220 | 220 | } |
221 | 221 | |
222 | 222 | /** |