如何选择 PHPUnit 用于代码覆盖的驱动程序?

How to choose the driver that PHPUnit uses for code coverage?

我收到 PHPUnit 的错误代码覆盖率报告,我认为这是 XDebug 的错误。

如何配置 PHP 单元以使用 one of its other drivers,即 PHPDBG?

(我使用的是 PHP 单元 4.7.7 和 PHP 5.5.12)

PHPUnit 从 PHP 运行时环境中选择驱动程序,因此要使用 PHPDBG 运行 PHPUnit,您必须安装该二进制文件.

您必须使用选项 '--enable-phpdbg' 编译 PHP 但这仅适用于 PHP 5.6 及更高版本。

PHP 5.4 及更高版本的安装说明是,(这些来自 https://github.com/krakjoe/phpdbg),并引用

To install phpdbg, you must compile the source against your PHP installation sources, and enable the SAPI with the configure command.

cd /usr/src/php-src/sapi
git clone https://github.com/krakjoe/phpdbg
cd ../
./buildconf --force
./configure --enable-phpdbg
make -j8
make install-phpdbg

安装后,您必须通过位于“/usr/local/php7/bin”中的 phpdbg 二进制文件调用 PHPUnit,因此我将使用的命令是

/usr/local/php7/bin/phpdbg -qrr phpunit -v

这假设您的 'phpunit' 在您的环境路径中,否则使用 'phpunit' 的完整路径或相对路径。

我通过 composer 在我的项目源文件夹中安装了 PHPUnit,它位于 'vendor' 文件夹中的三个目录之上,所以我的命令是

/usr/local/php7/bin/phpdbg -qrr ../../../vendor/bin/phpunit -v

有关详细信息,请参阅 PHPDBG http://phpdbg.com/docs/introduction

的文档

希望对您有所帮助