mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-11-27 16:30:12 +00:00
Rename ReferencesFormatter to ReferenceListFormatter
I always found the name a little ambiguous. The fact that it outputs an actual HTML list and not just some "references" – whatever that means – is relevant, in my opinion. Change-Id: I0d169455c8d2b42d62da4dccb8376c09fb6902bc
This commit is contained in:
parent
8333e70453
commit
7c75d44b8a
|
@ -50,7 +50,7 @@ class Cite {
|
|||
|
||||
private bool $isSectionPreview;
|
||||
private FootnoteMarkFormatter $footnoteMarkFormatter;
|
||||
private ReferencesFormatter $referencesFormatter;
|
||||
private ReferenceListFormatter $referenceListFormatter;
|
||||
private ErrorReporter $errorReporter;
|
||||
|
||||
/**
|
||||
|
@ -83,7 +83,7 @@ class Cite {
|
|||
$anchorFormatter,
|
||||
$messageLocalizer
|
||||
);
|
||||
$this->referencesFormatter = new ReferencesFormatter(
|
||||
$this->referenceListFormatter = new ReferenceListFormatter(
|
||||
$this->errorReporter,
|
||||
$anchorFormatter,
|
||||
$messageLocalizer
|
||||
|
@ -306,7 +306,7 @@ class Cite {
|
|||
): string {
|
||||
global $wgCiteResponsiveReferences;
|
||||
|
||||
return $this->referencesFormatter->formatReferences(
|
||||
return $this->referenceListFormatter->formatReferences(
|
||||
$parser,
|
||||
$this->referenceStack->popGroup( $group ),
|
||||
$responsive !== null ? $responsive !== '0' : $wgCiteResponsiveReferences,
|
||||
|
|
|
@ -11,7 +11,7 @@ use Parser;
|
|||
*
|
||||
* @license GPL-2.0-or-later
|
||||
*/
|
||||
class ReferencesFormatter {
|
||||
class ReferenceListFormatter {
|
||||
|
||||
/**
|
||||
* The backlinks, in order, to pass as $3 to
|
|
@ -4,7 +4,7 @@ namespace Cite\Tests;
|
|||
|
||||
use Cite\Cite;
|
||||
use Cite\ErrorReporter;
|
||||
use Cite\ReferencesFormatter;
|
||||
use Cite\ReferenceListFormatter;
|
||||
use Cite\ReferenceStack;
|
||||
use Language;
|
||||
use Parser;
|
||||
|
@ -38,15 +38,15 @@ class CiteIntegrationTest extends \MediaWikiIntegrationTestCase {
|
|||
$referenceStack = new ReferenceStack();
|
||||
TestingAccessWrapper::newFromObject( $referenceStack )->refs = $initialRefs;
|
||||
|
||||
$referencesFormatter = $this->createMock( ReferencesFormatter::class );
|
||||
$referencesFormatter->method( 'formatReferences' )->willReturn( '<references />' );
|
||||
$formatter = $this->createMock( ReferenceListFormatter::class );
|
||||
$formatter->method( 'formatReferences' )->willReturn( '<references />' );
|
||||
|
||||
$cite = $this->newCite();
|
||||
/** @var Cite $spy */
|
||||
$spy = TestingAccessWrapper::newFromObject( $cite );
|
||||
$spy->referenceStack = $referenceStack;
|
||||
$spy->errorReporter = $mockErrorReporter;
|
||||
$spy->referencesFormatter = $referencesFormatter;
|
||||
$spy->referenceListFormatter = $formatter;
|
||||
$spy->isSectionPreview = $isSectionPreview;
|
||||
|
||||
$parser = $this->createNoOpMock( Parser::class );
|
||||
|
|
|
@ -5,7 +5,7 @@ namespace Cite\Tests\Integration;
|
|||
use Cite\Cite;
|
||||
use Cite\ErrorReporter;
|
||||
use Cite\FootnoteMarkFormatter;
|
||||
use Cite\ReferencesFormatter;
|
||||
use Cite\ReferenceListFormatter;
|
||||
use Cite\ReferenceStack;
|
||||
use Cite\Tests\TestUtils;
|
||||
use Language;
|
||||
|
@ -139,8 +139,8 @@ class CiteTest extends \MediaWikiIntegrationTestCase {
|
|||
$spy->errorReporter->method( 'halfParsed' )->willReturnCallback(
|
||||
static fn ( $parser, ...$args ) => '(' . implode( '|', $args ) . ')'
|
||||
);
|
||||
$spy->referencesFormatter = $this->createMock( ReferencesFormatter::class );
|
||||
$spy->referencesFormatter->method( 'formatReferences' )
|
||||
$spy->referenceListFormatter = $this->createMock( ReferenceListFormatter::class );
|
||||
$spy->referenceListFormatter->method( 'formatReferences' )
|
||||
->with( $parser, [], $expectedResponsive, false )
|
||||
->willReturn( 'references!' );
|
||||
$spy->isSectionPreview = false;
|
||||
|
|
|
@ -4,18 +4,18 @@ namespace Cite\Tests\Unit;
|
|||
|
||||
use Cite\AnchorFormatter;
|
||||
use Cite\ErrorReporter;
|
||||
use Cite\ReferenceListFormatter;
|
||||
use Cite\ReferenceMessageLocalizer;
|
||||
use Cite\ReferencesFormatter;
|
||||
use Cite\Tests\TestUtils;
|
||||
use Message;
|
||||
use Parser;
|
||||
use Wikimedia\TestingAccessWrapper;
|
||||
|
||||
/**
|
||||
* @covers \Cite\ReferencesFormatter
|
||||
* @covers \Cite\ReferenceListFormatter
|
||||
* @license GPL-2.0-or-later
|
||||
*/
|
||||
class ReferencesFormatterTest extends \MediaWikiUnitTestCase {
|
||||
class ReferenceListFormatterTest extends \MediaWikiUnitTestCase {
|
||||
|
||||
/**
|
||||
* @dataProvider provideFormatReferences
|
||||
|
@ -38,7 +38,7 @@ class ReferencesFormatterTest extends \MediaWikiUnitTestCase {
|
|||
}
|
||||
);
|
||||
|
||||
$formatter = new ReferencesFormatter(
|
||||
$formatter = new ReferenceListFormatter(
|
||||
$mockErrorReporter,
|
||||
$this->createMock( AnchorFormatter::class ),
|
||||
$mockMessageLocalizer
|
||||
|
@ -172,8 +172,8 @@ class ReferencesFormatterTest extends \MediaWikiUnitTestCase {
|
|||
* @dataProvider provideCloseIndention
|
||||
*/
|
||||
public function testCloseIndention( $closingLi, $expectedOutput ) {
|
||||
/** @var ReferencesFormatter $formatter */
|
||||
$formatter = TestingAccessWrapper::newFromObject( new ReferencesFormatter(
|
||||
/** @var ReferenceListFormatter $formatter */
|
||||
$formatter = TestingAccessWrapper::newFromObject( new ReferenceListFormatter(
|
||||
$this->createMock( ErrorReporter::class ),
|
||||
$this->createMock( AnchorFormatter::class ),
|
||||
$this->createMock( ReferenceMessageLocalizer::class )
|
||||
|
@ -220,8 +220,8 @@ class ReferencesFormatterTest extends \MediaWikiUnitTestCase {
|
|||
}
|
||||
);
|
||||
|
||||
/** @var ReferencesFormatter $formatter */
|
||||
$formatter = TestingAccessWrapper::newFromObject( new ReferencesFormatter(
|
||||
/** @var ReferenceListFormatter $formatter */
|
||||
$formatter = TestingAccessWrapper::newFromObject( new ReferenceListFormatter(
|
||||
$mockErrorReporter,
|
||||
$anchorFormatter,
|
||||
$mockMessageLocalizer
|
||||
|
@ -311,8 +311,8 @@ class ReferencesFormatterTest extends \MediaWikiUnitTestCase {
|
|||
static fn ( $parser, ...$args ) => '(' . implode( '|', $args ) . ')'
|
||||
);
|
||||
|
||||
/** @var ReferencesFormatter $formatter */
|
||||
$formatter = TestingAccessWrapper::newFromObject( new ReferencesFormatter(
|
||||
/** @var ReferenceListFormatter $formatter */
|
||||
$formatter = TestingAccessWrapper::newFromObject( new ReferenceListFormatter(
|
||||
$mockErrorReporter,
|
||||
$this->createMock( AnchorFormatter::class ),
|
||||
$this->createMock( ReferenceMessageLocalizer::class )
|
||||
|
@ -367,8 +367,8 @@ class ReferencesFormatterTest extends \MediaWikiUnitTestCase {
|
|||
$errorReporter->expects( $expectedLabel ? $this->never() : $this->once() )
|
||||
->method( 'plain' );
|
||||
|
||||
/** @var ReferencesFormatter $formatter */
|
||||
$formatter = TestingAccessWrapper::newFromObject( new ReferencesFormatter(
|
||||
/** @var ReferenceListFormatter $formatter */
|
||||
$formatter = TestingAccessWrapper::newFromObject( new ReferenceListFormatter(
|
||||
$errorReporter,
|
||||
$this->createMock( AnchorFormatter::class ),
|
||||
$mockMessageLocalizer
|
||||
|
@ -398,8 +398,8 @@ class ReferencesFormatterTest extends \MediaWikiUnitTestCase {
|
|||
$mockMessageLocalizer->method( 'localizeSeparators' )->willReturnArgument( 0 );
|
||||
$mockMessageLocalizer->method( 'localizeDigits' )->willReturnArgument( 0 );
|
||||
|
||||
/** @var ReferencesFormatter $formatter */
|
||||
$formatter = TestingAccessWrapper::newFromObject( new ReferencesFormatter(
|
||||
/** @var ReferenceListFormatter $formatter */
|
||||
$formatter = TestingAccessWrapper::newFromObject( new ReferenceListFormatter(
|
||||
$this->createMock( ErrorReporter::class ),
|
||||
$this->createMock( AnchorFormatter::class ),
|
||||
$mockMessageLocalizer
|
||||
|
@ -430,8 +430,8 @@ class ReferencesFormatterTest extends \MediaWikiUnitTestCase {
|
|||
}
|
||||
);
|
||||
|
||||
/** @var ReferencesFormatter $formatter */
|
||||
$formatter = TestingAccessWrapper::newFromObject( new ReferencesFormatter(
|
||||
/** @var ReferenceListFormatter $formatter */
|
||||
$formatter = TestingAccessWrapper::newFromObject( new ReferenceListFormatter(
|
||||
$this->createMock( ErrorReporter::class ),
|
||||
$this->createMock( AnchorFormatter::class ),
|
||||
$mockMessageLocalizer
|
Loading…
Reference in a new issue