Add a few missing `@group Language` tags as well. Remove stray `@group Cache` from two classes since "Cache" is not a MediaWiki core component (per T248519 and related tasks, we did long ago in Bugzilla have a "MediaWiki-Cache" category, but that's since been re-orged into BagOStuff, HTTP-Cache, and Parser/ParserCache, and Internationalization/LocalisationCache, per the description at <https://phabricator.wikimedia.org/project/profile/1329/>.) Ref https://gerrit.wikimedia.org/r/q/owner:Krinkle+is:merged+message:Widen > Given all called methods are de-facto and liberally claimed, and > that we keep the coverage limited to the subject class, it maintains > the spirit and intent by listing the class explicitly instead. > > PHPUnit offers a more precise tool when you need it (i.e. when testing > legacy monster/god classes), but for well-written code, the > class-wide tag is exactly what you want. > > We lose useful coverage and waste valuable time on keeping tags > accurate through refactors (or worse, forget to do so). > Tracking tiny per-method details wastes time in realizing (and > fixing) when people inevitably don't keep them in sync, and time > lost in finding uncovered code to write tests to realize it was > already covered but "not yet claimed". Bug: T364652 Change-Id: I9cfc4c210b90bfed6fd988a2525f80f5f5ee4870
76 lines
2.1 KiB
PHP
76 lines
2.1 KiB
PHP
<?php
|
|
namespace MediaWiki\Tests\Languages;
|
|
|
|
use MediaWikiIntegrationTestCase;
|
|
use Wikimedia\Bcp47Code\Bcp47CodeValue;
|
|
|
|
/**
|
|
* @group Language
|
|
* @covers \MediaWiki\Languages\LanguageFactory
|
|
*/
|
|
class LanguageFactoryIntegrationTest extends MediaWikiIntegrationTestCase {
|
|
private function createFactory() {
|
|
return $this->getServiceContainer()->getLanguageFactory();
|
|
}
|
|
|
|
/**
|
|
* @dataProvider provideCodes
|
|
*/
|
|
public function testGetParentLanguage( $code, $ignore, $parent = null ) {
|
|
$factory = $this->createFactory();
|
|
$lang = $factory->getParentLanguage( $code );
|
|
$this->assertSame( $parent, $lang ? $lang->getCode() : null );
|
|
}
|
|
|
|
/**
|
|
* @dataProvider provideCodes
|
|
*/
|
|
public function testGetParentLanguageBcp47Code( $ignore, $bcp47code, $parent = null ) {
|
|
$factory = $this->createFactory();
|
|
$bcp47obj = new Bcp47CodeValue( $bcp47code );
|
|
$lang = $factory->getParentLanguage( $bcp47obj );
|
|
$this->assertSame( $parent, $lang ? $lang->getCode() : null );
|
|
}
|
|
|
|
public static function provideCodes() {
|
|
return [
|
|
# Basic codes
|
|
[ 'de', 'de' ],
|
|
[ 'fr', 'fr' ],
|
|
[ 'ja', 'ja' ],
|
|
# Base languages with variants are their own parents
|
|
[ 'en', 'en', 'en' ],
|
|
[ 'sr', 'sr', 'sr' ],
|
|
[ 'crh', 'crh', 'crh' ],
|
|
[ 'zh', 'zh', 'zh' ],
|
|
# Variant codes
|
|
[ 'zh-hans', 'zh-Hans', 'zh' ],
|
|
# Non standard codes
|
|
# Unlike deprecated codes, this *are* valid internal codes and
|
|
# will be returned from Language::getCode()
|
|
[ 'cbk-zam', 'cbk' ],
|
|
[ 'de-formal', 'de-x-formal' ],
|
|
[ 'eml', 'egl' ],
|
|
[ 'en-rtl', 'en-x-rtl' ],
|
|
[ 'es-formal', 'es-x-formal' ],
|
|
[ 'hu-formal', 'hu-x-formal' ],
|
|
[ 'map-bms', 'jv-x-bms' ],
|
|
[ 'mo', 'ro-Cyrl-MD' ],
|
|
[ 'nrm', 'nrf' ],
|
|
[ 'nl-informal', 'nl-x-informal' ],
|
|
[ 'roa-tara', 'nap-x-tara' ],
|
|
[ 'simple', 'en-simple' ],
|
|
[ 'sr-ec', 'sr-Cyrl', 'sr' ],
|
|
[ 'sr-el', 'sr-Latn', 'sr' ],
|
|
[ 'zh-cn', 'zh-Hans-CN', 'zh' ],
|
|
[ 'zh-sg', 'zh-Hans-SG', 'zh' ],
|
|
[ 'zh-my', 'zh-Hans-MY', 'zh' ],
|
|
[ 'zh-tw', 'zh-Hant-TW', 'zh' ],
|
|
[ 'zh-hk', 'zh-Hant-HK', 'zh' ],
|
|
[ 'zh-mo', 'zh-Hant-MO', 'zh' ],
|
|
[ 'zh-hans', 'zh-Hans', 'zh' ],
|
|
[ 'zh-hant', 'zh-Hant', 'zh' ],
|
|
];
|
|
}
|
|
|
|
}
|