PHPackages                             rask/wp-test-framework - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. rask/wp-test-framework

ActiveLibrary[Testing &amp; Quality](/categories/testing)

rask/wp-test-framework
======================

Extracted library from WordPress PHPUnit framework to aid in integration testing of plugins and themes

0.2.0(6y ago)43.3k↓66.7%2[1 issues](https://github.com/rask/wp-test-framework/issues)[1 PRs](https://github.com/rask/wp-test-framework/pulls)GPL-3.0-or-laterPHPPHP &gt;=7.1

Since Feb 15Pushed 4y ago2 watchersCompare

[ Source](https://github.com/rask/wp-test-framework)[ Packagist](https://packagist.org/packages/rask/wp-test-framework)[ RSS](/packages/rask-wp-test-framework/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)DependenciesVersions (4)Used By (0)

rask/wp-test-framework
======================

[](#raskwp-test-framework)

Extracted and librarized version of WordPress core's PHPUnit test framework to help with writing integration tests in WordPress plugins and themes.

The test framework is fetched from `https://develop.svn.wordpress.org/trunk/tests/phpunit/` and is stored in `src/phpunit` (with minor changes to make it work better as a Composer package).

The sources are updated when needed, so there may be minor differences between the core framework and this extracted library version. Let the maintainers know if there are bigger changes which need to be merged here.

Installation
------------

[](#installation)

This library should be installed as a Composer dependency inside your plugin or theme:

```
$ composer require --dev rask/wp-test-framework

```

### WordPress testing installation setup

[](#wordpress-testing-installation-setup)

You need to have a WordPress instance downloaded locally into a directory where your user account can load and execute PHP code from:

```
$ cd /home/you/wordpress
$ wp-cli core download

```

Next, you do not need to install WP in there but instead you need a `wp-tests-config.php` file to be available. It is similar to a regular `wp-config.php` but is solely for testing purposes.

You can find an example configuration at `https://develop.svn.wordpress.org/trunk/wp-tests-config-sample.php`. Copy the contents into the WordPress root directory (`ABSPATH`) and set up the configuration for your system (databases, etc.).

Your plugin/theme can (and probably should) live outside the WordPress testing installation.

Setting up PHPUnit for your plugin/theme
----------------------------------------

[](#setting-up-phpunit-for-your-plugintheme)

Inside your plugin/theme directory you need to setup PHPUnit. Any regular-ish `phpunit.xml` configuration should work. In your PHPUnit bootstrap file you should load the WordPress test framework as such:

```
