koding.io wordpress phpunit environment

If you want to use koding.io as wordpress plugin developer with tests (executed by phpunit) you can follow this guide.

This guide illustrates how the test environment is set up on koding.io. You should already familiar with wordpress & testing to understand the tutorial.

Maybe you don’t want to follow the tutorial if you don’t want to hurt the integrity aspect of tests! We use the same wordpress for each test run. You should avoid this setup if your plugin executes any database operations.

Install WordPress on your koding.io vm:

Install wordpress on koding.io

Install wordpress on koding.io

Follow the instructions to complete the installation.

Now that wordpress is installed we will use it as test environment.

copy/clone or check out your wordpress plugin as usually to ~/Web/wordpress/wp-content/plugins/

At next just merge from the wp-cli sample plugin into you development plugin:


At least you just need to merge the phpunit.xml (describes our test envionment) and the tests/ folder ( there is a bootstrap file that does the bootstrap.. & there is example test)

(we don’t need the bin directory. The script in it should be a good start point if you want to setup a fresh wordpress for each test run)


We start installing phpunit on our vm via terminal.

We create a wordpress-utils which containts all stuff needed for testing.

We check out the includes for phpunit.

We check out the config for tests

Now we have to take over the database setting from our wordpress installation manually:

Copy the settings for

and $table_prefix

to our test config

In my case the wp-tests-config.php looks like this:

Also modify the first statement to:

Now we have to do a change in our plugin.

Change the $_tests_dir to

We can change the directory to our plugin now and let phpunit execute our test:

The output should be

You can now write some more tests, write the code to pass the tests and check the results of the tests by executing phpunit in the root of your plugin.

Don’t hesitate to use the comments if you are struggling at some point.

Tip: Make use of travis if possible for continuous test executing for each commit to your code base.

For further information about koding and some pictures I suggest WordPress in the Cloud: How to Set Up a Development Site with Koding.
You might be interested in alternatives for koding.io.

If you have found a spelling error, please, notify us by selecting that text and pressing Ctrl+Enter.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Spelling error report

The following text will be sent to our editors: