wiki.techinc.nl/tests/phpunit/languages/LanguageCodeTest.php
This, that and the other 48ab87d0a3 Break up $wgDummyLanguageCodes
$wgDummyLanguageCodes is a set and mapping of different language codes:

* Renamed language codes: ['als' => 'gsw', 'bat-smg' => 'sgs',
                           'be-xold' => 'be-tarask', 'fiu-vro' => 'vro',
                           'roa-rup' => 'rup', 'zh-classical' => 'lzh',
                           'zh-min-nan' => 'nan', 'zh-yue' => 'yue'].
  The old language codes are deprecated because they are invalid but
  should be supported for compatibility reasons for a while.
* Language codes of macro languages, which get mapped to the main
  language: ['bh' => 'bho', 'no' => 'nb'].
* Language variants which get mapped to main language:
  ['simple' => 'en'].
* Internal language codes of the private-use-area which get mapped to
  itself: ['qqq' => 'qqq', 'qqx' => 'qqx']

This is a very strange conglomeration which should get differentiated,
and were split up in the following ways:

* Renamed language codes are available from
  LanguageCode::getDeprecatedCodeMapping().
* Language codes of macro languages and the variants that are mapped to
  the main language are available as $wgExtraLanguageCodes and are set
  in DefaultSettings.php.
* Internal language codes are set in $wgDummyLanguageCodes in Setup.php.

Change-Id: If73c74ee87d8235381449cab7dcd9f46b0f23590
2017-03-08 12:11:30 -08:00

40 lines
1.2 KiB
PHP

<?php
/**
* @covers LanguageCode
*
* @group Language
*
* @license GPL-2.0+
* @author Thiemo Mättig
*/
class LanguageCodeTest extends PHPUnit_Framework_TestCase {
public function testConstructor() {
$instance = new LanguageCode();
$this->assertInstanceOf( LanguageCode::class, $instance );
}
public function testGetDeprecatedCodeMapping() {
$map = LanguageCode::getDeprecatedCodeMapping();
$this->assertInternalType( 'array', $map );
$this->assertContainsOnly( 'string', array_keys( $map ) );
$this->assertArrayNotHasKey( '', $map );
$this->assertContainsOnly( 'string', $map );
$this->assertNotContains( '', $map );
// Codes special to MediaWiki should never appear in a map of "deprecated" codes
$this->assertArrayNotHasKey( 'qqq', $map, 'documentation' );
$this->assertNotContains( 'qqq', $map, 'documentation' );
$this->assertArrayNotHasKey( 'qqx', $map, 'debug code' );
$this->assertNotContains( 'qqx', $map, 'debug code' );
// Valid language codes that are currently not "deprecated"
$this->assertArrayNotHasKey( 'bh', $map, 'family of Bihari languages' );
$this->assertArrayNotHasKey( 'no', $map, 'family of Norwegian languages' );
$this->assertArrayNotHasKey( 'simple', $map );
}
}