mirror of https://github.com/FriendsOfTYPO3/tea.git synced 2024-12-22 20:26:11 +01:00
tea/Documentation/Running.rst
Eike Starkmann 8605fe303b
[FEATURE] One command to fix them all (#1409)
* [FEATURE] One command to fix them all

Fixes #1386

* Add help text for the `fix` command

* Include `composer normalize` in the `fix` command

* Document the new `fix` Composer script in the manual

---------

Co-authored-by: Oliver Klee <typo3-coding@oliverklee.de>
2024-11-25 12:52:00 +01:00

5.6 KiB

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, you can run them using composer <scriptname>.

The code-quality-related Composer scripts make use of the PHIVE-installed tools.

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.

Running code checks

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

Commands; composer ci:composer:normalize

composer ci:composer:normalize

Checks the composer.json.

Commands; composer ci:json:lint

composer ci:json:lint

Lints the JSON files.

Commands; composer ci:php

composer ci:php

Runs all static checks for the PHP files.

Commands; composer ci:php:cs-fixer

composer ci:php:cs-fixer

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

Commands; composer ci:php:lint

composer ci:php:lint

Lints the PHP files for syntax errors.

Commands; composer ci:php:sniff

composer ci:php:sniff

Checks the code style with PHP_CodeSniffer (PHPCS).

Commands; composer ci:php:stan

composer ci:php:stan

Checks the PHP types using PHPStan.

Commands; composer ci:static

composer ci:static

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

Commands; composer ci:typoscript:lint

composer ci:typoscript:lint

Lints the TypoScript files.

Commands; composer ci:yaml:lint

composer ci:yaml:lint

Lints the YAML files.

Commands; composer fix

composer fix

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

Commands; composer fix:php

composer fix:php

Runs all fixers for the PHP code.

Commands; composer fix:php:cs

composer fix:php:cs

Fixes the code style with PHP-CS-Fixer.

Commands; composer fix:php:sniff

composer fix:php:sniff

Fixes the code style with PHP_CodeSniffer.

Commands; composer phpstan:baseline

composer phpstan:baseline

Updates the PHPStan baseline file to match the code.

Running unit and functional tests

Note

Executing tests on Windows via runTests.sh should be done within the [Windows Subsystem for Linux (WSL 2)](https://en.wikipedia.org/wiki/Windows_Subsystem_for_Linux). Before running any commands you need to install all dependencies with

runTests.sh -s composer install

You can currently run these tests and coverages on the command line:

Commands; composer ci:coverage

composer ci:coverage

Runs the ci:coverage script as defined in composer.json.

Commands; composer ci:coverage:functional

composer ci:coverage:functional

Generates the code coverage report for functional tests.

Commands; composer ci:coverage:merge

composer ci:coverage:merge

Merges the code coverage reports for unit and functional tests.

Commands; composer ci:coverage:unit

composer ci:coverage:unit

Generates the code coverage report for unit tests.

Commands; composer ci:tests:functional

composer ci:tests:functional

Runs the functional tests.

Commands; composer ci:tests:unit

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/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.