2019-12-06 09:12:25 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Cite\Tests\Unit;
|
|
|
|
|
|
|
|
use Cite\ReferenceMessageLocalizer;
|
|
|
|
use Language;
|
|
|
|
|
|
|
|
/**
|
2023-12-15 11:12:16 +00:00
|
|
|
* @covers \Cite\ReferenceMessageLocalizer
|
|
|
|
* @license GPL-2.0-or-later
|
2019-12-06 09:12:25 +00:00
|
|
|
*/
|
2019-12-10 15:24:49 +00:00
|
|
|
class ReferenceMessageLocalizerUnitTest extends \MediaWikiUnitTestCase {
|
2019-12-06 09:12:25 +00:00
|
|
|
|
2020-09-02 07:40:33 +00:00
|
|
|
public function testLocalizeSeparators() {
|
2023-07-27 09:39:46 +00:00
|
|
|
$mockLanguage = $this->createNoOpMock( Language::class, [ 'separatorTransformTable' ] );
|
2020-09-02 07:40:33 +00:00
|
|
|
$mockLanguage->method( 'separatorTransformTable' )->willReturn( [ '.' => ',', '0' => '' ] );
|
2019-12-06 09:12:25 +00:00
|
|
|
$messageLocalizer = new ReferenceMessageLocalizer( $mockLanguage );
|
2020-09-02 07:40:33 +00:00
|
|
|
$this->assertSame( '10,0', $messageLocalizer->localizeSeparators( '10.0' ) );
|
2019-12-06 09:12:25 +00:00
|
|
|
}
|
|
|
|
|
2019-12-10 15:21:12 +00:00
|
|
|
public function testLocalizeDigits() {
|
2023-07-27 09:39:46 +00:00
|
|
|
$mockLanguage = $this->createNoOpMock( Language::class, [ 'formatNumNoSeparators' ] );
|
2023-07-25 13:34:09 +00:00
|
|
|
$mockLanguage->method( 'formatNumNoSeparators' )->willReturnArgument( 0 );
|
2019-12-06 09:12:25 +00:00
|
|
|
$messageLocalizer = new ReferenceMessageLocalizer( $mockLanguage );
|
2023-07-25 13:34:09 +00:00
|
|
|
$this->assertSame( '50005', $messageLocalizer->localizeDigits( '50005' ) );
|
2019-12-06 09:12:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|