In the PHP settings section of the plugin builder, you can choose to enable PHP unit tests and/ or WordPress integration tests.
Both types of tests use phpunit. Learn more about setting up PHP options here.
Automated tests, which can be run locally and using Github actions, help make sure our code keeps working, as expected. They are also excellent tools for speeding up development.
Using The Automated Tests
There are two types of tests you might have added “unit” and “WordPress”. The phpunit polyfills package by Yoast will be installed for both test types.
Writing And Running Unit Tests
Before running the tests, you will need to run “composer install”. The README of your plugin will include the command to run these types of tests.
The unit tests will be located in the directory “tests/Unit”. You will find some example tests there. These tests do not have WordPress, you will see examples of how to use Brain Monkey for mocking.
Writing And Running WordPress Tests
The WordPress integration tests will be located in the directory “tests/Integration”. You will find some example tests there. When you enable these tests, the generated docker-compose file will have a container for running these tests. Starting this container installs WordPress, the WordPress test suite with a dedicated MySQL database. The README of your plugin will include the command to enter the container, and once inside, the one command to run the tests.
There is no additional setup needed.