This project purpose is so developers who need quick access to Unit testing tools in Drupal 9, can have an approach to easily do so using Lando.
It is worth mentioning that this little project presumes default Lando configuration is in place, extra work might be done to adapt this repo to some local setups.
To start on a fresh Vanilla Drupal 9 site. Do the following:
- Create a Drupal 9 project locally and clone this repo files into your project root:
composer create-project drupal/recommended-project d9phpunit
cd d9phpunit
git clone git@github.com:fourkitchens/lando-d9phpunit.git
mv lando-d9phpunit/.* .
mv lando-d9phpunit/* .
rm -rf lando-d9phpunit
You should end up with the files found in this repo at the root of your project.
- With composer, install development tools:
composer require drupal/core-dev --dev --with-all-dependencies && composer require --dev phpspec/prophecy-phpunit
- Make directories for browser output, which will help debug Functional tests:
mkdir web/sites/simpletest && mkdir web/sites/simpletest/browser_output
- Run
lando start
to get your local environment setup and running. - Start testing with
lando test
, (e.g.lando test --verbose --debug --stop-on-failure web/core/modules/color/tests/src/Functional/ColorConfigSchemaTest.php
)
- If deprecations are getting in your way, uncomment the
phpunit.xml
env varSYMFONY_DEPRECATIONS_HELPER
which is set todisabled
.
This was based on this very cool article: https://agile.coop/blog/drupal-phpunit-tests-lando/.