I have been scratching my head trying to resolve the issues arising from implementing a Continuous Integration setup for a Zend Framework project using Phing and PHPUnit.
What should have been a straight forward exercise turned into a head scratching one and after hours of visiting the PHPUnit and Phing manual, I did not have an answer to the problem. Then I saw a bug entered on the Zend Framework Issue Tracker and there it was!
First, PHPUnit 3.6 changed it’s implementation of the evaluate method in PHPUnit_Framework_Constraint. This meant that the same method in Zend_Test_PHPUnit_Constraint_DomQuery was no longer compatible therefore making it impossible to run tests for projects running Zend Framework 1.11.
The folks at Zend were not ready to fix this issue as they are currently working towards the release of the Zend Framework 2. It therefore meant that the other option was for me to install PHPUnit 3.4 which is the ZF supported version.
I had two options, one was to run multiple versions of phpunit but I chose to downgrade as follow
sudo pear uninstall phpunit/PHPUnit
sudo pear uninstall phpunit/DbUnit
sudo pear uninstall phpunit/PHP_CodeCoverage
sudo pear uninstall phpunit/File_Iterator
sudo pear uninstall phpunit/Text_Template
sudo pear uninstall phpunit/PHP_Timer
sudo pear uninstall phpunit/PHPUnit_MockObject
sudo pear uninstall phpunit/PHPUnit_Selenium
sudo pear uninstall pear.symfony-project.com/YAML
I manually downloaded the PHPUnit-3.4 source and copied it to /usr/share.PHPUnit
Finally, I copied the phpunit.php file to /usr/bin/phpunit
PHPUnit 3.4.15 by Sebastian Bergmann
When I ran Phing, again I got another error. The phpunit PhingTask required phpunit >= 3.6.0. What??
Another head scratching exercise. How did I solve this?
I modified the build file and changed the phpunit task to an exec task and passed the command line parameters.
ciproject > phpunit:
[echo] phpunit test start
[echo] phpunit test end
Total time: 0.1633 seconds
Note: Remember to set the attributes passthru=”true” and set dir=”tests” or else you will have include errors to grapple with.
Thanks for reading.