8

My tools:

  • Instance generated with buildkit - civibuild: $ civibuild create dmaster --url http://d47.localhost --admin-pass mypass
  • Mac OS + PHPStorm 8.0.4 + MAMP (/Applications/MAMP/bin/php/php5.6.10/bin/php)

I've been close to getting this to work a number of times - but still coming up short. I've looked at Eileen's: https://wiki.civicrm.org/confluence/display/CRMDOC/Tests+in+phpstorm and at Tim's How can I use Xdebug with CiviCRM unit tests? - but something is always slightly different.

7

Here are the steps/complete set of screenshots of a configuration that now works for me:

1) from command line ensure you can run buildkit -> civibuild

$ civibuild create dmaster --url http://d47.localhost --admin-pass mypass

2) from command line ensure you can run tests - that all is working properly

karins-macbook-pro:civicrm sysadmin$ pwd /Applications/MAMP/htdocs/buildkit/build/dmaster/sites/all/modules/civicrm

$ cd /path/to/civicrm
$ env CIVICRM_UF=UnitTests phpunit4 ./tests/phpunit/CRM/AllTests.php

Installing dmastertes_7by9i schema

Installing dmastertes_7by9i database
PHPUnit 4.8.21 by Sebastian Bergmann and contributors.

...............................................

.......
^X^C

3) Ensure you can fire up a http://d47.localhost/ in a browser and debug/set breakpoints anywhere in PHPStorm / step through code in your Drupal/CiviCRM code base - e.g.

enter image description here

4. PHPStorm: Preferences -> Languages & Frameworks -> PHP:

enter image description here

5. PHPStorm: Preferences -> Project: Directories:

enter image description here

6. PHPStorm: Preferences -> Language & Frameworks -> PHP -> PHPUnit:

enter image description here

7. PHPStorm: Run -> Edit Configurations -> Default -> PHP Unit:

enter image description here

8. Run the test by right clicking on the test itself:

enter image description here

9. Et voila:

enter image description here enter image description here

UPDATE JULY 2018 After updating buildkit:

cd ~/buildkit
git pull
./bin/civi-download-tools

I had to make some edits as some of the paths have changed. The edits I made are:

ad 4: enter image description here

ad 5: enter image description here

ad 7: note you want to Include parent environment variables enter image description here

And we're up and running again: enter image description here

0

Having a wild guess - are you setting

define('CIVICRM_UF', 'Drupal');

somewhere in your civicrm.setting file (I know we do)?

  • This is a buildkit - civibuild: $ civibuild create dmaster --url d47.localhost --admin-pass mypass – KarinG - Semper IT Jan 2 '17 at 15:30
  • 1
    So this didn't work for me, until I updated the composer version of phpunit shipped with buildkit to 4.8.21 and used that in phpstorm. Then everything worked beautifully! – Matthew Wire Aug 10 '17 at 21:52
  • How old is your buildkit? 😀 – KarinG - Semper IT Sep 26 '17 at 16:51
  • checking versions: karins-macbook-pro:buildkit sysadmin$ phpunit4 --version PHPUnit 4.8.21 by Sebastian Bergmann and contributors. – KarinG - Semper IT Aug 1 '18 at 1:19

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.