mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-11-24 06:54:00 +00:00
5aa6cb0c7b
This parser test is a bit obscure, in my opinion. We added it in I8c4de96 to make sure we don't get thousand separators in most places. We continued reworking the code since then. By now it's effectively impossible to "accidentally" get thousand separators. The problematic methods from the Language class are not even accessible any more from this code. To make the tests more robust we now use createNoOpMock (done via the previous patch) where it matters, specifically for all Language and Parser mocks. This proves the problematic Language methods are never called. Bug: T253743 Bug: T238187 Change-Id: I9bfe1f4decfaf699996da63e19473c2c0d581d9d
35 lines
1 KiB
PHP
35 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->createNoOpMock( Language::class, [ 'separatorTransformTable' ] );
|
|
$mockLanguage->method( 'separatorTransformTable' )->willReturn( [ '.' => ',', '0' => '' ] );
|
|
$messageLocalizer = new ReferenceMessageLocalizer( $mockLanguage );
|
|
$this->assertSame( '10,0', $messageLocalizer->localizeSeparators( '10.0' ) );
|
|
}
|
|
|
|
/**
|
|
* @covers ::localizeDigits
|
|
*/
|
|
public function testLocalizeDigits() {
|
|
$mockLanguage = $this->createNoOpMock( Language::class, [ 'formatNumNoSeparators' ] );
|
|
$mockLanguage->method( 'formatNumNoSeparators' )->willReturnArgument( 0 );
|
|
$messageLocalizer = new ReferenceMessageLocalizer( $mockLanguage );
|
|
$this->assertSame( '50005', $messageLocalizer->localizeDigits( '50005' ) );
|
|
}
|
|
|
|
}
|