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
This commit is contained in:
Moritz Schubotz (physikerwelt) 2024-04-08 14:45:40 +02:00
parent 23a8d519a5
commit 0f11a20d8f
No known key found for this signature in database
GPG key ID: F803DB146DDF36C3

View file

@ -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;
@ -51,6 +52,15 @@ class MathWikibaseConnectorTestFactory extends MediaWikiUnitTestCase {
]
];
public static function setUpBeforeClass(): void {
ExtensionRegistry::enableForTest();
if ( !ExtensionRegistry::getInstance()->isLoaded( 'WikibaseClient' ) ) {
self::markTestSkipped( 'WikibaseClient is not installed. Skipping tests.' );
}
ExtensionRegistry::disableForTest();
parent::setUpBeforeClass();
}
public function getWikibaseConnectorWithExistingItems(
EntityRevision $entityRevision,
bool $storageExceptionOnQ3 = false,