Skip to main content

Magento, Docker, PHPUnit

This blog post might be outdated!
This blog post was published more than one year ago and might be outdated!
· One min read
Stephan Hochdörfer
Head of IT Business Operations

As I have written before, we are big fans of Mark Shust's Docker Configuration for Magento project. It comes with quite some useful tools installed out of the box. However, I was missing one: Being able to run PHPUnit from the host environment.

To solve this problem, I added a shell script called bin/phpunit to our code repository that looks like this:

#!/bin/bash
bin/cli /var/www/html/vendor/bin/phpunit -c /var/www/html/dev/tests/unit/phpunit.xml.dist /var/www/html/app/code/

Next up I needed to make the bash script executable:

chmod +x bin/phpunit

Now I can invoke phpunit from the host by running the following command:

./bin/phpunit