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...
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"
Comments 6 Comments
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.
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.
Have you tried changing your PHP Version on MAMP? ...and maybe also try turning off the Cache to see if that affects it?
thanks for the help
Preferences > PHP Tab
You will find the PHP Version and Cache settings there. ; )
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 ;)