1

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.

Community
  • 1
  • 1
Awais Qarni
  • 17,492
  • 24
  • 75
  • 137

1 Answers1

0

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.

Roberto
  • 2,206
  • 4
  • 24
  • 31
  • It means I will create a folder `vendors/bin` and in that folder I will install phpunit 3.5.x? – Awais Qarni Nov 20 '12 at 10:13
  • And how to install that view composer? Means I will create a `compsor.json` file in above directory and will put the code that they have give there? – Awais Qarni Nov 20 '12 at 10:14
  • Can you please elaborate your answer more deeply? – Awais Qarni Nov 20 '12 at 10:17
  • All the set-up instructions can be found in the link above - but yes you will have to download `composer.phar`, create the `composer.json` with your dependencies (just use the example given in the PHPUnit installation page), and run `php composer.phar install` – Roberto Nov 20 '12 at 10:17
  • I will save the file `composer.phar` in my project directory? – Awais Qarni Nov 20 '12 at 10:54
  • yes - as it says the guide above just run `curl -s https://getcomposer.org/installer | php` in your project directory. please before commenting further make sure to read the guide linked and try it out – Roberto Nov 20 '12 at 10:59
  • 3
    @Roberto , The link above to the PHPUnit docs specifically says "Support for Composer and PHP Archive (PHAR) was added in PHPUnit 3.7 (and is known to be stable since PHPUnit 3.7.5). Earlier releases of PHPUnit are not available through these distribution channels." .. Hence you cannot use composer for 3.5 . – Mike Graf Mar 18 '13 at 15:35
  • did anybody get a seperate install working? I still have old projects to maintain and need to run two versions... – spankmaster79 May 27 '13 at 14:03