From c228fa25431d322792e7d171d0c535b8d4389a54 Mon Sep 17 00:00:00 2001 From: aude Date: Sat, 18 Mar 2017 14:26:25 -0400 Subject: [PATCH] Don't create user in AuthManagerTest dataProvider Creating users involves database access and the test database isn't fully setup yet when data providers run. In this particular test / data provider, all that is needed is the user name so we can just set that w/o creating the user in the data provider. The user gets created during the test. (after the test database is setup) also $id set in $id = $user->getId() was unused and was the specific code that involved making a database connection. Change-Id: I1685dfdd6cfc60cd2c59a4d9de95bcbbaba5e153 --- tests/phpunit/includes/auth/AuthManagerTest.php | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/tests/phpunit/includes/auth/AuthManagerTest.php b/tests/phpunit/includes/auth/AuthManagerTest.php index f57db11b23..f7be8019b9 100644 --- a/tests/phpunit/includes/auth/AuthManagerTest.php +++ b/tests/phpunit/includes/auth/AuthManagerTest.php @@ -1083,10 +1083,6 @@ class AuthManagerTest extends \MediaWikiTestCase { } public function provideAuthentication() { - $user = \User::newFromName( 'UTSysop' ); - $id = $user->getId(); - $name = $user->getName(); - $rememberReq = new RememberMeAuthenticationRequest; $rememberReq->action = AuthManager::ACTION_LOGIN; @@ -1108,6 +1104,8 @@ class AuthManagerTest extends \MediaWikiTestCase { $restartResponse2->createRequest->action = AuthManager::ACTION_LOGIN; $restartResponse2->neededRequests = [ $rememberReq, $restartResponse2->createRequest ]; + $userName = 'UTSysop'; + return [ 'Failure in pre-auth' => [ StatusValue::newFatal( 'fail-from-pre' ), @@ -1202,7 +1200,7 @@ class AuthManagerTest extends \MediaWikiTestCase { 'Secondary fail' => [ StatusValue::newGood(), [ - AuthenticationResponse::newPass( $name ), + AuthenticationResponse::newPass( $userName ), ], $tmp = [ AuthenticationResponse::newFail( $this->message( 'fail-in-secondary' ) ), @@ -1212,7 +1210,7 @@ class AuthManagerTest extends \MediaWikiTestCase { 'Secondary UI, then abstain' => [ StatusValue::newGood(), [ - AuthenticationResponse::newPass( $name ), + AuthenticationResponse::newPass( $userName ), ], [ $tmp = AuthenticationResponse::newUI( [ $req ], $this->message( '...' ) ), @@ -1220,19 +1218,19 @@ class AuthManagerTest extends \MediaWikiTestCase { ], [ $tmp, - AuthenticationResponse::newPass( $name ), + AuthenticationResponse::newPass( $userName ), ] ], 'Secondary pass' => [ StatusValue::newGood(), [ - AuthenticationResponse::newPass( $name ), + AuthenticationResponse::newPass( $userName ), ], [ AuthenticationResponse::newPass() ], [ - AuthenticationResponse::newPass( $name ), + AuthenticationResponse::newPass( $userName ), ] ], ]; -- 2.20.1