ZF-7984 – Zend_Tool Exits with Fatal Errors after installing PHPUnit 3.4.0+
Posted on October 21st, 2009 in Development | 4 Comments »
I’m lucky enough to have made it to ZendCon again this year, and I’m having a blast learning new stuff, hanging out with old friends, making new friends, and generally grabbing up as much schwag as possible.
One of the topics that I’m most interested in is unit testing, specifically unit testing Zend Framework MVC apps. While there’s a lot I have yet to learn on that topic, I ran into a bug last night that I wanted to let you know about.
In preparation to dig into ZF unit testing, I updated my install of PHPUnit to the latest version (currently 3.4.1, installed via PEAR). When I tried to create a new ZF project using Zend_Tool, I received the following error:
jkendall@san-diego:~/dev/www$ zf create project asplode
Fatal error: Cannot redeclare class phpunit_framework_testsuite_dataprovider in /usr/share/php/PHPUnit/Framework/TestSuite/DataProvider.php on line 64
Call Stack:
0.0020 111440 1. {main}() /usr/share/phplib/ZendFramework-1.9.3PL1/bin/zf.php:0
0.0020 111560 2. zf_main() /usr/share/phplib/ZendFramework-1.9.3PL1/bin/zf.php:23
0.0220 686832 3. zf_run($zfConfig = array ('HOME' => '/home/jkendall')) /usr/share/phplib/ZendFramework-1.9.3PL1/bin/zf.php:36
0.0221 686952 4. Zend_Tool_Framework_Client_Console::main($options = array ()) /usr/share/phplib/ZendFramework-1.9.3PL1/bin/zf.php:214
0.0221 687440 5. Zend_Tool_Framework_Client_Abstract->dispatch() /usr/share/phplib/ZendFramework-1.9.3PL1/library/Zend/Tool/Framework/Client/Console.php:96
0.0222 687560 6. Zend_Tool_Framework_Client_Abstract->initialize() /usr/share/phplib/ZendFramework-1.9.3PL1/library/Zend/Tool/Framework/Client/Abstract.php:209
0.0296 866600 7. Zend_Tool_Framework_Loader_Abstract->load() /usr/share/phplib/ZendFramework-1.9.3PL1/library/Zend/Tool/Framework/Client/Abstract.php:118
0.4100 2729736 8. include_once('/usr/share/php/PHPUnit/Framework/TestSuite/DataProvider.php') /usr/share/phplib/ZendFramework-1.9.3PL1/library/Zend/Tool/Framework/Loader/Abstract.php:90
jkendall@san-diego:~/dev/www$As it turns out, this is a known bug in version 1.9.0+ of the Zend Framework. See ZF-7894 in the ZF issue tracker for full details. While this issue is not yet resolved in the tracker, Raphael Stolt has provided a workaround in the form of a diff file attached to the issue. While your mileage may vary, the patch worked perfectly for me. I’m able to go ahead and dive into unit testing my Zend Framework applications.
UPDATE: ZF-7894 was resolved during Bug Hunt days this week. Many thanks to Benjamin Eberlei!








4 Responses
I installed phpUnit and just ran into this problem. What a synchronous miracle that you posted this only a few minutes ago! Sorta ironic that a unit testing tool caused a bug in zf — guess they need to write a new test for phpUnit integration! :p
Hey Mike, glad that the article helped!
You are my life saver. thanks a lot.
Thanks, Akmal. Glad to hear this helped out so much.