Subscribe to PHP Freaks RSS

Matt Glaman: Running Drupal's PHPUnit test suites on DDEV

syndicated from www.phpdeveloper.org on October 15, 2018

Matt Glaman has a new post to his site where he walks you through the setup and execution of Drupal's unit tests in the DDEV platform (a Docker-based project that makes it easy to get an environment up quickly).

DDEV is a local development stack built on top of Docker. It gives you all of your environment needs without messy configured on your host machine, without needing to know Docker or configure your own containers. Which is great, and makes life easier. Instead of just using DDEV to develop your site or application locally, why not also run your tests within it?

I have had quite a few people ask me how I configure my setup for testing with Drupal’s PHPUnit test suites. [...] All of these are the same reasons for using a virtual machine or containerized local development stack. So, it is fitting we run our tests within these local stacks as well!

In this article, part one of three, he assumes you already have a DDEV environment up and running with a Drupal application running inside (there's a guide here). With that in place, he shows how to configure PHPUnit via the phpunit.xml file, changing the "SIMPLETEST_*" values for the localhost and local DB connections. He shows how to run the tests by SSHing into the web Docker container and pointing PHPUnit at the configuration file. The end result should look something like this in a terminal.