Skip to content

PHPUnit and issues with html code coverage #137

@auroraeosrose

Description

@auroraeosrose

When using

phpunit:
     config: phpunit.xml
     reports:
        file:
            coverage: [html]

This creates incorrect command line arguments and menu items for html code coverage

First - the --coverage-html argument takes a directory path, NOT a filename. If you send it a filename it treats it as a directory name
Second the men item says "coverage.html" and links to "coverage.html.html" - which is in fact a directory

I've changed the code in Phpunit.php to cover the "weird" use case of coverage in html format with a special path for the coverage format when html is selected. It detects that the format is coverage and the format is html, creates a filename as a directory name for the arguments, and creates a menu item in userReports that links to the index.html in the code coverage directory

            foreach ($this->config->value('phpunit.reports.file') as $report => $formats) {
                foreach ($formats as $format) {
                    if($report == 'coverage' && $format == 'html') {
                        $filename = "{$report}-{$format}";
                        $args["{$report}-{$format}"] = $this->options->toFile($filename);
                        $this->tool->userReports["{$report}.{$format}"] = $this->options->rawFile($filename . '/index.html');
                    } else {
                        $extension = array_key_exists($format, $extensions) ? $extensions[$format] : $format;
                        $filename = "{$report}-{$format}.{$extension}";
                        $args["{$report}-{$format}"] = $this->options->toFile($filename);
                        $this->tool->userReports["{$report}.{$format}"] = $this->options->rawFile($filename);
                    }
                }
            }

I've tested this with all the other code coverage, testdoxs, and log output

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions