public static function setUpBeforeClass()
 {
     static::_populateDB(TRUE);
     // also set this global hack
     $GLOBALS['_PEAR_ERRORSTACK_OVERRIDE_CALLBACK'] = array();
     $env = new CRM_Utils_Check_Env();
     CRM_Utils_Check::singleton()->assertValid($env->checkMysqlTime());
 }
 /**
  *  Common setup functions for all unit tests.
  */
 protected function setUp()
 {
     $session = CRM_Core_Session::singleton();
     $session->set('userID', NULL);
     $this->errorScope = CRM_Core_TemporaryErrorScope::useException();
     // REVERT
     //  Use a temporary file for STDIN
     $GLOBALS['stdin'] = tmpfile();
     if ($GLOBALS['stdin'] === FALSE) {
         echo "Couldn't open temporary file\n";
         exit(1);
     }
     //  Get and save a connection to the database
     $this->_dbconn = $this->getConnection();
     // reload database before each test
     //        $this->_populateDB();
     // "initialize" CiviCRM to avoid problems when running single tests
     // FIXME: look at it closer in second stage
     // initialize the object once db is loaded
     CRM_Core_Config::$_mail = NULL;
     $config = CRM_Core_Config::singleton();
     // when running unit tests, use mockup user framework
     $config->setUserFramework('UnitTests');
     $this->hookClass = CRM_Utils_Hook::singleton(TRUE);
     // also fix the fatal error handler to throw exceptions,
     // rather than exit
     $config->fatalErrorHandler = 'CiviUnitTestCase_fatalErrorHandler';
     // enable backtrace to get meaningful errors
     $config->backtrace = 1;
     // disable any left-over test extensions
     CRM_Core_DAO::executeQuery('DELETE FROM civicrm_extension WHERE full_name LIKE "test.%"');
     // reset all the caches
     CRM_Utils_System::flushCache();
     // Make sure the DB connection is setup properly
     $config->userSystem->setMySQLTimeZone();
     $env = new CRM_Utils_Check_Env();
     CRM_Utils_Check::singleton()->assertValid($env->checkMysqlTime());
     // clear permissions stub to not check permissions
     $config = CRM_Core_Config::singleton();
     $config->userPermissionClass->permissions = NULL;
     //flush component settings
     CRM_Core_Component::getEnabledComponents(TRUE);
     error_reporting(E_ALL);
     $this->_sethtmlGlobals();
 }
Esempio n. 3
0
 /**
  * Run some sanity checks.
  *
  * This could become a hook so that CiviCRM can run both built-in
  * configuration & sanity checks, and modules/extensions can add
  * their own checks.
  *
  * We might even expose the results of these checks on the Wordpress
  * plugin status page or the Drupal admin/reports/status path.
  *
  * @return array of messages
  * @see Drupal's hook_requirements() -
  * https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_requirements
  */
 public function checkAll()
 {
     $security = new CRM_Utils_Check_Security();
     $env = new CRM_Utils_Check_Env();
     $messages = array_merge($security->checkAll(), $env->checkAll());
     return $messages;
 }