pillarOfLight pillarOfLight - 21 days ago 5
PHP Question

Trying to debug phpunit unit test on cli using xdebug fails

I'm using PHPStorm which is configured to use xDebug (I can debug via the web browser just fine)

I run the debugger in PHPStorm which has the idekey of 11854 and I'm trying to debug a unit test, and I've set the breakpoints properly

so I executed this command through the cli:

phpunit -d xdebug.profiler_enable=on -d xdebug.idekey=11854 --filter testFunction s_function/sFunctionTest.php


Nonetheless, it wouldn't debug at the breakpoint accordingly...

when I tried executing this in the test script:

error_log(ini_get('xdebug.profiler_enable'));
error_log(ini_get('xdebug.idekey'));


it would reveal that xdebug.profiler_enable is 0 and xdebug.idekey is just my username.

What did I do wrong and how can I get xdebug to work on phpunit through the cli

Answer

You are just setting arguments to phpunit, not to PHP. The following should do what you want:

php -d xdebug.profiler_enable=on -d xdebug.idekey=11854 `which phpunit` --filter testFunction s_function/sFunctionTest.php