Skip to content
This repository has been archived by the owner on Apr 21, 2018. It is now read-only.

Latest commit

 

History

History
68 lines (53 loc) · 3.39 KB

old-readme.md

File metadata and controls

68 lines (53 loc) · 3.39 KB

WordPress Plugin Tests

A Travis CI compatible unit testing architecture for WordPress plugins that use WordPress core's official unit-testing framework and PHPUnit

Build Status

How it Works

  • Automatically fires after every commit (or you can specify certain branches)
  • Downloads and sets up multiple versions of WordPress and PHP (as many as you want to specify)
  • Runs all the tests and e-mails you on failure

Assumptions

  • You have a WordPress plugin in GitHub (and thus a GitHub account)
  • You posses basic knowledge of how to add and edit files using git

How to integrate with your plugin

  1. Place .travis.yml file in your plugin's root folder (you may want to customize your build settings here)
  2. Create a subfolder of your plugin called tests/ and copy over the bootstrap.php and phpunit.xml files from this repo's test/ folder
  3. Customize the newly copied /tests/bootstrap.php with the path to your plugin file
  4. Activate Travis CI for your plugin
  5. Add tests to the tests/ folder following the instructions below

Running the tests locally

  1. Check out the test suite locally:
cd /path/to/your-plugin/
svn co http://unit-tests.svn.wordpress.org/trunk/includes/ tests/lib
  1. Set up a wp-tests-config.php file inside the tests directory. (sample)

  2. Run the tests:

cd /path/to/your-plugin/tests
phpunit

The Tests

  • Each test file should live in the tests/ folder and should be named in the format of test_{name_of_test}.php.
  • Each test file should contain a single class named in the form of WP_Test_{name_of_test} that extends WP_UnitTestCase.
  • Example Tests: WP Document Revisions

Note

There's a separate branch setup which contains setup and config files which are pulled down on the fly when testing.

How to Contribute

  1. Fork the project to your account, make changes, and submit a pull request
  2. Integrate with your plugin and open issues / feature requests as you see fit

Changelog

  • 2012-09-15 - Removed wordpress-tests submodule in favor of core's SVN.
  • 2012-04-16 - Initial commit of skeleton based off of (legacy) core testing framework.
  • 2012-06-30 - Complete rewrite to rely on newer wordpress-tests framework and better PHPUnit integration.

Contributors

Special thanks to @johnpbloch and @scribu for doing much of the legwork on the rewrite.