Merge "phpunit: Avoid use of deprecated getMock for PHPUnit 5 compat"
[lhc/web/wiklou.git] / tests / phpunit / includes / auth / LocalPasswordPrimaryAuthenticationProviderTest.php
index caf1680..6e2058c 100644 (file)
@@ -2,6 +2,8 @@
 
 namespace MediaWiki\Auth;
 
+use MediaWiki\MediaWikiServices;
+
 /**
  * @group AuthManager
  * @group Database
@@ -28,7 +30,7 @@ class LocalPasswordPrimaryAuthenticationProviderTest extends \MediaWikiTestCase
                }
                $config = new \MultiConfig( [
                        $this->config,
-                       \ConfigFactory::getDefaultInstance()->makeConfig( 'main' )
+                       MediaWikiServices::getInstance()->getMainConfig()
                ] );
 
                if ( !$this->manager ) {
@@ -36,11 +38,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;
@@ -346,7 +347,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 +443,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;