From 354393b670d9499b1dfdaaec50795fe6da37e465 Mon Sep 17 00:00:00 2001 From: "Moritz Schubotz (physikerwelt)" Date: Mon, 8 Apr 2024 14:45:40 +0200 Subject: [PATCH] Conditionally skip tests that depend on Wikibase While investigating the dependency between Math and Wikibase, it turned out there was a hard dependency in the test code. This change makes the availability of the Wikibase Extension optional and conditionally skips tests. Bug: T362027 Change-Id: I9401d7d4a3277b6923dcd81f411ac5a08f1242d2 (cherry picked from commit 0f11a20d8f35ae2e10ab72e39158d33e4fbf30a0) --- tests/phpunit/unit/MathWikibaseConnectorTestFactory.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/phpunit/unit/MathWikibaseConnectorTestFactory.php b/tests/phpunit/unit/MathWikibaseConnectorTestFactory.php index 6bc6fae1a..90901d1df 100644 --- a/tests/phpunit/unit/MathWikibaseConnectorTestFactory.php +++ b/tests/phpunit/unit/MathWikibaseConnectorTestFactory.php @@ -3,6 +3,7 @@ namespace MediaWiki\Extension\Math\Tests; use DataValues\StringValue; +use ExtensionRegistry; use Language; use MediaWiki\Config\ServiceOptions; use MediaWiki\Extension\Math\MathFormatter; @@ -50,6 +51,13 @@ class MathWikibaseConnectorTestFactory extends MediaWikiUnitTestCase { ] ]; + public static function setUpBeforeClass(): void { + if ( !ExtensionRegistry::getInstance()->isLoaded( 'WikibaseClient' ) ) { + self::markTestSkipped( 'WikibaseClient is not installed. Skipping tests.' ); + } + parent::setUpBeforeClass(); + } + public function getWikibaseConnectorWithExistingItems( EntityRevision $entityRevision, bool $storageExceptionOnQ3 = false,