2021-08-12 00:59:21 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace MediaWiki\Extension\Math\Tests;
|
|
|
|
|
|
|
|
use MediaWikiIntegrationTestCase;
|
|
|
|
use RequestContext;
|
|
|
|
use Title;
|
2023-07-17 21:36:23 +00:00
|
|
|
use User;
|
2021-08-12 00:59:21 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @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()
|
2023-07-17 21:36:23 +00:00
|
|
|
->getFormDescriptor( $this->createMock( User::class ), $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']
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|