-
Notifications
You must be signed in to change notification settings - Fork 13
Home
MockPress is a helper library that makes setting up automated tests for WordPress plugins and themes simple. It simulates as many of the core WordPress functions as possible, allowing you to set up PHPUnit or SimpleTest test suites against your plugin without needing to load in WordPress.
It doesn’t provide mocked versions of actual WordPress objects. Both PHPUnit and SimpleTest allow you to create mock objects easily. This library handles the global functions that WP provides and through which you’ll be doing most of your interaction with WordPress.
The recommended method is using PEAR. I don’t have a PEAR channel set up for MockPress yet so you’ll have to use a slightly more complicated installation procedure beyond the normal one. The PEAR builds are at http://www.coswellproductions.com/mockpress/pear/ and the latest build is always linked to latest.tgz.
pear upgrade -f http://www.coswellproductions.com/mockpress/pear/latest.tgz
pear uninstall __uri/MockPress
See Using MockPress to Test Your Plugin or Theme.
The most important functions for working with:
- Blog options
- Strings & i18n
- Categories
- Tags
- Posts
- Hooks (setting only)
- Admin UI
- Plugin API
- Nonces
- Theme API
- Query strings
- Pre-WordPress 2.8 and WP 2.8 Widgets
- Template tags
- Theme state
- Media attachments
- Users
- User metadata
And it includes an XPath test suite for checking XML and XHTML output from functions.
Take a look at the automatically generated PHPDocumentor documentation for more information.
- PHP 5 or better for SimpleXML support
- A unit testing framework (PHPUnit or SimpleTest)
If you’ve run into a bug or need a function mocked up:
- Fork the project on GitHub, add your code, and send me a Pull Request. I’ll pull them into the main codebase.
- Mail me with a patch or the working mock function and I’ll insert it into the main codebase.