Merge "phpunit: Avoid use of deprecated getMock for PHPUnit 5 compat"
[lhc/web/wiklou.git] / tests / phpunit / maintenance / MaintenanceTest.php
index 245a97a..6b0e344 100644 (file)
@@ -5,6 +5,7 @@
 // without changing the visibility and without working around hacks in
 // Maintenance.php
 // For the same reason, we cannot just use FakeMaintenance.
+use MediaWiki\MediaWikiServices;
 
 /**
  * makes parts of the API of Maintenance that is hidden by protected visibily
@@ -23,7 +24,6 @@
  * Due to a hack in Maintenance.php using register_shutdown_function, be sure to
  * finally call simulateShutdown on MaintenanceFixup instance before a test
  * ends.
- *
  */
 class MaintenanceFixup extends Maintenance {
 
@@ -80,7 +80,7 @@ class MaintenanceFixup extends Maintenance {
                        return;
                }
 
-               call_user_func_array( array( "parent", __FUNCTION__ ), func_get_args() );
+               call_user_func_array( [ "parent", __FUNCTION__ ], func_get_args() );
        }
 
        /**
@@ -117,17 +117,17 @@ class MaintenanceFixup extends Maintenance {
                // Maintenance::output signature. However, we do not use (or rely on)
                // those variables. Instead we pass to Maintenance::output whatever we
                // receive at runtime.
-               return call_user_func_array( array( "parent", __FUNCTION__ ), func_get_args() );
+               return call_user_func_array( [ "parent", __FUNCTION__ ], func_get_args() );
        }
 
        public function addOption( $name, $description, $required = false,
                $withArg = false, $shortName = false, $multiOccurance = false
        ) {
-               return call_user_func_array( array( "parent", __FUNCTION__ ), func_get_args() );
+               return call_user_func_array( [ "parent", __FUNCTION__ ], func_get_args() );
        }
 
        public function getOption( $name, $default = null ) {
-               return call_user_func_array( array( "parent", __FUNCTION__ ), func_get_args() );
+               return call_user_func_array( [ "parent", __FUNCTION__ ], func_get_args() );
        }
 
        // --- Requirements for getting instance of abstract class
@@ -826,7 +826,7 @@ class MaintenanceTest extends MediaWikiTestCase {
        public function testGetConfig() {
                $this->assertInstanceOf( 'Config', $this->m->getConfig() );
                $this->assertSame(
-                       ConfigFactory::getDefaultInstance()->makeConfig( 'main' ),
+                       MediaWikiServices::getInstance()->getMainConfig(),
                        $this->m->getConfig()
                );
        }
@@ -835,7 +835,7 @@ class MaintenanceTest extends MediaWikiTestCase {
         * @covers Maintenance::setConfig
         */
        public function testSetConfig() {
-               $conf = $this->getMock( 'Config' );
+               $conf = $this->createMock( 'Config' );
                $this->m->setConfig( $conf );
                $this->assertSame( $conf, $this->m->getConfig() );
        }
@@ -844,10 +844,10 @@ class MaintenanceTest extends MediaWikiTestCase {
                $m2 = new MaintenanceFixup( $this );
                // Create an option with an argument allowed to be specified multiple times
                $m2->addOption( 'multi', 'This option does stuff', false, true, false, true );
-               $m2->loadWithArgv( array( '--multi', 'this1', '--multi', 'this2' ) );
+               $m2->loadWithArgv( [ '--multi', 'this1', '--multi', 'this2' ] );
 
-               $this->assertEquals( array( 'this1', 'this2' ), $m2->getOption( 'multi' ) );
-               $this->assertEquals( array( array( 'multi', 'this1' ), array( 'multi', 'this2' ) ),
+               $this->assertEquals( [ 'this1', 'this2' ], $m2->getOption( 'multi' ) );
+               $this->assertEquals( [ [ 'multi', 'this1' ], [ 'multi', 'this2' ] ],
                        $m2->orderedOptions );
 
                $m2->simulateShutdown();
@@ -855,20 +855,20 @@ class MaintenanceTest extends MediaWikiTestCase {
                $m2 = new MaintenanceFixup( $this );
 
                $m2->addOption( 'multi', 'This option does stuff', false, false, false, true );
-               $m2->loadWithArgv( array( '--multi', '--multi' ) );
+               $m2->loadWithArgv( [ '--multi', '--multi' ] );
 
-               $this->assertEquals( array( 1, 1 ), $m2->getOption( 'multi' ) );
-               $this->assertEquals( array( array( 'multi', 1 ), array( 'multi', 1 ) ), $m2->orderedOptions );
+               $this->assertEquals( [ 1, 1 ], $m2->getOption( 'multi' ) );
+               $this->assertEquals( [ [ 'multi', 1 ], [ 'multi', 1 ] ], $m2->orderedOptions );
 
                $m2->simulateShutdown();
 
                $m2 = new MaintenanceFixup( $this );
                // Create an option with an argument allowed to be specified multiple times
                $m2->addOption( 'multi', 'This option doesn\'t actually support multiple occurrences' );
-               $m2->loadWithArgv( array( '--multi=yo' ) );
+               $m2->loadWithArgv( [ '--multi=yo' ] );
 
                $this->assertEquals( 'yo', $m2->getOption( 'multi' ) );
-               $this->assertEquals( array( array( 'multi', 'yo' ) ), $m2->orderedOptions );
+               $this->assertEquals( [ [ 'multi', 'yo' ] ], $m2->orderedOptions );
 
                $m2->simulateShutdown();
        }