This document describes how to run and configure tests for this project.
This environment uses PHPUnit and includes the following types of tests as defined by Symfony:
- Application tests
- Integration tests
- Unit tests
To learn about our practical strategy for applying these tests efficiently in real-world projects, watch our video guide on YouTube: Robust Testing.
Note on naming: In Symfony's terminology, Application tests are the same as Functional tests. We follow the official Symfony naming convention as described here.
There are two main ways to run tests: using a single make command (recommended) or running them manually inside the Docker container (for advanced use/debugging).
This is the simplest way to run the entire test suite and generate a code coverage report. From your local shell, run:
make phpunitAfter the command finishes, you can open the code coverage report in your browser. The report is generated at: reports/coverage/index.html.
If you need to run a single test file, a specific directory, or a test suite (e.g., only "Unit" tests), you must do so from within the container's shell.
Step 1. Enter the Symfony container shell:
make sshStep 2. Run PHPUnit manually:
Once inside the container, you can execute phpunit directly.
- To run a single test class:
./vendor/bin/phpunit ./tests/Application/ApiKey/Transport/Controller/Api/V1/ApiKeyControllerTest.php- To run all tests in a directory:
./vendor/bin/phpunit ./tests/Application/ApiKey/Transport/Controller/Api/V2/- To run a specific test suite (e.g., Unit, as defined in phpunit.xml.dist):
./vendor/bin/phpunit --testsuite UnitBy default, tests run in an isolated environment using a separate database.
This environment is configured in the .env.test file. If you need to change the test database connection or other service settings for the test environment, you should edit this file.
You can run and debug tests directly from your IDE.
Please follow PhpStorm Setup Guide documentation to configure it.
Please note that this environment does not use the standard Symfony ./bin/phpunit command.
-
Use
make phpunitto run the full suite from your local machine. -
Use
./vendor/bin/phpunitto run specific tests from inside the container (make ssh).