From bb72bc65f5fa9b9610396e7a6b5eb8b3528fced6 Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Fri, 20 May 2022 12:11:31 +1000 Subject: [PATCH] Use new ResourceLoader namespace Extensions using Phan need to be updated simultaneously with core due to T308443. Bug: T308718 Depends-On: Id08a220e1d6085e2b33f3f6c9d0e3935a4204659 Change-Id: Iebc5768a3125ce2b173e9b55fc3ea20616553824 --- extension.json | 2 +- src/ResourceLoader/CiteCSSFileModule.php | 5 +++-- src/ResourceLoader/CiteVisualEditorModule.php | 12 ++++++------ tests/phpunit/CiteCSSFileModuleTest.php | 4 ++-- tests/phpunit/unit/CiteDataModuleTest.php | 6 +++--- 5 files changed, 15 insertions(+), 14 deletions(-) diff --git a/extension.json b/extension.json index 239a8bbf9..5b82b6fae 100644 --- a/extension.json +++ b/extension.json @@ -15,7 +15,7 @@ "license-name": "GPL-2.0-or-later", "type": "parserhook", "requires": { - "MediaWiki": ">= 1.38.0" + "MediaWiki": ">= 1.39.0" }, "MessagesDirs": { "Cite": [ diff --git a/src/ResourceLoader/CiteCSSFileModule.php b/src/ResourceLoader/CiteCSSFileModule.php index b4cbf596e..957767d45 100644 --- a/src/ResourceLoader/CiteCSSFileModule.php +++ b/src/ResourceLoader/CiteCSSFileModule.php @@ -3,14 +3,15 @@ namespace Cite\ResourceLoader; use MediaWiki\MediaWikiServices; +use MediaWiki\ResourceLoader\FileModule; /** - * ResourceLoaderFileModule for adding the content language Cite CSS + * ResourceLoader FileModule for adding the content language Cite CSS * * @copyright 2011-2018 VisualEditor Team's Cite sub-team and others; see AUTHORS.txt * @license MIT */ -class CiteCSSFileModule extends \ResourceLoaderFileModule { +class CiteCSSFileModule extends FileModule { /** * @inheritDoc diff --git a/src/ResourceLoader/CiteVisualEditorModule.php b/src/ResourceLoader/CiteVisualEditorModule.php index 70b070001..0c9edb92c 100644 --- a/src/ResourceLoader/CiteVisualEditorModule.php +++ b/src/ResourceLoader/CiteVisualEditorModule.php @@ -2,7 +2,7 @@ namespace Cite\ResourceLoader; -use ResourceLoaderContext; +use MediaWiki\ResourceLoader as RL; /** * File module with extra data generated by the server. @@ -12,19 +12,19 @@ use ResourceLoaderContext; * @copyright 2011-2018 VisualEditor Team's Cite sub-team and others; see AUTHORS.txt * @license MIT */ -class CiteVisualEditorModule extends \ResourceLoaderFileModule { +class CiteVisualEditorModule extends RL\FileModule { /** @inheritDoc */ - public function getScript( ResourceLoaderContext $context ) { + public function getScript( RL\Context $context ) { return $this->makePrependedScript( $context ) . parent::getScript( $context ); } /** * @internal - * @param ResourceLoaderContext $context + * @param RL\Context $context * @return string JavaScript code */ - public function makePrependedScript( ResourceLoaderContext $context ) { + public function makePrependedScript( RL\Context $context ) { $citationDefinition = json_decode( $context->msg( 'cite-tool-definition.json' ) ->inContentLanguage() @@ -61,7 +61,7 @@ class CiteVisualEditorModule extends \ResourceLoaderFileModule { } /** @inheritDoc */ - public function getDefinitionSummary( ResourceLoaderContext $context ) { + public function getDefinitionSummary( RL\Context $context ) { $summary = parent::getDefinitionSummary( $context ); $summary[] = [ 'script' => $this->makePrependedScript( $context ), diff --git a/tests/phpunit/CiteCSSFileModuleTest.php b/tests/phpunit/CiteCSSFileModuleTest.php index 6495385ea..e2bd6a2bd 100644 --- a/tests/phpunit/CiteCSSFileModuleTest.php +++ b/tests/phpunit/CiteCSSFileModuleTest.php @@ -4,7 +4,7 @@ namespace Cite\Tests; use Cite\ResourceLoader\CiteCSSFileModule; use MediaWiki\MediaWikiServices; -use ResourceLoaderContext; +use MediaWiki\ResourceLoader\Context; /** * @covers \Cite\ResourceLoader\CiteCSSFileModule @@ -24,7 +24,7 @@ class CiteCSSFileModuleTest extends \MediaWikiIntegrationTestCase { public function testModule() { $module = new CiteCSSFileModule( [], __DIR__ . '/../../modules' ); - $styles = $module->getStyleFiles( $this->createMock( ResourceLoaderContext::class ) ); + $styles = $module->getStyleFiles( $this->createMock( Context::class ) ); $this->assertSame( [ 'ext.cite.style.fa.css' ], $styles['all'] ); } diff --git a/tests/phpunit/unit/CiteDataModuleTest.php b/tests/phpunit/unit/CiteDataModuleTest.php index 9bedd8baa..9c4b67954 100644 --- a/tests/phpunit/unit/CiteDataModuleTest.php +++ b/tests/phpunit/unit/CiteDataModuleTest.php @@ -3,8 +3,8 @@ namespace Cite\Tests\Unit; use Cite\ResourceLoader\CiteVisualEditorModule; +use MediaWiki\ResourceLoader\Context; use Message; -use ResourceLoaderContext; /** * @covers \Cite\ResourceLoader\CiteVisualEditorModule @@ -34,7 +34,7 @@ class CiteDataModuleTest extends \MediaWikiUnitTestCase { ); } - private function createResourceLoaderContext(): ResourceLoaderContext { + private function createResourceLoaderContext(): Context { $msg = $this->createMock( Message::class ); $msg->method( 'inContentLanguage' ) ->willReturnSelf(); @@ -43,7 +43,7 @@ class CiteDataModuleTest extends \MediaWikiUnitTestCase { $msg->method( 'text' ) ->willReturn( 't' ); - $context = $this->createStub( ResourceLoaderContext::class ); + $context = $this->createStub( Context::class ); $context->method( 'msg' ) ->withConsecutive( [ 'cite-tool-definition.json' ],