Toolkit

TestsCommands extends AbstractCommands
in package

Class TestsCommands.

Tags
SuppressWarnings

(PHPMD.CouplingBetweenObjects)

Table of Contents

Methods

getConfigurationFile()  : string
Path to YAML configuration file containing command defaults.
getJson()  : array<string|int, mixed>
Returns the JSON parsed content.
getWorkingDir()  : string
Returns the current working directory.
isWebsiteInstalled()  : bool
Check if the website is installed.
toolkitCheckPhpcsRequirements()  : mixed
Make sure that the config file exists and configuration is correct.
toolkitRunPhpcbf()  : mixed
Run PHP code autofixing.
toolkitSetupPhpcs()  : void
Setup PHP code sniffer.
toolkitTestBehat()  : int|ResultData
Run Behat tests.
toolkitTestPhpcs()  : int|ResultData
Run PHP code sniffer.
toolkitTestPhpmd()  : int
Run PHPMD.
toolkitTestPhpstan()  : CollectionBuilder
Run PHPStan.
toolkitTestPhpunit()  : CollectionBuilder
Run PHPUnit tests.
getBin()  : string
Validate and return the path to given bin.
getBinPath()  : string
Return the path to given bin.
getConfigValue()  : mixed|null
Return the configuration value.
getNodeBin()  : string
Validate and return the path to given bin from node packages.
getNodeBinPath()  : string
Return the path to given bin from node packages.
isJunit()  : bool
Check whether Junit option is being used, or env var is set.
isSimulating()  : bool
Check if current command is being executed with option simulate.
taskExecute()  : CollectionBuilder
Execute a command.
taskProcess()  : ReplaceBlock|CollectionBuilder
Process the file.
taskReplaceBlock()  : ReplaceBlock|CollectionBuilder
Replace block in a file.
toolkitRunGrumphp()  : int|ResultData
Run PHP code sniffer within GrumPHP.
toolkitRunPhpcs()  : Result
Run PHP code sniffer.
toolkitTestPhpunitParallelTask()  : ParallelExec
Returns the task to execute PHPUnit in parallel.

Methods

getConfigurationFile()

Path to YAML configuration file containing command defaults.

public getConfigurationFile() : string
Return values
string

Configuration file path.

getJson()

Returns the JSON parsed content.

public getJson(string $filename[, bool $throwException = true ]) : array<string|int, mixed>
Parameters
$filename : string
$throwException : bool = true

If the file is not found.

Return values
array<string|int, mixed>

Json parsed content.

getWorkingDir()

Returns the current working directory.

public getWorkingDir() : string
Return values
string

The current working directory.

isWebsiteInstalled()

Check if the website is installed.

public isWebsiteInstalled() : bool
Return values
bool

toolkitCheckPhpcsRequirements()

Make sure that the config file exists and configuration is correct.

public toolkitCheckPhpcsRequirements() : mixed
Tags
command

toolkit:check-phpcs-requirements

Return values
mixed

The status if exists config file.

toolkitRunPhpcbf()

Run PHP code autofixing.

public toolkitRunPhpcbf() : mixed
Tags
command

toolkit:run-phpcbf

aliases

tk-phpcbf

Return values
mixed

The run phpcbf code autofixing.

toolkitSetupPhpcs()

Setup PHP code sniffer.

public toolkitSetupPhpcs() : void

Check configurations at config/default.yml - 'toolkit.test.phpcs'.

Tags
command

toolkit:setup-phpcs

SuppressWarnings

(PHPMD.CyclomaticComplexity)

SuppressWarnings

(PHPMD.NPathComplexity)

Return values
void

The toolkit setup check configuration status.

toolkitTestBehat()

Run Behat tests.

public toolkitTestBehat([array<string|int, mixed> $options = ['from' => InputOption::VALUE_OPTIONAL, 'to' => InputOption::VALUE_OPTIONAL, 'profile' => InputOption::VALUE_OPTIONAL, 'suite' => InputOption::VALUE_OPTIONAL, 'options' => InputOption::VALUE_OPTIONAL] ]) : int|ResultData

Check configurations at config/default.yml - 'toolkit.test.behat'. Accept commands to run before and/or after the Behat tests.

