0
votes

I'm using PHP 5.6.24 with PHPUnit 5.5.4 and XDebug 2.4.1 and I reach a code coverage of 0,83%. However, before I was using PHP 5.6.0 with PHPUnit 4.7.7 and XDebug 2.3.3 and reached a code coverage of more than 84%.

I found out that since PHP 5.5.x you need to have a phpunit.xml with a whitelist configured. This was new for me, so I added the following file:

<?xml version="1.0" encoding="UTF-8"?>
<phpunit>
    <filter>
        <whitelist processUncoveredFilesFromWhitelist="true">
            <directory suffix=".php">./</directory>
            <file></file>
        </whitelist>
    </filter>
    <logging>
        <log type="coverage-html" target="../results/report" lowUpperBound="35" highLowerBound="70"/>
    </logging>
    <testsuites>
        <testsuite name="DTS">
            <directory>./</directory>
        </testsuite>
    </testsuites>
</phpunit>

The unit tests still work. When I run them by command line I still see that all tests are executed successfully, but it's just the code coverage report which has such odd result.

1

1 Answers

0
votes

I am running 5.5.4, which is the latest stable release, 5.6 is a beta release. I added the logging to mine to see if it would work, and it did. It generated a HTML report that was in the report directory that showed me percentages correctly. Here is my phpunit.xml file

<?xml version="1.0" encoding="UTF-8"?>
<phpunit colors="true" bootstrap="vendor/autoload.php">
    <testsuite name="Full Suite">
        <directory>tests/</directory>
    </testsuite>
    <filter>
        <whitelist processUncoveredFilesFromWhitelist="true">
            <directory suffix=".php">src</directory>
        </whitelist>
    </filter>
    <logging>
        <log type="coverage-html" target="report"/>
    </logging>
</phpunit>

So it could be the beta release, but you can at least see my xml file and know that it works with 5.5.4. Good luck!