X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;ds=sidebyside;f=tests%2Fphpunit%2Fincludes%2Fauth%2FTemporaryPasswordPrimaryAuthenticationProviderTest.php;h=1708f1c06374fa997d2f1260df055e78de05d809;hb=5049af1048c77b1ea6ab3193688d23a48ddf8df0;hp=bc7d65e81d8e6103645f44e644cac68a7045b57e;hpb=4cb9c1a24bde6e29c5e8f05c7cd1de54ffdd342a;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/auth/TemporaryPasswordPrimaryAuthenticationProviderTest.php b/tests/phpunit/includes/auth/TemporaryPasswordPrimaryAuthenticationProviderTest.php index bc7d65e81d..1708f1c063 100644 --- a/tests/phpunit/includes/auth/TemporaryPasswordPrimaryAuthenticationProviderTest.php +++ b/tests/phpunit/includes/auth/TemporaryPasswordPrimaryAuthenticationProviderTest.php @@ -4,6 +4,7 @@ namespace MediaWiki\Auth; use MediaWiki\MediaWikiServices; use Wikimedia\ScopedCallback; +use Wikimedia\TestingAccessWrapper; /** * @group AuthManager @@ -42,11 +43,10 @@ class TemporaryPasswordPrimaryAuthenticationProviderTest extends \MediaWikiTestC $this->validity = \Status::newGood(); $mockedMethods[] = 'checkPasswordValidity'; - $provider = $this->getMock( - TemporaryPasswordPrimaryAuthenticationProvider::class, - $mockedMethods, - [ $params ] - ); + $provider = $this->getMockBuilder( TemporaryPasswordPrimaryAuthenticationProvider::class ) + ->setMethods( $mockedMethods ) + ->setConstructorArgs( [ $params ] ) + ->getMock(); $provider->expects( $this->any() )->method( 'checkPasswordValidity' ) ->will( $this->returnCallback( function () { return $this->validity; @@ -107,13 +107,13 @@ class TemporaryPasswordPrimaryAuthenticationProviderTest extends \MediaWikiTestC 'PasswordReminderResendTime' => 101, ] ); - $p = \TestingAccessWrapper::newFromObject( new TemporaryPasswordPrimaryAuthenticationProvider() ); + $p = TestingAccessWrapper::newFromObject( new TemporaryPasswordPrimaryAuthenticationProvider() ); $p->setConfig( $config ); $this->assertSame( false, $p->emailEnabled ); $this->assertSame( 100, $p->newPasswordExpiry ); $this->assertSame( 101, $p->passwordReminderResendTime ); - $p = \TestingAccessWrapper::newFromObject( new TemporaryPasswordPrimaryAuthenticationProvider( [ + $p = TestingAccessWrapper::newFromObject( new TemporaryPasswordPrimaryAuthenticationProvider( [ 'emailEnabled' => true, 'newPasswordExpiry' => 42, 'passwordReminderResendTime' => 43, @@ -136,7 +136,7 @@ class TemporaryPasswordPrimaryAuthenticationProviderTest extends \MediaWikiTestC $pwhash = $passwordFactory->newFromPlaintext( 'password' )->toString(); $provider = $this->getProvider(); - $providerPriv = \TestingAccessWrapper::newFromObject( $provider ); + $providerPriv = TestingAccessWrapper::newFromObject( $provider ); $this->assertFalse( $provider->testUserCanAuthenticate( '' ) ); $this->assertFalse( $provider->testUserCanAuthenticate( 'DoesNotExist' ) ); @@ -250,7 +250,7 @@ class TemporaryPasswordPrimaryAuthenticationProviderTest extends \MediaWikiTestC $reqs = [ PasswordAuthenticationRequest::class => $req ]; $provider = $this->getProvider(); - $providerPriv = \TestingAccessWrapper::newFromObject( $provider ); + $providerPriv = TestingAccessWrapper::newFromObject( $provider ); $providerPriv->newPasswordExpiry = 100; @@ -366,7 +366,7 @@ class TemporaryPasswordPrimaryAuthenticationProviderTest extends \MediaWikiTestC ) { $req = new $type(); } else { - $req = $this->getMock( $type ); + $req = $this->createMock( $type ); } $req->action = AuthManager::ACTION_CHANGE; $req->username = $user; @@ -446,7 +446,7 @@ class TemporaryPasswordPrimaryAuthenticationProviderTest extends \MediaWikiTestC ) { $changeReq = new $type(); } else { - $changeReq = $this->getMock( $type ); + $changeReq = $this->createMock( $type ); } $changeReq->action = AuthManager::ACTION_CHANGE; $changeReq->username = $user; @@ -574,7 +574,7 @@ class TemporaryPasswordPrimaryAuthenticationProviderTest extends \MediaWikiTestC ScopedCallback::consume( $resetMailer ); $this->assertTrue( $mailed ); - $priv = \TestingAccessWrapper::newFromObject( $provider ); + $priv = TestingAccessWrapper::newFromObject( $provider ); $req->username = ''; $status = $priv->sendPasswordResetEmail( $req ); $this->assertEquals( \Status::newFatal( 'noname' ), $status ); @@ -647,7 +647,7 @@ class TemporaryPasswordPrimaryAuthenticationProviderTest extends \MediaWikiTestC $req->password = 'bar'; $expect = AuthenticationResponse::newPass( 'Foo' ); - $expect->createRequest = clone( $req ); + $expect->createRequest = clone $req; $expect->createRequest->username = 'Foo'; $this->assertEquals( $expect, $provider->beginPrimaryAccountCreation( $user, $user, $reqs ) ); $this->assertNull( $this->manager->getAuthenticationSessionData( 'no-email' ) ); @@ -703,7 +703,7 @@ class TemporaryPasswordPrimaryAuthenticationProviderTest extends \MediaWikiTestC } ); $expect = AuthenticationResponse::newPass( $user->getName() ); - $expect->createRequest = clone( $req ); + $expect->createRequest = clone $req; $expect->createRequest->username = $user->getName(); $res = $provider->beginPrimaryAccountCreation( $user, $creator, [ $req ] ); $this->assertEquals( $expect, $res );