A child class of PHPUnit_TextUI_Command can hook into the argument
parsing by adding the switch(es) to the $longOptions array and point to a
callback method that handles the switch(es) in the child class like this
longOptions['my-switch'] = 'myHandler';
my-secondswitch will accept a value - note the equals sign
$this->longOptions['my-secondswitch='] = 'myOtherHandler';
}
--my-switch -> myHandler()
protected function myHandler()
{
}
--my-secondswitch foo -> myOtherHandler('foo')
protected function myOtherHandler ($value)
{
}
You will also need this - the static keyword in the
PHPUnit_TextUI_Command will mean that it'll be
PHPUnit_TextUI_Command that gets instantiated,
not MyCommand
public static function main($exit = true)
{
$command = new static;
return $command->run($_SERVER['argv'], $exit);
}
}
protected handleArguments ( array $argv ) | ||
$argv | array |