Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

prontoarm/wordpress-plugin-tests

Open more actions menu
 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

64 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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

Update: Use WP-CLI to create all these files automatically. See http://wp-cli.org/blog/plugin-unit-tests.html

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. Set up the tests library as a submodule: git submodule add git://github.com/scribu/wp-tests-lib.git tests/lib
  5. Activate Travis CI for your plugin
  6. Add tests to the tests/ folder following the instructions below

Running the tests locally

All you need to do is set up a wp-tests-config.php file inside the tests directory. (sample)

Then, 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

  • 2013-01-19 - Mandate plugins have wp-tests-lib as a submodule.
  • 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.

About

A Travis CI compatible unit testing for WordPress plugins that utilizes the WordPress core unit testing framework and PHPUnit

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
Morty Proxy This is a proxified and sanitized view of the page, visit original site.