| 1 |
<?php |
| 2 |
namespace MediaWiki\Extension\Math\Tests; |
| 3 |
|
| 4 |
use MediaWiki\Config\HashConfig; |
| 5 |
use MediaWiki\Config\ServiceOptions; |
| 6 |
use MediaWiki\Extension\Math\Math; |
| 7 |
use MediaWiki\Extension\Math\MathConfig; |
| 8 |
use MediaWiki\MediaWikiServices; |
| 9 |
use MediaWiki\Registration\ExtensionRegistry; |
| 10 |
use MediaWikiUnitTestCase; |
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
class MathTest extends MediaWikiUnitTestCase { |
| 16 |
private const DUMMY_URL = 'https://example.com/api.php'; |
| 17 |
|
| 18 |
public function testGetMathConfigService() { |
| 19 |
$config = new HashConfig( [ |
| 20 |
'MathDisableTexFilter' => MathConfig::NEW, |
| 21 |
'MathValidModes' => [ MathConfig::MODE_SOURCE ], |
| 22 |
'MathEntitySelectorFallbackUrl' => self::DUMMY_URL, |
| 23 |
] ); |
| 24 |
$services = new MediaWikiServices( $config ); |
| 25 |
$services->defineService( 'Math.Config', |
| 26 |
function ( MediaWikiServices $services ) use ( $config ) { |
| 27 |
return new MathConfig( |
| 28 |
new ServiceOptions( |
| 29 |
MathConfig::CONSTRUCTOR_OPTIONS, |
| 30 |
$config |
| 31 |
), |
| 32 |
$this->createMock( ExtensionRegistry::class ) |
| 33 |
); |
| 34 |
} |
| 35 |
); |
| 36 |
$mathConfig = Math::getMathConfig( $services ); |
| 37 |
$this->assertStringContainsString( 'new', $mathConfig->texCheckDisabled() ); |
| 38 |
} |
| 39 |
} |