TigerMunky’s Grrreat Trek

Leading banana slips and paw tracks along the digital highway...

    • Edit
    • Delete
    • Autopost

    Manually Installing PHPUnit with MAMP on Snow Leopard (3rd time is a charm)

     

    After scouring the web for awhile and having problems with installing PHPUnit with PEAR and MAMP, I figured it out, so I thought I would share...

    1. Get a copy of the latest version of PHPUnit (PHPUnit 3.4.1 - 8 Oct 2009) here ~ http://pear.phpunit.de/get/

    2. Extract your folder to your desktop.

    3. Edit "phpunit.php" found in "PHPUnit-3.4.1/PHPUnit-3.4.1/".
    3.1. Scroll near to the bottom and replace "@php_bin@" with "/Applications/Mamp/bin/php5/bin/php".

    3.2. <Save As> "phpunit" (*Notice no extension used.) in "/usr/local/bin/", or save to your Desktop, then copy to "/usr/local/bin/".

    [ Side Note: if you want to reveal hidden files and folders in Finder, you may type this in the Terminal:

    defaults write com.apple.finder AppleShowAllFiles TRUE

    then

    killall Finder

    to "reboot" finder (Note: this will close all your Finder windows and reopen all of them)
    you can use FALSE instead of TRUE to return it back to "normal".

    ]

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

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

    4. Edit "PHP.php" found in "PHPUnit-3.4.1/PHPUnit-3.4.1/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. Copy "PHPUnit-3.4.1/PHPUnit-3.4.1/PHPUnit" folder to "/usr/lib/php/". That's it!

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

    <?php

    class HowsitWorldTest extends PHPUnit_Framework_TestCase
    {
    public function testHowsit()
    {
    $this->assertTrue(1 == 1);
    }
    }

    ?>

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

    7. Type "phpunit HowsitWorldTest". Hopefully you will see the following:

    TM

    "It's only work if somebody makes you do it"

       
    Click here to download:
    Manually_Installing_PHPUnit_wi.zip (21 KB)

    Tags » MAMP PHPUnit Snow Leopard
    • 8 October 2009
    • Views
    • Permalink
    • Favorited 0 Times
    • Tweet

    Comments 6 Comments

    Aug 27, 2010
    oluwaseun said...
    I tried it on the Mac OS X Leopard but I keep having this error;

    Warning: require_once(PHPUnit/Util/Filter.php): failed to open stream: Not a directory in /usr/local/bin/phpunit on line 45

    Fatal error: require_once(): Failed opening required 'PHPUnit/Util/Filter.php' (include_path='.:') in /usr/local/bin/phpunit on line 45

    Is there anyway around this as i have copied the PHPUnit directory into /usr/lib/php instead of the PHPUnit-3.4.1 directory but it still fails. I also corrected the /Applications/Mamp/bin/php5/bin/php to /Applications/MAMP/bin/php5/bin/php has installed on my Mac os x but I still get the same error report.

    Aug 27, 2010
    oluwaseun said...
    After roaming the internet I found a fix, at the top of the phpunit file

    change #!/usr/bin/env php to #!/Applications/MAMP/bin/php5/bin/php. And that should fix it.

    However, with the initial problem fixed, another sprang up.

    Xdebug requires Zend Engine API version 220090626.
    The Zend Engine API version 220060519 which is installed, is outdated.

    This may not be related wth the post but of anyone finds a way to fix this problem pls help out.

    Thanks guys.

    Aug 31, 2010
    Tiger Munky said...
    Hi oluwaseun, sorry I can't help ya as I haven't encountered this kinda problem before...

    Have you tried changing your PHP Version on MAMP? ...and maybe also try turning off the Cache to see if that affects it?

    Sep 01, 2010
    oluwaseun said...
    I'd try anything right now cos' it rather frustrating. Could you tell me how you change your PHP version on MAMP and how you turn off the Cache.

    thanks for the help

    Sep 01, 2010
    Tiger Munky said...
    No problem, on your "MAMP Control Panel" goto:

    Preferences > PHP Tab

    You will find the PHP Version and Cache settings there. ; )

    Sep 07, 2010
    Aziz Light said...
    Hello,

    First of all, thanks for this guide. I would like to submit some updates to it so that it becomes compatible with MAMP 1.9.1 on Mac OS X 10.6:

    - every occurence of "@php_bin@" as stated in this guide should be replaced by "/Applications/MAMP/bin/php5.2/bin/php"
    - "#!/usr/bin/env" at the top of the "phpunit.php" file should also be replaced by "/Applications/MAMP/bin/php5.2/bin/php"
    - "PHPUnit-3.4.9/PHPUnit-3.4.9/PHPUnit" (which is the latest stable version) should be moved to "/Applications/MAMP/bin/php5.2/lib/php/" since that is the php include path. "/usr/lib/php/" is the system php include path and will not work.

    With those three changes, your guide is fully up to date and everything should work properly, I just tested it 5 minutes ago ;)

    Leave a Comment

  • Tiger Munky's Posterous

    Life, Innovation, Fun, Tech, Dev, Design, Recipes, Teaching,  and Sushi!

  • About Tiger Munky

    Life, Innovation, Fun, Tech, Dev, Design, Recipes, Teaching,  and Sushi!

  • Subscribe

    Subscribe to this posterous
    Unsubscribe
    Follow this posterous RSS
  • Follow Me

                                     

Theme created for Posterous by Obox and tweaked by TigerMunky