Skip to content

Problem with coverage-html #675

@blink2004

Description

@blink2004
Q A
php-code-coverage version ?
PHP version 7.3.3
Driver Xdebug
Xdebug version (if used) 2.7.0
Installation Method PHPUnit PHAR
Usage Method PHPUnit
PHPUnit version (if used) 8.0.5

I just created own class and covered it with PHPUnit's tests. After executed command phpunit -v (1) they working. Was generated report about covered code by command phpunit --coverage-html ./report/ (2) then. It's working.

I decided use PHPUnit in more real project then. Took CMS WordPress by base. Created file /vendor/autolad.php, writen require_once '/wp-include/class-wp.php';. Run command (1) receive OK result. Then I decided generate report by command (2) and received message:
PHP Fatal error: Cannot declare class WP, because the name is already in use in /var/www/html/wordpress/wp-includes/class-wp.php on line 8

I commented line in autolad.php //require_once '/wp-include/class-wp.php';.

Then run command (2) again. Tests was executed - OK, but on generating report step received error:
Generating code coverage report in HTML format ...PHP Fatal error: Uncaught TypeError: date() expects parameter 2 to be int, string given in phar:///usr/local/bin/phpunit/php-code-coverage/Report/Html/Facade.php:63 Stack trace: #0 phar:///usr/local/bin/phpunit/php-code-coverage/Report/Html/Facade.php(63): date('D M j G:i:s T Y', '1554286376')

If I use XML format instead of HTML then all working.

I understand what mean this error, but don't understand why it happens with WordPress and not with my own demo-class? What I'm doing wrong?

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