mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-11-23 22:45:20 +00:00
Merge "Rename ReferencesFormatter to ReferenceListFormatter"
This commit is contained in:
commit
46499cd9c0
|
@ -50,7 +50,7 @@ class Cite {
|
||||||
|
|
||||||
private bool $isSectionPreview;
|
private bool $isSectionPreview;
|
||||||
private FootnoteMarkFormatter $footnoteMarkFormatter;
|
private FootnoteMarkFormatter $footnoteMarkFormatter;
|
||||||
private ReferencesFormatter $referencesFormatter;
|
private ReferenceListFormatter $referenceListFormatter;
|
||||||
private ErrorReporter $errorReporter;
|
private ErrorReporter $errorReporter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -83,7 +83,7 @@ class Cite {
|
||||||
$anchorFormatter,
|
$anchorFormatter,
|
||||||
$messageLocalizer
|
$messageLocalizer
|
||||||
);
|
);
|
||||||
$this->referencesFormatter = new ReferencesFormatter(
|
$this->referenceListFormatter = new ReferenceListFormatter(
|
||||||
$this->errorReporter,
|
$this->errorReporter,
|
||||||
$anchorFormatter,
|
$anchorFormatter,
|
||||||
$messageLocalizer
|
$messageLocalizer
|
||||||
|
@ -306,7 +306,7 @@ class Cite {
|
||||||
): string {
|
): string {
|
||||||
global $wgCiteResponsiveReferences;
|
global $wgCiteResponsiveReferences;
|
||||||
|
|
||||||
return $this->referencesFormatter->formatReferences(
|
return $this->referenceListFormatter->formatReferences(
|
||||||
$parser,
|
$parser,
|
||||||
$this->referenceStack->popGroup( $group ),
|
$this->referenceStack->popGroup( $group ),
|
||||||
$responsive !== null ? $responsive !== '0' : $wgCiteResponsiveReferences,
|
$responsive !== null ? $responsive !== '0' : $wgCiteResponsiveReferences,
|
||||||
|
|
|
@ -11,7 +11,7 @@ use Parser;
|
||||||
*
|
*
|
||||||
* @license GPL-2.0-or-later
|
* @license GPL-2.0-or-later
|
||||||
*/
|
*/
|
||||||
class ReferencesFormatter {
|
class ReferenceListFormatter {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The backlinks, in order, to pass as $3 to
|
* The backlinks, in order, to pass as $3 to
|
|
@ -4,7 +4,7 @@ namespace Cite\Tests;
|
||||||
|
|
||||||
use Cite\Cite;
|
use Cite\Cite;
|
||||||
use Cite\ErrorReporter;
|
use Cite\ErrorReporter;
|
||||||
use Cite\ReferencesFormatter;
|
use Cite\ReferenceListFormatter;
|
||||||
use Cite\ReferenceStack;
|
use Cite\ReferenceStack;
|
||||||
use Language;
|
use Language;
|
||||||
use Parser;
|
use Parser;
|
||||||
|
@ -38,15 +38,15 @@ class CiteIntegrationTest extends \MediaWikiIntegrationTestCase {
|
||||||
$referenceStack = new ReferenceStack();
|
$referenceStack = new ReferenceStack();
|
||||||
TestingAccessWrapper::newFromObject( $referenceStack )->refs = $initialRefs;
|
TestingAccessWrapper::newFromObject( $referenceStack )->refs = $initialRefs;
|
||||||
|
|
||||||
$referencesFormatter = $this->createMock( ReferencesFormatter::class );
|
$formatter = $this->createMock( ReferenceListFormatter::class );
|
||||||
$referencesFormatter->method( 'formatReferences' )->willReturn( '<references />' );
|
$formatter->method( 'formatReferences' )->willReturn( '<references />' );
|
||||||
|
|
||||||
$cite = $this->newCite();
|
$cite = $this->newCite();
|
||||||
/** @var Cite $spy */
|
/** @var Cite $spy */
|
||||||
$spy = TestingAccessWrapper::newFromObject( $cite );
|
$spy = TestingAccessWrapper::newFromObject( $cite );
|
||||||
$spy->referenceStack = $referenceStack;
|
$spy->referenceStack = $referenceStack;
|
||||||
$spy->errorReporter = $mockErrorReporter;
|
$spy->errorReporter = $mockErrorReporter;
|
||||||
$spy->referencesFormatter = $referencesFormatter;
|
$spy->referenceListFormatter = $formatter;
|
||||||
$spy->isSectionPreview = $isSectionPreview;
|
$spy->isSectionPreview = $isSectionPreview;
|
||||||
|
|
||||||
$parser = $this->createNoOpMock( Parser::class );
|
$parser = $this->createNoOpMock( Parser::class );
|
||||||
|
|
|
@ -5,7 +5,7 @@ namespace Cite\Tests\Integration;
|
||||||
use Cite\Cite;
|
use Cite\Cite;
|
||||||
use Cite\ErrorReporter;
|
use Cite\ErrorReporter;
|
||||||
use Cite\FootnoteMarkFormatter;
|
use Cite\FootnoteMarkFormatter;
|
||||||
use Cite\ReferencesFormatter;
|
use Cite\ReferenceListFormatter;
|
||||||
use Cite\ReferenceStack;
|
use Cite\ReferenceStack;
|
||||||
use Cite\Tests\TestUtils;
|
use Cite\Tests\TestUtils;
|
||||||
use Language;
|
use Language;
|
||||||
|
@ -139,8 +139,8 @@ class CiteTest extends \MediaWikiIntegrationTestCase {
|
||||||
$spy->errorReporter->method( 'halfParsed' )->willReturnCallback(
|
$spy->errorReporter->method( 'halfParsed' )->willReturnCallback(
|
||||||
static fn ( $parser, ...$args ) => '(' . implode( '|', $args ) . ')'
|
static fn ( $parser, ...$args ) => '(' . implode( '|', $args ) . ')'
|
||||||
);
|
);
|
||||||
$spy->referencesFormatter = $this->createMock( ReferencesFormatter::class );
|
$spy->referenceListFormatter = $this->createMock( ReferenceListFormatter::class );
|
||||||
$spy->referencesFormatter->method( 'formatReferences' )
|
$spy->referenceListFormatter->method( 'formatReferences' )
|
||||||
->with( $parser, [], $expectedResponsive, false )
|
->with( $parser, [], $expectedResponsive, false )
|
||||||
->willReturn( 'references!' );
|
->willReturn( 'references!' );
|
||||||
$spy->isSectionPreview = false;
|
$spy->isSectionPreview = false;
|
||||||
|
|
|
@ -4,18 +4,18 @@ namespace Cite\Tests\Unit;
|
||||||
|
|
||||||
use Cite\AnchorFormatter;
|
use Cite\AnchorFormatter;
|
||||||
use Cite\ErrorReporter;
|
use Cite\ErrorReporter;
|
||||||
|
use Cite\ReferenceListFormatter;
|
||||||
use Cite\ReferenceMessageLocalizer;
|
use Cite\ReferenceMessageLocalizer;
|
||||||
use Cite\ReferencesFormatter;
|
|
||||||
use Cite\Tests\TestUtils;
|
use Cite\Tests\TestUtils;
|
||||||
use Message;
|
use Message;
|
||||||
use Parser;
|
use Parser;
|
||||||
use Wikimedia\TestingAccessWrapper;
|
use Wikimedia\TestingAccessWrapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers \Cite\ReferencesFormatter
|
* @covers \Cite\ReferenceListFormatter
|
||||||
* @license GPL-2.0-or-later
|
* @license GPL-2.0-or-later
|
||||||
*/
|
*/
|
||||||
class ReferencesFormatterTest extends \MediaWikiUnitTestCase {
|
class ReferenceListFormatterTest extends \MediaWikiUnitTestCase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider provideFormatReferences
|
* @dataProvider provideFormatReferences
|
||||||
|
@ -38,7 +38,7 @@ class ReferencesFormatterTest extends \MediaWikiUnitTestCase {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
$formatter = new ReferencesFormatter(
|
$formatter = new ReferenceListFormatter(
|
||||||
$mockErrorReporter,
|
$mockErrorReporter,
|
||||||
$this->createMock( AnchorFormatter::class ),
|
$this->createMock( AnchorFormatter::class ),
|
||||||
$mockMessageLocalizer
|
$mockMessageLocalizer
|
||||||
|
@ -172,8 +172,8 @@ class ReferencesFormatterTest extends \MediaWikiUnitTestCase {
|
||||||
* @dataProvider provideCloseIndention
|
* @dataProvider provideCloseIndention
|
||||||
*/
|
*/
|
||||||
public function testCloseIndention( $closingLi, $expectedOutput ) {
|
public function testCloseIndention( $closingLi, $expectedOutput ) {
|
||||||
/** @var ReferencesFormatter $formatter */
|
/** @var ReferenceListFormatter $formatter */
|
||||||
$formatter = TestingAccessWrapper::newFromObject( new ReferencesFormatter(
|
$formatter = TestingAccessWrapper::newFromObject( new ReferenceListFormatter(
|
||||||
$this->createMock( ErrorReporter::class ),
|
$this->createMock( ErrorReporter::class ),
|
||||||
$this->createMock( AnchorFormatter::class ),
|
$this->createMock( AnchorFormatter::class ),
|
||||||
$this->createMock( ReferenceMessageLocalizer::class )
|
$this->createMock( ReferenceMessageLocalizer::class )
|
||||||
|
@ -220,8 +220,8 @@ class ReferencesFormatterTest extends \MediaWikiUnitTestCase {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
/** @var ReferencesFormatter $formatter */
|
/** @var ReferenceListFormatter $formatter */
|
||||||
$formatter = TestingAccessWrapper::newFromObject( new ReferencesFormatter(
|
$formatter = TestingAccessWrapper::newFromObject( new ReferenceListFormatter(
|
||||||
$mockErrorReporter,
|
$mockErrorReporter,
|
||||||
$anchorFormatter,
|
$anchorFormatter,
|
||||||
$mockMessageLocalizer
|
$mockMessageLocalizer
|
||||||
|
@ -311,8 +311,8 @@ class ReferencesFormatterTest extends \MediaWikiUnitTestCase {
|
||||||
static fn ( $parser, ...$args ) => '(' . implode( '|', $args ) . ')'
|
static fn ( $parser, ...$args ) => '(' . implode( '|', $args ) . ')'
|
||||||
);
|
);
|
||||||
|
|
||||||
/** @var ReferencesFormatter $formatter */
|
/** @var ReferenceListFormatter $formatter */
|
||||||
$formatter = TestingAccessWrapper::newFromObject( new ReferencesFormatter(
|
$formatter = TestingAccessWrapper::newFromObject( new ReferenceListFormatter(
|
||||||
$mockErrorReporter,
|
$mockErrorReporter,
|
||||||
$this->createMock( AnchorFormatter::class ),
|
$this->createMock( AnchorFormatter::class ),
|
||||||
$this->createMock( ReferenceMessageLocalizer::class )
|
$this->createMock( ReferenceMessageLocalizer::class )
|
||||||
|
@ -367,8 +367,8 @@ class ReferencesFormatterTest extends \MediaWikiUnitTestCase {
|
||||||
$errorReporter->expects( $expectedLabel ? $this->never() : $this->once() )
|
$errorReporter->expects( $expectedLabel ? $this->never() : $this->once() )
|
||||||
->method( 'plain' );
|
->method( 'plain' );
|
||||||
|
|
||||||
/** @var ReferencesFormatter $formatter */
|
/** @var ReferenceListFormatter $formatter */
|
||||||
$formatter = TestingAccessWrapper::newFromObject( new ReferencesFormatter(
|
$formatter = TestingAccessWrapper::newFromObject( new ReferenceListFormatter(
|
||||||
$errorReporter,
|
$errorReporter,
|
||||||
$this->createMock( AnchorFormatter::class ),
|
$this->createMock( AnchorFormatter::class ),
|
||||||
$mockMessageLocalizer
|
$mockMessageLocalizer
|
||||||
|
@ -398,8 +398,8 @@ class ReferencesFormatterTest extends \MediaWikiUnitTestCase {
|
||||||
$mockMessageLocalizer->method( 'localizeSeparators' )->willReturnArgument( 0 );
|
$mockMessageLocalizer->method( 'localizeSeparators' )->willReturnArgument( 0 );
|
||||||
$mockMessageLocalizer->method( 'localizeDigits' )->willReturnArgument( 0 );
|
$mockMessageLocalizer->method( 'localizeDigits' )->willReturnArgument( 0 );
|
||||||
|
|
||||||
/** @var ReferencesFormatter $formatter */
|
/** @var ReferenceListFormatter $formatter */
|
||||||
$formatter = TestingAccessWrapper::newFromObject( new ReferencesFormatter(
|
$formatter = TestingAccessWrapper::newFromObject( new ReferenceListFormatter(
|
||||||
$this->createMock( ErrorReporter::class ),
|
$this->createMock( ErrorReporter::class ),
|
||||||
$this->createMock( AnchorFormatter::class ),
|
$this->createMock( AnchorFormatter::class ),
|
||||||
$mockMessageLocalizer
|
$mockMessageLocalizer
|
||||||
|
@ -430,8 +430,8 @@ class ReferencesFormatterTest extends \MediaWikiUnitTestCase {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
/** @var ReferencesFormatter $formatter */
|
/** @var ReferenceListFormatter $formatter */
|
||||||
$formatter = TestingAccessWrapper::newFromObject( new ReferencesFormatter(
|
$formatter = TestingAccessWrapper::newFromObject( new ReferenceListFormatter(
|
||||||
$this->createMock( ErrorReporter::class ),
|
$this->createMock( ErrorReporter::class ),
|
||||||
$this->createMock( AnchorFormatter::class ),
|
$this->createMock( AnchorFormatter::class ),
|
||||||
$mockMessageLocalizer
|
$mockMessageLocalizer
|
Loading…
Reference in a new issue