Automated tests
The farmOS development Docker image comes pre-installed with all the dependencies necessary for running automated tests via PHPUnit.
The following command will run all automated tests provided by farmOS:
docker exec -it farmos_www_1 phpunit /opt/drupal/web/profiles/farmTests from other projects/dependencies can be run in a similar fashion. For example, the following command will run all tests in the Log module:
docker exec -it farmos_www_1 phpunit /opt/drupal/web/modules/logChrome/Selenium Container
The PHPUnit tests depend on having Chrome/Selenium available at port 4444 and hostname "chrome".
If using a docker-compose.yml based off docker-compose.development.yml, this can be easily achieved by adding the following container:
chrome:
# Tests are failing on later versions of this image.
# See https://github.com/farmOS/farmOS/issues/514
image: selenium/standalone-chrome:4.1.2-20220217Faster testing without XDebug
The instructions above will run tests with XDebug enabled which may be helpful
for debugging, 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:
www:
...
environment:
...
XDEBUG_MODE: 'off'The tests could then be run via docker compose exec as follows:
docker compose exec -T www phpunit /opt/drupal/web/profiles/farmAlternatively, the XDEBUG_MODE environment variable can be specified directly:
docker compose exec -T --env XDEBUG_MODE=off www phpunit /opt/drupal/web/profiles/farm