Open knallcharge opened 4 years ago
Sigh. You wrote Windows....
I'll try to have a look but i'm assuming it's a path mapping issue - again. Why do people in 2020 still use windows and drive letters...?
Again, I'll try to have a look as soon as I can but since I don't usually use windows I'll have to resurrect my Windows 10 VM and see if i can debug this somehow.
Any chance you can provide me with a simple sample project that exhibts the problem?
Thanks for getting back. Can't change company policy, so also Sigh for having to use Windows. I have setup a sample project here: https://github.com/Knallcharge/phpdox-test When building the project on Jenkins (using the same build-files as in the original project), phpdox returns "Enricher PHPUnit Coverage XML initialized successfully", also in the report it displays "Used Enrichers: build, phpcs, phploc, phpunit, pmd". The class is claimed "EMPTY": There a little difference to the original project which I couldn't track: clicking on the classname shows no coverage at all (maybe because the file is too small?) while in the original project it displayed "coverage 0%". But as the class is said to be "EMPTY" while it should not, I guess the origin of the problem is illustrated. Hope this helps.
Thanks for the sample project. I'll try to have a look over the weekend!
I found what cause the issue.
And it had nothing to do with Windows 😅
They are in fact 2 issues.
The coverage xml generated by phpunit change with the value of addUncoveredFilesFromWhitelist
addUncoveredFilesFromWhitelist
set to false
<phpunit xmlns="https://schema.phpunit.de/coverage/1.0">
<!-- [...] -->
<project source="${projectRoot}/phpdox-test-master/src/Service">
<!-- [...] -->
<directory name="/">
<!-- [...] -->
<file name="Math.php" href="Math.php.xml">
addUncoveredFilesFromWhitelist
set to true
<phpunit xmlns="https://schema.phpunit.de/coverage/1.0">
<!-- [...] -->
<project source="${projectRoot}/phpdox-test-master/src">
<!-- [...] -->
<directory name="/">
<!-- [...] -->
<directory name="Service">
<!-- [...] -->
<file name="Math.php" href="Service/Math.php.xml">
Note that the project source is not the same. And phpDox use the XPath query //pu:project/pu:directory/pu:directory[@name = "Service"]/pu:file[@name = "Math.php"]
(TheSeer\phpDox\Generator\Enricher\PHPUnit::loadCoverageInformation
)
So in the first version (which is used in the sample project), phpDox can't find the node as directories are merged in the project source.
The second issue is that PHPUnit coverage change its namespace from http://schema.phpunit.de/coverage/1.0
to https://schema.phpunit.de/coverage/1.0
(HTTP to HTTPS).
And in the xsl templates, the namespace is referenced with HTTP, so the namespace alias (pu
) don't match the actual namespace.
Which cause, for example, <xsl:when test="$class//pu:coverage/@coverage != 0 or $class//pu:coverage/@executable != 0">
to always failing (in units.xsl
)
Wow. Thanks for the in-depth analysis and for figuring this out. I'll try to have a look at it as soon as possible and provide a fixed version.
@sebastianbergmann Does the difference in output from PHPUnit qualify as a bug or as "works as intended"? :)
I'm using phpdox to generate the documentation for a project and I'm trying to include the PHPUnit-coverage, but it shows "EMPTY" for all files, e.g. my entities:
In issue #147 you state that "EMPTY" means that the file is "Not executable (e.g. an in interface)", but this happens for all my files. Also in the generated coverage-xml, the status for all files is "PASSED", e.g. for my User-entity:
Also in the corresponding xml for the Entity (User.php.xml) coverage is marked as "100":
But somehow phpdox is not able to map the information for some reason.
Here's the part of my phpunit.xml that generates the output:
This is my phpdox.xml:
And this the output of phpdox (from Jenkins) which shows no error:
Using phpdox 0.12.0 and PHPUnit 8.5.2 running on Jenkins 2.220 on Windows.