mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-12-04 03:18:19 +00:00
7ce27b432f
This is done to make the discussion in If3dcfd7 easier. When we introduced this code we actually used it to format entire numbers. We had to change this later to *not* localize digits, but only separators. Language::formatNum is and always was able to do this, so we just continued to use it. This is discussed now. It turns out there is only a single place left where we use formatNum, and it does nothing but localizing the decimal point. There is another way to do the same. Bug: T237467 Change-Id: I89b17a9e11b3afc6c653ba7ccc6ff84c37863b66
37 lines
1 KiB
PHP
37 lines
1 KiB
PHP
<?php
|
|
|
|
namespace Cite\Tests\Unit;
|
|
|
|
use Cite\ReferenceMessageLocalizer;
|
|
use Language;
|
|
|
|
/**
|
|
* @coversDefaultClass \Cite\ReferenceMessageLocalizer
|
|
*/
|
|
class ReferenceMessageLocalizerUnitTest extends \MediaWikiUnitTestCase {
|
|
|
|
/**
|
|
* @covers ::localizeSeparators
|
|
* @covers ::__construct
|
|
*/
|
|
public function testLocalizeSeparators() {
|
|
$mockLanguage = $this->createMock( Language::class );
|
|
$mockLanguage->method( 'separatorTransformTable' )->willReturn( [ '.' => ',', '0' => '' ] );
|
|
/** @var Language $mockLanguage */
|
|
$messageLocalizer = new ReferenceMessageLocalizer( $mockLanguage );
|
|
$this->assertSame( '10,0', $messageLocalizer->localizeSeparators( '10.0' ) );
|
|
}
|
|
|
|
/**
|
|
* @covers ::localizeDigits
|
|
*/
|
|
public function testLocalizeDigits() {
|
|
$mockLanguage = $this->createMock( Language::class );
|
|
$mockLanguage->method( 'formatNumNoSeparators' )->willReturn( 'ה' );
|
|
/** @var Language $mockLanguage */
|
|
$messageLocalizer = new ReferenceMessageLocalizer( $mockLanguage );
|
|
$this->assertSame( 'ה', $messageLocalizer->localizeDigits( '5' ) );
|
|
}
|
|
|
|
}
|