I want to contribute to a guys plugin (TimberWp). I'd like to do it with tests. his plugin has a test dir that looks just like the wp-cli scaffolded dir. all v standard.

Iv'e managed to get as far as installing wp-cli, phpunit (already had that) and I got past the couldn't connect to mysql issue (make it use the mamp php5.4 version)

now, running:

WP_TESTS_DIR=~/sites/kindling/wp-unit-tests phpunit

gives me

Warning: require_once(PHPUnit/Autoload.php): failed to open stream: No such file or directory in /Users/willbarker/sites/kindling/wp-unit-tests/includes/bootstrap.php on line 7

So i made sure my path to phpunit is set in my php.ini

  timber git:(master) ✗ php -r 'foreach (explode(":", get_include_path()) as $path) echo $path . PHP_EOL;'

So i am out of ideas how to get phpunit working with WP. Have i got the right version of phpunit? its a phar, is that why i can't include files from it? I'm obviously confused / running into the extent of my knowledge. Here is my installed phpunit version:

➜  timber git:(master) ✗ phpunit --which 
PHPUnit 3.7.28 by Sebastian Bergmann.
  • Between PHPUnit and plugin's tests I am fuzzy how this relates to WP. Does plugin provide instructions on testing it? Have you tried inquiring with its developers?
    – Rarst
    Commented Oct 29, 2013 at 11:06
  • rarst - WP has a test set up that plugins use in a fairly standardised way. I've downloaded the plugins tests & im trying to get them to run by installing the WP test suite. If somebody comes accross this that uses WP tests i expect it will turn out to be a simple thing ive missed in the configuration.
    – Will
    Commented Oct 29, 2013 at 11:16

2 Answers 2


I have a setup similar to yours, with MAMP. I also have had this problem with PHPUnit. It seems that no matter what you do, PHPUnit does not recognize the include_path from MAMP. You have to add the correct path to the php.ini in /private/etc/.


I got this working. Possibly more by luck than judgement

As phpunit is a system thing, not a project thing phptherightway said to use pear to insall. I had it installed using composer.

So i installed it with pear:


and then update my mamp php.ini include path

include_path = ".:/Applications/MAMP/bin/php/php5.4.4/lib/php:/Applications/MAMP/bin/php/php5.4.4/bin/phpunit"

Then i cd'd to the plugin dir and ran

WP_TESTS_DIR=~/sites/kindling/wp-unit-tests phpunit

Hope that helps someone.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.