From b39d3589ba4d6a2c738cacd1280a2910ad9f2d57 Mon Sep 17 00:00:00 2001 From: Lucas Werkmeister Date: Wed, 6 Sep 2023 11:33:42 +0200 Subject: [PATCH] Remove Database group again where possible MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Override the target language in the parser options, so that it isn’t looked up from the database; this lets UriLibraryTest avoid database access. And since the Database group is no longer strictly required, remove the statement to that effect from the phpdoc again. Bug: T345372 Change-Id: I79f35257b123eb939d9ab67b16aa56d34586bb67 --- tests/phpunit/Engines/LuaCommon/LuaEngineTestBase.php | 2 -- tests/phpunit/Engines/LuaCommon/LuaEngineTestHelper.php | 4 +++- tests/phpunit/Engines/LuaCommon/UriLibraryTest.php | 2 -- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/tests/phpunit/Engines/LuaCommon/LuaEngineTestBase.php b/tests/phpunit/Engines/LuaCommon/LuaEngineTestBase.php index 13fbcd47..27355058 100644 --- a/tests/phpunit/Engines/LuaCommon/LuaEngineTestBase.php +++ b/tests/phpunit/Engines/LuaCommon/LuaEngineTestBase.php @@ -16,8 +16,6 @@ use PHPUnit\Framework\TestSuite; * - $moduleName: Name of the module being tested * - getTestModules(): Add a mapping from $moduleName to the file containing * the code. - * - * Also, your test must be in the Database group. */ abstract class LuaEngineTestBase extends MediaWikiLangTestCase { use LuaEngineTestHelper; diff --git a/tests/phpunit/Engines/LuaCommon/LuaEngineTestHelper.php b/tests/phpunit/Engines/LuaCommon/LuaEngineTestHelper.php index b2fe40ac..6e74b26c 100644 --- a/tests/phpunit/Engines/LuaCommon/LuaEngineTestHelper.php +++ b/tests/phpunit/Engines/LuaCommon/LuaEngineTestHelper.php @@ -143,9 +143,11 @@ trait LuaEngineTestHelper { */ protected function getEngine() { if ( !$this->engine ) { - $parser = MediaWikiServices::getInstance()->getParserFactory()->create(); + $services = MediaWikiServices::getInstance(); + $parser = $services->getParserFactory()->create(); $options = ParserOptions::newFromAnon(); $options->setTemplateCallback( [ $this, 'templateCallback' ] ); + $options->setTargetLanguage( $services->getLanguageFactory()->getLanguage( 'en' ) ); $parser->startExternalParse( $this->getTestTitle(), $options, Parser::OT_HTML, true ); // HACK diff --git a/tests/phpunit/Engines/LuaCommon/UriLibraryTest.php b/tests/phpunit/Engines/LuaCommon/UriLibraryTest.php index e513c054..48a6da84 100644 --- a/tests/phpunit/Engines/LuaCommon/UriLibraryTest.php +++ b/tests/phpunit/Engines/LuaCommon/UriLibraryTest.php @@ -4,8 +4,6 @@ namespace MediaWiki\Extension\Scribunto\Tests\Engines\LuaCommon; /** * @covers \MediaWiki\Extension\Scribunto\Engines\LuaCommon\UriLibrary - * - * @group Database */ class UriLibraryTest extends LuaEngineTestBase { /** @inheritDoc */