user: Unregister hooks that interfere with unit testing
authorHuji Lee <huji.huji@gmail.com>
Mon, 18 Sep 2017 01:10:27 +0000 (21:10 -0400)
committerKrinkle <krinklemail@gmail.com>
Wed, 27 Sep 2017 22:50:05 +0000 (22:50 +0000)
testExecute_email() should unregister the hooks
mailPasswordInternal and SpecialPasswordResetOnSubmit
for proper unit testing.

Bug: T176102
Change-Id: Id7403f57cc9d751ada85b611193c1d8f3503e713

tests/phpunit/includes/user/PasswordResetTest.php

index 53f02df..feae26a 100644 (file)
@@ -5,7 +5,7 @@ use MediaWiki\Auth\AuthManager;
 /**
  * @group Database
  */
-class PasswordResetTest extends PHPUnit_Framework_TestCase {
+class PasswordResetTest extends MediaWikiTestCase {
        /**
         * @dataProvider provideIsAllowed
         */
@@ -150,6 +150,12 @@ class PasswordResetTest extends PHPUnit_Framework_TestCase {
                        'EnableEmail' => true,
                ] );
 
+               // Unregister the hooks for proper unit testing
+               $this->mergeMwGlobalArrayValue( 'wgHooks', [
+                       'mailPasswordInternal' => [],
+                       'SpecialPasswordResetOnSubmit' => [],
+               ] );
+
                $authManager = $this->getMockBuilder( AuthManager::class )->disableOriginalConstructor()
                        ->getMock();
                $authManager->expects( $this->any() )->method( 'allowsAuthenticationDataChange' )