Documentation

Command
in package

Tags
no-named-arguments

Parameter names are not covered by the backward compatibility promise for PHPUnit

Table of Contents

$arguments  : array<string, mixed>
$longOptions  : array<string, mixed>
$versionStringPrinted  : bool
$warnings  : mixed
main()  : int
run()  : int
createRunner()  : TestRunner
Create a TestRunner, override in subclasses.
handleArguments()  : void
Handles the command-line arguments.
handleBootstrap()  : void
Loads a bootstrap file.
handleCustomTestSuite()  : void
Custom callback for test suite discovery.
handleLoader()  : TestSuiteLoader|null
Handles the loading of the PHPUnit\Runner\TestSuiteLoader implementation.
handlePrinter()  : null|Printer|string
Handles the loading of the PHPUnit\Util\Printer implementation.
handleVersionCheck()  : void
showHelp()  : void
Show the help message.
configurationFileInDirectory()  : string|null
exitWithErrorMessage()  : void
generateConfiguration()  : void
handleCustomOptions()  : void
handleListGroups()  : int
handleListSuites()  : int
handleListTests()  : int
handleListTestsXml()  : int
handleWarmCoverageCache()  : void
migrateConfiguration()  : void
printVersionString()  : void

Properties

$arguments

protected array<string, mixed> $arguments = []

$longOptions

protected array<string, mixed> $longOptions = []

$versionStringPrinted

private bool $versionStringPrinted = false

$warnings

private mixed $warnings = []
Tags
psalm-var

list

Methods

main()

public static main([bool $exit = true ]) : int
Parameters
$exit : bool = true
Tags
throws
Exception
Return values
int

run()

public run(array<string|int, mixed> $argv[, bool $exit = true ]) : int
Parameters
$argv : array<string|int, mixed>
$exit : bool = true
Tags
throws
Exception
Return values
int

createRunner()

Create a TestRunner, override in subclasses.

protected createRunner() : TestRunner
Return values
TestRunner

handleArguments()

Handles the command-line arguments.

protected handleArguments(array<string|int, mixed> $argv) : void

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

}

Parameters
$argv : array<string|int, mixed>
Tags
throws
Exception
Return values
void

handleBootstrap()

Loads a bootstrap file.

protected handleBootstrap(string $filename) : void
Parameters
$filename : string
Return values
void

handleCustomTestSuite()

Custom callback for test suite discovery.

protected handleCustomTestSuite() : void
Return values
void

handleLoader()

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

protected handleLoader(string $loaderClass[, string $loaderFile = '' ]) : TestSuiteLoader|null
Parameters
$loaderClass : string
$loaderFile : string = ''
Tags
deprecated

see https://github.com/sebastianbergmann/phpunit/issues/4039

Return values
TestSuiteLoader|null

handlePrinter()

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

protected handlePrinter(string $printerClass[, string $printerFile = '' ]) : null|Printer|string
Parameters
$printerClass : string
$printerFile : string = ''
Return values
null|Printer|string

handleVersionCheck()

protected handleVersionCheck() : void
Return values
void

showHelp()

Show the help message.

protected showHelp() : void
Return values
void

configurationFileInDirectory()

private configurationFileInDirectory(string $directory) : string|null
Parameters
$directory : string
Return values
string|null

exitWithErrorMessage()

private exitWithErrorMessage(string $message) : void
Parameters
$message : string
Return values
void

generateConfiguration()

private generateConfiguration() : void
Return values
void

handleCustomOptions()

private handleCustomOptions(array<string|int, mixed> $unrecognizedOptions) : void
Parameters
$unrecognizedOptions : array<string|int, mixed>
Return values
void

handleListGroups()

private handleListGroups(TestSuite $suite, bool $exit) : int
Parameters
$suite : TestSuite
$exit : bool
Return values
int

handleListSuites()

private handleListSuites(bool $exit) : int
Parameters
$exit : bool
Tags
throws
Exception
throws
Exception
Return values
int

handleListTests()

private handleListTests(TestSuite $suite, bool $exit) : int
Parameters
$suite : TestSuite
$exit : bool
Tags
throws
InvalidArgumentException
Return values
int

handleListTestsXml()

private handleListTestsXml(TestSuite $suite, string $target, bool $exit) : int
Parameters
$suite : TestSuite
$target : string
$exit : bool
Tags
throws
InvalidArgumentException
Return values
int

handleWarmCoverageCache()

private handleWarmCoverageCache(Configuration $configuration) : void
Parameters
$configuration : Configuration
Return values
void

migrateConfiguration()

private migrateConfiguration(string $filename) : void
Parameters
$filename : string
Return values
void

printVersionString()

private printVersionString() : void
Return values
void

Search results