From b52d63ee9dad9681c467037dcb8329e43bb33768 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerg=C5=91=20Tisza?= Date: Wed, 17 Jan 2024 04:46:58 +0000 Subject: [PATCH] Revert "Drop various class aliases" This reverts commit 3798d424e2b54d3fa1d1da1bca3e12549c76db5a. Bug: T355198 Change-Id: I99ecee703cdfa06198eeede96e6c3bdda2d457e0 --- FancyCaptcha/extension.json | 4 ++++ FancyCaptcha/includes/FancyCaptcha.php | 2 ++ MathCaptcha/extension.json | 4 ++++ MathCaptcha/includes/MathCaptcha.php | 2 ++ QuestyCaptcha/extension.json | 4 ++++ QuestyCaptcha/includes/QuestyCaptcha.php | 2 ++ extension.json | 12 ++++++------ includes/Hooks.php | 2 ++ includes/Store/CaptchaCacheStore.php | 2 ++ tests/phpunit/HTMLFancyCaptchaFieldTest.php | 13 +++++++++++++ tests/phpunit/HTMLReCaptchaNoCaptchaFieldTest.php | 13 +++++++++++++ tests/phpunit/QuestyCaptchaTest.php | 11 +++++++++++ .../ReCaptchaNoCaptchaAuthenticationRequestTest.php | 12 ++++++++++++ 13 files changed, 77 insertions(+), 6 deletions(-) diff --git a/FancyCaptcha/extension.json b/FancyCaptcha/extension.json index d1464b419..a0ee8519a 100644 --- a/FancyCaptcha/extension.json +++ b/FancyCaptcha/extension.json @@ -17,6 +17,10 @@ "i18n/api" ] }, + "AutoloadClasses": { + "FancyCaptcha": "includes/FancyCaptcha.php", + "MediaWiki\\Extension\\ConfirmEdit\\FancyCaptcha\\FancyCaptcha": "includes/FancyCaptcha.php" + }, "AutoloadNamespaces": { "MediaWiki\\Extension\\ConfirmEdit\\FancyCaptcha\\": "includes/" }, diff --git a/FancyCaptcha/includes/FancyCaptcha.php b/FancyCaptcha/includes/FancyCaptcha.php index d3317fb38..0102fe85d 100644 --- a/FancyCaptcha/includes/FancyCaptcha.php +++ b/FancyCaptcha/includes/FancyCaptcha.php @@ -514,3 +514,5 @@ class FancyCaptcha extends SimpleCaptcha { ] + $formDescriptor['captchaWord']; } } + +class_alias( FancyCaptcha::class, 'FancyCaptcha' ); diff --git a/MathCaptcha/extension.json b/MathCaptcha/extension.json index f1da9a978..542cc3c59 100644 --- a/MathCaptcha/extension.json +++ b/MathCaptcha/extension.json @@ -17,6 +17,10 @@ "i18n" ] }, + "AutoloadClasses": { + "MathCaptcha": "includes/MathCaptcha.php", + "MediaWiki\\Extension\\ConfirmEdit\\MathCaptcha\\MathCaptcha": "includes/MathCaptcha.php" + }, "AutoloadNamespaces": { "MediaWiki\\Extension\\ConfirmEdit\\MathCaptcha\\": "includes/" }, diff --git a/MathCaptcha/includes/MathCaptcha.php b/MathCaptcha/includes/MathCaptcha.php index 1adcc28be..b840061bf 100644 --- a/MathCaptcha/includes/MathCaptcha.php +++ b/MathCaptcha/includes/MathCaptcha.php @@ -125,3 +125,5 @@ class MathCaptcha extends SimpleCaptcha { $formDescriptor['captchaWord']['label-message'] = null; } } + +class_alias( MathCaptcha::class, 'MathCaptcha' ); diff --git a/QuestyCaptcha/extension.json b/QuestyCaptcha/extension.json index c96fae28a..3303a2f0d 100644 --- a/QuestyCaptcha/extension.json +++ b/QuestyCaptcha/extension.json @@ -12,6 +12,10 @@ "i18n" ] }, + "AutoloadClasses": { + "QuestyCaptcha": "includes/QuestyCaptcha.php", + "MediaWiki\\Extension\\ConfirmEdit\\QuestyCaptcha\\QuestyCaptcha": "includes/QuestyCaptcha.php" + }, "AutoloadNamespaces": { "MediaWiki\\Extension\\ConfirmEdit\\QuestyCaptcha\\": "includes/" }, diff --git a/QuestyCaptcha/includes/QuestyCaptcha.php b/QuestyCaptcha/includes/QuestyCaptcha.php index 1c482d2b1..073a6a903 100644 --- a/QuestyCaptcha/includes/QuestyCaptcha.php +++ b/QuestyCaptcha/includes/QuestyCaptcha.php @@ -146,3 +146,5 @@ class QuestyCaptcha extends SimpleCaptcha { $formDescriptor['captchaWord']['label-message'] = null; } } + +class_alias( QuestyCaptcha::class, 'QuestyCaptcha' ); diff --git a/extension.json b/extension.json index 24a0cb942..abb2554d4 100644 --- a/extension.json +++ b/extension.json @@ -55,16 +55,16 @@ "ExtensionMessagesFiles": { "ConfirmEditAlias": "ConfirmEdit.alias.php" }, + "AutoloadClasses": { + "CaptchaCacheStore": "includes/Store/CaptchaCacheStore.php", + "ConfirmEditHooks": "includes/Hooks.php", + "MediaWiki\\Extension\\ConfirmEdit\\Hooks": "includes/Hooks.php", + "MediaWiki\\Extension\\ConfirmEdit\\Store\\CaptchaCacheStore": "includes/Store/CaptchaCacheStore.php" + }, "AutoloadNamespaces": { "MediaWiki\\Extension\\ConfirmEdit\\": "includes/", "MediaWiki\\Extension\\ConfirmEdit\\SimpleCaptcha\\": "SimpleCaptcha/" }, - "TestAutoloadClasses": { - "MediaWiki\\Extension\\ConfirmEdit\\FancyCaptcha\\HTMLFancyCaptchaField": "FancyCaptcha/includes/HTMLFancyCaptchaField.php", - "MediaWiki\\Extension\\ConfirmEdit\\QuestyCaptcha\\QuestyCaptcha": "QuestyCaptcha/includes/QuestyCaptcha.php", - "MediaWiki\\Extension\\ConfirmEdit\\ReCaptchaNoCaptcha\\HTMLReCaptchaNoCaptchaField": "ReCaptchaNoCaptcha/includes/HTMLReCaptchaNoCaptchaField.php", - "MediaWiki\\Extension\\ConfirmEdit\\ReCaptchaNoCaptcha\\ReCaptchaNoCaptchaAuthenticationRequest": "ReCaptchaNoCaptcha/includes/ReCaptchaNoCaptchaAuthenticationRequest.php" - }, "ResourceModules": { "ext.confirmEdit.editPreview.ipwhitelist.styles": { "styles": "ext.confirmEdit.editPreview.ipwhitelist.styles.css" diff --git a/includes/Hooks.php b/includes/Hooks.php index b536e21ac..115246b8a 100644 --- a/includes/Hooks.php +++ b/includes/Hooks.php @@ -337,3 +337,5 @@ class Hooks implements } } + +class_alias( Hooks::class, 'ConfirmEditHooks' ); diff --git a/includes/Store/CaptchaCacheStore.php b/includes/Store/CaptchaCacheStore.php index 6162e47bc..7bf5229d3 100644 --- a/includes/Store/CaptchaCacheStore.php +++ b/includes/Store/CaptchaCacheStore.php @@ -54,3 +54,5 @@ class CaptchaCacheStore extends CaptchaStore { return false; } } + +class_alias( CaptchaCacheStore::class, 'CaptchaCacheStore' ); diff --git a/tests/phpunit/HTMLFancyCaptchaFieldTest.php b/tests/phpunit/HTMLFancyCaptchaFieldTest.php index 14c7a3634..cca917c78 100644 --- a/tests/phpunit/HTMLFancyCaptchaFieldTest.php +++ b/tests/phpunit/HTMLFancyCaptchaFieldTest.php @@ -10,6 +10,19 @@ use MediaWiki\Title\Title; * @group Database */ class HTMLFancyCaptchaFieldTest extends MediaWikiIntegrationTestCase { + + public function setUp(): void { + parent::setUp(); + + $this->mergeMwGlobalArrayValue( + 'wgAutoloadClasses', + [ + 'MediaWiki\\Extension\\ConfirmEdit\\FancyCaptcha\\HTMLFancyCaptchaField' + => __DIR__ . '/../../FancyCaptcha/includes/HTMLFancyCaptchaField.php' + ] + ); + } + public function testGetHTML() { $html = $this->getForm( [ 'imageUrl' => 'https://example.com/' ] )->getHTML( false ); $this->assertMatchesRegularExpression( '/"fancycaptcha-image"/', $html ); diff --git a/tests/phpunit/HTMLReCaptchaNoCaptchaFieldTest.php b/tests/phpunit/HTMLReCaptchaNoCaptchaFieldTest.php index 316c1b7dd..bc014b165 100644 --- a/tests/phpunit/HTMLReCaptchaNoCaptchaFieldTest.php +++ b/tests/phpunit/HTMLReCaptchaNoCaptchaFieldTest.php @@ -8,6 +8,19 @@ use MediaWiki\Title\Title; * @covers \MediaWiki\Extension\ConfirmEdit\ReCaptchaNoCaptcha\HTMLReCaptchaNoCaptchaField */ class HTMLReCaptchaNoCaptchaFieldTest extends MediaWikiIntegrationTestCase { + + public function setUp(): void { + parent::setUp(); + + $this->mergeMwGlobalArrayValue( + 'wgAutoloadClasses', + [ + 'MediaWiki\\Extension\\ConfirmEdit\\ReCaptchaNoCaptcha\\HTMLReCaptchaNoCaptchaField' + => __DIR__ . '/../../ReCaptchaNoCaptcha/includes/HTMLReCaptchaNoCaptchaField.php' + ] + ); + } + public function testSubmit() { $request = new FauxRequest( [ 'foo' => 'abc', diff --git a/tests/phpunit/QuestyCaptchaTest.php b/tests/phpunit/QuestyCaptchaTest.php index 7a78511e4..335771543 100644 --- a/tests/phpunit/QuestyCaptchaTest.php +++ b/tests/phpunit/QuestyCaptchaTest.php @@ -6,6 +6,17 @@ use MediaWiki\Extension\ConfirmEdit\QuestyCaptcha\QuestyCaptcha; * @covers \MediaWiki\Extension\ConfirmEdit\QuestyCaptcha\QuestyCaptcha */ class QuestyCaptchaTest extends MediaWikiIntegrationTestCase { + + public function setUp(): void { + parent::setUp(); + + $this->mergeMwGlobalArrayValue( + 'wgAutoloadClasses', + [ 'MediaWiki\\Extension\\ConfirmEdit\\QuestyCaptcha\\QuestyCaptcha' + => __DIR__ . '/../../QuestyCaptcha/includes/QuestyCaptcha.php' ] + ); + } + /** * @covers \MediaWiki\Extension\ConfirmEdit\QuestyCaptcha\QuestyCaptcha::getCaptcha * @dataProvider provideGetCaptcha diff --git a/tests/phpunit/ReCaptchaNoCaptchaAuthenticationRequestTest.php b/tests/phpunit/ReCaptchaNoCaptchaAuthenticationRequestTest.php index 37fbd3822..671e12335 100644 --- a/tests/phpunit/ReCaptchaNoCaptchaAuthenticationRequestTest.php +++ b/tests/phpunit/ReCaptchaNoCaptchaAuthenticationRequestTest.php @@ -8,6 +8,18 @@ use MediaWiki\Extension\ConfirmEdit\ReCaptchaNoCaptcha\ReCaptchaNoCaptchaAuthent */ class ReCaptchaNoCaptchaAuthenticationRequestTest extends AuthenticationRequestTestCase { + public function setUp(): void { + parent::setUp(); + + $this->mergeMwGlobalArrayValue( + 'wgAutoloadClasses', + [ + 'MediaWiki\\Extension\\ConfirmEdit\\ReCaptchaNoCaptcha\\ReCaptchaNoCaptchaAuthenticationRequest' + => __DIR__ . '/../../ReCaptchaNoCaptcha/includes/ReCaptchaNoCaptchaAuthenticationRequest.php' + ] + ); + } + protected function getInstance( array $args = [] ) { return new ReCaptchaNoCaptchaAuthenticationRequest(); }