From 1af67c04161cadc37ac6893d984e6701d102aca5 Mon Sep 17 00:00:00 2001 From: Adam Wight Date: Wed, 23 Oct 2024 22:23:26 +0200 Subject: [PATCH] Prematurely move References test to integration This isn't needed until patch I576dfff415, but is split into a predecessor to keep the test and logic changes obviously separate. Bug: T377454 Change-Id: Iff4a96be77af53a71a1ebe179f31bcc214182bfe --- tests/phpunit/integration/CiteParsoidTest.php | 24 ++++++++++++ tests/phpunit/unit/Parsoid/ReferencesTest.php | 37 ------------------- 2 files changed, 24 insertions(+), 37 deletions(-) delete mode 100644 tests/phpunit/unit/Parsoid/ReferencesTest.php diff --git a/tests/phpunit/integration/CiteParsoidTest.php b/tests/phpunit/integration/CiteParsoidTest.php index 16fda5d94..863602280 100644 --- a/tests/phpunit/integration/CiteParsoidTest.php +++ b/tests/phpunit/integration/CiteParsoidTest.php @@ -4,16 +4,21 @@ declare( strict_types = 1 ); namespace Cite\Tests\Integration; +use Cite\Parsoid\References; +use MediaWiki\Config\Config; use MediaWiki\Registration\ExtensionRegistry; use Wikimedia\ObjectFactory\ObjectFactory; use Wikimedia\Parsoid\Core\SelserData; use Wikimedia\Parsoid\DOM\Element; +use Wikimedia\Parsoid\Ext\ParsoidExtensionAPI; use Wikimedia\Parsoid\Mocks\MockDataAccess; use Wikimedia\Parsoid\Mocks\MockPageConfig; use Wikimedia\Parsoid\Mocks\MockPageContent; use Wikimedia\Parsoid\Mocks\MockSiteConfig; +use Wikimedia\Parsoid\NodeData\DataMw; use Wikimedia\Parsoid\Parsoid; use Wikimedia\Parsoid\Utils\DOMCompat; +use Wikimedia\Parsoid\Utils\DOMDataUtils; use Wikimedia\Parsoid\Utils\DOMUtils; /** @@ -237,4 +242,23 @@ EOT; ); $this->wtToLint( "{{#tag:ref||name=x}}" ); } + + /** + * @covers \Cite\Parsoid\References::processAttributeEmbeddedHTML + */ + public function testProcessAttributeEmbeddedHTML() { + $doc = DOMUtils::parseHTML( '' ); + DOMDataUtils::prepareDoc( $doc ); + $elt = $doc->createElement( 'a' ); + DOMDataUtils::setDataMw( $elt, new DataMw( [ 'body' => (object)[ 'html' => 'old' ] ] ) ); + + $refs = new References( $this->createNoOpMock( Config::class ) ); + $refs->processAttributeEmbeddedHTML( + $this->createNoOpMock( ParsoidExtensionAPI::class ), + $elt, + fn () => 'new' + ); + + $this->assertSame( 'new', DOMDataUtils::getDataMw( $elt )->body->html ); + } } diff --git a/tests/phpunit/unit/Parsoid/ReferencesTest.php b/tests/phpunit/unit/Parsoid/ReferencesTest.php deleted file mode 100644 index d8871bdc5..000000000 --- a/tests/phpunit/unit/Parsoid/ReferencesTest.php +++ /dev/null @@ -1,37 +0,0 @@ -createElement( 'a' ); - DOMDataUtils::setDataMw( $elt, new DataMw( [ 'body' => (object)[ 'html' => 'old' ] ] ) ); - - $refs = new References( $this->createNoOpMock( Config::class ) ); - $refs->processAttributeEmbeddedHTML( - $this->createNoOpMock( ParsoidExtensionAPI::class ), - $elt, - fn () => 'new' - ); - - $this->assertSame( 'new', DOMDataUtils::getDataMw( $elt )->body->html ); - } - - // TODO: Incomplete, there are many more static and non-static methods to test - -}