Merge pull request #12356 from pradpnayak/issue-202
[civicrm-core.git] / tests / phpunit / CiviTest / bootstrap.php
index 84b52d71635d8ac90a21fc2b85fc4b7fffc80a0b..d50ff31fadaef4550c8714ec856223e24013d9a5 100644 (file)
@@ -18,6 +18,10 @@ ini_set('memory_limit', '2G');
 define('CIVICRM_TEST', 1);
 eval(cv('php:boot --level=settings', 'phpcode'));
 
+if (CIVICRM_UF === 'UnitTests') {
+  Civi\Test::headless()->apply();
+}
+
 // ------------------------------------------------------------------------------
 
 /**
@@ -35,8 +39,10 @@ eval(cv('php:boot --level=settings', 'phpcode'));
 function cv($cmd, $decode = 'json') {
   $cmd = 'cv ' . $cmd;
   $descriptorSpec = array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => STDERR);
-  $env = $_ENV + array('CV_OUTPUT' => 'json');
-  $process = proc_open($cmd, $descriptorSpec, $pipes, __DIR__, $env);
+  $oldOutput = getenv('CV_OUTPUT');
+  putenv("CV_OUTPUT=json");
+  $process = proc_open($cmd, $descriptorSpec, $pipes, __DIR__);
+  putenv("CV_OUTPUT=$oldOutput");
   fclose($pipes[0]);
   $result = stream_get_contents($pipes[1]);
   fclose($pipes[1]);