Download the PHP package automattic/wordbless without Composer
On this page you can find all versions of the php package automattic/wordbless. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Short Description WorDBless allows you to use WordPress core functions in your PHPUnit tests without having to set up a database and the whole WordPress environment
All versions of wordbless with dependencies
Informations about the package wordbless
WorDBless allows you to use WordPress core functions in your PHPUnit tests without having to set up a database and the whole WordPress environment
Make sure to copy db.php
Add this script to your
Alternatively, you can manually copy the file.
Initialize it in your bootstrap file
In your PHP Unit bootstrap file add:
That's it! You can now use WordPress core functions in your tests!
BaseTestCase in order to have all the
If you choose not to extend this base class, no problem, just make sure to call its
What will work and what will not work?
Disclaimer: This is still experimental, so all testing is very welcome.
Basically any WordPress core function will work. Things like
Hooks and filters will work.
Most of the things that uses the database WILL NOT work, unless you believe in magic.
What magic WorDBless adds?
Manipulating options will work.
delete_option should work fine!
Posts and Post meta
Manipulating (creating, updating, deleting) posts and attachments will work. Fetching a single post will also work. Here is a non-exaustive list of functions supported:
- and almost anything related to the manipulation of one attachment
Note: Fetching for posts using
WP_Query will not work (yet)! To get a post use
get_post( $id ).
Populating default options
By default, only
home options are populated with
If you want, you can add more options to be loaded by default.
Just declare a
dbless_default_options() function in your bootstrap and make it return an array where the keys are option names and values, options values.
See a live example here -> https://github.com/Automattic/jetpack/pull/16163
Running our CI locally
First install phive globally on your computer.
Then issue the following single command.