mediawiki-extensions-Math/tests/phpunit/integration/PreferencesIntegrationTest.php
gerritbot fd1e7e2a67 Replace some moved Title class uses, now MediaWiki\Title\Title
Bug: T321681
Change-Id: I1c875fcf7456ea03420b316f58fcd18aa748301f
2023-08-19 04:17:34 +00:00

39 lines
1.2 KiB
PHP

<?php
namespace MediaWiki\Extension\Math\Tests;
use MediaWiki\Title\Title;
use MediaWikiIntegrationTestCase;
use RequestContext;
use User;
/**
* @covers \MediaWiki\Extension\Math\HookHandlers\PreferencesHooksHandler
* @group Database
*/
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()
->getFormDescriptor( $this->createMock( User::class ), $context );
$this->assertArrayHasKey( 'math', $allPreferences );
$mathPrefs = $allPreferences['math'];
$this->assertSame( 'radio', $mathPrefs['type'] );
$this->assertSame(
$this->getServiceContainer()->getUserOptionsLookup()->getDefaultOption( 'math' ),
$mathPrefs['default']
);
}
}