PHPunit Comaptiablity issue with Zend

696 views Asked by At

I have configured PHPUnit with Zend Framework. When I run the command

phpunit --configuration phpunit.xml

I receive the failure message like

Declaration of Zend_Test_PHPUnit_Constraint_ResponseHeader::evaluate() should be compatible with that of PHPUnit_Framework_Constraint::evaluate()

I have following assert functions

$this->assertModule($urlParams['module']);
$this->assertController($urlParams['controller']);
$this->assertAction($urlParams['action']);
$this->assertResponseCode(200);

I searched out the problem and found many related solutions like stated here. I checked my PHPUnit version it is 3.7.9 and Zend Framework 1 only properly function with PHPUnit 3.5.x.

Then I tried to downgrade the PHPUnit as stated here. The un-installation process runs successfully. But when I go to install the downgraded version and run the command

pear install phpunit/PHP_CodeCoverage-1.0.2

It generates an error

phing/phing requires package "phpunit/PHP_CodeCoverage" (version >= 1.1.0). phpunit/PHP_CodeCoverage cannot be installed, Conflicts with installed packages. 

Some body tell me how to handle this situation? How to make installed PHPUnit version compatible with Zend Framework 1.X or how to properly downgrade my PHPUnit??

Best Regards.

1

There are 1 answers

8
Roberto On

You can always install 2 different instances of PHPUnit. Install with pear the latest version of PHPUnit to get Phing to work, and install the PHPunit version 3.5.x with Composer - as instructed here.

If everything is done correctly, you will have a system-wide PHPUnit at the latest version, and in your project folder in vendors/bin you will have PHPunit 3.5.x . Use the second one to build tests in ZF1.