开发者

sfYaml echoln() error in Zend Framework project PHPUnit tests

I'm starting a Zend Framework project and I decided to use Doctrine 1.2.3 instead of the Zend_Db classes. I configured my project and doctrine command line script works just fine, my index controller can query my database without problems, but Unit Tests with PHPUnit throws an error:

Fatal error: Cannot redeclare echoln() (previously declared in D:\Zend\Apache2\vhost\myproject\library\Doctrine\Parser\sfYaml\sfYaml.php:132) in D:\Zend\ZendServer\bin\PEAR\SymfonyComponents\YAML\sfYaml.php on line 135

I'm using Zend Server with PHP 5.3. PHPUnit requires the PEAR SymfonyComponents' YAML package. This happens everytime my unit test bootstrap tries to re-create and load the whole test开发者_如何学Cing database, specially when loading the fixtures files. This is the full command and output:

D:\Zend\Apache2\vhost\myproject\tests>phpunit
build-all-reload - Successfully dropped database for connection named 'doctrine'
build-all-reload - Successfully created database for connection named 'doctrine'
build-all-reload - Created tables successfully
build-all-reload - Data was successfully loaded
PHPUnit 3.5.10 by Sebastian Bergmann.


Fatal error: Cannot redeclare echoln() (previously declared in D:\Zend\Apache2\vhost\myproject\library\Doctrine\Parser\sfYaml\sfYaml.php:132) in D:\Zend\ZendServer\bin\PEAR\SymfonyComponents\YAML\sfYaml.php on line 135

D:\Zend\Apache2\vhost\myproject\tests>

As result, my database is completely created and data fixtures are loaded successfully. But this error stops the Unit Testing process. I only have one test class for Doctrine models but this error happens even if I comment its testing code.

It is strange, because if I execute the doctrine script by hand, It runs without problems, and no error happens when the system runs via web. This just happens for Unit Testing.

How can I avoid this libraries collition, if both, Doctrine and PHPUnit include the same sfYaml class from PEAR and from inside Doctrine, without breaking the working system?


You can see in the error message that sfYaml.php is being loaded from two different locations. You must clean up your include path so it has only one copy of each library you need. Use var_dump(get_include_path()) in your bootstrap.php to diagnose the issue.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