Setting up Drupal test framework for docker4drupal site

Deeps
Jun 24, 2021

In this post, I’ll show how I configured test framework for local development using Docker 4 Drupal.

  1. Go to web/core and copy phpunit.xml.dist to phpunit.xml
cp phpunit.xml.dist phpunit.xml

2. Open phpunit.xml and update to values following

<env name="SIMPLETEST_BASE_URL" value="http://nginx"/><env name="SIMPLETEST_DB" value="mysql://drupal:drupal@mariadb/drupal"/><env name="BROWSERTEST_OUTPUT_DIRECTORY" value="/var/www/html/drupal/web/sites/simpletest/browser_output"/><env name="BROWSERTEST_OUTPUT_BASE_URL" value="http://drupal.docker.localhost:8000"/>

3. Now create a directory inside sites folder called /simpletest/browser_output and give write permission to that directory.

mkdir -p sites/simpletest/browser_outputchmod 777 sites/simpletest/browser_output

That’s it.

Run following command from side docker to see if the configuration is working correctly. Go to web folder first.

../vendor/bin/phpunit -c core core/modules/node/tests/src/Functional/NodeAccessFieldTest.php

Output

--

--