From 53d8aaa04aec3f4cd345d6df8a30ff093ff6286d Mon Sep 17 00:00:00 2001 From: Fomafix Date: Sat, 28 Sep 2024 21:13:00 +0000 Subject: [PATCH] Use $this->getServiceContainer() in tests Change-Id: I80a915e773a087a1fa663e0eebe9f0bab9be6d03 --- tests/phpunit/integration/CiteParsoidTest.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/tests/phpunit/integration/CiteParsoidTest.php b/tests/phpunit/integration/CiteParsoidTest.php index 67f443128..cfff6d025 100644 --- a/tests/phpunit/integration/CiteParsoidTest.php +++ b/tests/phpunit/integration/CiteParsoidTest.php @@ -5,7 +5,6 @@ declare( strict_types = 1 ); namespace Cite\Tests\Integration; use ExtensionRegistry; -use MediaWiki\MediaWikiServices; use Wikimedia\ObjectFactory\ObjectFactory; use Wikimedia\Parsoid\Core\SelserData; use Wikimedia\Parsoid\DOM\Element; @@ -31,9 +30,20 @@ class CiteParsoidTest extends \MediaWikiIntegrationTestCase { } private function getSiteConfig( $options ) { - $siteConfig = new class( $options ) extends MockSiteConfig { + $objectFactory = $this->getServiceContainer()->getObjectFactory(); + $siteConfig = new class( $options, $objectFactory ) extends MockSiteConfig { + private ObjectFactory $objectFactory; + + public function __construct( + array $opts, + ObjectFactory $objectFactory + ) { + parent::__construct( $opts ); + $this->objectFactory = $objectFactory; + } + public function getObjectFactory(): ObjectFactory { - return MediaWikiServices::getInstance()->getObjectFactory(); + return $this->objectFactory; } }; // Ensure that the Cite module is registered!