mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-11-12 01:01:29 +00:00
22627f074d
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
67 lines
1.5 KiB
PHP
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'
|
|
],
|
|
];
|
|
}
|
|
|
|
}
|