| 1 |
<?php |
| 2 |
namespace MediaWiki\Tests\Languages; |
| 3 |
|
| 4 |
use MediaWikiIntegrationTestCase; |
| 5 |
use Wikimedia\Bcp47Code\Bcp47CodeValue; |
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
class LanguageFactoryIntegrationTest extends MediaWikiIntegrationTestCase { |
| 12 |
private function createFactory() { |
| 13 |
return $this->getServiceContainer()->getLanguageFactory(); |
| 14 |
} |
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
public function testGetParentLanguage( $code, $ignore, $parent = null ) { |
| 20 |
$factory = $this->createFactory(); |
| 21 |
$lang = $factory->getParentLanguage( $code ); |
| 22 |
$this->assertSame( $parent, $lang ? $lang->getCode() : null ); |
| 23 |
} |
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
public function testGetParentLanguageBcp47Code( $ignore, $bcp47code, $parent = null ) { |
| 29 |
$factory = $this->createFactory(); |
| 30 |
$bcp47obj = new Bcp47CodeValue( $bcp47code ); |
| 31 |
$lang = $factory->getParentLanguage( $bcp47obj ); |
| 32 |
$this->assertSame( $parent, $lang ? $lang->getCode() : null ); |
| 33 |
} |
| 34 |
|
| 35 |
public static function provideCodes() { |
| 36 |
return [ |
| 37 |
|
| 38 |
[ 'de', 'de' ], |
| 39 |
[ 'fr', 'fr' ], |
| 40 |
[ 'ja', 'ja' ], |
| 41 |
|
| 42 |
[ 'en', 'en', 'en' ], |
| 43 |
[ 'sr', 'sr', 'sr' ], |
| 44 |
[ 'crh', 'crh', 'crh' ], |
| 45 |
[ 'zh', 'zh', 'zh' ], |
| 46 |
|
| 47 |
[ 'zh-hans', 'zh-Hans', 'zh' ], |
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
[ 'cbk-zam', 'cbk' ], |
| 52 |
[ 'de-formal', 'de-x-formal' ], |
| 53 |
[ 'eml', 'egl' ], |
| 54 |
[ 'en-rtl', 'en-x-rtl' ], |
| 55 |
[ 'es-formal', 'es-x-formal' ], |
| 56 |
[ 'hu-formal', 'hu-x-formal' ], |
| 57 |
[ 'map-bms', 'jv-x-bms' ], |
| 58 |
[ 'mo', 'ro-Cyrl-MD' ], |
| 59 |
[ 'nrm', 'nrf' ], |
| 60 |
[ 'nl-informal', 'nl-x-informal' ], |
| 61 |
[ 'roa-tara', 'nap-x-tara' ], |
| 62 |
[ 'simple', 'en-simple' ], |
| 63 |
[ 'sr-ec', 'sr-Cyrl', 'sr' ], |
| 64 |
[ 'sr-el', 'sr-Latn', 'sr' ], |
| 65 |
[ 'zh-cn', 'zh-Hans-CN', 'zh' ], |
| 66 |
[ 'zh-sg', 'zh-Hans-SG', 'zh' ], |
| 67 |
[ 'zh-my', 'zh-Hans-MY', 'zh' ], |
| 68 |
[ 'zh-tw', 'zh-Hant-TW', 'zh' ], |
| 69 |
[ 'zh-hk', 'zh-Hant-HK', 'zh' ], |
| 70 |
[ 'zh-mo', 'zh-Hant-MO', 'zh' ], |
| 71 |
[ 'zh-hans', 'zh-Hans', 'zh' ], |
| 72 |
[ 'zh-hant', 'zh-Hant', 'zh' ], |
| 73 |
]; |
| 74 |
} |
| 75 |
|
| 76 |
} |