PHPUnit files needed to run PHPUnit as standalone in CakePHP 2.x
Pull request Compare This branch is 6 commits ahead, 5 commits behind Hyra:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

PHPUnit installer as CakePHP standalone plugin


This plugin is deprecated as of now since the PEAR channel for it has been shut down. Please composer your app and use that to include PHPUnit or simply use the phar file (Support for this has been added in recent 2.x versions, as well).


This "installer" prepares all the dependencies needed to use PHPUnit with CakePHP 2.x through the use of vendor files.

PHPUnit installer now supports 3.7 (default, currently 3.7.32), 3.6 and maybe 4.0 (careful, that version is not yet fully working with CakePHP).


Because I'm a fan of self-contained systems. Sure, installing PHPUnit through PEAR systemwide is supposed to be "easy", but when you're working on multiple workstations and deploy to different hosting setups its just nice to know you have everything within reach.


PHP5.3 and CakePHP2.x (>= 2.3)

Note: This is ONLY for non-composer apps. Using composer for CakePHP2+ apps is highly recommended, though. Thus modern apps shouldn't need this plugin, at all :)

Install the Plugin

Install this plugin to your app/Plugin folder by cloning it to a folder called "Phpunit"

Make sure you got either CakePlugin::loadAll() - or specifically CakePlugin::load('Phpunit') in your bootstrap! Otherwise the plugin will not be available.


To install PHPUnit to your CakePHP 2.x install you can use the Shell.

Run cake Phpunit.Phpunit install directly from your console. This will download and extract all the necessary files, and put them in your specified Vendor folder.

You can now use PHPUnit through the CLI or your favourite browser. Try it by running:

cake testsuite core Basics

If all went well you will see the PHPUnit run the CakePHP basic tests.

It works with Mac OSX, Linux and Windows. Please report any problems.


If you have it installed in your ROOT vendors and get (fatal) errors while baking put this at the top of the VENDORS/PHPUnit/Autoload.php file:

if (strpos(get_include_path(), dirname(dirname(__FILE__))) === false) {
    set_include_path(get_include_path() . PATH_SEPARATOR . dirname(dirname(__FILE__)));

This way the vendors folder itself is also an include path and those errors will go away. The PHPUnit files are checked/included prior to baking unit tests. So if you did not already set the path in your system, you need to do it this way.

Checking for updates

Running Phpunit.Phpunit info you can check for updates. This is mainly for maintaining the plugin and keeping it up to date.


Mark Scherer (dereuromark) and Stef van den Ham (Hyra)