ZF-3835: Exception generating code coverage html


Using PHPUnit 3.2.21

$ phpunit --coverage-html ...
RuntimeException: Could not create and run test suite: Overloading of non-public properties is prohibited in /usr/share/php/PHPUnit/TextUI/Command.php on line 118

$ phpunit --coverage-xml ...
[runs fine]

This exception is being triggered by a property in PHPUnit called __liHtml in Util/Report/Node/File.php


I believe this is due to overloading in the Zend_Test_PHPUnit test suite... and I think it may have been fixed already. Can you please pull from SVN and try running report coverage from there to verify?

Thanks, I forgot to test Svn before reporting.

It stopped throwing the exception but the reports are somehow weird and not what they should be.

For instance:

  • the file names of the pages are being generated incorrectly
  • index.html doesn't contain what it should

I'll come back as soon as I have more information.

Do coverage reports work normally on non-controller test suites (i.e., the ZF test suite, or your own test suites)? If not, then it's an issue with PHPUnit and/or XDebug. Otherwise, I'll consult with Sebastian to see what could be skewing the coverage creation.

When the XDebug trace passes through a view script from Zend_View, the filename resolves to something like


This causes confusion in a PHPUnit function called reducePaths() (PHPUnit/Util/Report.php), which "Reduces the paths by cutting the longest common start path."

So, it will always reduce the path to " " if you use Zend_View and the reports are generated incorrectly.

That's easy, then. In your bootstrap process, call:


or, if you need short tags, add the following flag when calling phpunit:

phpunit -d "short_open_tags=on" ...

Both options will disable the stream wrapper, which should fix the coverage reports. (BTW, the stream wrapper will be disabled by default prior to the 1.6.0 final release.)

Issue previously resolved, and phpunit coverage report issue can be solved via settings.

Thanks! Worked perfectly with the stream wrapper turned off.

I've found it works fine when using the Latest Version of Zend_Test_PHPUnit_ControllerTestCase from the Repository. I copied it straight over the version in the 1.6.0RC3 branch.

Updating for the 1.6.0 release.

Hey Guys,

I think this is still an issue in the final release of 1.6.0. I updated the 1.6.0 release with the version from trunk and it appears to be working correctly again.

The only differences are that the trunk version does a 'require_once' of Zend_Registry and the overloading method (__set) is written as:

if ('_' == substr($name, 0, 1) && ('__' != substr($name, 0, 2))) {

as opposed to:

if ('_' == substr($name, 0, 1)) {

This seems to make the phpunit coverage reports work correctly.