CRM-17860 - phpunit bootstrap - Set CIVICRM_UF=UnitTests
authorTim Otten <totten@civicrm.org>
Fri, 22 Jan 2016 10:43:34 +0000 (02:43 -0800)
committerTim Otten <totten@civicrm.org>
Tue, 2 Feb 2016 04:56:23 +0000 (21:56 -0700)
This has been set in civicrm.settings.dist.php, but we're moving toward a
consolidated settings file.  But we still need bit of logic which says: "Run
most unit tests in a headless environment." This pushes the policy pretty
far outside the code.

tests/phpunit/CiviTest/bootstrap.php
tools/scripts/phpunit

index e23312f52c02a4dcf67d8f2a0af75dafb41991bd..e688e6d26caf724fff9ac6c09d229c6cd1ed3e11 100644 (file)
@@ -31,3 +31,7 @@ require $GLOBALS['base_dir'] . DIRECTORY_SEPARATOR .
 'PHPUnit' . DIRECTORY_SEPARATOR .
 'Autoload.php';
  */
+
+if (!defined('CIVICRM_UF') && getenv('CIVICRM_UF')) {
+  define('CIVICRM_UF', getenv('CIVICRM_UF'));
+}
\ No newline at end of file
index 72e46ef00c0c4f211260b5fba69d543209664797..6e16d0a2053c6680cd755023d96f604578801e5b 100755 (executable)
@@ -36,6 +36,10 @@ foreach ($argv as $k => $v) {
   elseif (preg_match('/^Civi\\\\/', $v)) {
     $argv[$k] = 'tests/phpunit/' . strtr($v, '\\', '/') . '.php';
   }
+
+  if (!preg_match('/^(WebTest)/', $v)) {
+    putenv('CIVICRM_UF=UnitTests');
+  }
 }
 
 // Transition: Make sure we use phpunit code from PATH, not
@@ -50,6 +54,7 @@ if (is_dir('packages/PHPUnit/')) {
 
 $cmd =
   findPhp() // In case this system has multiple copies of PHP, use the active/preferred one.
+  // . ' -ddisplay_errors=1'
   . ' '
   . escapeshellarg($phpunit)
   . ' '