Remove not needed int type from ReferenceListFormatter

It's always a string anyway. Also improve the test coverage. The
localization was pretty much untested before.

Change-Id: Ie6f34c67ae7dd9559346eb45a2604e14c5633991
This commit is contained in:
thiemowmde 2024-08-13 10:46:52 +02:00
parent d847caf5b8
commit a4ffedbcc2
2 changed files with 10 additions and 9 deletions

View file

@ -241,14 +241,14 @@ class ReferenceListFormatter {
* offset, e.g. $base = 1, $offset = 2; = 1.2
* Since bug #5525, it correctly does 1.9 -> 1.10 as well as 1.099 -> 1.100
*
* @param int|string $base
* @param string $base
* @param int $offset
* @param int $max Maximum value expected.
*
* @return string
*/
private function referencesFormatEntryNumericBacklinkLabel(
$base,
string $base,
int $offset,
int $max
): string {

View file

@ -389,10 +389,10 @@ class ReferenceListFormatterTest extends \MediaWikiUnitTestCase {
* @dataProvider provideReferencesFormatEntryNumericBacklinkLabel
*/
public function testReferencesFormatEntryNumericBacklinkLabel(
string $expectedLabel, int $base, int $offset, int $max
string $expectedLabel, string $base, int $offset, int $max
) {
$mockMessageLocalizer = $this->createMock( ReferenceMessageLocalizer::class );
$mockMessageLocalizer->method( 'localizeSeparators' )->willReturnArgument( 0 );
$mockMessageLocalizer->method( 'localizeSeparators' )->willReturn( ',' );
$mockMessageLocalizer->method( 'localizeDigits' )->willReturnArgument( 0 );
/** @var ReferenceListFormatter $formatter */
@ -407,11 +407,12 @@ class ReferenceListFormatterTest extends \MediaWikiUnitTestCase {
}
public static function provideReferencesFormatEntryNumericBacklinkLabel() {
yield [ '1.2', 1, 2, 9 ];
yield [ '1.02', 1, 2, 99 ];
yield [ '1.002', 1, 2, 100 ];
yield [ '1.50005', 1, 50005, 50005 ];
yield [ '2.1', 2, 1, 1 ];
yield [ '1,2', '1', 2, 9 ];
yield [ '1,02', '1', 2, 99 ];
yield [ '1,002', '1', 2, 100 ];
yield [ '1,50005', '1', 50005, 50005 ];
yield [ '2,1', '2', 1, 1 ];
yield [ '3.2,1', '3.2', 1, 1 ];
}
/**