Parameters
$options : array<string|int, mixed> = ['from' => InputOption::VALUE_OPTIONAL, 'to' => InputOption::VALUE_OPTIONAL, 'profile' => InputOption::VALUE_OPTIONAL, 'suite' => InputOption::VALUE_OPTIONAL, 'options' => InputOption::VALUE_OPTIONAL]

Command options.

Tags
command

toolkit:test-behat

option

from The dist config file (behat.yml.dist).

option

to The destination config file (behat.yml).

option

profile The profile to execute.

option

suite The suite to execute, default runs all suites of profile.

option

options Extra options for the command without -- (only options with no value).

option

junit Whether to export results as junit.

aliases

tk-behat, tb

usage

--profile='prod' --options='strict stop-on-failure'

SuppressWarnings

(PHPMD.NPathComplexity)

SuppressWarnings

(PHPMD.CyclomaticComplexity)

Return values
int|ResultData

The check toolkit test behat status.

toolkitTestPhpcs()

Run PHP code sniffer.

public toolkitTestPhpcs() : int|ResultData
Tags
command

toolkit:test-phpcs

option

junit Whether to export results as junit.

aliases

tk-phpcs

see
toolkitRunPhpcs()
Return values
int|ResultData

The toolkit run phpcs task status.

toolkitTestPhpmd()

Run PHPMD.

public toolkitTestPhpmd(ConsoleIO $io[, array<string|int, mixed> $options = ['config' => InputOption::VALUE_REQUIRED, 'format' => InputOption::VALUE_REQUIRED, 'ignore_patterns' => InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'triggered_by' => InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'files' => InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY] ]) : int

Check configurations at config/default.yml - 'toolkit.test.phpmd'.

Parameters
$io : ConsoleIO
$options : array<string|int, mixed> = ['config' => InputOption::VALUE_REQUIRED, 'format' => InputOption::VALUE_REQUIRED, 'ignore_patterns' => InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'triggered_by' => InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'files' => InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY]

Command options.

Tags
command

toolkit:test-phpmd

option

config The config file.

option

format The format to use.

option

ignore_patterns An array with ignore patterns.

option

triggered_by An array with extensions to check.

option

files An array with paths to check.

option

junit Whether to export results as junit.

aliases

tk-phpmd

SuppressWarnings

(PHPMD.CyclomaticComplexity)

Return values
int

The toolkit phpmd task status.

toolkitTestPhpstan()

Run PHPStan.

public toolkitTestPhpstan([array<string|int, mixed> $options = ['config' => InputOption::VALUE_REQUIRED, 'level' => InputOption::VALUE_REQUIRED, 'files' => InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'memory-limit' => InputOption::VALUE_OPTIONAL, 'options' => InputOption::VALUE_OPTIONAL] ]) : CollectionBuilder

Check configurations at config/default.yml - 'toolkit.test.phpstan'.

Parameters
$options : array<string|int, mixed> = ['config' => InputOption::VALUE_REQUIRED, 'level' => InputOption::VALUE_REQUIRED, 'files' => InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'memory-limit' => InputOption::VALUE_OPTIONAL, 'options' => InputOption::VALUE_OPTIONAL]

Command options.

Tags
command

toolkit:test-phpstan

option

config The path to the config file.

option

level The level of rule options.

option

files The files to check.

option

memory-limit The PHP memory limit.

option

options Extra options for the command without -- (only options with no value).

option

junit Whether to export results as junit.

aliases

tk-phpstan

usage

--memory-limit='4G' --options='debug'

Return values
CollectionBuilder

The toolkit test phpstan task status.

toolkitTestPhpunit()

Run PHPUnit tests.

public toolkitTestPhpunit([array<string|int, mixed> $options = ['execution' => InputOption::VALUE_REQUIRED, 'from' => InputOption::VALUE_REQUIRED, 'to' => InputOption::VALUE_REQUIRED, 'testsuite' => InputOption::VALUE_REQUIRED, 'group' => InputOption::VALUE_REQUIRED, 'covers' => InputOption::VALUE_REQUIRED, 'uses' => InputOption::VALUE_REQUIRED, 'filter' => InputOption::VALUE_REQUIRED, 'options' => InputOption::VALUE_REQUIRED, 'printer' => InputOption::VALUE_NONE] ]) : CollectionBuilder

Check configurations at config/default.yml - 'toolkit.test.phpunit'. Accept commands to run before and/or after the PHPUnit tests.

