Skip to content

Feature: Post-process PHPUnit's PHP format using phpcov #216

Open

Description

@jwmwalrus

Hi.

Right now, PHP Censor seems to report coverage and artifacts from the generated HTML report.

In some cases (e.g., when the test invokes a headless browser through a behat/mink driver), the reported coverage is not accurate ---generation of coverage on both ends is required.

In order to solve the issue, one can modify the application router (e.g., web/app_test.php) to generate the actual coverage of each request from the browser's side (in PHP format) (using SebastianBergmann\CodeCoverage API). The generated files can later be combined with the the PHPUnit report (also in PHP format), using phpcov's merge option.

So the proposed feature comes down to:

  • adding one configuration option to the PHPUnit plugin, to indicate where to find the partial coverage files. For example:
test:
    php_unit:
        config:
            - "phpunit.xml.dist"
        coverage: "tests/reports/coverage"
        coverage_php: "tests/reports/tmp"
  • If applicable and/or possible, checking that there's a logging option for the PHP report in the phpuni.xml[.dist] file
        <log type="coverage-php"
            target="tests/reports/tmp/coverage.cov"
            />
  • Check that the bin/phpcov executable exists

  • After the tests run, generate the HTML report with

bin/phpcov ${coverage_php} ${coverage}

If there's no coverage_php option in the project's configuration, then the behavior is the current one.

Activity

  1. added this to the milestone on Sep 25, 2018
  2. corpsee commented on Sep 25, 2018

    @corpsee
    Member

    @jwmwalrus Thank you for the detailed issue with idea!

  3. modified the milestones: , Any future minor version (minor) on Apr 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions