ZF-4839: ControllerTestCase broken with PHPUnit 3.3.3
Description
Zend_Test_PHPUnit_ControllerTestCase is broken with PHPUnit 3.3.3 (most recent version) in revision 12333. ControllerTestCase uses {{PHPUnit_Framework_TestCase::incrementAssertionCounter()}} in line 1099, but this method is not available any more with PHPUnit 3.3.3 (don't know in which version this was removed). The appropriate method in PHPUnit 3.3.3 is {{PHPUnit_Framework_TestCase::addToAssertionCount($count)}}.
Comments
Posted by Matthew Weier O'Phinney (matthew) on 2008-11-07T08:32:29.000+0000
Fixed in r12372; now checks for PHPUnit version and calls appropriate method for that version.
Posted by Stefan Gehrig (sgehrig) on 2008-11-07T09:00:23.000+0000
Still not solved...
Line 1098 now reads
but must be
Posted by Stefan Gehrig (sgehrig) on 2008-11-07T09:02:02.000+0000
Still not solved...
Line 1098 now reads
but must be
or
Posted by Matthew Weier O'Phinney (matthew) on 2008-11-07T09:17:57.000+0000
Um... no. We don't want <=, because at version 3.3.3 the change was introduced. Versions less than 3.3.3 require the handling as originally written.
Posted by Stefan Gehrig (sgehrig) on 2008-11-07T09:31:25.000+0000
Please see my comments in the following code:
But in PHPUnit 3.3.3 {{incrementAssertionCounter()}} is not available any more...
Posted by Stefan Gehrig (sgehrig) on 2008-11-07T09:32:55.000+0000
Please see my comments in the following code:
But in PHPUnit 3.3.3 {{incrementAssertionCounter()}} is not available any more...
Sorry to bother you with this!
Posted by Matthew Weier O'Phinney (matthew) on 2008-11-07T10:04:31.000+0000
I've rewritten it to the following:
which should make the intention clearer.
Posted by Emil Ivanov (vladev) on 2008-12-05T05:58:23.000+0000
We are running from an svn:externals of phpunit and it doesn't have a version there. Can this be some sort of other check, for example method_exists or something?
Posted by Matthew Weier O'Phinney (matthew) on 2008-12-05T08:13:41.000+0000
Sure. I'm reopening the issue so we can track that.
Posted by Matthew Weier O'Phinney (matthew) on 2008-12-05T08:14:45.000+0000
Changing to trivial and improvement, as it will work for most users of PHPUnit as-is right now; the improvement is for those tracking svn of PHPUnit.
Posted by Brian Hazzard (bhazzard) on 2009-04-24T05:55:12.000+0000
I too have this issue. I tried changing the source code to the method_exists approach and had no luck. I also tried a hack-fix of defining incrementAssertionCounter in my test class and simply calling addToAssertionCount(1) in it's body... again, no luck. Has this been resolved?
Posted by Brian Hazzard (bhazzard) on 2009-04-24T06:12:44.000+0000
In the meantime "upgrading" to PHPUnit 3.3.16 does indeed fix this problem.
Posted by Ivan Bonilla Cortes (ibonilla) on 2009-05-18T16:56:42.000+0000
This actually affects more users than those tracking svn of PHPUnit: Neither incrementAssertionCounter nor addtoAssertionCount exist on versions prior to 3.3.0 incrementAssertionCounter exists on versions 3.3.0 to 3.3.2 addtoAssertionCount exists on versions 3.3.3 and on
You may be wondering why someone would want to use an older version of phpunit. Sadly the latest version that ubuntu gnu/linux packages is 3.2.16: http://packages.ubuntu.com/jaunty/phpunit so this bug affects all ubuntu users that want to use a package manager.
Posted by Dolf Schimmel (Freeaqingme) (freak) on 2009-07-01T07:35:41.000+0000
As mentioned in the previous comment, somewhat older versions of PHPUnit don't have any of these methods for the simple reason that not all distributions are as keen on keeping everything cutting edge as others :'(
If there's no alternate solution in versions before 3.3.0 of PHPUnit, I suggest a following 'fix':
I'm setting the priority to major, as for there will certainly be many more people running distros like these...
Posted by Lorna Mitchell (lornajane) on 2009-07-16T04:24:05.000+0000
I ran into this issue as well - using debian lenny, ZF 1.8 and the standard phpunit from apt-get which is 3.2.167. The patch from Dolf works perfectly for me (thanks!)
Posted by Matthew Weier O'Phinney (matthew) on 2010-01-21T10:13:16.000+0000
Fixed in trunk and 1.10 release branch.