define('CIVICRM_TEST', 1);
eval(cv('php:boot --level=settings', 'phpcode'));
-// This is exists to support CiviUnitTestCase::populateDB(). That doesn't make it a good idea.
-require_once "DB.php";
-$dsninfo = DB::parseDSN(CIVICRM_DSN);
-$GLOBALS['mysql_host'] = $dsninfo['hostspec'];
-$GLOBALS['mysql_port'] = @$dsninfo['port'];
-$GLOBALS['mysql_user'] = $dsninfo['username'];
-$GLOBALS['mysql_pass'] = $dsninfo['password'];
-$GLOBALS['mysql_db'] = $dsninfo['database'];
+if (CIVICRM_UF === 'UnitTests') {
+ Civi\Test::headless()->apply();
+}
// ------------------------------------------------------------------------------
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]);