wpstarter / wp-testbench
A tool to set up a WordPress test environment for PHPUnit testing
Installs: 1 198
Dependents: 1
Suggesters: 0
Security: 0
Stars: 3
Watchers: 1
Forks: 1
Open Issues: 0
Requires
- php: ^7.3|^8.0
- ext-json: *
- ext-mysqli: *
- ext-readline: *
This package is auto-updated.
Last update: 2024-12-05 08:01:34 UTC
README
WpTestbench is a tool used to set up a WordPress test environment for PHPUnit testing, in order to test your plugin.
Installation
Install testbench via composer
composer require wpstarter/wp-testbench --dev
Install WordPress
./vendor/bin/wp-testbench-install <db-name> <db-user> [db-pass] [db-host] [wp-version] [--skip-database-creation]
Update phpunit.xml
<phpunit
...
bootstrap="./vendor/wpstarter/wp-testbench/bootstrap.php"
>
...
<php>
<server name="WP_TESTBENCH_PLUGIN" value="your-plugin.php"/>
...
</php>
</phpunit>
Custom wp-config.php
<phpunit>
<php>
<server name="WP_TESTBENCH_CONFIG" value="your-config.php"/>
</php>
</phpunit>
That's all then you can run the PHPUnit test
./vendor/bin/phpunit