From: aude Date: Sat, 18 Mar 2017 18:26:25 +0000 (-0400) Subject: Don't create user in AuthManagerTest dataProvider X-Git-Tag: 1.31.0-rc.0~3661^2 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/?a=commitdiff_plain;h=c228fa25431d322792e7d171d0c535b8d4389a54;p=lhc%2Fweb%2Fwiklou.git 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 --- 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 ), ] ], ];