From 2c1989c338cfa856511d9b1a76e3919dc0a8dad1 Mon Sep 17 00:00:00 2001 From: Arlo Breault Date: Wed, 30 Aug 2023 10:45:38 -0400 Subject: [PATCH] Stop injecting ServiceOptions in VisualEditorParsoidClientFactory Change-Id: I7a3c5ef6435a38ef136e830b343dc19166659ef0 --- includes/ServiceWiring.php | 9 +-------- includes/VisualEditorParsoidClientFactory.php | 13 ------------- .../VisualEditorParsoidClientFactoryTest.php | 8 ++------ 3 files changed, 3 insertions(+), 27 deletions(-) diff --git a/includes/ServiceWiring.php b/includes/ServiceWiring.php index 5dc20cfb4a..63e7f55f44 100644 --- a/includes/ServiceWiring.php +++ b/includes/ServiceWiring.php @@ -11,7 +11,6 @@ namespace MediaWiki\Extension\VisualEditor; -use MediaWiki\Config\ServiceOptions; use MediaWiki\MediaWikiServices; return [ @@ -22,12 +21,6 @@ return [ VisualEditorParsoidClientFactory::SERVICE_NAME => static function ( MediaWikiServices $services ): VisualEditorParsoidClientFactory { - return new VisualEditorParsoidClientFactory( - new ServiceOptions( - VisualEditorParsoidClientFactory::CONSTRUCTOR_OPTIONS, - $services->getMainConfig() - ), - $services->getPageRestHelperFactory() - ); + return new VisualEditorParsoidClientFactory( $services->getPageRestHelperFactory() ); }, ]; diff --git a/includes/VisualEditorParsoidClientFactory.php b/includes/VisualEditorParsoidClientFactory.php index 46b89dc524..fe922ed046 100644 --- a/includes/VisualEditorParsoidClientFactory.php +++ b/includes/VisualEditorParsoidClientFactory.php @@ -2,7 +2,6 @@ namespace MediaWiki\Extension\VisualEditor; -use MediaWiki\Config\ServiceOptions; use MediaWiki\Permissions\Authority; use MediaWiki\Rest\Handler\Helper\PageRestHelperFactory; use RequestContext; @@ -18,23 +17,11 @@ class VisualEditorParsoidClientFactory { */ public const SERVICE_NAME = 'VisualEditor.ParsoidClientFactory'; - /** - * @internal For used by ServiceWiring.php - * - * @var array - */ - public const CONSTRUCTOR_OPTIONS = []; - - private ServiceOptions $options; private PageRestHelperFactory $pageRestHelperFactory; public function __construct( - ServiceOptions $options, PageRestHelperFactory $pageRestHelperFactory ) { - $this->options = $options; - $this->options->assertRequiredOptions( self::CONSTRUCTOR_OPTIONS ); - $this->pageRestHelperFactory = $pageRestHelperFactory; } diff --git a/tests/phpunit/integration/VisualEditorParsoidClientFactoryTest.php b/tests/phpunit/integration/VisualEditorParsoidClientFactoryTest.php index f9761741e9..4e123ea6b8 100644 --- a/tests/phpunit/integration/VisualEditorParsoidClientFactoryTest.php +++ b/tests/phpunit/integration/VisualEditorParsoidClientFactoryTest.php @@ -2,7 +2,6 @@ namespace MediaWiki\Extension\VisualEditor\Tests; -use MediaWiki\Config\ServiceOptions; use MediaWiki\Extension\VisualEditor\DirectParsoidClient; use MediaWiki\Extension\VisualEditor\VisualEditorParsoidClientFactory; use MediaWiki\Http\HttpRequestFactory; @@ -26,16 +25,13 @@ class VisualEditorParsoidClientFactoryTest extends MediaWikiIntegrationTestCase $this->assertInstanceOf( VisualEditorParsoidClientFactory::class, $veParsoidClientFactory ); } - private function newClientFactory( array $optionValues ) { - $options = new ServiceOptions( VisualEditorParsoidClientFactory::CONSTRUCTOR_OPTIONS, $optionValues ); - + private function newClientFactory() { $httpRequestFactory = $this->createNoOpMock( HttpRequestFactory::class, [ 'createMultiClient' ] ); $httpRequestFactory->method( 'createMultiClient' )->willReturn( $this->createNoOpMock( MultiHttpClient::class ) ); return new VisualEditorParsoidClientFactory( - $options, $this->createNoOpMock( PageRestHelperFactory::class ) ); } @@ -46,7 +42,7 @@ class VisualEditorParsoidClientFactoryTest extends MediaWikiIntegrationTestCase public function testGetClient() { $authority = $this->createNoOpMock( Authority::class ); - $factory = $this->newClientFactory( [] ); + $factory = $this->newClientFactory(); $client = $factory->createParsoidClient( $authority ); $this->assertInstanceOf( DirectParsoidClient::class, $client );