Facilitates the execution of the PHPUnit testing framework.
Description
This class MUST NOT be overridden and SHALL configure testing parameters dynamically.
'tests'
'Runs PHPUnit tests.'
'This command runs PHPUnit to execute your tests.'
Constants
Properties
Methods
Constructs a new AbstractCommand instance.
Configures the testing command input constraints.
Triggers the PHPUnit engine based on resolved paths and settings.
Computes the absolute path for a given relative or absolute path.
Determines the correct absolute path to a configuration file.
Retrieves the current working directory of the application.
Resolves the absolute path to a file within the fast-forward/dev-tools package.
Configures and executes a registered console command by name.
Executes a given system process gracefully and outputs its buffer.
Safely constructs an absolute path tied to a defined capability option.
protected
Filesystem
$filesystem
private
ComposerJson
$composerJson
private
CoverageSummaryLoaderInterface
$coverageSummaryLoader
Constructs a new AbstractCommand instance.
public
__construct(CoverageSummaryLoaderInterface
$coverageSummaryLoader, ComposerJson
$composerJson, Filesystem
$filesystem) : mixed
Parameters
Description
the loader used for coverage-php summaries
Description
the composer.json reader for autoload information
$filesystem
:
Filesystem
Description
the filesystem utility used for path resolution
Configures the testing command input constraints.
protected
configure() : void
Description
The method MUST specify valid arguments for testing paths, caching directories, bootstrap scripts, and coverage instructions. It SHALL align with robust testing standards.
Triggers the PHPUnit engine based on resolved paths and settings.
protected
execute(InputInterface
$input, OutputInterface
$output) : int
Description
The method MUST assemble the necessary commands to initiate PHPUnit securely. It SHOULD optionally construct advanced configuration arguments such as caching and coverage.
Parameters
$input
:
InputInterface
Description
the runtime instruction set from the CLI
$output
:
OutputInterface
Description
the console feedback relay
Return values
Description
the status integer describing the termination code
Computes the absolute path for a given relative or absolute path.
protected
getAbsolutePath(
string
$relativePath) : string
Description
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
$relativePath
:
string
Description
the path to evaluate or resolve
Return values
Description
the resolved absolute path
Determines the correct absolute path to a configuration file.
protected
getConfigFile(
string
$filename[,
bool
$force = false]) : string
Description
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
$filename
:
string
Description
the name of the configuration file
$force
:
bool
=
false
Description
determines whether to bypass fallback and forcefully return the local file path
Return values
Description
the resolved absolute path to the configuration file
Retrieves the current working directory of the application.
protected
getCurrentWorkingDirectory() : string
Description
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 values
Description
the absolute path to the current working directory
Resolves the absolute path to a file within the fast-forward/dev-tools package.
protected
getDevToolsFile(
string
$filename) : string
Description
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
$filename
:
string
Description
the name of the file to resolve within the dev-tools package
Return values
Description
the absolute path to the file inside the dev-tools package
Configures and executes a registered console command by name.
protected
runCommand(
string
$command, OutputInterface
$output) : int
Description
The method MUST run the specified command with the provided input and output interfaces.
Parameters
$command
:
string
Description
the commandline name of the command to execute
$output
:
OutputInterface
Description
the interface for buffering output
Return values
Description
the status code resulting from the dispatched command
Executes a given system process gracefully and outputs its buffer.
protected
runProcess(Process
$command, OutputInterface
$output[,
bool
$tty = true]) : int
Description
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
$command
:
Process
Description
the configured process instance to run
$output
:
OutputInterface
Description
the output interface to log warnings or results
$tty
:
bool
=
true
Return values
Description
the status code of the command execution
private
configureCoverageArguments(InputInterface
$input,
array<int, string>
&$arguments,
bool
$requiresCoverageReport) : string|null
Parameters
$input
:
InputInterface
Description
the raw parameter definitions
$arguments
:
array<int, string>
Description
the mutable argument list for the PHPUnit process
$requiresCoverageReport
:
bool
Description
indicates whether a coverage-php report is required
Return values
Description
the absolute path to the generated coverage-php report
private
resolveMinimumCoverage(InputInterface
$input) : float|null
Parameters
$input
:
InputInterface
Description
the raw parameter definitions
Return values
Description
the validated minimum coverage percentage, if configured
Safely constructs an absolute path tied to a defined capability option.
private
resolvePath(InputInterface
$input,
string
$option) : string
Description
The method MUST compute absolute properties based on the supplied input parameters. It SHALL strictly return a securely bounded path string.
Parameters
$input
:
InputInterface
Description
the raw parameter definitions
$option
:
string
Description
the requested option key to resolve
Return values
Description
validated absolute path string
private
validateMinimumCoverage(
string
$coverageReportPath,
float
$minimumCoverage, OutputInterface
$output) : int
Parameters
$coverageReportPath
:
string
Description
the generated coverage-php report path
$minimumCoverage
:
float
Description
the required line coverage percentage
$output
:
OutputInterface
Description
the output interface to log validation results
Return values
Description
the final status code after validating minimum coverage