Ejemplo n.º 1
0
 /**
  * @param bool $perClass
  * @param null $object
  * @return bool
  *   TRUE if the populate logic runs; FALSE if it is skipped
  */
 protected static function _populateDB($perClass = FALSE, &$object = NULL)
 {
     if (CIVICRM_UF !== 'UnitTests') {
         throw new \RuntimeException("_populateDB requires CIVICRM_UF=UnitTests");
     }
     if ($perClass || $object == NULL) {
         $dbreset = TRUE;
     } else {
         $dbreset = $object->requireDBReset();
     }
     if (self::$populateOnce || !$dbreset) {
         return FALSE;
     }
     self::$populateOnce = NULL;
     Civi\Test::data()->populate();
     return TRUE;
 }
Ejemplo n.º 2
0
ini_set('safe_mode', 0);
ini_set('include_path', dirname(__DIR__) . PATH_SEPARATOR . ini_get('include_path'));
#  Relying on system timezone setting produces a warning,
#  doing the following prevents the warning message
if (file_exists('/etc/timezone')) {
    $timezone = trim(file_get_contents('/etc/timezone'));
    if (ini_set('date.timezone', $timezone) === FALSE) {
        echo "ini_set( 'date.timezone', '{$timezone}' ) failed\n";
    }
}
# Crank up the memory
ini_set('memory_limit', '2G');
define('CIVICRM_TEST', 1);
eval(cv('php:boot --level=settings', 'phpcode'));
if (CIVICRM_UF === 'UnitTests') {
    Civi\Test::headless()->apply();
}
// ------------------------------------------------------------------------------
/**
 * Call the "cv" command.
 *
 * @param string $cmd
 *   The rest of the command to send.
 * @param string $decode
 *   Ex: 'json' or 'phpcode'.
 * @return string
 *   Response output (if the command executed normally).
 * @throws \RuntimeException
 *   If the command terminates abnormally.
 */
function cv($cmd, $decode = 'json')