Eunit is a php library to make WordPress PHPUnit less painful. Eunit is a collection of Test cases, common WordPress test helpers, and a few DB helpers to make the developer's life a little easier.
Getting started with Eunit is simple and quick, just make sure you follow this guide.
To install Eunit, via composer run the command below, and you will get the latest version
composer require --dev elementor/eunitthen you need to do is make sure to include composer autoloader in your PHPUnit bootstrap.php
// Require composer dependencies.
// Pending on your vendor directory
require_once dirname( dirname( __FILE__ ) ) . '/vendor/autoload.php';You can also install Eunit via git,
git clone https://github.com/elementor/eunit.gitThen you need to do is make sure to include Eunit instance in your PHPUnit bootstrap.php
// Require eunit.php
// Pending on your directory structure
require_once dirname( dirname( __FILE__ ) ) . '/eunit/eunit.php';
\Eunit\Eunit::instance();Before actually using Eunit you need to add a few environment variables to you PHPUnit runtime which can be done be editing your phpunit.xml in the element.
EUNIT_TEST_CASE_NAMESPACE should be set to the plugin main namespace
<php>
<env name="EUNIT_TEST_CASE_NAMESPACE" value="YourMainNamespace">
</php>All that is left is to start using Eunit, head over to the Docs to learn more.