Running checks & tests 

Most code checks and tests can be run via Composer commands.

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 ./Build/Scripts/runTests.sh -s composer to display a list of all available Composer commands and scripts. For all custom Composer scripts there are descriptions in the script-description section of the composer.json.

If you have problems with missing dependencies on your local machine, it is recommended to execute tests with the usage of the runTests.sh script.

./Build/Scripts/runTests.sh -s composer check:php:lint
Copied!

This makes your life easier because you don't have to worry about local dependencies.

Running code checks 

You can currently run these code checks on the command line:

./Build/Scripts/runTests.sh -s composer check:composer:normalize
Copied!

Checks the composer.json.

./Build/Scripts/runTests.sh -s composer check:json:lint
Copied!

Lints the JSON files.

./Build/Scripts/runTests.sh -s composer check:php
Copied!

Runs all static checks for the PHP files.

./Build/Scripts/runTests.sh -s composer check:php:cs-fixer
Copied!

Checks the code style with the PHP Coding Standards Fixer (PHP-CS-Fixer).

./Build/Scripts/runTests.sh -s composer check:php:lint
Copied!

Lints the PHP files for syntax errors.

./Build/Scripts/runTests.sh -s composer check:php:stan
Copied!

Checks the PHP types using PHPStan.

./Build/Scripts/runTests.sh -s composer check:static
Copied!

Runs all static code checks (syntax, style, types).

./Build/Scripts/runTests.sh -scomposer check:typoscript:lint
Copied!

Lints the TypoScript files.

./Build/Scripts/runTests.sh -s composer check:yaml:lint
Copied!

Lints the YAML files.

./Build/Scripts/runTests.sh -s composer fix
Copied!

Runs all fixers (except for the ones that need JavaScript).

./Build/Scripts/runTests.sh -s composer fix:php
Copied!

Runs all fixers for the PHP code.

./Build/Scripts/runTests.sh -s composer fix:php:cs
Copied!

Fixes the code style with PHP-CS-Fixer.

./Build/Scripts/runTests.sh -s composer phpstan:baseline
Copied!

Updates the PHPStan baseline file to match the code.

Running unit and functional tests 

./Build/Scripts/runTests.sh -s composer update
Copied!

You can currently run these tests on the command line:

./Build/Scripts/runTests.sh -s functional
Copied!

Runs the functional tests using a database populated from the CSV files in Tests/Functional/Controller/Fixtures/Database folder.

./Build/Scripts/runTests.sh -s unit
Copied!

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/vendor/autoload.php in your project folder.

In the Run configurations, edit the PHPUnit configuration and use these settings so this configuration can serve as a template:

  • Directory: use the Tests/Unit directory in your project.
  • (*) Use alternative configuration file.
  • Use .Build/vendor/typo3/testing-framework/Resources/Core/Build/UnitTests.xml in your project folder.
  • 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/Unit directory in your project

Functional tests configuration 

In the Run configurations, copy the PHPUnit configuration and use these settings:

  • Directory: use the Tests/Functional directory in your project.
  • (*) Use alternative configuration file.
  • Use .Build/vendor/typo3/testing-framework/Resources/Core/Build/FunctionalTests.xml.