Merge "phpunit: Avoid use of deprecated getMock for PHPUnit 5 compat"
[lhc/web/wiklou.git] / tests / phpunit / includes / auth / AuthenticationRequestTest.php
index cac031c..0e549a5 100644 (file)
@@ -7,15 +7,6 @@ namespace MediaWiki\Auth;
  * @covers MediaWiki\Auth\AuthenticationRequest
  */
 class AuthenticationRequestTest extends \MediaWikiTestCase {
-       protected function setUp() {
-               global $wgDisableAuthManager;
-
-               parent::setUp();
-               if ( $wgDisableAuthManager ) {
-                       $this->markTestSkipped( '$wgDisableAuthManager is set' );
-               }
-       }
-
        public function testBasics() {
                $mock = $this->getMockForAbstractClass( AuthenticationRequest::class );
 
@@ -147,7 +138,7 @@ class AuthenticationRequestTest extends \MediaWikiTestCase {
        public function testMergeFieldInfo() {
                $msg = wfMessage( 'foo' );
 
-               $req1 = $this->getMock( AuthenticationRequest::class );
+               $req1 = $this->createMock( AuthenticationRequest::class );
                $req1->required = AuthenticationRequest::REQUIRED;
                $req1->expects( $this->any() )->method( 'getFieldInfo' )->will( $this->returnValue( [
                        'string1' => [
@@ -174,13 +165,14 @@ class AuthenticationRequestTest extends \MediaWikiTestCase {
                        ],
                ] ) );
 
-               $req2 = $this->getMock( AuthenticationRequest::class );
+               $req2 = $this->createMock( AuthenticationRequest::class );
                $req2->required = AuthenticationRequest::REQUIRED;
                $req2->expects( $this->any() )->method( 'getFieldInfo' )->will( $this->returnValue( [
                        'string1' => [
                                'type' => 'string',
                                'label' => $msg,
                                'help' => $msg,
+                               'sensitive' => true,
                        ],
                        'string3' => [
                                'type' => 'string',
@@ -195,7 +187,7 @@ class AuthenticationRequestTest extends \MediaWikiTestCase {
                        ],
                ] ) );
 
-               $req3 = $this->getMock( AuthenticationRequest::class );
+               $req3 = $this->createMock( AuthenticationRequest::class );
                $req3->required = AuthenticationRequest::REQUIRED;
                $req3->expects( $this->any() )->method( 'getFieldInfo' )->will( $this->returnValue( [
                        'string1' => [
@@ -205,7 +197,7 @@ class AuthenticationRequestTest extends \MediaWikiTestCase {
                        ],
                ] ) );
 
-               $req4 = $this->getMock( AuthenticationRequest::class );
+               $req4 = $this->createMock( AuthenticationRequest::class );
                $req4->required = AuthenticationRequest::REQUIRED;
                $req4->expects( $this->any() )->method( 'getFieldInfo' )->will( $this->returnValue( [] ) );
 
@@ -215,6 +207,7 @@ class AuthenticationRequestTest extends \MediaWikiTestCase {
                $expect = $req1->getFieldInfo();
                foreach ( $expect as $name => &$options ) {
                        $options['optional'] = !empty( $options['optional'] );
+                       $options['sensitive'] = !empty( $options['sensitive'] );
                }
                unset( $options );
                $this->assertEquals( $expect, $fields );
@@ -234,8 +227,10 @@ class AuthenticationRequestTest extends \MediaWikiTestCase {
 
                $fields = AuthenticationRequest::mergeFieldInfo( [ $req1, $req2 ] );
                $expect += $req2->getFieldInfo();
+               $expect['string1']['sensitive'] = true;
                $expect['string2']['optional'] = false;
                $expect['string3']['optional'] = false;
+               $expect['string3']['sensitive'] = false;
                $expect['select']['options']['bar'] = $msg;
                $this->assertEquals( $expect, $fields );
 
@@ -246,6 +241,7 @@ class AuthenticationRequestTest extends \MediaWikiTestCase {
                $fields = AuthenticationRequest::mergeFieldInfo( [ $req1, $req2 ] );
                $expect += $req2->getFieldInfo();
                $expect['string1']['optional'] = false;
+               $expect['string1']['sensitive'] = true;
                $expect['string3']['optional'] = false;
                $expect['select']['optional'] = false;
                $expect['select']['options']['bar'] = $msg;
@@ -255,7 +251,11 @@ class AuthenticationRequestTest extends \MediaWikiTestCase {
 
                $fields = AuthenticationRequest::mergeFieldInfo( [ $req1, $req2 ] );
                $expect = $req1->getFieldInfo() + $req2->getFieldInfo();
+               foreach ( $expect as $name => &$options ) {
+                       $options['sensitive'] = !empty( $options['sensitive'] );
+               }
                $expect['string1']['optional'] = false;
+               $expect['string1']['sensitive'] = true;
                $expect['string2']['optional'] = true;
                $expect['string3']['optional'] = true;
                $expect['select']['optional'] = false;