From b4592fb5c6a382f05f76bc246adde255c209023b Mon Sep 17 00:00:00 2001 From: Huji Lee Date: Sun, 17 Sep 2017 21:10:27 -0400 Subject: [PATCH] user: Unregister hooks that interfere with unit testing testExecute_email() should unregister the hooks mailPasswordInternal and SpecialPasswordResetOnSubmit for proper unit testing. Bug: T176102 Change-Id: Id7403f57cc9d751ada85b611193c1d8f3503e713 --- tests/phpunit/includes/user/PasswordResetTest.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/phpunit/includes/user/PasswordResetTest.php b/tests/phpunit/includes/user/PasswordResetTest.php index 53f02df69c..feae26a2dc 100644 --- a/tests/phpunit/includes/user/PasswordResetTest.php +++ b/tests/phpunit/includes/user/PasswordResetTest.php @@ -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' ) -- 2.20.1