2 require_once dirname(dirname(__FILE__
)). '/bootstrap.php';
4 class LanguageTest
extends MediaWikiTestCase
{
8 $this->lang
= Language
::factory( 'en' );
14 function testLanguageConvertDoubleWidthToSingleWidth() {
16 "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
17 $this->lang
->normalizeForSearch(
18 "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
20 'convertDoubleWidth() with the full alphabet and digits'
24 function testFormatTimePeriod() {
27 $this->lang
->formatTimePeriod( 9.45 ),
28 'formatTimePeriod() rounding (<10s)'
33 $this->lang
->formatTimePeriod( 9.95 ),
34 'formatTimePeriod() rounding (<10s)'
39 $this->lang
->formatTimePeriod( 59.55 ),
40 'formatTimePeriod() rounding (<60s)'
45 $this->lang
->formatTimePeriod( 119.55 ),
46 'formatTimePeriod() rounding (<1h)'
51 $this->lang
->formatTimePeriod( 3599.55 ),
52 'formatTimePeriod() rounding (<1h)'
57 $this->lang
->formatTimePeriod( 7199.55 ),
58 'formatTimePeriod() rounding (>=1h)'
63 * Test Language::isValidBuiltInCode()
64 * @dataProvider provideLanguageCodes
66 function testBuiltInCodeValidation( $code, $message = '' ) {
68 (bool) Language
::isValidBuiltInCode( $code ),
69 "validating code $code $message"
73 function testBuiltInCodeValidationRejectUnderscore() {
75 (bool) Language
::isValidBuiltInCode( 'be_tarask' ),
76 "reject underscore in language code"
80 function provideLanguageCodes() {
82 array( 'fr' , 'Two letters, minor case' ),
83 array( 'EN' , 'Two letters, upper case' ),
84 array( 'tyv' , 'Three letters' ),
85 array( 'tokipona' , 'long language code' ),
86 array( 'be-tarask', 'With dash' ),
87 array( 'Zh-classical', 'Begin with upper case, dash' ),
88 array( 'Be-x-old', 'With extension (two dashes)' ),