2020-04-27 21:53:27 +02:00
|
|
|
# Automated tests
|
|
|
|
|
|
|
|
The farmOS development Docker image comes pre-installed with all the
|
|
|
|
dependencies necessary for running automated tests via
|
|
|
|
[PHPUnit](https://phpunit.de).
|
|
|
|
|
|
|
|
The following command will run all automated tests provided by farmOS:
|
|
|
|
|
2020-11-27 03:46:15 +01:00
|
|
|
```sh
|
2021-01-08 12:34:56 +01:00
|
|
|
docker exec -it -u www-data farmos_www_1 phpunit --verbose --debug /opt/drupal/web/profiles/farm
|
2020-11-27 03:46:15 +01:00
|
|
|
```
|
2020-04-27 21:53:27 +02:00
|
|
|
|
|
|
|
Tests from other projects/dependencies can be run in a similar fashion. For
|
|
|
|
example, the following command will run all tests in the Log module:
|
|
|
|
|
2020-11-27 03:46:15 +01:00
|
|
|
```sh
|
2021-01-08 12:34:56 +01:00
|
|
|
docker exec -it -u www-data farmos_www_1 phpunit --verbose --debug /opt/drupal/web/modules/log
|
2020-11-27 03:46:15 +01:00
|
|
|
```
|
|
|
|
|
2021-09-18 18:03:50 +02:00
|
|
|
## Chrome/Selenium Container
|
2020-11-27 03:46:15 +01:00
|
|
|
|
2021-09-18 18:03:50 +02:00
|
|
|
The PHPUnit tests depend on having Chrome/Selenium available at port 4444 and hostname "chrome".
|
2020-11-27 03:46:15 +01:00
|
|
|
|
2021-09-18 18:03:50 +02:00
|
|
|
If using a docker-compose.yml based off [docker-compose.development.yml], this can be easily achieved
|
|
|
|
by adding the following container:
|
2020-11-27 03:46:15 +01:00
|
|
|
|
2021-09-18 18:03:50 +02:00
|
|
|
```yml
|
|
|
|
chrome:
|
2022-03-31 17:17:57 +02:00
|
|
|
# Tests are failing on later versions of this image.
|
|
|
|
# See https://github.com/farmOS/farmOS/issues/514
|
|
|
|
image: selenium/standalone-chrome:4.1.2-20220217
|
2021-09-18 18:03:50 +02:00
|
|
|
```
|
2020-11-27 03:46:15 +01:00
|
|
|
|
2021-09-18 18:03:50 +02:00
|
|
|
## Faster testing without XDebug
|
|
|
|
|
|
|
|
The instructions above will run tests with XDebug enabled which may be helpful
|
|
|
|
for [debugging](/development/environment/debug), but is also slower. XDebug can be disabled
|
|
|
|
by setting the `XDEBUG_MODE` environment variable to "off".
|
|
|
|
|
|
|
|
In a docker-compose.yml based off [docker-compose.development.yml], this might look like:
|
2020-11-27 03:46:15 +01:00
|
|
|
|
|
|
|
```yml
|
2021-09-18 18:03:50 +02:00
|
|
|
www:
|
|
|
|
...
|
|
|
|
environment:
|
|
|
|
...
|
|
|
|
XDEBUG_MODE: 'off'
|
2020-11-27 03:46:15 +01:00
|
|
|
```
|
|
|
|
|
2021-09-18 18:03:50 +02:00
|
|
|
The tests could then be run via `docker-compose exec` as follows:
|
2020-11-27 03:46:15 +01:00
|
|
|
|
|
|
|
```sh
|
2021-09-18 18:03:50 +02:00
|
|
|
docker-compose exec -u www-data -T www phpunit --verbose --debug /opt/drupal/web/profiles/farm
|
2020-11-27 03:46:15 +01:00
|
|
|
```
|
|
|
|
|
2021-09-18 18:03:50 +02:00
|
|
|
Alternatively, the `XDEBUG_MODE` environment variable can be specified directly:
|
2020-11-27 03:46:15 +01:00
|
|
|
|
2021-09-18 18:03:50 +02:00
|
|
|
```sh
|
|
|
|
docker-compose exec -u www-data -T --env XDEBUG_MODE=off www phpunit --verbose --debug /opt/drupal/web/profiles/farm
|
|
|
|
```
|
2020-11-27 03:46:15 +01:00
|
|
|
|
|
|
|
[run-tests.yml]: https://raw.githubusercontent.com/farmOS/farmOS/2.x/.github/workflows/run-tests.yml
|
|
|
|
[docker-compose.development.yml]: https://raw.githubusercontent.com/farmOS/farmOS/2.x/docker/docker-compose.development.yml
|