Answers.Body: <p>It's also worth noting that if you're using <code>civicrm-buildkit</code> to create your test sites (highly recommended) you can also rebuild a site with <code>civibuild reinstall</code>.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-10-18T06:31:30.970Z
Answers.Text: Using civi-buildkit is the only way I've gotten tests to run at all, as required files are not present in standards installs. I'm not sure a site rebuild would result in a schema rebuild (?) since I don't think any of the data used to create the comparison hash would have changed. I think I tried that once.
Answers.UserDisplayName: artfulrobot
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-10-18T06:38:16.597Z
Answers.Text: I didn't realize you needed a schema rebuild - for that you can always run `bin/regen.sh`, then do the reinstall.
Answers.UserDisplayName: Jon G - Megaphone Tech
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-10-18T06:42:22.857Z
Answers.Text: I think what you're suggesting will rebuild the main schema of the civi-buildkit site. When you run headless (the default type) tests a separate new database is created; the original buildkit one is supposedly untouched. I'll check out that command though, thanks
Answers.UserDisplayName: artfulrobot
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-10-18T06:23:10.103Z
Answers.LastActivityDate: 2017-10-18T06:23:10.103Z
Answers.UserDisplayName: Jon G - Megaphone Tech
Answers.Body: <p>ah-ha!</p>
  
  <p>In your test class edit the <code>setUpHeadless()</code> method which might look at first like this:</p>
  
  <pre><code>  public function setUpHeadless() {                                                                                                                                                                                                           
      // Civi\Test has many helpers, like install(), uninstall(), sql(), and sqlFile().
      // See: https://github.com/civicrm/org.civicrm.testapalooza/blob/master/civi-test.md
      return \Civi\Test::headless()
        -&gt;installMe(__DIR__)
        -&gt;apply();
  </code></pre>
  
  <p>But pass <code>TRUE</code> to <code>apply()</code>, ie</p>
  
  <pre><code>  public function setUpHeadless() {                                                                                                                                                                                                           
      // Civi\Test has many helpers, like install(), uninstall(), sql(), and sqlFile().
      // See: https://github.com/civicrm/org.civicrm.testapalooza/blob/master/civi-test.md
      return \Civi\Test::headless()
        -&gt;installMe(__DIR__)
        -&gt;apply(TRUE);
  </code></pre>
  
  <p>Ta-daa! And now your tests will run super slow as the schema will be reinstalled every time. But helps you out of  a spot, and you can of course remove that param.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-10-16T15:33:07.537Z
Answers.LastActivityDate: 2017-10-16T15:33:07.537Z
Answers.UserDisplayName: artfulrobot
Body: <p>I'm using headless phpunit tests. I noticed that the first time I do this it pauses and says about installing schema for xxxx - a test database.</p>
  
  <p>If you break stuff enough, you can end up with a corrupted/no-good test CRM database. How do you get a fresh one back?</p>
  
  <p>I tried dropping the test database, but that just caused errors.</p>
  
  <p>Thanks.</p>
  
Tags: <developer><civix><testing><cv>
Title: How to reset the headless test db?
ThreadText: # How to reset the headless test db?
  
  (Asked by: username_0 on 2017-07-03)
  
  I'm using headless phpunit tests. I noticed that the first time I do this it pauses and says about installing schema for xxxx - a test database.
  
  If you break stuff enough, you can end up with a corrupted/no-good test CRM database. How do you get a fresh one back?
  
  I tried dropping the test database, but that just caused errors.
  
  Thanks.
  
  **Tags:** developer, civix, testing, cv
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_0 on 2017-10-16. Score: 6 | Accepted answer
  
  ah-ha!
  
  In your test class edit the `setUpHeadless()` method which might look at first like this:
  
  ```
    public function setUpHeadless() {                                                                                                                                                                                                           
      // Civi\Test has many helpers, like install(), uninstall(), sql(), and sqlFile().
      // See: https://github.com/civicrm/org.civicrm.testapalooza/blob/master/civi-test.md
      return \Civi\Test::headless()
        ->installMe(__DIR__)
        ->apply();
  
  ```
  
  But pass `TRUE` to `apply()`, ie
  
  ```
    public function setUpHeadless() {                                                                                                                                                                                                           
      // Civi\Test has many helpers, like install(), uninstall(), sql(), and sqlFile().
      // See: https://github.com/civicrm/org.civicrm.testapalooza/blob/master/civi-test.md
      return \Civi\Test::headless()
        ->installMe(__DIR__)
        ->apply(TRUE);
  
  ```
  
  Ta-daa! And now your tests will run super slow as the schema will be reinstalled every time. But helps you out of a spot, and you can of course remove that param.
  
  
  ---
  
  ### Answer by username_1 on 2017-10-18. Score: 1
  
  It's also worth noting that if you're using `civicrm-buildkit` to create your test sites (highly recommended) you can also rebuild a site with `civibuild reinstall`.
  
  > **Comments:**
  > **username_0**: Using civi-buildkit is the only way I've gotten tests to run at all, as required files are not present in standards installs. I'm not sure a site rebuild would result in a schema rebuild (?) since I don't think any of the data used to create the comparison hash would have changed. I think I tried that once.  
  > **username_1**: I didn't realize you needed a schema rebuild - for that you can always run `bin/regen.sh`, then do the reinstall.  
  > **username_0**: I think what you're suggesting will rebuild the main schema of the civi-buildkit site. When you run headless (the default type) tests a separate new database is created; the original buildkit one is supposedly untouched. I'll check out that command though, thanks  
  
  ---
  
  