// instead of the MaintenanceFixup hack below. However, we cannot do
// without changing the visibility and without working around hacks in
// Maintenance.php
-//
// For the same reason, we cannot just use FakeMaintenance.
/**
return call_user_func_array( 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() );
+ }
+
+ public function getOption( $name, $default = null ) {
+ return call_user_func_array( array( "parent", __FUNCTION__ ), func_get_args() );
+ }
+
// --- Requirements for getting instance of abstract class
public function execute() {
$this->m->setConfig( $conf );
$this->assertSame( $conf, $this->m->getConfig() );
}
+
+ function testParseArgs() {
+ $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' ) );
+
+ $this->assertEquals( array( 'this1', 'this2' ), $m2->getOption( 'multi' ) );
+ $this->assertEquals( array( array( 'multi', 'this1' ), array( 'multi', 'this2' ) ),
+ $m2->orderedOptions );
+
+ $m2->simulateShutdown();
+
+ $m2 = new MaintenanceFixup( $this );
+
+ $m2->addOption( 'multi', 'This option does stuff', false, false, false, true );
+ $m2->loadWithArgv( array( '--multi', '--multi' ) );
+
+ $this->assertEquals( array( 1, 1 ), $m2->getOption( 'multi' ) );
+ $this->assertEquals( array( array( 'multi', 1 ), array( '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' ) );
+
+ $this->assertEquals( 'yo', $m2->getOption( 'multi' ) );
+ $this->assertEquals( array( array( 'multi', 'yo' ) ), $m2->orderedOptions );
+
+ $m2->simulateShutdown();
+ }
}