2022-07-21 15:47:52 +00:00
|
|
|
<?php
|
|
|
|
namespace MediaWiki\Extension\Math\Tests;
|
|
|
|
|
2022-07-17 09:59:09 +00:00
|
|
|
use ExtensionRegistry;
|
2022-07-21 15:47:52 +00:00
|
|
|
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 {
|
2022-07-17 09:59:09 +00:00
|
|
|
private const DUMMY_URL = 'https://example.com/api.php';
|
2022-07-21 15:47:52 +00:00
|
|
|
|
|
|
|
public function testGetMathConfigService() {
|
|
|
|
$config = new HashConfig( [
|
|
|
|
'MathDisableTexFilter' => MathConfig::NEW,
|
2022-07-17 09:59:09 +00:00
|
|
|
'MathValidModes' => [ MathConfig::MODE_SOURCE ],
|
|
|
|
'MathEntitySelectorFallbackUrl' => self::DUMMY_URL,
|
2022-07-21 15:47:52 +00:00
|
|
|
] );
|
|
|
|
$services = new MediaWikiServices( $config );
|
|
|
|
$services->defineService( 'Math.Config',
|
|
|
|
static function ( MediaWikiServices $services ){
|
|
|
|
return new MathConfig(
|
2022-07-17 09:59:09 +00:00
|
|
|
new ServiceOptions(
|
|
|
|
MathConfig::CONSTRUCTOR_OPTIONS,
|
|
|
|
$services->get( 'BootstrapConfig' ) ),
|
|
|
|
ExtensionRegistry::getInstance()
|
2022-07-21 15:47:52 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
$mathConfig = Math::getMathConfig( $services );
|
|
|
|
$this->assertStringContainsString( 'new', $mathConfig->texCheckDisabled() );
|
|
|
|
}
|
|
|
|
}
|