Skip to content

Class not found (custom autoloader) #101

@mrodikov

Description

@mrodikov
Q A
PHPUnit version 9.3.8
PHPCov version 8.1.0
PHP version 7.3.11, 7.4.7
Installation Method Composer

(PHAR doesn't work for me with the above PHPUnit & PHPCov versions, coverage file produced by PHPUnit is loaded as "Incomplete" class in PHPCov)

Summary

When using a custom class loader and processUncoveredFiles="true", an error occurs in PHPCov due to inability to find the class.

Current behavior

Generating code coverage report in HTML format ...
[Uncaught Error in /path/to/phpcov-issue-demo/lib/MyPreciousLib/Seasonings/TikkaMassala.php on line 3]
Error: Class 'BaseSeasonings_Curry' not found in /path/to/phpcov-issue-demo/lib/MyPreciousLib/Seasonings/TikkaMassala.php:3

How to reproduce

  1. Clone demo project https://github.com/mrodikov/phpcov-issue-demo
phpdbg -qrr /path/to/any/phpunit/bin/phpunit -c /path/to/phpcov-issue-demo/lib/MyPreciousLib/phpunit.xml --coverage-php /path/to/phpcov-issue-demo/var/coverage.cov
phpdbg -qrr /path/to/any/phpcov/bin/phpcov  merge --html /path/to/html/report/ /path/to/phpcov-issue-demo/var/

Expected behavior

HTML coverage report generated

Notes

The problem is that the custom autoloader is used, which can load Path_To_My_Real_Class classes from Path/To/My/Real/Class.php (obviously, the includePath option will not work here).
PHPUnit uses a custom autoloader since I explicitly included it in bootstrap.php.
PHPCov knows nothing about phpunit.xml or bootstrap.php, so it cannot find the class.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions