<?php
-class LanguageTest extends MediaWikiTestCase {
-
- /**
- * @var Language
- */
- private $lang;
-
- protected function setUp() {
- $this->lang = Language::factory( 'en' );
- }
- protected function tearDown() {
- unset( $this->lang );
- }
+class LanguageTest extends LanguageClassesTestCase {
function testLanguageConvertDoubleWidthToSingleWidth() {
$this->assertEquals(
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
- $this->lang->normalizeForSearch(
+ $this->getLang()->normalizeForSearch(
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
),
'convertDoubleWidth() with the full alphabet and digits'
* @dataProvider provideFormattableTimes
*/
function testFormatTimePeriod( $seconds, $format, $expected, $desc ) {
- $this->assertEquals( $expected, $this->lang->formatTimePeriod( $seconds, $format ), $desc );
+ $this->assertEquals( $expected, $this->getLang()->formatTimePeriod( $seconds, $format ), $desc );
}
function provideFormattableTimes() {
function testTruncate() {
$this->assertEquals(
"XXX",
- $this->lang->truncate( "1234567890", 0, 'XXX' ),
+ $this->getLang()->truncate( "1234567890", 0, 'XXX' ),
'truncate prefix, len 0, small ellipsis'
);
$this->assertEquals(
"12345XXX",
- $this->lang->truncate( "1234567890", 8, 'XXX' ),
+ $this->getLang()->truncate( "1234567890", 8, 'XXX' ),
'truncate prefix, small ellipsis'
);
$this->assertEquals(
"123456789",
- $this->lang->truncate( "123456789", 5, 'XXXXXXXXXXXXXXX' ),
+ $this->getLang()->truncate( "123456789", 5, 'XXXXXXXXXXXXXXX' ),
'truncate prefix, large ellipsis'
);
$this->assertEquals(
"XXX67890",
- $this->lang->truncate( "1234567890", -8, 'XXX' ),
+ $this->getLang()->truncate( "1234567890", -8, 'XXX' ),
'truncate suffix, small ellipsis'
);
$this->assertEquals(
"123456789",
- $this->lang->truncate( "123456789", -5, 'XXXXXXXXXXXXXXX' ),
+ $this->getLang()->truncate( "123456789", -5, 'XXXXXXXXXXXXXXX' ),
'truncate suffix, large ellipsis'
);
}
// Actual HTML...
$this->assertEquals(
$expected,
- $this->lang->truncateHTML( $input, $len, $ellipsis )
+ $this->getLang()->truncateHTML( $input, $len, $ellipsis )
);
}
function testSprintfDate( $format, $ts, $expected, $msg ) {
$this->assertEquals(
$expected,
- $this->lang->sprintfDate( $format, $ts ),
+ $this->getLang()->sprintfDate( $format, $ts ),
"sprintfDate('$format', '$ts'): $msg"
);
}
$this->assertEquals(
$expected,
- $this->lang->sprintfDate( $format, $ts ),
+ $this->getLang()->sprintfDate( $format, $ts ),
"sprintfDate('$format', '$ts'): $msg"
);
function testFormatSize( $size, $expected, $msg ) {
$this->assertEquals(
$expected,
- $this->lang->formatSize( $size ),
+ $this->getLang()->formatSize( $size ),
"formatSize('$size'): $msg"
);
}
function testFormatBitrate( $bps, $expected, $msg ) {
$this->assertEquals(
$expected,
- $this->lang->formatBitrate( $bps ),
+ $this->getLang()->formatBitrate( $bps ),
"formatBitrate('$bps'): $msg"
);
}
function testFormatDuration( $duration, $expected, $intervals = array() ) {
$this->assertEquals(
$expected,
- $this->lang->formatDuration( $duration, $intervals ),
+ $this->getLang()->formatDuration( $duration, $intervals ),
"formatDuration('$duration'): $expected"
);
}
function testCheckTitleEncoding( $s ) {
$this->assertEquals(
$s,
- $this->lang->checkTitleEncoding($s),
+ $this->getLang()->checkTitleEncoding($s),
"checkTitleEncoding('$s')"
);
}
* @dataProvider providePluralData
*/
function testConvertPlural( $expected, $number, $forms ) {
- $chosen = $this->lang->convertPlural( $number, $forms );
+ $chosen = $this->getLang()->convertPlural( $number, $forms );
$this->assertEquals( $expected, $chosen );
}