mediawiki-extensions-Math/tests/phpunit/integration/PreferencesIntegrationTest.php
Umherirrender b97ef597e0 Use namespaced classes
Changes to the use statements done automatically via script
Addition of missing use statement done manually

Change-Id: I8fad94b215664fb77acf8cd8140232271d2c2837
2024-01-06 16:30:26 +01:00

39 lines
1.2 KiB
PHP

<?php
namespace MediaWiki\Extension\Math\Tests;
use MediaWiki\Title\Title;
use MediaWiki\User\User;
use MediaWikiIntegrationTestCase;
use RequestContext;
/**
* @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']
);
}
}