Answers.Body: <p>Having a wild guess - are you setting </p>
  
  <pre><code>define('CIVICRM_UF', 'Drupal');
  </code></pre>
  
  <p>somewhere in your civicrm.setting file (I know we do)?</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-01-02T15:30:16.530Z
Answers.Text: This is a buildkit - civibuild: $ civibuild create dmaster --url http://d47.localhost --admin-pass mypass
Answers.UserDisplayName: KarinG - Semper IT
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-08-10T21:52:13.857Z
Answers.Text: 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!
Answers.UserDisplayName: Matthew Wire
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-09-26T16:51:20.677Z
Answers.Text: How old is your buildkit? 
Answers.UserDisplayName: KarinG - Semper IT
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-08-01T01:19:51.823Z
Answers.Text: checking versions: karins-macbook-pro:buildkit sysadmin$ phpunit4 --version
  PHPUnit 4.8.21 by Sebastian Bergmann and contributors.
Answers.UserDisplayName: KarinG - Semper IT
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-01-02T07:03:24.753Z
Answers.LastActivityDate: 2017-01-02T07:03:24.753Z
Answers.UserDisplayName: ErichBSchulz
Answers.Body: <p>Here are the steps/complete set of screenshots of a configuration that now works for me:</p>
  <p><strong>1) from command line ensure you can run buildkit -&gt; civibuild</strong></p>
  <p>$ civibuild create dmaster --type drupal-demo --civi-ver master --url <a href="http://dmaster.localhost" rel="nofollow noreferrer">http://dmaster.localhost</a> --admin-user myuser --admin-pass mypass</p>
  <p><strong>2) from command line ensure you can run tests</strong> - that all is working properly</p>
  <p>karins-macbook-pro:civicrm sysadmin$ pwd
  /Applications/MAMP/htdocs/buildkit/build/dmaster/sites/all/modules/civicrm</p>
  <pre><code>$ 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
  </code></pre>
  <p><strong>3) Ensure you can fire up a <a href="http://d47.localhost/" rel="nofollow noreferrer">http://d47.localhost/</a> in a browser and debug/set breakpoints</strong> anywhere in PHPStorm / step through code in your Drupal/CiviCRM code base - e.g.</p>
  <p><a href="https://i.sstatic.net/mOvGu.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/mOvGu.png" alt="enter image description here" /></a></p>
  <p><strong>4. PHPStorm: Preferences -&gt; Languages &amp; Frameworks -&gt; PHP:</strong></p>
  <p><a href="https://i.sstatic.net/k9LdY.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/k9LdY.png" alt="enter image description here" /></a></p>
  <p><strong>5. PHPStorm: Preferences -&gt; Project: Directories:</strong></p>
  <p><a href="https://i.sstatic.net/gv3DD.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/gv3DD.png" alt="enter image description here" /></a></p>
  <p><strong>6. PHPStorm: Preferences -&gt; Language &amp; Frameworks -&gt; PHP -&gt; PHPUnit:</strong></p>
  <p><a href="https://i.sstatic.net/vw3cB.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/vw3cB.png" alt="enter image description here" /></a></p>
  <p><strong>7. PHPStorm: Run -&gt; Edit Configurations -&gt; Default -&gt; PHP Unit:</strong></p>
  <p><a href="https://i.sstatic.net/rwame.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/rwame.png" alt="enter image description here" /></a></p>
  <p><strong>8. Run the test by right clicking on the test itself:</strong></p>
  <p><a href="https://i.sstatic.net/v9c9V.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/v9c9V.png" alt="enter image description here" /></a></p>
  <p><strong>9. Et voila:</strong></p>
  <p><a href="https://i.sstatic.net/c93M7.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/c93M7.png" alt="enter image description here" /></a>
  <a href="https://i.sstatic.net/XP0A6.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/XP0A6.png" alt="enter image description here" /></a></p>
  <p><strong>UPDATE JULY 2018</strong>
  After updating buildkit:</p>
  <pre><code>cd ~/buildkit
  git pull
  ./bin/civi-download-tools
  </code></pre>
  <p>I had to make some edits as some of the paths have changed. The edits I made are:</p>
  <p>ad 4:
  <a href="https://i.sstatic.net/H9bih.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/H9bih.png" alt="enter image description here" /></a></p>
  <p>ad 5:
  <a href="https://i.sstatic.net/t3bWu.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/t3bWu.png" alt="enter image description here" /></a></p>
  <p>ad 7: note you want to <code>Include parent environment variables</code>
  <a href="https://i.sstatic.net/dOacU.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/dOacU.png" alt="enter image description here" /></a></p>
  <p>And we're up and running again:
  <a href="https://i.sstatic.net/9zw0j.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/9zw0j.png" alt="enter image description here" /></a></p>
  <p><strong>UPDATE AUGUST 2020</strong>
  After updating buildkit and PHPStorm -&gt; here's the new screenshots!</p>
  <p><a href="https://i.sstatic.net/uO164.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/uO164.png" alt="enter image description here" /></a>
  <a href="https://i.sstatic.net/jWQDT.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/jWQDT.png" alt="enter image description here" /></a>
  <a href="https://i.sstatic.net/znmvu.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/znmvu.png" alt="enter image description here" /></a>
  <a href="https://i.sstatic.net/ewbkM.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/ewbkM.png" alt="enter image description here" /></a>
  <a href="https://i.sstatic.net/wzYSq.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/wzYSq.png" alt="enter image description here" /></a></p>
  <p>Running a test via the command line also using phpunit5 now:</p>
  <pre><code>karins-MBP:civicrm sysadmin$ env CIVICRM_UF=UnitTests phpunit5 --filter testSubmitWithTax ./tests/phpunit/CRM/Member/Form/MembershipRenewalTest
  Parsing schema description /Applications/MAMP/htdocs/buildkit/build/dmaster/web/sites/all/modules/civicrm/xml/schema/Schema.xml
  Extracting database information
  Extracting table information
  PHPUnit 5.7.27 by Sebastian Bergmann and contributors.
  .                                                                   1 / 1 (100%)
  Installing dmastercivi_rb7eb database
  Time: 9.92 seconds, Memory: 58.50MB
  OK (1 test, 18 assertions)
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2017-01-02T17:02:28.687Z
Answers.LastActivityDate: 2020-08-30T20:27:00.433Z
Answers.LastEditDate: 2020-08-30T20:27:00.433Z
Answers.UserDisplayName: KarinG - Semper IT
Body: <p><strong>My tools:</strong></p>
  <ul>
  <li>Instance generated with buildkit - civibuild: $ civibuild create
  dmaster --url <a href="http://d47.localhost" rel="nofollow noreferrer">http://d47.localhost</a> --admin-pass mypass</li>
  <li>Mac OS + PHPStorm 8.0.4 + MAMP (/Applications/MAMP/bin/php/php5.6.10/bin/php)</li>
  </ul>
  <p>I've been close to getting this to work a number of times - but still coming up short. I've looked at Eileen's: <a href="https://wiki.civicrm.org/confluence/display/CRMDOC/Tests+in+phpstorm" rel="nofollow noreferrer">https://wiki.civicrm.org/confluence/display/CRMDOC/Tests+in+phpstorm</a> and at Tim's <a href="https://civicrm.stackexchange.com/questions/15896/how-can-i-use-xdebug-with-civicrm-unit-tests/15899#15899">How can I use Xdebug with CiviCRM unit tests?</a> - but something is always slightly different.</p>
  <p>UPDATE - after buildkit and phpstorm updates -&gt; I’ve posted new slides in the answer below!</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-11-21T05:52:52.463Z
