mediawiki-extensions-Cite/tests/phpunit/unit/ReferenceMessageLocalizerUnitTest.php
thiemowmde 4377f0923d More simple and consistent @covers and @license tags
Same arguments as in Iafa2412. The one reason to use more detailled
per-method @covers annotations is to avoid "accidental coverage"
where code is marked as being covered by tests that don't assert
anything that would be meaningful for this code. This is especially a
problem with older, bigger classes with lots of side effects.

But all the new classes we introduced over the years are small, with
predictable, local effects.

That's also why we keep the more detailled @covers annotations for
the original Cite class.

Bug: T353227
Bug: T353269
Change-Id: I69850f4d740d8ad5a7c2368b9068dc91e47cc797
2023-12-15 12:12:16 +01:00

29 lines
984 B
PHP

<?php
namespace Cite\Tests\Unit;
use Cite\ReferenceMessageLocalizer;
use Language;
/**
* @covers \Cite\ReferenceMessageLocalizer
* @license GPL-2.0-or-later
*/
class ReferenceMessageLocalizerUnitTest extends \MediaWikiUnitTestCase {
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' ) );
}
public function testLocalizeDigits() {
$mockLanguage = $this->createNoOpMock( Language::class, [ 'formatNumNoSeparators' ] );
$mockLanguage->method( 'formatNumNoSeparators' )->willReturnArgument( 0 );
$messageLocalizer = new ReferenceMessageLocalizer( $mockLanguage );
$this->assertSame( '50005', $messageLocalizer->localizeDigits( '50005' ) );
}
}