Sunday, July 1, 2018

cakephp3 laragon phpunit No code coverage driver is available

If you using CakePHP3 inside Laragon

Then when you study CakePHP3 testing you can generate the "testing results" into HTML

Problem is

phpunit --coverage-html webroot/coverage tests/TestCase/Model/Table/ArticlesTableTest

Return you this error "No code coverage driver is available"

Reason: Because no XDEBUG

Solution: Install it


How to install it, just follow this tutorial: https://forum.laragon.org/topic/264/tutorial-how-to-add-xdebug-to-laragon


I just repeat as the link

Check XDEBUG install or not, go to http://localhost/?q=info then search "xdebug"

If not install, press "ctrl + a" to select the whole page

Then go here https://xdebug.org/wizard.php and paste the whole page, then press button "Analyse my phpinfo() output"

The xdebug wizard will tell you what to do, in my case, to install XDEBUG into Laragon is

  1. Download php_xdebug-2.6.0-7.1-vc14-x86_64.dll
  2. Move the downloaded file to C:\laragon\bin\php\php-7.1.12-Win32-VC14-x64\ext
  3. Edit C:\laragon\bin\php\php-7.1.12-Win32-VC14-x64\php.ini and add the line
  4. zend_extension = C:\laragon\bin\php\php-7.1.12-Win32-VC14-x64\ext\php_xdebug-2.6.0-7.1-vc14-x86_64.dll
  5. Restart the webserver

After restart web server, run again the command

phpunit --coverage-html webroot/coverage tests/TestCase/Model/Table/ArticlesTableTest

and you will get, at the end of the console

Generating code coverage report in HTML format ... done

Then to access the HTML results, go

http://localhost/mycakeapp/coverage/index.html

-end-

No comments: