Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 2 additions & 56 deletions tests/php/LanguageUtilTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,10 @@
use Wikimedia\LanguageData\LanguageUtil;

/**
* @coversDefaultClass \Wikimedia\LanguageUtil
* @covers \Wikimedia\LanguageData\LanguageUtil
*/
class LanguageUtilTest extends TestCase {
/**
* @var LanguageUtil
*/
protected $languageUtil;
protected LanguageUtil $languageUtil;

private const UNKNOWN_LANGUAGE_CODE = 'xyz';

Expand All @@ -21,33 +18,21 @@ protected function setUp(): void {
$this->languageUtil = LanguageUtil::get();
}

/**
* @covers isKnown
*/
public function testIsKnown() {
$this->assertTrue( $this->languageUtil->isKnown( 'en' ) );
$this->assertFalse( $this->languageUtil->isKnown( self::UNKNOWN_LANGUAGE_CODE ) );
}

/**
* @covers isRedirect
*/
public function testIsRedirect() {
$this->assertFalse( $this->languageUtil->isRedirect( 'en' ) );
$this->assertEquals( 'aeb', $this->languageUtil->isRedirect( 'aeb-arab' ) );
}

/**
* @covers getScript
*/
public function testGetScript() {
$this->assertEquals( 'Latn', $this->languageUtil->getScript( 'en' ) );
$this->assertFalse( $this->languageUtil->getScript( self::UNKNOWN_LANGUAGE_CODE ) );
}

/**
* @covers getRegions
*/
public function testGetRegions() {
$this->assertFalse( $this->languageUtil->getRegions( self::UNKNOWN_LANGUAGE_CODE ) );
$this->assertEquals( [ 'AF' ], $this->languageUtil->getRegions( 'aeb' ) );
Expand All @@ -59,9 +44,6 @@ public function testGetRegions() {
}
}

/**
* @covers getAutonym
*/
public function testGetAutonym() {
$this->assertFalse( $this->languageUtil->getAutonym( self::UNKNOWN_LANGUAGE_CODE ) );
$this->assertEquals(
Expand All @@ -73,9 +55,6 @@ public function testGetAutonym() {
$this->assertEquals( 'English', $this->languageUtil->getAutonym( 'en' ) );
}

/**
* @covers getAutonyms
*/
public function testGetAutonyms() {
$autonyms = $this->languageUtil->getAutonyms();
$this->assertEquals( 'English', $autonyms['en'] );
Expand All @@ -85,9 +64,6 @@ public function testGetAutonyms() {
);
}

/**
* @covers getLanguagesInScripts
*/
public function testGetLanguagesInScripts() {
$this->assertCount(
0, $this->languageUtil->getLanguagesInScripts( [ self::UNKNOWN_LANGUAGE_CODE ] )
Expand All @@ -104,9 +80,6 @@ public function testGetLanguagesInScripts() {
);
}

/**
* @covers getGroupOfScript
*/
public function testGetGroupOfScript() {
$this->assertEquals( 'Latin', $this->languageUtil->getGroupOfScript( 'Latn' ) );
$this->assertEquals(
Expand All @@ -115,9 +88,6 @@ public function testGetGroupOfScript() {
);
}

/**
* @covers getScriptGroupOfLanguage
*/
public function testGetScriptGroupOfLanguage() {
$this->assertEquals(
LanguageUtil::OTHER_SCRIPT_GROUP,
Expand All @@ -130,9 +100,6 @@ public function testGetScriptGroupOfLanguage() {
);
}

/**
* @covers getLanguagesByScriptGroup
*/
public function testGetLanguagesByScriptGroup() {
$actuals = $this->languageUtil->getLanguagesByScriptGroup( [ 'en', 'sr-el', 'tt-cyrl' ] );

Expand All @@ -141,9 +108,6 @@ public function testGetLanguagesByScriptGroup() {
$this->assertContains( 'sr-el', $actuals['Latin'] );
}

/**
* @covers getLanguagesByScriptGroupInRegions
*/
public function testGetLanguagesByScriptGroupInRegions() {
$actuals = $this->languageUtil->getLanguagesByScriptGroupInRegions( [ 'AS', 'PA' ] );

Expand All @@ -157,9 +121,6 @@ public function testGetLanguagesByScriptGroupInRegions() {
);
}

/**
* @covers sortByAutonym
*/
public function testSortByAutonym() {
$sorted = $this->languageUtil->sortByAutonym(
[
Expand All @@ -185,9 +146,6 @@ public function testSortByAutonym() {
);
}

/**
* @covers sortByScriptGroup
*/
public function testSortByScriptGroup() {
$sorted = $this->languageUtil->sortByScriptGroup(
$this->languageUtil->sortByAutonym(
Expand Down Expand Up @@ -215,27 +173,18 @@ public function testSortByScriptGroup() {
);
}

/**
* @covers isRtl
*/
public function testIsRtl() {
$this->assertFalse( $this->languageUtil->isRtl( 'en' ) );
$this->assertFalse( $this->languageUtil->isRtl( self::UNKNOWN_LANGUAGE_CODE ) );
$this->assertTrue( $this->languageUtil->isRtl( 'he' ) );
}

/**
* @covers getDir
*/
public function testGetDir() {
$this->assertEquals( 'ltr', $this->languageUtil->getDir( 'en' ) );
$this->assertEquals( 'rtl', $this->languageUtil->getDir( 'he' ) );
$this->assertFalse( $this->languageUtil->getDir( self::UNKNOWN_LANGUAGE_CODE ) );
}

/**
* @covers getLanguagesInTerritory
*/
public function testGetLanguagesInTerritory() {
$actualsAFG = $this->languageUtil->getLanguagesInTerritory( 'AF' );
$actualsAT = $this->languageUtil->getLanguagesInTerritory( 'AT' );
Expand All @@ -249,9 +198,6 @@ public function testGetLanguagesInTerritory() {
$this->assertNotContains( 'de', $actualsAFG );
}

/**
* @covers addLanguage
*/
public function testAddLanguage() {
$this->assertFalse( $this->languageUtil->isKnown( 'xyz' ) );
$this->assertNotContains(
Expand Down