test: disable hook when testing default preferences
authorAntoine Musso <hashar@free.fr>
Thu, 19 Jul 2018 15:35:59 +0000 (17:35 +0200)
committerAntoine Musso <hashar@free.fr>
Mon, 10 Sep 2018 08:25:22 +0000 (10:25 +0200)
The GetPreferences hook lets extensions register additional user
preferences.  They show up on the form and that breaks the hardcoded
assertion that exactly 5 preferences are available.

Disable the hook in case the test is run with extensions loaded in (ex:
BetaFeatures).

Change-Id: I78b11e989110407cd721e8a3fbbe81d28ca4be5b

tests/phpunit/includes/preferences/DefaultPreferencesFactoryTest.php

index 43c678e..2eec5ce 100644 (file)
@@ -63,6 +63,8 @@ class DefaultPreferencesFactoryTest extends MediaWikiTestCase {
         * @covers MediaWiki\Preferences\DefaultPreferencesFactory::getForm()
         */
        public function testGetForm() {
+               $this->setTemporaryHook( 'GetPreferences', null );
+
                $testUser = $this->getTestUser();
                $form = $this->getPreferencesFactory()->getForm( $testUser->getUser(), $this->context );
                $this->assertInstanceOf( PreferencesFormLegacy::class, $form );