X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22suivi_revisions%22%2C%22id_auteur=%24connecte%22%29%20.%20%22?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2Fauth%2FLocalPasswordPrimaryAuthenticationProviderTest.php;h=b89f1e02e4642bf4ed6ad60a632047fb6ba01613;hb=525bfbc8df855aa12e01868d92532cd64482dc7d;hp=caf1680e3e249ed3d37bb00b1ffeab5a0c52dd23;hpb=5111bd2def4e63ecc8a2acbf468e5c39029f9efd;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/auth/LocalPasswordPrimaryAuthenticationProviderTest.php b/tests/phpunit/includes/auth/LocalPasswordPrimaryAuthenticationProviderTest.php index caf1680e3e..b89f1e02e4 100644 --- a/tests/phpunit/includes/auth/LocalPasswordPrimaryAuthenticationProviderTest.php +++ b/tests/phpunit/includes/auth/LocalPasswordPrimaryAuthenticationProviderTest.php @@ -2,6 +2,9 @@ namespace MediaWiki\Auth; +use MediaWiki\MediaWikiServices; +use Wikimedia\TestingAccessWrapper; + /** * @group AuthManager * @group Database @@ -28,7 +31,7 @@ class LocalPasswordPrimaryAuthenticationProviderTest extends \MediaWikiTestCase } $config = new \MultiConfig( [ $this->config, - \ConfigFactory::getDefaultInstance()->makeConfig( 'main' ) + MediaWikiServices::getInstance()->getMainConfig() ] ); if ( !$this->manager ) { @@ -36,11 +39,10 @@ class LocalPasswordPrimaryAuthenticationProviderTest extends \MediaWikiTestCase } $this->validity = \Status::newGood(); - $provider = $this->getMock( - LocalPasswordPrimaryAuthenticationProvider::class, - [ 'checkPasswordValidity' ], - [ [ 'loginOnly' => $loginOnly ] ] - ); + $provider = $this->getMockBuilder( LocalPasswordPrimaryAuthenticationProvider::class ) + ->setMethods( [ 'checkPasswordValidity' ] ) + ->setConstructorArgs( [ [ 'loginOnly' => $loginOnly ] ] ) + ->getMock(); $provider->expects( $this->any() )->method( 'checkPasswordValidity' ) ->will( $this->returnCallback( function () { return $this->validity; @@ -130,7 +132,7 @@ class LocalPasswordPrimaryAuthenticationProviderTest extends \MediaWikiTestCase $provider->setConfig( $this->config ); $provider->setLogger( new \Psr\Log\NullLogger() ); $provider->setManager( $this->manager ); - $providerPriv = \TestingAccessWrapper::newFromObject( $provider ); + $providerPriv = TestingAccessWrapper::newFromObject( $provider ); $user = $this->getMutableTestUser()->getUser(); $userName = $user->getName(); @@ -346,7 +348,7 @@ class LocalPasswordPrimaryAuthenticationProviderTest extends \MediaWikiTestCase } elseif ( $type === PasswordDomainAuthenticationRequest::class ) { $req = new $type( [] ); } else { - $req = $this->getMock( $type ); + $req = $this->createMock( $type ); } $req->action = AuthManager::ACTION_CHANGE; $req->username = $user; @@ -442,14 +444,14 @@ class LocalPasswordPrimaryAuthenticationProviderTest extends \MediaWikiTestCase if ( $type === PasswordAuthenticationRequest::class ) { $changeReq = new $type(); } else { - $changeReq = $this->getMock( $type ); + $changeReq = $this->createMock( $type ); } $changeReq->action = AuthManager::ACTION_CHANGE; $changeReq->username = $user; $changeReq->password = $newpass; $provider->providerChangeAuthenticationData( $changeReq ); - if ( $loginOnly ) { + if ( $loginOnly && $changed ) { $old = 'fail'; $new = 'fail'; $expectExpiry = null;