From f5dfa52e0b4ace718afb9e52713e93febefe4f9f Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Fri, 22 Jan 2016 02:43:34 -0800 Subject: [PATCH] CRM-17860 - phpunit bootstrap - Set CIVICRM_UF=UnitTests 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 | 4 ++++ tools/scripts/phpunit | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/tests/phpunit/CiviTest/bootstrap.php b/tests/phpunit/CiviTest/bootstrap.php index e23312f52c..e688e6d26c 100644 --- a/tests/phpunit/CiviTest/bootstrap.php +++ b/tests/phpunit/CiviTest/bootstrap.php @@ -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 diff --git a/tools/scripts/phpunit b/tools/scripts/phpunit index 72e46ef00c..6e16d0a205 100755 --- a/tools/scripts/phpunit +++ b/tools/scripts/phpunit @@ -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) . ' ' -- 2.25.1