mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Math
synced 2024-12-24 13:23:17 +00:00
bc193d41a7
`$this->createMock( User::class )` will return a mock User object with all fields defaulting to null and this will fail when the `onGetPreferences()` hook fires in CA since that gets consumed by `getFormDescriptor()` in PreferencesFactory. This patch changes the mock user object to a test user object and this is fine because it's already an integration test. Bug: T357854 Change-Id: I3d80fc1e59ff00a1a08def41c53d82bc093b6e00
38 lines
1.2 KiB
PHP
38 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace MediaWiki\Extension\Math\Tests;
|
|
|
|
use MediaWiki\Title\Title;
|
|
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->getTestUser()->getUser(), $context );
|
|
$this->assertArrayHasKey( 'math', $allPreferences );
|
|
$mathPrefs = $allPreferences['math'];
|
|
$this->assertSame( 'radio', $mathPrefs['type'] );
|
|
$this->assertSame(
|
|
$this->getServiceContainer()->getUserOptionsLookup()->getDefaultOption( 'math' ),
|
|
$mathPrefs['default']
|
|
);
|
|
}
|
|
}
|