Download the PHP package alleyinteractive/pest-plugin-wordpress without Composer
On this page you can find all versions of the php package alleyinteractive/pest-plugin-wordpress. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package pest-plugin-wordpress
WordPress Pest Plugin
Supports integrating Pest with your WordPress code base through the Mantle Framework. Read about the Mantle Testing Framework here.
- WordPress Pest Plugin
- Overview
- Getting Started
- Setting up Pest
- Replacing the Pest Test Case
- Using With the Mantle Framework
- Writing Tests
If you want to start testing your application with Pest, visit the main Pest Repository.
Pest was created by Nuno Maduro under the Sponsorware license. It got open-sourced and is now licensed under the MIT license.
Overview
The WordPress Pest Plugin allows WordPress to be tested using the Pest testing framework. Tests can be written in a very simple manner to 'bring the joy of testing to PHP'.
Getting Started
The WordPress Pest Plugin does not require the Mantle Framework to be used on your site (though having the framework greatly enhances your ability to use Pest).
Install the WordPress plugin via the Composer package manager:
Setting up Pest
Note: if you are using the Mantle Framework, skip ahead to Using With the Mantle Framework.
Let's get started integrating your project with Mantle and Pest. This guide assumes that your project is placed inside an existing WordPress installation as a plugin or a theme. Read more information about setting up the test framework here.
The default configuration will install WordPress using a
localhost
database namedwordpress_unit_tests
with the username/password pair ofroot
/root
. All constants can be overridden using thewp-tests-config.php
file or your unit test's bootstrap file.
Assuming you do not have Pest setup in your project, create a tests
folder and
run the pest --init
command:
Replacing the Pest Test Case
Open up the tests/Pest.php
file in your project the above command created for you. Look for a line that looks like this:
Replace that with the following:
Mantle also uses
composer-wordpress-autoloader
so you will need to load vendor/wordpress-autoload.php
instead of just
vendor/autoload.php
.
Finally, you can run Pest directly from the command line:
You can now use the Mantle Testing Framework with Pest to test your WordPress plugin with ease and simplicity. Your IDE will be able to type-hint you as well to allow you to use the testing framework.
Using with the Mantle Framework
Requiring the WordPress Pest Plugin on an existing Mantle project will allow you to install Pest with a few commands.
Install the WordPress plugin via the Composer package manager and run the mantle pest:install
WP-CLI command:
That's it! Pest is installed successfully on your Mantle project. You can run your pest tests through Pest now:
Mantle can also generate a Pest-friendly test by running the pest:test
WP-CLI command:
Writing Tests
More information can be found on the Testing Framework page.
All versions of pest-plugin-wordpress with dependencies
mantle-framework/testkit Version ^1.0
pestphp/pest-plugin Version ^2.0.1
pestphp/pest Version ^2.5
symfony/var-dumper Version ^6.4