I'm having a strange issue with PHPUnit. I'm working on a project with a team of developers, all of which must use PHPUnit 3.6.5. For the most part, my PHPUnit works great and yields the same results as on other developers' machines. However, I will occasionally find that a certain line isn't covered on my machine, but is on other developers' machines. Here is a recent scenario:
- Bob is checking in a new file that he just updated. He made sure the unit test passed for this file and had 95% code coverage. After performing this check, he checks in the file, where it is built and the unit test is run. If the unit test fails on the server, our build goes red and nobody can check in.
- The server runs the phpunit test and it passes.
- Other developers, including myself, get the latest from the perforce repository
-
After making my own set of changes, I run all of the phpunit tests for the application, but I notice one of the files does not have enough code coverage. It's the file that Bob just checked in. I check with some of the other developers on my team and the file passes code coverage without any problems for them. When I check the code coverage report, I see the following:
array_walk( $variable1, function($val,$key) use(&$variableData, &$variable2) { $variableData[$variable2][$key] = 1; } );
$variable1,
function($val,$key) use(&$variableData, &$variable2)
These two lines are not covered! I don't understand why my phpunit doesn't want to cover these lines. There must be a setting that I am not aware of that is causing this as I have the same version of PHPUnit as other developers and it passes fine on their machine but not on mine. I'm also seeing the same problem in a statement like this:
if ($var === 1) {
echo 'yes';
} else {
echo 'nope';
}
Now, the unit test will cover both conditions, however, it doesn't cover the following line:
} else {
Does this make any sense at all? The strangest part about it is that it works most of the time, but there are a few locations that have this behavior, though there is no pattern to indicate what it causing it. I've had other developers look at this issue on my machine and they are baffled and cannot explain what is causing it. The problem is, since it is failing for me locally, even though I haven't touched Bob's file, it is preventing me from checking in my changes. Has anyone ran into this problem before? I am going to try uninstalling php unit and re-installing it, but other than that, I am at a loss for words. Any help would be greatly appreciated! Here are my specs:
PHPUnit: Version 3.6.5 Operating system: OS X 10.6.8 PHP: PHP 5.3.8-ZS5.5.0 (cli) (built: Aug 24 2011 11:03:29) Zend Debugger: Turned off XDebug: Turned on Zend Optimizer+: off
Regards,
Will