| 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
- 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.
(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
How to reproduce
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.