Stop injecting ServiceOptions in VisualEditorParsoidClientFactory

Change-Id: I7a3c5ef6435a38ef136e830b343dc19166659ef0
This commit is contained in:
Arlo Breault 2023-08-30 10:45:38 -04:00 committed by Bartosz Dziewoński
parent de2935928c
commit 2c1989c338
3 changed files with 3 additions and 27 deletions

View file

@ -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() );
},
];

View file

@ -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;
}

View file

@ -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 );