Add test to cover Cite::listToText()

As far as I can see this must (for now) be an integration test because
it is calling wfMessage().

Change-Id: Ic581c38128364990ccf81539996d1dda53bdcda5
This commit is contained in:
Thiemo Kreuz 2019-11-27 11:58:03 +01:00
parent 40942620b2
commit f5b9360467

View file

@ -8,6 +8,7 @@ use Parser;
use ParserOptions;
use ParserOutput;
use StripState;
use Wikimedia\TestingAccessWrapper;
/**
* @coversDefaultClass \Cite\Cite
@ -21,6 +22,7 @@ class CiteTest extends \MediaWikiIntegrationTestCase {
$this->setMwGlobals( [
'wgCiteBookReferencing' => true,
'wgLanguageCode' => 'qqx',
] );
}
@ -50,4 +52,36 @@ class CiteTest extends \MediaWikiIntegrationTestCase {
$cite->ref( 'contentB', [ Cite::BOOK_REF_ATTRIBUTE => 'a' ], $mockParser );
}
/**
* @covers ::listToText
* @dataProvider provideLists
*/
public function testListToText( array $list, $expected ) {
/** @var Cite $cite */
$cite = TestingAccessWrapper::newFromObject( new Cite() );
$this->assertSame( $expected, $cite->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'
],
];
}
}