Namespaced classes seem to be throwing Phing code coverage report generation for a loop. I’m getting a folder in the root of my project called .%5Creports%5Ccoverage that contains the .html files for any classes that are namespaced. All other classes generate the files in the proper directory as defined by ${reports.dir}/coverage.
When viewing the report in the browser, the links to the class files are pointing to where they should be, but of course I get a 404 because the files themselves have been put in the wrong place. Is this a bug, or am I doing something wrong?
Here are the relevant lines from each of my files:
build.properties:
base.dir = .
tests.dir = ${base.dir}/tests
reports.dir = ${base.dir}/reports
build.xml:
<!-- Run code coverage for PHP files -->
<target name="coverage">
<coverage-setup database="${reports.dir}/coverage/coverage.db">
<fileset refid="php-files" />
</coverage-setup>
<phpunit bootstrap="${tests.dir}/library/bootstrap.php" codecoverage="true">
<batchtest>
<fileset refid="tests" />
</batchtest>
</phpunit>
<coverage-report outfile="${reports.dir}/coverage/coverage.xml">
<report todir="${reports.dir}/coverage" />
</coverage-report>
</target>
<!-- PHP files -->
<fileset dir="${application.dir}" id="php-files">
<include name="**/*.php" />
</fileset>
<!-- Test files -->
<fileset dir="${tests.dir}/application" id="tests">
<include name="**/*Test.php" />
</fileset>
Example namespaced class:
<?php
namespace GDI\WebService;
class PredictionRequest
{
public $prefix;
}
Ended up tracking it down to this change http://www.phing.info/trac/changeset/1123/trunk/classes/phing/tasks/ext/coverage/CoverageReportTransformer.php. Edited phing/tasks/ext/coverage/CoverageReportTransformer.php to revert back to
$proc->setParameter('', 'output.dir', $dir->toString());and everything is working great now. Not sure what ‘efile’ confusion the changeset is referring to, but nothing broke for me after the edit.