Commit graph

6 commits

Author SHA1 Message Date
C. Scott Ananian
e185a570ae Add efficient LanguageCode::bcp47ToInternal() helper
LanguageFactory::getLanguage() will accept *lowercased* BCP-47 codes, so
this method is equivalent to
  LanguageFactory::getLanguage(strtolower($code))->getCode()
but should be much more efficient in practice.

Change-Id: I180765604d08ed57f655b69dfb32686f0b2a0dce
2022-10-20 10:11:14 -04:00
Fomafix
b50aa1a47d Add 'zh-classical' to the test cases for isWellFormedLanguageTag
This shows that 'zh-classical' is not even a well-formed language tag
because 'classical' has more than 8 characters.

Change-Id: Ic07baf98ca4d92fa4c196895533650145c440584
2022-08-31 20:15:00 +00:00
Fomafix
233677a9a5 Move isWellFormedLanguageTag from Language to LanguageCode
The static function isWellFormedLanguageTag is related to BCP 47
language codes not to the internal language codes or language names.

The new function LanguageCode::isWellFormedLanguageTag uses type hints.
THe explicit type cast (bool) is not necessary anymore.

The old function Language::isWellFormedLanguageTag is now deprecated.

Change-Id: I6431dbd82ed6dfcc2a7c3495eca025506551db05
2022-08-30 11:39:26 +00:00
Daimona Eaytoy
6365eaab8d Autofix 94 PHPUnit 8 compat issues
Done automatically using the master version of MW codesniffer and
running composer fix.

Bug: T192167
Change-Id: If6b40f515fde32ab5eff074a90e821c30c791827
2019-12-13 15:29:10 +01:00
Thiemo Kreuz
c2211946f7 tests: Replace PHPUnit's loose assertEquals(null) with assertNull()
assertEquals( null, … ) still succeeds when the actual value is 0, false,
an empty string, even an empty array. All these should be reported as a
failure, I would argue.

Note this patch previously also touched assertSame( null ). I reverted
these. The only benefit would have been consistency within this codebase,
but there is no strict reason to prefer one over the other. assertNull()
and assertSame( null ) are functionally identical.

Change-Id: I92102e833a8bc6af90b9516826abf111e2b79aac
2019-09-27 19:15:38 +00:00
Timo Tijhof
6284ed6971 tests: Move unit/languages to unit/includes/language
These source classes they test were also moved from
languages/ to includes/languages/.

Bug: T225756
Change-Id: I6931d459bbfa243d2a28f391f92bce70f1e52256
2019-07-15 00:16:44 +01:00
Renamed from tests/phpunit/unit/languages/LanguageCodeTest.php (Browse further)