Parameters
$options : array<string|int, mixed> = ['execution' => InputOption::VALUE_REQUIRED, 'from' => InputOption::VALUE_REQUIRED, 'to' => InputOption::VALUE_REQUIRED, 'testsuite' => InputOption::VALUE_REQUIRED, 'group' => InputOption::VALUE_REQUIRED, 'covers' => InputOption::VALUE_REQUIRED, 'uses' => InputOption::VALUE_REQUIRED, 'filter' => InputOption::VALUE_REQUIRED, 'options' => InputOption::VALUE_REQUIRED, 'printer' => InputOption::VALUE_NONE]

Command options.

Tags
command

toolkit:test-phpunit

option

execution The execution type (default or parallel).

option

from The dist config file (phpunit.xml.dist).

option

to The destination config file (phpunit.xml).

option

testsuite Filter which testsuite to run.

option

group Only runs tests from the specified group(s).

option

covers Only runs tests annotated with "@covers ".

option

uses Only runs tests annotated with "@uses ".

option

filter Filter which tests to run.

option

options Extra options for the command without -- (only options with no value).

option

printer If set, use printer defined in config toolkit.test.phpunit.printer.

option

junit Whether to export results as junit.

aliases

tk-phpunit tp

usage

--options='stop-on-error process-isolation do-not-cache-result'

usage

--group=Example

SuppressWarnings

(PHPMD.CyclomaticComplexity)

SuppressWarnings

(PHPMD.NPathComplexity)

Return values
CollectionBuilder

The toolkit phpunit task status.

getBin()

Validate and return the path to given bin.

protected getBin(string $name) : string
Parameters
$name : string

The bin to look for.

Tags
throws
TaskException
Return values
string

The bin path.

getBinPath()

Return the path to given bin.

protected getBinPath(string $name) : string
Parameters
$name : string
Return values
string

The path to given binary.

getConfigValue()

Return the configuration value.

protected getConfigValue(string $key[, mixed|null $default = null ]) : mixed|null
Parameters
$key : string

The config item to look up.

$default : mixed|null = null

Default configuration value for the key item if neither has value nor exists.

Return values
mixed|null

The configuration value.

getNodeBin()

Validate and return the path to given bin from node packages.

protected getNodeBin(string $name) : string
Parameters
$name : string

The bin to look for.

Tags
throws
TaskException
Return values
string

The bin path.

getNodeBinPath()

Return the path to given bin from node packages.

protected getNodeBinPath(string $name) : string
Parameters
$name : string
Return values
string

The path to given binary.

isJunit()

Check whether Junit option is being used, or env var is set.

protected isJunit() : bool
Return values
bool

isSimulating()

Check if current command is being executed with option simulate.

protected isSimulating() : bool
Return values
bool

True if using --simulate, false otherwise.

taskExecute()

Execute a command.

protected taskExecute(array<string|int, string> $tasks) : CollectionBuilder
Parameters
$tasks : array<string|int, string>

An array with tasks to execute.

Return values
CollectionBuilder

The task executed.

taskProcess()

Process the file.

protected taskProcess(string $source[, string $destination = '' ]) : ReplaceBlock|CollectionBuilder
Parameters
$source : string

The source file to process.

$destination : string = ''

The destination file.

Return values
ReplaceBlock|CollectionBuilder

The file task processed.

taskReplaceBlock()

Replace block in a file.

protected taskReplaceBlock([string $filename = '' ]) : ReplaceBlock|CollectionBuilder
Parameters
$filename : string = ''

The file to process.

Return values
ReplaceBlock|CollectionBuilder

The file replaced.

toolkitRunGrumphp()

Run PHP code sniffer within GrumPHP.

protected toolkitRunGrumphp() : int|ResultData
Tags
throws
TaskException
Return values
int|ResultData

The toolkit run grumphp task status.

toolkitRunPhpcs()

Run PHP code sniffer.

protected toolkitRunPhpcs() : Result

Check configurations at config/default.yml - 'toolkit.test.phpcs'.

Return values
Result

The toolkit run phpcs code sniffer.

toolkitTestPhpunitParallelTask()

Returns the task to execute PHPUnit in parallel.

private toolkitTestPhpunitParallelTask(array<string|int, mixed> $options) : ParallelExec
Parameters
$options : array<string|int, mixed>

Command options.

Return values
ParallelExec

Task to execute PHPUnit in parallel.


        
On this page

Search results