Answers.Body: <p>I found the answer: I was using a backup: the CiviCRM unit test framework uses files and services not found without doing a git clone (or buildkit equivalent). The folders you need from a git clone are Tests and Tools.</p>
  <p>Leaving this here in case it assists someone who encounters the same problem.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-03-06T23:54:24.903Z
Answers.LastActivityDate: 2021-03-06T23:54:24.903Z
Answers.UserDisplayName: JohnFF
Answers.Body: <p>I've found that I have to replace</p>
  <pre><code>eval(cv('php:boot --level=classloader', 'phpcode'));
  </code></pre>
  <p>with</p>
  <pre><code>eval(`cv php:boot --level=classloader`);
  </code></pre>
  <p>I had to make <a href="https://github.com/totten/civix/pull/153/files" rel="nofollow noreferrer">one other change</a> too but it's windows-specific.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-03-06T22:50:08.337Z
Answers.LastActivityDate: 2021-03-06T22:50:08.337Z
Answers.UserDisplayName: Demerit
Body: <p>Starting with a new machine, and a new buildkit instance! Buildkit/bin's contents added to PATH successfully.</p>
  <p>When I run cv php:boot --level classloader on the command line, I get:</p>
  <pre><code>/*BEGINPHP*/
  require_once  '/var/www/project/sites/all/modules/civicrm' . &quot;/CRM/Core/ClassLoader.php&quot;;\CRM_Core_ClassLoader::singleton()-&gt;register();
  /*ENDPHP*/
  </code></pre>
  <p>But when phpunit tests are through the command line (with any of phpunit5, phpunit6, or phpunit7), the cv command line fails, returning &quot;&quot;.</p>
  <p>In the test directory's phpunit bootstrap file, replacing $result with what's output above works until the next time cv is called in the process, whereupon it also breaks.</p>
  <p>I have set the execute permission on ~/buildkit/bin/cv to be globally executable. But it's the same user running it that cloned the buildkit repo.</p>
  <p>Any ideas?</p>
  
Tags: <civicrm-buildkit><phpunit>
Title: Why are cv php:boot calls failing only when running unit tests and not through direct CLI calls?
ThreadText: # Why are cv php:boot calls failing only when running unit tests and not through direct CLI calls?
  
  (Asked by: username_0 on 2021-03-06)
  
  Starting with a new machine, and a new buildkit instance! Buildkit/bin's contents added to PATH successfully.
  When I run cv php:boot --level classloader on the command line, I get:
  /*BEGINPHP*/
  require_once  '/var/www/project/sites/all/modules/civicrm' . "/CRM/Core/ClassLoader.php";\CRM_Core_ClassLoader::singleton()->register();
  /*ENDPHP*/
  
  But when phpunit tests are through the command line (with any of phpunit5, phpunit6, or phpunit7), the cv command line fails, returning "".
  In the test directory's phpunit bootstrap file, replacing $result with what's output above works until the next time cv is called in the process, whereupon it also breaks.
  I have set the execute permission on ~/buildkit/bin/cv to be globally executable. But it's the same user running it that cloned the buildkit repo.
  Any ideas?
  
  **Tags:** civicrm-buildkit, phpunit
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_0 on 2021-03-06. Score: 1
  
  I found the answer: I was using a backup: the CiviCRM unit test framework uses files and services not found without doing a git clone (or buildkit equivalent). The folders you need from a git clone are Tests and Tools.
  
  Leaving this here in case it assists someone who encounters the same problem.
  
  
  ---
  
  ### Answer by username_1 on 2021-03-06. Score: 0
  
  I've found that I have to replace
  eval(cv('php:boot --level=classloader', 'phpcode'));
  
  with
  eval(`cv php:boot --level=classloader`);
  
  I had to make one other change too but it's windows-specific.
  
  
  ---
  
  