file-fetcher
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
PHPUnit\TextUI\Command Class Reference
Inheritance diagram for PHPUnit\TextUI\Command:
MyCommand

Detailed Description

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

Public Member Functions

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

Static Public Member Functions

static main (bool $exit=true)
 

Protected Member Functions

 createRunner ()
 
 handleArguments (array $argv)
 
 handleLoader (string $loaderClass, string $loaderFile='')
 
 handlePrinter (string $printerClass, string $printerFile='')
 
 handleBootstrap (string $filename)
 
 handleVersionCheck ()
 
 showHelp ()
 
 handleCustomTestSuite ()
 

Protected Attributes

 $arguments
 
 $options = []
 
 $longOptions
 

Member Function Documentation

◆ createRunner()

PHPUnit\TextUI\Command::createRunner ( )
protected

Create a TestRunner, override in subclasses.

◆ handleArguments()

PHPUnit\TextUI\Command::handleArguments ( array  $argv)
protected

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); }

}

Exceptions
Exception

◆ handleBootstrap()

PHPUnit\TextUI\Command::handleBootstrap ( string  $filename)
protected

Loads a bootstrap file.

◆ handleCustomTestSuite()

PHPUnit\TextUI\Command::handleCustomTestSuite ( )
protected

Custom callback for test suite discovery.

◆ handleLoader()

PHPUnit\TextUI\Command::handleLoader ( string  $loaderClass,
string  $loaderFile = '' 
)
protected

Handles the loading of the PHPUnit\Runner\TestSuiteLoader implementation.

◆ handlePrinter()

PHPUnit\TextUI\Command::handlePrinter ( string  $printerClass,
string  $printerFile = '' 
)
protected

Handles the loading of the PHPUnit\Util\Printer implementation.

Returns
null|Printer|string

◆ handleVersionCheck()

PHPUnit\TextUI\Command::handleVersionCheck ( )
protected

◆ main()

static PHPUnit\TextUI\Command::main ( bool  $exit = true)
static
Exceptions

◆ run()

PHPUnit\TextUI\Command::run ( array  $argv,
bool  $exit = true 
)
Exceptions
Exception

◆ showHelp()

PHPUnit\TextUI\Command::showHelp ( )
protected

Show the help message.

Member Data Documentation

◆ $arguments

PHPUnit\TextUI\Command::$arguments
protected
Initial value:
= [
'listGroups' => false,
'listSuites' => false,
'listTests' => false,
'listTestsXml' => false,
'loader' => null,
'useDefaultConfiguration' => true,
'loadedExtensions' => [],
'notLoadedExtensions' => [],
]

◆ $longOptions

PHPUnit\TextUI\Command::$longOptions
protected

◆ $options

PHPUnit\TextUI\Command::$options = []
protected

The documentation for this class was generated from the following file: