Skip to content

TestsCommand

github-actions edited this page Mar 26, 2026 · 4 revisions

Facilitates the execution of the PHPUnit testing framework.

This class MUST NOT be overridden and SHALL configure testing parameters dynamically.


Constants

Constant Visibility Type Value
CONFIG public string 'phpunit.xml'

Methods

configure

Configures the testing command input constraints.

protected configure(): void

The method MUST specify valid arguments for testing paths, caching directories, bootstrap scripts, and coverage instructions. It SHALL align with robust testing standards.


execute

Triggers the PHPUnit engine based on resolved paths and settings.

protected execute(\Symfony\Component\Console\Input\InputInterface $input, \Symfony\Component\Console\Output\OutputInterface $output): int

The method MUST assemble the necessary commands to initiate PHPUnit securely. It SHOULD optionally construct advanced configuration arguments such as caching and coverage.

Parameters:

Parameter Type Description
$input \Symfony\Component\Console\Input\InputInterface the runtime instruction set from the CLI
$output \Symfony\Component\Console\Output\OutputInterface the console feedback relay

Return Value:

the status integer describing the termination code


Inherited methods

__construct

Constructs a new AbstractCommand instance.

public __construct(\Symfony\Component\Filesystem\Filesystem|null $filesystem = null): mixed

The method MAY accept a Filesystem instance; if omitted, it SHALL instantiate a new one.

Parameters:

Parameter Type Description
$filesystem \Symfony\Component\Filesystem\Filesystem|null the filesystem utility to use

runProcess

Executes a given system process gracefully and outputs its buffer.

protected runProcess(\Symfony\Component\Process\Process $command, \Symfony\Component\Console\Output\OutputInterface $output): int

The method MUST execute the provided command ensuring the output is channeled to the OutputInterface. It SHOULD leverage TTY if supported. If the process fails, it MUST return self::FAILURE; otherwise, it SHALL return self::SUCCESS.

Parameters:

Parameter Type Description
$command \Symfony\Component\Process\Process the configured process instance to run
$output \Symfony\Component\Console\Output\OutputInterface the output interface to log warnings or results

Return Value:

the status code of the command execution


getCurrentWorkingDirectory

Retrieves the current working directory of the application.

protected getCurrentWorkingDirectory(): string

The method MUST return the initial working directory defined by the application. If not available, it SHALL fall back to the safe current working directory.

Return Value:

the absolute path to the current working directory


getAbsolutePath

Computes the absolute path for a given relative or absolute path.

protected getAbsolutePath(string $relativePath): string

This method MUST return the exact path if it is already absolute. If relative, it SHALL make it absolute relying on the current working directory.

Parameters:

Parameter Type Description
$relativePath string the path to evaluate or resolve

Return Value:

the resolved absolute path


getConfigFile

Determines the correct absolute path to a configuration file.

protected getConfigFile(string $filename, bool $force = false): string

The method MUST attempt to resolve the configuration file locally in the working directory. If absent and not forced, it SHALL provide the default equivalent from the package itself.

Parameters:

Parameter Type Description
$filename string the name of the configuration file
$force bool determines whether to bypass fallback and forcefully return the local file path

Return Value:

the resolved absolute path to the configuration file


getDevToolsFile

Resolves the absolute path to a file within the fast-forward/dev-tools package.

protected getDevToolsFile(string $filename): string

This method uses Composer's InstalledVersions to determine the installation path of the fast-forward/dev-tools package and returns the absolute path to the given filename within it. It is used as a fallback when a configuration file is not found in the project root.

Parameters:

Parameter Type Description
$filename string the name of the file to resolve within the dev-tools package

Return Value:

the absolute path to the file inside the dev-tools package


runCommand

Configures and executes a registered console command by name.

protected runCommand(string $commandName, array|\Symfony\Component\Console\Input\InputInterface $input, \Symfony\Component\Console\Output\OutputInterface $output): int

The method MUST look up the command from the application and run it. It SHALL ignore generic validation errors and route the custom input and output correctly.

Parameters:

Parameter Type Description
$commandName string the name of the required command
$input array|\Symfony\Component\Console\Input\InputInterface the input arguments or array definition
$output \Symfony\Component\Console\Output\OutputInterface the interface for buffering output

Return Value:

the status code resulting from the dispatched command


getPsr4Namespaces

Retrieves configured PSR-4 namespaces from the composer configuration.

protected getPsr4Namespaces(): array

This method SHALL parse the underlying composer.json using the Composer instance, and MUST provide an empty array if no specific paths exist.

Return Value:

the PSR-4 namespaces mappings


getProjectName

Computes the human-readable title or description of the current application.

protected getProjectName(): string

The method SHOULD utilize the package description as the title, but MUST provide the raw package name as a fallback mechanism.

Return Value:

the computed title or description string


getProjectDescription

Computes the human-readable description of the current application.

protected getProjectDescription(): string

The method SHOULD utilize the package description as the title, but MUST provide the raw package name as a fallback mechanism.

Return Value:

the computed title or description string


Clone this wiki locally