mediawiki-extensions-Cite/tests/phpunit/FootnoteBodyFormatterTest.php
Thiemo Kreuz 22627f074d Make the normalizeKey() method private
There was a call in the API that was *not* using normalizeKey(). Now
that the API is gone, we can inline this.

This patch also contains a bunch of cleanups that might already been
resolved in the previous patches.

Change-Id: Id3767b5830268c8cfe9c10efabfa4a31e9dafeb8
2019-11-29 19:02:48 +01:00

67 lines
1.5 KiB
PHP

<?php
namespace Cite\Tests;
use Cite\CiteErrorReporter;
use Cite\CiteKeyFormatter;
use Cite\FootnoteBodyFormatter;
use MediaWikiIntegrationTestCase;
use Parser;
use Wikimedia\TestingAccessWrapper;
/**
* @coversDefaultClass \Cite\FootnoteBodyFormatter
*
* @license GPL-2.0-or-later
*/
class FootnoteBodyFormatterTest extends MediaWikiIntegrationTestCase {
public function setUp() : void {
parent::setUp();
$this->setMwGlobals( [
'wgLanguageCode' => 'qqx',
] );
}
/**
* @covers ::listToText
* @dataProvider provideLists
*/
public function testListToText( array $list, $expected ) {
/** @var Parser $mockErrorReporter */
$mockParser = $this->createMock( Parser::class );
/** @var CiteErrorReporter $mockErrorReporter */
$mockErrorReporter = $this->createMock( CiteErrorReporter::class );
/** @var CiteKeyFormatter $mockKeyFormatter */
$mockKeyFormatter = $this->createMock( CiteKeyFormatter::class );
/** @var FootnoteBodyFormatter $formatter */
$formatter = TestingAccessWrapper::newFromObject( new FootnoteBodyFormatter(
$mockParser, $mockErrorReporter, $mockKeyFormatter ) );
$this->assertSame( $expected, $formatter->listToText( $list ) );
}
public function provideLists() {
return [
[
[],
''
],
[
// This is intentionally using numbers to test the to-string cast
[ 1 ],
'1'
],
[
[ 1, 2 ],
'1(cite_references_link_many_and)2'
],
[
[ 1, 2, 3 ],
'1(cite_references_link_many_sep)2(cite_references_link_many_and)3'
],
];
}
}