mediawiki-extensions-Cite/tests/phpunit/unit/ReferenceMessageLocalizerUnitTest.php
Adam Wight 3d80501829 Narrow message localizer interface
We never access Language directly, so proxy its method instead of
returning the full object.

I believe I've found a bug, but not fixing here: the footnote body
numeric backlinks like "2.1" behave as if they were decimals rather
than two numbers stuck together with a dot.  So they are localized
to "2,1".

Bug: T239725
Change-Id: If386bf96d48cb95c0a287a02bedfe984941efe30
2019-12-06 12:17:09 +01:00

38 lines
1 KiB
PHP

<?php
namespace Cite\Tests\Unit;
use Cite\ReferenceMessageLocalizer;
use Language;
use MediaWikiUnitTestCase;
/**
* @coversDefaultClass \Cite\ReferenceMessageLocalizer
*/
class ReferenceMessageLocalizerUnitTest extends MediaWikiUnitTestCase {
/**
* @covers ::formatNum
* @covers ::__construct
*/
public function testFormatNum() {
$mockLanguage = $this->createMock( Language::class );
$mockLanguage->method( 'formatNum' )->willReturn( '10,0' );
/** @var Language $mockLanguage */
$messageLocalizer = new ReferenceMessageLocalizer( $mockLanguage );
$this->assertSame( '10,0', $messageLocalizer->formatNum( '10.0' ) );
}
/**
* @covers ::formatNumNoSeparators
*/
public function testFormatNumNoSeparators() {
$mockLanguage = $this->createMock( Language::class );
$mockLanguage->method( 'formatNumNoSeparators' )->willReturn( 'ה' );
/** @var Language $mockLanguage */
$messageLocalizer = new ReferenceMessageLocalizer( $mockLanguage );
$this->assertSame( 'ה', $messageLocalizer->formatNumNoSeparators( '5' ) );
}
}