ZF-11828: Zend_Test_PHPUnit_Constraint_*::evaluate() not compatible with PHPUnit (3.6RC4) API


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


PHPUnit 3.6 PHPUnit_Framework_Constraint::evaluate (See here)

public function evaluate($other, $description = '', $returnResult = FALSE)


public function evaluate($other, $assertType = null)

@[~matthew] What is the policy on PHPUnit compatibility in ZFv1?

Another consideration related to this issue is that {{assertType}}, which is used extensively in ZFv1's test suite, will be removed in PHPUnit v3.6.

The supported branch of PHPUnit for Zend Framework v1 is v3.4.x. There are no plans to update ZFv1 to any newer version of PHPUnit.

On a side note, I've been using various releases of 3.5 without any obvious negative side-effects (beside the flood of deprecation notices). YMMV, though.

I'd like to re-open this.

I can provide a patch for this, but please don't make us run an older version of PHPUnit.

As being responsible for many QA tasks for several customers I cannot imagine ZF1 cannot be modified to support PHPUnit v.3.6.x. ZF is an industry leading framework used in projects with a lifetime over 5 years. PHPUnit is a not-to-be-neglected tool alongside ZF.

As I'm facing these issues myself now (our server admins upgraded all servers to PHPUnit 3.6.x) I need to solve this issue. So I can modify my changes to Zend_Test to support both PHPUnit 3.x and 3.6 versions and submit them to ZF trunk. Just want to see some more votes for this update.


Mike -- the problem is that PHPUnit has broken BC both from 3.4 to 3.5 and from 3.5 to 3.6. Add into this the fact that we have folks with a variety of different PHPUnit versions, and this becomes a game of whack-a-mole to support -- and takes time away from actual maintenance of the framework. (As an example, updating the unit test suite in ZF2 to use PHPUnit 3.5 took 40 hours of time.) Additionally, we either end up saying, "install the latest PHPUnit" (which may not be possible or easy for many, and which means if testing with an older version that there will be fatal errors due to unknown assertion methods), or we end up adding conditional logic to test for PHP versions in order to determine what assertions to run (or whether or not AllTests suites are enabled). Either way, we end up with a lot of work, and a lot of developer education.

I think time might be better spent creating a phar with PHPUnit 3.4 that we can include in the ZF1 repo to make it easier for maintainers to run tests under that version -- I suspect this would only take an hour or two tops to achieve.

Hey Matthew. Yeah I know the difficulties PHPUnit powered applications are struggling with, and I know there should be more protection against sysadmins that just upgrade PEAR packages without knowing what the side effects will be of their actions. Trust me, getting a call at 2am because CI barfs out nothing but errors because SysAdmin upgraded the servers at 1am is not funny. Especially when discovering what truly happened at 6am, makes a nice guy homicidal...

Using Phar is indeed a very good idea (why haven't I come up with this?!?). This allows us to execute PHPUnit straight from the library or wherever the Phar will be placed.

Let me play a little with it as I have way too many setups on which I can test it and I'll get back to you on this.



I've worked around the problem by following the instructions here:… Then setting the PHPUNIT environment variable prior to invoking tests:

$ export PHPUNIT=/usr/share/phpunit34/usr/local/bin/phpunit
$ ./

I've been working on the PHAR idea again, and have made some progress. What I have done is strip the include calls from the PHPUnit source and added a simple autoloader to the PHAR manifest. Seems to avoid the problems I blogged about back in November but does introduce new problems: * Now getting plenty of these:

PHP Warning:  array_flip(): Can only flip STRING and INTEGER values! in phar:///path/to/phpunit.phar/PHPUnit/Util/GlobalState.php on line 192
  • A slightly different result between the using PHAR and not:

3.4.16 PHAR: Tests: 15844, Assertions: 49727, Failures: 277, Errors: 116, Incomplete: 20, Skipped: 599
3.4.16 Standalone: Tests: 15844, Assertions: 49742, Failures: 279, Errors: 107, Incomplete: 20, Skipped: 599.

Oh, and with the PHAR I get a fatal error like this:

Fatal error: Cannot redeclare class SampleClass in /tmp/UnitFileiHNOCw on line 4
(require_once'd from tests/Zend/CodeGenerator/Php/FileTest.php:104)


Closing as won't fix due to a collection of reasons:

  • Matthew has stated repeatedly that PHPUnit 3.4.x is the officially-supported version of ZFv1
  • Repeated attempts (both official and unofficial) have not yielded a workable PHAR archive of PHPUnit 3.4.x which could be bundled with ZFv1
  • Alternate solutions exist (ie: altroot PEAR install + PHPUnit 3.4.x)

I'm running Zend Studio 9.0.4 and encountered the same error - and the only version of PHPUnit I was using was the one that came with Zend Studio, 3.6.10

I had to do two few things to make this work.

1) I had to get ZS to recognize the Zend classes so that my test class could extend Zend_Test_PHPUnit_ControllerTestCase without getting an error.

To do this I had to right-click on my project, then: Include Path -> Configure Include Path -> Add Library -> Zend Framework 1.x -> Next -> Finish

2) I had to make ZS not use PHPUnit 3.6.10 (which is what happened when I did Include Path -> Configure Include Path -> Add Library -> PHPUnit 3.x - DON'T do that, I tried it and had to "Remove" that library once I figured out it was pointing to C:\Program Files\Zend\Zend Studio 9.0.4\plugins\com.zend.php.phpunit_9.0.4.201210081806\resources\library\3.6.10)

Instead, do the following: Include Path -> Configure Include Path -> Add Library -> User Library -> Next -> New -> User library name: PHPUnit 3.5.14 (check "Add to environment") -> OK -> Add External Folder -> navigate to C:\Program Files\Zend\Zend Studio 9.0.4\plugins\com.zend.php.phpunit_9.0.4.201210081806\resources\library\3.5.14 and OK -> Finish

Then Projects -> Clean -> Clean All Projects -> OK, and File -> Restart

I based this on the "Zend Studio - Update PHPUnit video" I found at