Skip to content

Instantly share code, notes, and snippets.

@alexbepple
Last active December 17, 2015 06:49
Show Gist options
  • Save alexbepple/5568364 to your computer and use it in GitHub Desktop.
Save alexbepple/5568364 to your computer and use it in GitHub Desktop.

Set up PHPUnit

Upgrade PEAR itself:

$ pear install PEAR

Do not use pear upgrade. For me, this installed a version of pear.symfony-project.com/YAML that is incompatible with PHPUnit 3.6.

Install PHPUnit

$ pear config-set auto_discover 1
$ pear install pear.phpunit.de/PHPUnit

Create a very simple test:

<?php
class FooTest extends PHPUnit_Framework_TestCase
{
    public function testBar()
    {
        $this->assertEmpty('foo');
    }
}
?>

Run it: phpunit FooTest.php

The run should fail with this message:

1) FooTest::testBar
Failed asserting that a string is empty.

If you run into environment problems

This could happen if something else that you have installed needs pear.symfony-project.com/YAML in a version other than 1.0.2 (that is the version that PHPUnit 3.6.12 needs).

I think your best bet would be to create a separate PHP installation with php-build and switch between the two using phpenv.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment