Merge "Fix sessionfailure i18n message during authentication"
[lhc/web/wiklou.git] / tests / phpunit / includes / auth / AuthenticationRequestTestCase.php
index aafcd09..f483b9b 100644 (file)
@@ -6,15 +6,6 @@ namespace MediaWiki\Auth;
  * @group AuthManager
  */
 abstract class AuthenticationRequestTestCase extends \MediaWikiTestCase {
-       protected function setUp() {
-               global $wgDisableAuthManager;
-
-               parent::setUp();
-               if ( $wgDisableAuthManager ) {
-                       $this->markTestSkipped( '$wgDisableAuthManager is set' );
-               }
-       }
-
        abstract protected function getInstance( array $args = [] );
 
        /**
@@ -28,11 +19,11 @@ abstract class AuthenticationRequestTestCase extends \MediaWikiTestCase {
                        $this->assertType( 'array', $data, "Field $field" );
                        $this->assertArrayHasKey( 'type', $data, "Field $field" );
                        $this->assertArrayHasKey( 'label', $data, "Field $field" );
-                       $this->assertInstanceOf( 'Message', $data['label'], "Field $field, label" );
+                       $this->assertInstanceOf( \Message::class, $data['label'], "Field $field, label" );
 
                        if ( $data['type'] !== 'null' ) {
                                $this->assertArrayHasKey( 'help', $data, "Field $field" );
-                               $this->assertInstanceOf( 'Message', $data['help'], "Field $field, help" );
+                               $this->assertInstanceOf( \Message::class, $data['help'], "Field $field, help" );
                        }
 
                        if ( isset( $data['optional'] ) ) {
@@ -41,6 +32,13 @@ abstract class AuthenticationRequestTestCase extends \MediaWikiTestCase {
                        if ( isset( $data['image'] ) ) {
                                $this->assertType( 'string', $data['image'], "Field $field, image" );
                        }
+                       if ( isset( $data['sensitive'] ) ) {
+                               $this->assertType( 'bool', $data['sensitive'], "Field $field, sensitive" );
+                       }
+                       if ( $data['type'] === 'password' ) {
+                               $this->assertTrue( !empty( $data['sensitive'] ),
+                                       "Field $field, password field must be sensitive" );
+                       }
 
                        switch ( $data['type'] ) {
                                case 'string':
@@ -52,7 +50,7 @@ abstract class AuthenticationRequestTestCase extends \MediaWikiTestCase {
                                        $this->assertArrayHasKey( 'options', $data, "Field $field" );
                                        $this->assertType( 'array', $data['options'], "Field $field, options" );
                                        foreach ( $data['options'] as $val => $msg ) {
-                                               $this->assertInstanceOf( 'Message', $msg, "Field $field, option $val" );
+                                               $this->assertInstanceOf( \Message::class, $msg, "Field $field, option $val" );
                                        }
                                        break;
                                case 'checkbox':