The changes are mostly automatic and add languages that were recently added to language-data or updated in the CLDR. I went over the whole long diff and couldn't find any issues that would affect the usage of the ULS search box. Tests are updated to reflect the current names, but here, too, the language finding functionality is not supposed to be affected. Two kinds of tests were affected: * The name of Hindi (Latin) in Malayalam: I removed the test because Hindi (Latin) is not used in MediaWiki anyway, so it doesn't matter. * Some names of Chinese varieties. I updated the tests and also added aliases for languages whose names were changed, so that searching for "chinese" would find them (so it's good that we had those tests!). Change-Id: I22344dadb0b01d7704ab7d76271ab27077daedb3
136 lines
3.6 KiB
PHP
136 lines
3.6 KiB
PHP
<?php
|
|
/**
|
|
* PHPUnit tests for UniversalLanguageSelector extension.
|
|
*
|
|
* Copyright (C) 2012 Alolita Sharma, Amir Aharoni, Arun Ganesh, Brandon Harris,
|
|
* Niklas Laxström, Pau Giner, Santhosh Thottingal, Siebrand Mazeland and other
|
|
* contributors. See CREDITS for a list.
|
|
*
|
|
* UniversalLanguageSelector is dual licensed GPLv2 or later and MIT. You don't
|
|
* have to do anything special to choose one license or the other and you don't
|
|
* have to notify anyone which license you are using. You are free to use
|
|
* UniversalLanguageSelector in commercial projects as long as the copyright
|
|
* header is left intact. See files GPL-LICENSE and MIT-LICENSE for details.
|
|
*
|
|
* @file
|
|
* @ingroup Extensions
|
|
* @license GPL-2.0-or-later
|
|
* @license MIT
|
|
*/
|
|
|
|
use MediaWiki\Extension\CLDR\LanguageNames;
|
|
|
|
/**
|
|
* @covers \LanguageNameSearch
|
|
* @covers \LanguageNameSearchData
|
|
*/
|
|
class LanguageSearchTest extends PHPUnit\Framework\TestCase {
|
|
/**
|
|
* @dataProvider searchDataProvider
|
|
*/
|
|
public function testSearch( $searchKey, $expected ) {
|
|
$actual = LanguageNameSearch::search( $searchKey, 1, 'en' );
|
|
// This is for better error messages
|
|
$this->assertEquals( $expected, $actual );
|
|
// This is for identical order
|
|
$this->assertSame( $expected, $actual );
|
|
}
|
|
|
|
public static function searchDataProvider() {
|
|
return [
|
|
[ 'ഹിന്ദി', [
|
|
'hi' => 'ഹിന്ദി',
|
|
]
|
|
],
|
|
[ 'മല', [
|
|
'mg' => 'മലഗാസി',
|
|
'ml' => 'മലയാളം',
|
|
'pqm' => 'മലിസീറ്റ്-പസാമക്വുഡി',
|
|
'ms' => 'മലെയ്',
|
|
]
|
|
],
|
|
[ 'Φινλαν', [
|
|
'fi' => 'φινλανδικά',
|
|
]
|
|
],
|
|
[ 'blargh', []
|
|
],
|
|
[ 'الفرنسية', [
|
|
'fr' => 'الفرنسية',
|
|
'fr-ch' => 'الفرنسية السويسرية',
|
|
'fro' => 'الفرنسية القديمة',
|
|
'frc' => 'الفرنسية الكاجونية',
|
|
'crs' => 'الفرنسية الكريولية السيشيلية',
|
|
'fr-ca' => 'الفرنسية الكندية',
|
|
'frm' => 'الفرنسية الوسطى',
|
|
]
|
|
],
|
|
[ 'മലയളം', [
|
|
'ml' => 'മലയാളം',
|
|
]
|
|
],
|
|
[ 'punja', [
|
|
// Presence of CLDR extension affects the results
|
|
'pa' => class_exists( LanguageNames::class ) ? 'punjabi' : 'punjaabi sennii',
|
|
'pa-guru' => 'punjabi (gurmukhi-skrift)',
|
|
'pnb' => 'punjabi western'
|
|
]
|
|
],
|
|
[ 'castellano', [
|
|
'es' => 'castellano',
|
|
]
|
|
],
|
|
[ 'hayeren', [
|
|
'hy' => 'hayeren',
|
|
]
|
|
],
|
|
[ 'kartuli', [
|
|
'ka' => 'kartuli',
|
|
]
|
|
],
|
|
[ 'qartuli', [
|
|
'ka' => 'qartuli',
|
|
]
|
|
],
|
|
[ 'nihongo', [
|
|
'ja' => 'nihongo',
|
|
]
|
|
],
|
|
[ 'にほんご', [
|
|
'ja' => 'にほんご',
|
|
]
|
|
],
|
|
[ 'valencia', [
|
|
'ca' => 'valencia',
|
|
]
|
|
],
|
|
[ 'chinese', [
|
|
// Presence of CLDR extension affects the results
|
|
'zh' => class_exists( LanguageNames::class ) ? 'chinese' : 'chines',
|
|
'zh-cn' => 'chinese (china)',
|
|
'zh-hk' => 'chinese (hong kong)',
|
|
'zh-mo' => 'chinese (macau)',
|
|
'zh-my' => 'chinese (malaysia)',
|
|
'zh-sg' => 'chinese (singapore)',
|
|
'zh-tw' => 'chinese (taiwan)',
|
|
'cdo' => 'chinese min dong',
|
|
'zh-min-nan' => 'chinese min nan',
|
|
'zh-hans' => 'chinese simplificate',
|
|
'zh-hant' => 'chinese traditional',
|
|
'hak' => 'chinese — hakka chinese',
|
|
'gan' => 'chinese — isi-gan chinese',
|
|
'nan' => 'chinese — isi-min nan chinese',
|
|
'wuu' => 'chinese — isi-wu chinese',
|
|
'hsn' => 'chinese — isi-xiang chinese',
|
|
'zh-classical' => 'chinese — literary chinese',
|
|
'lzh' => 'chinesesch — klassescht chinesesch',
|
|
]
|
|
],
|
|
[ 'finnisj', [
|
|
'fi' => 'finnish'
|
|
]
|
|
],
|
|
];
|
|
}
|
|
}
|