Command
class 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
No description
No description
Create a TestRunner, override in subclasses.
Handles the command-line arguments.
Handles the loading of the PHPUnit\Runner\TestSuiteLoader implementation.
Handles the loading of the PHPUnit\Util\Printer implementation.
Loads a bootstrap file.
No description
Show the help message.
Custom callback for test suite discovery.
Details
        at         line 144
                static            
    main(bool $exit = true)
        
    
    
        at         line 157
                            int
    run(array $argv, bool $exit = true)
        
    
    
        at         line 220
                    protected        TestRunner
    createRunner()
        
    
    Create a TestRunner, override in subclasses.
        at         line 270
                    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);
}
}
        at         line 807
                    protected        TestSuiteLoader|null
    handleLoader(string $loaderClass, string $loaderFile = '')
        
    
    Handles the loading of the PHPUnit\Runner\TestSuiteLoader implementation.
        at         line 852
                    protected        Printer|string|null
    handlePrinter(string $printerClass, string $printerFile = '')
        
    
    Handles the loading of the PHPUnit\Util\Printer implementation.
        at         line 922
                    protected        
    handleBootstrap(string $filename)
        
    
    Loads a bootstrap file.
        at         line 931
                    protected        
    handleVersionCheck()
        
    
    
        at         line 954
                    protected        
    showHelp()
        
    
    Show the help message.
        at         line 1058
                    protected        
    handleCustomTestSuite()
        
    
    Custom callback for test suite discovery.