Documentation

Command
in package

Tags
no-named-arguments

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

Table of Contents

Properties

$arguments  : array<string, mixed>
$longOptions  : array<string, mixed>
$versionStringPrinted  : bool
$warnings  : mixed

Methods

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
mapKeyToOptionForWarning()  : string
migrateConfiguration()  : void
printVersionString()  : void
warnAboutConflictingOptions()  : 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

handleBootstrap()

Loads a bootstrap file.

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

handleCustomTestSuite()

Custom callback for test suite discovery.

protected handleCustomTestSuite() : void

handleLoader()

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

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

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

Parameters
$loaderClass : string
$loaderFile : string = ''
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

showHelp()

Show the help message.

protected showHelp() : void

configurationFileInDirectory()

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

exitWithErrorMessage()

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

generateConfiguration()

private generateConfiguration() : void

handleCustomOptions()

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

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

mapKeyToOptionForWarning()

private mapKeyToOptionForWarning(string $key) : string
Parameters
$key : string
Tags
psalm-param

"listGroups"|"listSuites"|"listTests"|"listTestsXml"|"filter"|"groups"|"excludeGroups"|"testsuite" $key

Return values
string

migrateConfiguration()

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

printVersionString()

private printVersionString() : void

warnAboutConflictingOptions()

private warnAboutConflictingOptions(string $key, array<string|int, mixed> $keys) : void
Parameters
$key : string
$keys : array<string|int, mixed>
Tags
psalm-param

"listGroups"|"listSuites"|"listTests"|"listTestsXml"|"filter"|"groups"|"excludeGroups"|"testsuite" $key

psalm-param

list<"listGroups"|"listSuites"|"listTests"|"listTestsXml"|"filter"|"groups"|"excludeGroups"|"testsuite"> $keys


        
On this page

Search results