2019-12-06 09:12:25 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Cite\Tests\Unit;
|
|
|
|
|
|
|
|
use Cite\ReferenceMessageLocalizer;
|
|
|
|
use Language;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @coversDefaultClass \Cite\ReferenceMessageLocalizer
|
|
|
|
*/
|
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
|
|
|
* @covers ::localizeSeparators
|
2019-12-06 09:12:25 +00:00
|
|
|
* @covers ::__construct
|
|
|
|
*/
|
2020-09-02 07:40:33 +00:00
|
|
|
public function testLocalizeSeparators() {
|
2019-12-06 09:12:25 +00:00
|
|
|
$mockLanguage = $this->createMock( Language::class );
|
2020-09-02 07:40:33 +00:00
|
|
|
$mockLanguage->method( 'separatorTransformTable' )->willReturn( [ '.' => ',', '0' => '' ] );
|
2019-12-06 09:12:25 +00:00
|
|
|
/** @var Language $mockLanguage */
|
|
|
|
$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
|
|
|
* @covers ::localizeDigits
|
2019-12-06 09:12:25 +00:00
|
|
|
*/
|
2019-12-10 15:21:12 +00:00
|
|
|
public function testLocalizeDigits() {
|
2019-12-06 09:12:25 +00:00
|
|
|
$mockLanguage = $this->createMock( Language::class );
|
|
|
|
$mockLanguage->method( 'formatNumNoSeparators' )->willReturn( 'ה' );
|
|
|
|
/** @var Language $mockLanguage */
|
|
|
|
$messageLocalizer = new ReferenceMessageLocalizer( $mockLanguage );
|
2019-12-10 15:21:12 +00:00
|
|
|
$this->assertSame( 'ה', $messageLocalizer->localizeDigits( '5' ) );
|
2019-12-06 09:12:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|