Running checks & tests
Most code checks and tests can be run via Composer commands.
Table of Contents:
Composer scripts
For most development-related tasks, this extension provides Composer scripts.
If you are working locally (Composer needs to be installed on your local
machine), you can run them using composer <scriptname>
.
You can run composer
or ./
to
display a list of all available Composer commands and scripts. For all custom
Composer scripts there are descriptions in the script-
section of
the composer.
.
If you have problems with missing dependencies on your local machine, it is
recommended to execute tests with the usage of the run
script.
Example: ./
It is not necessary to executing the tests only with the composer scripts.
You can also use the run
. This makes your life easier because you
don't have to worry about local dependencies.
Note
It's always a good idea to look into the run
"Examples" section to
get an idea how it works. In the "Options" section you can find all
available options.
Running code checks
You can currently run these code checks on the command line:
composer ci:composer:normalize
Checks the composer.json.
composer ci:json:lint
Lints the JSON files.
composer ci:php
Runs all static checks for the PHP files.
composer ci:php:cs-fixer
Checks the code style with the PHP Coding Standards Fixer (PHP-CS-Fixer).
composer ci:php:lint
Lints the PHP files for syntax errors.
composer ci:php:stan
Checks the PHP types using PHPStan.
composer ci:static
Runs all static code checks (syntax, style, types).
composer ci:typoscript:lint
Lints the TypoScript files.
composer ci:yaml:lint
Lints the YAML files.
composer fix
Runs all fixers (except for the ones that need JavaScript).
composer fix:php
Runs all fixers for the PHP code.
composer fix:php:cs
Fixes the code style with PHP-CS-Fixer.
composer phpstan:baseline
Updates the PHPStan baseline file to match the code.
Running unit and functional tests
Note
Executing tests on Windows via run
should be done within the
[Windows Subsystem for Linux (WSL 2)](https://en.wikipedia.org/wiki/Windows_Subsystem_for_Linux).
Important
Before running any commands you need to install all dependencies with
run
You can currently run these tests and coverages on the command line:
composer ci:coverage
Runs the ci:coverage script as defined in composer.json.
composer ci:coverage:functional
Generates the code coverage report for functional tests.
composer ci:coverage:merge
Merges the code coverage reports for unit and functional tests.
composer ci:coverage:unit
Generates the code coverage report for unit tests.
composer ci:tests:functional
Runs the functional tests.
On executing functional tests a database connection is needed. Therefore you
should execute functional tests directly with the command in the run
.
Otherwise you have to take care of the database connection by yourself.
Example: ./
composer ci:tests:unit
Runs the unit tests.
Running unit and functional tests in PHPStorm
General setup
- Open File > Settings > PHP > Test Frameworks.
- (*) Use Composer autoloader.
- Path to script: select
.Build/
in your project folder.vendor/ autoload. php
In the Run configurations, edit the PHPUnit configuration and use these settings so this configuration can serve as a template:
- Directory: use the
Tests/
directory in your project.Unit - (*) Use alternative configuration file.
- Use
.Build/
in your project folder.vendor/ typo3/ testing- framework/ Resources/ Core/ Build/ Unit Tests. xml -
Add the following environment variables:
- typo3DatabaseUsername
- typo3DatabasePassword
- typo3DatabaseHost
- typo3DatabaseName
Unit tests configuration
In the Run configurations, copy the PHPUnit configuration and use these settings:
- Directory: use the
Tests/
directory in your projectUnit
Functional tests configuration
In the Run configurations, copy the PHPUnit configuration and use these settings:
- Directory: use the
Tests/
directory in your project.Functional - (*) Use alternative configuration file.
- Use
.Build/
.vendor/ typo3/ testing- framework/ Resources/ Core/ Build/ Functional Tests. xml