Support PHPUnit clover reports (silently reported as zero coverage) - #617
Open
Eljees wants to merge 1 commit into
Open
Support PHPUnit clover reports (silently reported as zero coverage)#617Eljees wants to merge 1 commit into
Eljees wants to merge 1 commit into
Conversation
Bachmann1234
reviewed
Aug 7, 2026
| # Loop through the files that contain the xml roots | ||
| for i, xml_document in enumerate(self._xml_roots): | ||
| if xml_document.findall(".[@clover]"): | ||
| if self._is_clover_report(xml_document): |
Owner
There was a problem hiding this comment.
we should not have to recompute this for every file.
Perhaps we just compute a mapping in init so we can just turn this check into a dict lookup rather then re-searchign though the xml file?
Bachmann1234
reviewed
Aug 7, 2026
Comment on lines
149
to
151
| for file_tree in files: | ||
| lines.append(file_tree.findall('./line[@type="stmt"]')) | ||
| lines.append(file_tree.findall('./line[@type="cond"]')) |
Owner
There was a problem hiding this comment.
I think you need to add one of these for @type="method"
https://github.com/sebastianbergmann/php-code-coverage/blob/main/src/Report/Clover.php#L116
Owner
There was a problem hiding this comment.
to be clear, I know this was not in your changes, but I think it will prove important for ... honeslty both php clover and other clover reports
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #272.
A
clover.xmlwritten by PHPUnit comes out as zero coverage, without an error. Two independent reasons:XmlCoverageReporterrecognises Clover by.[@clover]on the root node. Atlassian Clover writes that attribute; PHPUnit writes a bare<coverage generated="…">, so the document falls through to the Cobertura branch, which finds nothing and returns an empty set instead of failing._get_src_path_line_nodes_clover()matches onfile/@path. PHPUnit identifies files with@name, so even once detection is fixed the lookup finds nothing.Detection now also accepts a document containing
file/line[@num][@count]— the element shape both dialects always produce — and the file lookup falls back to@name, comparing normalised paths and accepting a path that ends with the requested source path (PHPUnit writes absolute paths).Test added alongside the existing clover tests: a PHPUnit-shaped report whose covered lines are found. It fails on
main(empty result) and passes with the fix.AI-assisted (LLM used for drafting and for running the checks); the analysis and the runs are mine.