I had all sorts of issues using phpunit with my x2engine install. Since phpunit should be installed with phar or composer now (not pear, see https://github.com/sebastianbergmann/phpunit/wiki/End-of-Life-for-PEAR-Installation-Method), I had to find a different way to do it.

I found: http://stackoverflow.com/a/23081776/140541

Here are my modified instructions

Basically create your composer.json:

    "require-dev": {
        "phpunit/phpunit": "3.7.*",
        "phpunit/phpunit-selenium": ">=1.2",
        "phpunit/dbunit": ">=1.2",
        "phpunit/phpunit-story": "*",
        "phpunit/php-invoker": "*"
    "autoload": {
        "psr-0": {"": "src"}
    "config": {
        "bin-dir": "bin/"

Note: if using windows (xampp, wampp, etc...) remove the "phpunit/php-invoker": "*" line as it needs pcntl which doesn't work with windows.

Run composer: composer install --dev

Tehere are a ton of ways of installing/runing composer. See: https://getcomposer.org/download/ (if on windows, its super easy to use the windows installer).

Run your unit tests: ./bin/phpunit -c ./protected/tests/phpunit.oca.xml

If using Teamcity

Here is the composer build step:

Here is the phpunit build step (I have a custom phpunit xml file):

The above pics are using https://github.com/JetBrains/meta-runner-power-pack