But finally I found a tutorial that gave me a good start. And with a little bit more research, I found solutions for the problems I posted above too.
Here I just want share my steps and all the links you can go thru to get it run :)
First step is to follow Zank's tutorial.
But after I did his steps, I got several errors. Because the list of modules you have to install is not complete. This ended up in following errors when I tried to run a test:
PHP Warning: include(): Failed opening 'PHP_Invoker.php'
PHP Warning: include(): Failed opening
'PHPUnit_Extensions_Database_TestCase.php'
PHP Warning: include(): Failed opening
'PHPUnit_Extensions_Story_TestCase.php'
Second step
So I googled and figured out that I have to do following lines too:
pear install phpunit/PHPUnit_Story
pear install phpunit/DbUnit
But the 'invoker' problem was not that easy. Because when you try
pear install phpunit/PHP_Invoker
it will result in an error like
phpunit/PHP_Invoker requires PHP extension "pcntl"
and to install this extension to MAMP is a pain in the ass. But I found here this solution:
- went to pear.phpunit.de
- manually downloaded PHP_Invoker utility class
- unzipped the file on my daughter's mac (I'm running Windows)
- put the "Invoker" directory under C:\xampp\php\pear\PHP
- put the "Invoker.php" file under C:\xampp\php\pear\PHP
For your MAMP installation the path should be something like "/Applications/MAMP/bin/php/php5.4.10/lib" - further I had to rename 'Invoker.php' to 'PHP_Invoker.php'.
Step Three
On command line everything should work now - write a test and try it out like in Zank's tutorial linked in step one. But what about Netbeans? Like in Zank's tutorial I entered the phpunit path and just right clicked one of my tests and selected "Run test" - error!
PHP Fatal error: Class 'CTestCase' not found
Solution can be found here. This happens when you do not right click the folder where the 'phpunit.xml' is in. But to avoid this you could do the following:
- Only right click the folder with the 'phpunit.xml' in it for 'Run test'.
- Or go under your test properties -> PHPUnit and check the checkbox 'Use XML Configuration' + select the 'phpunit.xml' file
That's it!
Here are some links that are interessting too: