Manually Installing PHPUnit with MAMP on Mac OS X 10.6 Snow Leopard


1. Get a copy of the latest version of PHPUnit (PHPUnit 3.4.6 – 4 Jan 2010) from http://pear.phpunit.de/get/

2. Extract your folder to your Desktop.

3. Edit “phpunit.php” found in “PHPUnit-3.4.6/PHPUnit-3.4.6/“.

3.1. Scroll near to the bottom and replace “@php_bin@” with “/Applications/MAMP/bin/php5/bin/php“.

3.2. Save as “phpunit” (no extension) in “/usr/local/bin/“, or save to your Desktop, then copy to “/usr/local/bin/“.

3.3. Make the phpunit file executable by typing the following in the Terminal:

sudo chmod +x /usr/local/bin/phpunit

4. Edit “PHP.php” found in “PHPUnit-3.4.6/PHPUnit-3.4.6/PHPUnit/Util/“.

4.1. Scroll about 3/4 near the bottom and replace “@php_bin@” with “/Applications/MAMP/bin/php5/bin/php“.

4.2. Save the file and copy the “PHPUnit-3.4.1/PHPUnit-3.4.1/PHPUnit” folder to “/usr/lib/php/“.

5. Test it out by making a test anywhere, here is some sample code you can plonk into “SampleTest.php“.

<?php
class SampleTest extends PHPUnit_Framework_TestCase
{
    public function testHowsit() {
        $this->assertTrue(1 == 1);
    }
}
?>

6. Open up your Terminal to where your test (SampleTest.php) is located.

7. Run the test using:

/usr/local/bin/phpunit SampleTest.php

You should see the following:

PHPUnit 3.4.6 by Sebastian Bergmann.

.

Time: 0 seconds, Memory: 5.75Mb

OK (1 test, 1 assertion)

[Credit goes to TigerMunky at http://tmshweetness.blogspot.com/2009/10/manually-installing-phpunit-with-mamp.html]

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.