class PHPUnit_TextUI_Command (View source)

A TestRunner for the Command Line Interface (CLI) PHP SAPI Module.

Properties

protected array $arguments
protected array $options
protected array $longOptions

Methods

static 
main(bool $exit = true)

No description

int
run(array $argv, bool $exit = true)

No description

createRunner()

Create a TestRunner, override in subclasses.

handleArguments(array $argv)

Handles the command-line arguments.

handleLoader(string $loaderClass, string $loaderFile = '')

Handles the loading of the PHPUnit_Runner_TestSuiteLoader implementation.

handlePrinter(string $printerClass, string $printerFile = '')

Handles the loading of the PHPUnit_Util_Printer implementation.

handleBootstrap(string $filename)

Loads a bootstrap file.

handleSelfUpdate($upgrade = false)

No description

handleVersionCheck()

No description

showHelp()

Show the help message.

handleCustomTestSuite()

Custom callback for test suite discovery.

Details

static main(bool $exit = true)

Parameters

bool $exit

int run(array $argv, bool $exit = true)

Parameters

array $argv
bool $exit

Return Value

int

protected PHPUnit_TextUI_TestRunner createRunner()

Create a TestRunner, override in subclasses.

protected handleArguments(array $argv)

Handles the command-line arguments.

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

<?php class MyCommand extends PHPUnit_TextUI_Command { public function __construct() { // my-switch won't accept a value, it's an on/off $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);
}

}

Parameters

array $argv

protected PHPUnit_Runner_TestSuiteLoader handleLoader(string $loaderClass, string $loaderFile = '')

Handles the loading of the PHPUnit_Runner_TestSuiteLoader implementation.

Parameters

string $loaderClass
string $loaderFile

Return Value

PHPUnit_Runner_TestSuiteLoader

protected PHPUnit_Util_Printer|string handlePrinter(string $printerClass, string $printerFile = '')

Handles the loading of the PHPUnit_Util_Printer implementation.

Parameters

string $printerClass
string $printerFile

Return Value

PHPUnit_Util_Printer|string

protected handleBootstrap(string $filename)

Loads a bootstrap file.

Parameters

string $filename

protected handleSelfUpdate($upgrade = false)

Parameters

$upgrade

protected handleVersionCheck()

protected showHelp()

Show the help message.

protected handleCustomTestSuite()

Custom callback for test suite discovery.