wp-media / phpunit
PHPUnit extender for bootstrapping unit and WordPress integration test suites.
Installs: 90 866
Dependents: 62
Suggesters: 0
Security: 0
Stars: 4
Watchers: 15
Forks: 1
Open Issues: 4
Requires
- php: ^7 || ^8
- mikey179/vfsstream: ^1.6
- yoast/wp-test-utils: ^1.0.0
README
This reusable package bootstraps our PHPUnit unit and integration tests. It includes:
- bootstrapping for both Unit and Integration tests
phpunit.xml.dist
for each test suiteTestCase
for each test suite- Common polyfill functions
This means your repo only needs its tests. w00t!
Configuring Composer in Your Repo
In your repo's composer.json
file, add the following "require-dev"
dependency:
"wp-media/phpunit": "^2.0"
Custom Bootstrapping Your Repo
Sometimes you need a custom bootstrapping solution in your repo, such as loading a factory, handling licensing, etc. Here are the steps to get you rolling:
- Add a
bootstrap.php
file inUnit
orIntegration
directory. - In your
Tests/Integration/bootstrap.php
file, add the following code to it:
tests_add_filter( 'muplugins_loaded', function() { // Do your bootstrapping work here. } );
Custom Test Case
When you need to customize the test case, extend off of the base test cases in this package:
- For a custom integration, extend off of
WPMedia\PHPUnit\Integration\TestCase
. - For a custom unit, extend off of
WPMedia\PHPUnit\Unit\TestCase
.