From 7c75d44b8a51c7aa0db0427eb72e1373b72a4585 Mon Sep 17 00:00:00 2001 From: thiemowmde Date: Wed, 7 Feb 2024 18:20:02 +0100 Subject: [PATCH] Rename ReferencesFormatter to ReferenceListFormatter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/Cite.php | 6 ++-- ...rmatter.php => ReferenceListFormatter.php} | 2 +- tests/phpunit/CiteIntegrationTest.php | 8 ++--- tests/phpunit/integration/CiteTest.php | 6 ++-- ...est.php => ReferenceListFormatterTest.php} | 32 +++++++++---------- 5 files changed, 27 insertions(+), 27 deletions(-) rename src/{ReferencesFormatter.php => ReferenceListFormatter.php} (99%) rename tests/phpunit/unit/{ReferencesFormatterTest.php => ReferenceListFormatterTest.php} (96%) diff --git a/src/Cite.php b/src/Cite.php index 20d8f79fc..b7ab01759 100644 --- a/src/Cite.php +++ b/src/Cite.php @@ -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, diff --git a/src/ReferencesFormatter.php b/src/ReferenceListFormatter.php similarity index 99% rename from src/ReferencesFormatter.php rename to src/ReferenceListFormatter.php index 329a93c36..e74ee4b66 100644 --- a/src/ReferencesFormatter.php +++ b/src/ReferenceListFormatter.php @@ -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 diff --git a/tests/phpunit/CiteIntegrationTest.php b/tests/phpunit/CiteIntegrationTest.php index a1cb9e2c9..0fb01b636 100644 --- a/tests/phpunit/CiteIntegrationTest.php +++ b/tests/phpunit/CiteIntegrationTest.php @@ -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( '' ); + $formatter = $this->createMock( ReferenceListFormatter::class ); + $formatter->method( 'formatReferences' )->willReturn( '' ); $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 ); diff --git a/tests/phpunit/integration/CiteTest.php b/tests/phpunit/integration/CiteTest.php index 4f5568542..cbd436d30 100644 --- a/tests/phpunit/integration/CiteTest.php +++ b/tests/phpunit/integration/CiteTest.php @@ -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; diff --git a/tests/phpunit/unit/ReferencesFormatterTest.php b/tests/phpunit/unit/ReferenceListFormatterTest.php similarity index 96% rename from tests/phpunit/unit/ReferencesFormatterTest.php rename to tests/phpunit/unit/ReferenceListFormatterTest.php index 81f784106..c9e8790ec 100644 --- a/tests/phpunit/unit/ReferencesFormatterTest.php +++ b/tests/phpunit/unit/ReferenceListFormatterTest.php @@ -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