Debian Codegraph @

extensions/Math/tests/phpunit/integration/PreferencesIntegrationTest.php

raw symbols SCIP
1 <?php
2
3 namespace MediaWiki\Extension\Math\Tests;
4
5 use MediaWiki\Context\RequestContext;
6 use MediaWiki\Title\Title;
7 use MediaWikiIntegrationTestCase;
8
9 /**
10 * @covers \MediaWiki\Extension\Math\HookHandlers\PreferencesHooksHandler
11 * @group Database
12 */
13 class PreferencesIntegrationTest extends MediaWikiIntegrationTestCase {
14
15 public function testInvalidDefaultOptionFixed() {
16 $this->mergeMwGlobalArrayValue( 'wgDefaultUserOptions', [ 'math' => 'garbage' ] );
17 $this->assertContains(
18 $this->getServiceContainer()->getUserOptionsLookup()->getDefaultOption( 'math' ),
19 $this->getServiceContainer()->get( 'Math.Config' )->getValidRenderingModes()
20 );
21 }
22
23 public function testMathOptionRegistered() {
24 $context = new RequestContext();
25 $context->setTitle( Title::makeTitle( NS_MAIN, 'Dummy' ) );
26 $allPreferences = $this->getServiceContainer()
27 ->getPreferencesFactory()
28 ->getFormDescriptor( $this->getTestUser()->getUser(), $context );
29 $this->assertArrayHasKey( 'math', $allPreferences );
30 $mathPrefs = $allPreferences['math'];
31 $this->assertSame( 'radio', $mathPrefs['type'] );
32 $this->assertSame(
33 $this->getServiceContainer()->getUserOptionsLookup()->getDefaultOption( 'math' ),
34 $mathPrefs['default']
35 );
36 }
37 }