Comments.Text: For Netbeans users, the [equivalent instructions are available here](https://civicrm.stackexchange.com/a/27429/12)
Comments.UserDisplayName: Jon G - Megaphone Tech
Tags: <phpunit><xdebug>
Title: How do I run PHP Unit Tests w/ XDEBUG from within PHPStorm [on Mac]?
ThreadText: # How do I run PHP Unit Tests w/ XDEBUG from within PHPStorm [on Mac]?
  
  (Asked by: username_0 on 2017-01-02)
  
  **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?](https://civicrm.stackexchange.com/questions/15896/how-can-i-use-xdebug-with-civicrm-unit-tests/15899#15899) - but something is always slightly different.
  
  UPDATE - after buildkit and phpstorm updates -> I’ve posted new slides in the answer below!
  
  **Tags:** phpunit, xdebug
  
  > **Comments:**
  > **username_1**: For Netbeans users, the [equivalent instructions are available here](https://civicrm.stackexchange.com/a/27429/12)  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_0 on 2017-01-02. Score: 9 | Accepted answer
  
  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 --type drupal-demo --civi-ver master --url <http://dmaster.localhost> --admin-user myuser --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](https://i.sstatic.net/mOvGu.png)](https://i.sstatic.net/mOvGu.png)
  
  **4. PHPStorm: Preferences -> Languages & Frameworks -> PHP:**
  
  [![enter image description here](https://i.sstatic.net/k9LdY.png)](https://i.sstatic.net/k9LdY.png)
  
  **5. PHPStorm: Preferences -> Project: Directories:**
  
  [![enter image description here](https://i.sstatic.net/gv3DD.png)](https://i.sstatic.net/gv3DD.png)
  
  **6. PHPStorm: Preferences -> Language & Frameworks -> PHP -> PHPUnit:**
  
  [![enter image description here](https://i.sstatic.net/vw3cB.png)](https://i.sstatic.net/vw3cB.png)
  
  **7. PHPStorm: Run -> Edit Configurations -> Default -> PHP Unit:**
  
  [![enter image description here](https://i.sstatic.net/rwame.png)](https://i.sstatic.net/rwame.png)
  
  **8. Run the test by right clicking on the test itself:**
  
  [![enter image description here](https://i.sstatic.net/v9c9V.png)](https://i.sstatic.net/v9c9V.png)
  
  **9. Et voila:**
  
  [![enter image description here](https://i.sstatic.net/c93M7.png)](https://i.sstatic.net/c93M7.png)
  [![enter image description here](https://i.sstatic.net/XP0A6.png)](https://i.sstatic.net/XP0A6.png)
  
  **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](https://i.sstatic.net/H9bih.png)](https://i.sstatic.net/H9bih.png)
  
  ad 5:
  [![enter image description here](https://i.sstatic.net/t3bWu.png)](https://i.sstatic.net/t3bWu.png)
  
  ad 7: note you want to `Include parent environment variables`
  [![enter image description here](https://i.sstatic.net/dOacU.png)](https://i.sstatic.net/dOacU.png)
  
  And we're up and running again:
  [![enter image description here](https://i.sstatic.net/9zw0j.png)](https://i.sstatic.net/9zw0j.png)
  
  **UPDATE AUGUST 2020**
  After updating buildkit and PHPStorm -> here's the new screenshots!
  
  [![enter image description here](https://i.sstatic.net/uO164.png)](https://i.sstatic.net/uO164.png)
  [![enter image description here](https://i.sstatic.net/jWQDT.png)](https://i.sstatic.net/jWQDT.png)
  [![enter image description here](https://i.sstatic.net/znmvu.png)](https://i.sstatic.net/znmvu.png)
  [![enter image description here](https://i.sstatic.net/ewbkM.png)](https://i.sstatic.net/ewbkM.png)
  [![enter image description here](https://i.sstatic.net/wzYSq.png)](https://i.sstatic.net/wzYSq.png)
  
  Running a test via the command line also using phpunit5 now:
  
  ```
  karins-MBP:civicrm sysadmin$ env CIVICRM_UF=UnitTests phpunit5 --filter testSubmitWithTax ./tests/phpunit/CRM/Member/Form/MembershipRenewalTest
  Parsing schema description /Applications/MAMP/htdocs/buildkit/build/dmaster/web/sites/all/modules/civicrm/xml/schema/Schema.xml
  Extracting database information
  Extracting table information
  PHPUnit 5.7.27 by Sebastian Bergmann and contributors.
  .                                                                   1 / 1 (100%)
  Installing dmastercivi_rb7eb database
  Time: 9.92 seconds, Memory: 58.50MB
  OK (1 test, 18 assertions)
  
  ```
  
  
  ---
  
  ### Answer by username_2 on 2017-01-02. Score: 0
  
  Having a wild guess - are you setting
  
  ```
  define('CIVICRM_UF', 'Drupal');
  
  ```
  
  somewhere in your civicrm.setting file (I know we do)?
  
  > **Comments:**
  > **username_0**: This is a buildkit - civibuild: $ civibuild create dmaster --url http://d47.localhost --admin-pass mypass  
  > **username_3**: 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!  
  > **username_0**: How old is your buildkit?   
  > **username_0**: checking versions: karins-macbook-pro:buildkit sysadmin$ phpunit4 --version PHPUnit 4.8.21 by Sebastian Bergmann and contributors.  
  
  ---
  
  