2022-07-21 15:47:52 +00:00
|
|
|
<?php
|
|
|
|
namespace MediaWiki\Extension\Math\Tests;
|
|
|
|
|
2024-01-06 15:30:26 +00:00
|
|
|
use MediaWiki\Config\HashConfig;
|
2022-07-21 15:47:52 +00:00
|
|
|
use MediaWiki\Config\ServiceOptions;
|
|
|
|
use MediaWiki\Extension\Math\Math;
|
|
|
|
use MediaWiki\Extension\Math\MathConfig;
|
|
|
|
use MediaWiki\MediaWikiServices;
|
2024-10-20 07:27:34 +00:00
|
|
|
use MediaWiki\Registration\ExtensionRegistry;
|
2022-07-21 15:47:52 +00:00
|
|
|
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',
|
2023-07-15 17:11:18 +00:00
|
|
|
function ( MediaWikiServices $services ) use ( $config ) {
|
|
|
|
return new MathConfig(
|
|
|
|
new ServiceOptions(
|
|
|
|
MathConfig::CONSTRUCTOR_OPTIONS,
|
|
|
|
$config
|
|
|
|
),
|
|
|
|
$this->createMock( ExtensionRegistry::class )
|
2022-07-21 15:47:52 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
$mathConfig = Math::getMathConfig( $services );
|
|
|
|
$this->assertStringContainsString( 'new', $mathConfig->texCheckDisabled() );
|
|
|
|
}
|
|
|
|
}
|