mediawiki-extensions-Math/tests/phpunit/unit/MathTest.php
Moritz Schubotz (physikerwelt) 480d241f97
Make dependency to Wikibase client config optional
The MathEntitySelector gets its config from wbRepo which caused a hard
dependency on the Wikibase client.
If the Wikibase client config is not available a default value (wikidata)
is used to determine the URL of the foreign repo.
As the dropdown will never do write operations, we restrict the repo
access to anonymous read only.

Bug: T313143
Change-Id: Iba33dfd32a78f4ad7c2e99a1f56218458ab884b4
2022-07-25 09:51:47 +02:00

39 lines
1.1 KiB
PHP

<?php
namespace MediaWiki\Extension\Math\Tests;
use ExtensionRegistry;
use HashConfig;
use MediaWiki\Config\ServiceOptions;
use MediaWiki\Extension\Math\Math;
use MediaWiki\Extension\Math\MathConfig;
use MediaWiki\MediaWikiServices;
use MediaWikiUnitTestCase;
/**
* @covers \MediaWiki\Extension\Math\Math
*/
class MathTest extends MediaWikiUnitTestCase {
private const DUMMY_URL = 'https://example.com/api.php';
public function testGetMathConfigService() {
$config = new HashConfig( [
'MathDisableTexFilter' => MathConfig::NEW,
'MathValidModes' => [ MathConfig::MODE_SOURCE ],
'MathEntitySelectorFallbackUrl' => self::DUMMY_URL,
] );
$services = new MediaWikiServices( $config );
$services->defineService( 'Math.Config',
static function ( MediaWikiServices $services ){
return new MathConfig(
new ServiceOptions(
MathConfig::CONSTRUCTOR_OPTIONS,
$services->get( 'BootstrapConfig' ) ),
ExtensionRegistry::getInstance()
);
}
);
$mathConfig = Math::getMathConfig( $services );
$this->assertStringContainsString( 'new', $mathConfig->texCheckDisabled() );
}
}