X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;ds=sidebyside;f=tests%2Fphpunit%2Fincludes%2Fauth%2FTemporaryPasswordPrimaryAuthenticationProviderTest.php;h=4b606227965ec01a40bbf9ce46204a9bb983f337;hb=f12a3edff708a1fb73a09d154693dba49b69d921;hp=8161ed4206f1dfd01453829d51405f3d6bb71a37;hpb=12313956c58e88b98d4baf722464e09b4a351bf3;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/auth/TemporaryPasswordPrimaryAuthenticationProviderTest.php b/tests/phpunit/includes/auth/TemporaryPasswordPrimaryAuthenticationProviderTest.php index 8161ed4206..4b60622796 100644 --- a/tests/phpunit/includes/auth/TemporaryPasswordPrimaryAuthenticationProviderTest.php +++ b/tests/phpunit/includes/auth/TemporaryPasswordPrimaryAuthenticationProviderTest.php @@ -2,6 +2,8 @@ namespace MediaWiki\Auth; +use Wikimedia\ScopedCallback; + /** * @group AuthManager * @group Database @@ -70,7 +72,7 @@ class TemporaryPasswordPrimaryAuthenticationProviderTest extends \MediaWikiTestC } ); } - return new \ScopedCallback( function () { + return new ScopedCallback( function () { \Hooks::clear( 'AlternateUserMailer' ); \Hooks::register( 'AlternateUserMailer', function () { return false; @@ -345,7 +347,6 @@ class TemporaryPasswordPrimaryAuthenticationProviderTest extends \MediaWikiTestC 'wrongpassword', $ret->message->getKey() ); - } /** @@ -414,7 +415,7 @@ class TemporaryPasswordPrimaryAuthenticationProviderTest extends \MediaWikiTestC $dbw = wfGetDB( DB_MASTER ); $oldHash = $dbw->selectField( 'user', 'user_newpassword', [ 'user_name' => $cuser ] ); - $cb = new \ScopedCallback( function () use ( $dbw, $cuser, $oldHash ) { + $cb = new ScopedCallback( function () use ( $dbw, $cuser, $oldHash ) { $dbw->update( 'user', [ 'user_newpassword' => $oldHash ], [ 'user_name' => $cuser ] ); } ); @@ -451,7 +452,7 @@ class TemporaryPasswordPrimaryAuthenticationProviderTest extends \MediaWikiTestC $changeReq->password = $newpass; $resetMailer = $this->hookMailer(); $provider->providerChangeAuthenticationData( $changeReq ); - \ScopedCallback::consume( $resetMailer ); + ScopedCallback::consume( $resetMailer ); $loginReq->password = $oldpass; $ret = $provider->beginPrimaryAuthentication( $loginReqs ); @@ -519,10 +520,6 @@ class TemporaryPasswordPrimaryAuthenticationProviderTest extends \MediaWikiTestC $provider = $this->getProvider( [ 'emailEnabled' => false ] ); $status = $provider->providerAllowsAuthenticationDataChange( $req, true ); $this->assertEquals( \StatusValue::newFatal( 'passwordreset-emaildisabled' ), $status ); - $req->hasBackchannel = true; - $status = $provider->providerAllowsAuthenticationDataChange( $req, true ); - $this->assertFalse( $status->hasMessage( 'passwordreset-emaildisabled' ) ); - $req->hasBackchannel = false; $provider = $this->getProvider( [ 'passwordReminderResendTime' => 10 ] ); $status = $provider->providerAllowsAuthenticationDataChange( $req, true ); @@ -573,7 +570,7 @@ class TemporaryPasswordPrimaryAuthenticationProviderTest extends \MediaWikiTestC return false; } ); $provider->providerChangeAuthenticationData( $req ); - \ScopedCallback::consume( $resetMailer ); + ScopedCallback::consume( $resetMailer ); $this->assertTrue( $mailed ); $priv = \TestingAccessWrapper::newFromObject( $provider ); @@ -685,18 +682,10 @@ class TemporaryPasswordPrimaryAuthenticationProviderTest extends \MediaWikiTestC $provider = $this->getProvider( [ 'emailEnabled' => false ] ); $status = $provider->testForAccountCreation( $user, $creator, [ $req ] ); $this->assertEquals( \StatusValue::newFatal( 'emaildisabled' ), $status ); - $req->hasBackchannel = true; - $status = $provider->testForAccountCreation( $user, $creator, [ $req ] ); - $this->assertFalse( $status->hasMessage( 'emaildisabled' ) ); - $req->hasBackchannel = false; $provider = $this->getProvider( [ 'emailEnabled' => true ] ); $status = $provider->testForAccountCreation( $user, $creator, [ $req ] ); $this->assertEquals( \StatusValue::newFatal( 'noemailcreate' ), $status ); - $req->hasBackchannel = true; - $status = $provider->testForAccountCreation( $user, $creator, [ $req ] ); - $this->assertFalse( $status->hasMessage( 'noemailcreate' ) ); - $req->hasBackchannel = false; $user->setEmail( 'test@localhost.localdomain' ); $status = $provider->testForAccountCreation( $user, $creator, [ $req ] ); @@ -723,7 +712,7 @@ class TemporaryPasswordPrimaryAuthenticationProviderTest extends \MediaWikiTestC $this->assertSame( 'byemail', $provider->finishAccountCreation( $user, $creator, $res ) ); $this->assertTrue( $mailed ); - \ScopedCallback::consume( $resetMailer ); + ScopedCallback::consume( $resetMailer ); $this->assertTrue( $mailed ); }