Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I'm getting incorrect code coverage reports with PHPUnit, and I believe it's a bug with XDebug.

How can I configure PHPUnit to use one of its other drivers, namely, PHPDBG?

(I'm using PHPUnit 4.7.7 and PHP 5.5.12)

like image 607
CL22 Avatar asked Nov 01 '15 19:11

CL22


1 Answers

PHPUnit selects the driver from the PHP Runtime environment so to run PHPUnit with PHPDBG you have to have that binary installed.

You will have to compile PHP with the option '--enable-phpdbg' but this is only for PHP 5.6 and above.

The instructions for installing for PHP 5.4 and above are, (these are taken from https://github.com/krakjoe/phpdbg), and to quote

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

Once installed you have to call PHPUnit through the phpdbg binary mine is located in '/usr/local/php7/bin' so the command I would use is

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

This assumes your 'phpunit' is in your environment path else use the full or relative path to your 'phpunit'.

I have PHPUnit installed via composer in my project source folder which is three directories up in the 'vendor' folder so my command would be

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

For more information see the documentation for PHPDBG http://phpdbg.com/docs/introduction

Hope this helps

like image 71
Shaun Freeman Avatar answered Oct 16 '22 03:10

Shaun Freeman