Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get XDebug to run with PHPUnit on the CLI?

I've tried running the following CLI command:

phpunit -d xdebug.profiler_enable=on XYZTestCase.php 

but it just runs as normal. Can anyone point me in the right direction?? Thx!

Here's the XDebug settings:

xdebug  xdebug support => enabled Version => 2.1.2  Supported protocols => Revision DBGp - Common DeBuGger Protocol => $Revision: 1.145 $  Directive => Local Value => Master Value xdebug.auto_trace => Off => Off xdebug.collect_assignments => Off => Off xdebug.collect_includes => On => On xdebug.collect_params => 0 => 0 xdebug.collect_return => Off => Off xdebug.collect_vars => Off => Off xdebug.default_enable => On => On xdebug.dump.COOKIE => no value => no value xdebug.dump.ENV => no value => no value xdebug.dump.FILES => no value => no value xdebug.dump.GET => no value => no value xdebug.dump.POST => no value => no value xdebug.dump.REQUEST => no value => no value xdebug.dump.SERVER => no value => no value xdebug.dump.SESSION => no value => no value xdebug.dump_globals => On => On xdebug.dump_once => On => On xdebug.dump_undefined => Off => Off xdebug.extended_info => On => On xdebug.file_link_format => no value => no value xdebug.idekey => Nam => no value xdebug.manual_url => http://www.php.net => http://www.php.net xdebug.max_nesting_level => 100 => 100 xdebug.overload_var_dump => On => On xdebug.profiler_aggregate => Off => Off xdebug.profiler_append => Off => Off xdebug.profiler_enable => Off => Off xdebug.profiler_enable_trigger => Off => Off xdebug.profiler_output_dir => c:/wamp/tmp => c:/wamp/tmp xdebug.profiler_output_name => cachegrind.out.%t.%p => cachegrind.out.%t.%p xdebug.remote_autostart => On => On xdebug.remote_connect_back => Off => Off xdebug.remote_cookie_expire_time => 3600 => 3600 xdebug.remote_enable => On => On xdebug.remote_handler => dbgp => dbgp xdebug.remote_host => localhost => localhost xdebug.remote_log => no value => no value xdebug.remote_mode => req => req xdebug.remote_port => 9000 => 9000 xdebug.scream => Off => Off xdebug.show_exception_trace => Off => Off xdebug.show_local_vars => Off => Off xdebug.show_mem_delta => Off => Off xdebug.trace_format => 0 => 0 xdebug.trace_options => 0 => 0 xdebug.trace_output_dir => \ => \ xdebug.trace_output_name => trace.%c => trace.%c xdebug.var_display_max_children => 128 => 128 xdebug.var_display_max_data => 512 => 512 xdebug.var_display_max_depth => 3 => 3 
like image 926
blacktie24 Avatar asked Aug 24 '12 06:08

blacktie24


People also ask

How do I run PHPUnit?

How to Run Tests in PHPUnit. You can run all the tests in a directory using the PHPUnit binary installed in your vendor folder. You can also run a single test by providing the path to the test file. You use the --verbose flag to get more information on the test status.


1 Answers

The xdebug.profiler_enable setting can't be changed at runtime but only at the start of script.

Running phpunit -d foo=bar will just lead to phpunit calling ini_set("foo", "bar"); and that doesn't work since the value can't change at runtime.

See: xdebug.profiler_enable

Enables Xdebug's profiler which creates files in the profile output directory. Those files can be read by KCacheGrind to visualize your data. This setting can not be set in your script with ini_set(). If you want to selectively enable the profiler, please set xdebug.profiler_enable_trigger to 1 instead of using this setting.

Solution:

php -d xdebug.profiler_enable=on /usr/bin/phpunit XYZTestCase.php 

By applying the setting directly to the PHP runtime and not phpunit it will be set before the script starts and should work.

like image 182
edorian Avatar answered Oct 08 '22 08:10

edorian