Actions
Debugging CiviCRM cheatsheet » History » Revision 7
« Previous |
Revision 7/47
(diff)
| Next »
Jon Goldberg, 11/09/2020 07:38 PM
{{last_updated_at}} by {{last_updated_by}}
Debugging CiviCRM cheatsheet¶
Command-line runs of PHPUnit:¶
From a buildkit civiroot, run a specific file's tests::
CIVICRM_UF=UnitTests phpunit5 tests/phpunit/CRM/Core/BAO/AddressTest.php
You can also limit to a single test by filtering on name:
CIVICRM_UF=UnitTests phpunit5 tests/phpunit/CRM/Core/BAO/AddressTest.php --filter testShared
With XDebug¶
- You need to define an additional php.ini setting at runtime (otherwise XDebug will always be on for CLI, leading to a big loss in performance);
- You need to specify a full path to phpunit5 (because running
php <script>
won't check your path for the script, justphp
). - You need to have XDebug otherwise configured for CLI. Here's the contents of my
/etc/php/7.3/cli/conf.d/xdebug.ini
:
xdebug.remote_enable=1
xdebug.remote_autostart=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
- You need to start a debugging session in VS Code with "Listen for XDebug".
Once you've got all that:
env CIVICRM_UF=UnitTests idekey=VSCODE php -dzend_extension=/usr/lib/php/20180731/xdebug.so /home/jon/local/civicrm-buildkit/bin/phpunit5 tests/phpunit/CRM/Contact/Import/Parser/ContactTest.php --filter '^.*::testIgnoreLocationTypeId( .*)?$
Command-line runs of standalong scripts¶
env idekey=VSCODE php -dzend_extension=/usr/lib/php/20180731/xdebug.so myscript.php
Updated by Jon Goldberg about 4 years ago · 7 revisions