2021-08-12 00:59:21 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace MediaWiki\Extension\Math\Tests;
|
|
|
|
|
2024-06-09 16:48:28 +00:00
|
|
|
use MediaWiki\Context\RequestContext;
|
2023-08-19 04:17:34 +00:00
|
|
|
use MediaWiki\Title\Title;
|
2021-08-12 00:59:21 +00:00
|
|
|
use MediaWikiIntegrationTestCase;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @covers \MediaWiki\Extension\Math\HookHandlers\PreferencesHooksHandler
|
2023-08-04 14:53:35 +00:00
|
|
|
* @group Database
|
2021-08-12 00:59:21 +00:00
|
|
|
*/
|
|
|
|
class PreferencesIntegrationTest extends MediaWikiIntegrationTestCase {
|
|
|
|
|
|
|
|
public function testInvalidDefaultOptionFixed() {
|
|
|
|
$this->mergeMwGlobalArrayValue( 'wgDefaultUserOptions', [ 'math' => 'garbage' ] );
|
|
|
|
$this->assertContains(
|
|
|
|
$this->getServiceContainer()->getUserOptionsLookup()->getDefaultOption( 'math' ),
|
|
|
|
$this->getServiceContainer()->get( 'Math.Config' )->getValidRenderingModes()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testMathOptionRegistered() {
|
|
|
|
$context = new RequestContext();
|
|
|
|
$context->setTitle( Title::makeTitle( NS_MAIN, 'Dummy' ) );
|
|
|
|
$allPreferences = $this->getServiceContainer()
|
|
|
|
->getPreferencesFactory()
|
2024-02-19 10:11:26 +00:00
|
|
|
->getFormDescriptor( $this->getTestUser()->getUser(), $context );
|
2021-08-12 00:59:21 +00:00
|
|
|
$this->assertArrayHasKey( 'math', $allPreferences );
|
|
|
|
$mathPrefs = $allPreferences['math'];
|
|
|
|
$this->assertSame( 'radio', $mathPrefs['type'] );
|
|
|
|
$this->assertSame(
|
|
|
|
$this->getServiceContainer()->getUserOptionsLookup()->getDefaultOption( 'math' ),
|
|
|
|
$mathPrefs['default']
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|