public function tearDown() { parent::tearDown(); \Civi::reset(); }
protected function tearDown() { parent::tearDown(); $this->cleanupFiles(); \Civi::reset(); }
/** * 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 $GLOBALS['civicrm_setting']['domain']['fatalErrorHandler'] = 'CiviUnitTestCase_fatalErrorHandler'; $GLOBALS['civicrm_setting']['domain']['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(); // initialize the object once db is loaded \Civi::reset(); $config = CRM_Core_Config::singleton(TRUE, TRUE); // ugh, performance // when running unit tests, use mockup user framework $this->hookClass = CRM_Utils_Hook::singleton(); // Make sure the DB connection is setup properly $config->userSystem->setMySQLTimeZone(); $env = new CRM_Utils_Check_Component_Env(); CRM_Utils_Check::singleton()->assertValid($env->checkMysqlTime()); // clear permissions stub to not check permissions $config->userPermissionClass->permissions = NULL; //flush component settings CRM_Core_Component::getEnabledComponents(TRUE); error_reporting(E_ALL); $this->_sethtmlGlobals(); }
/** * @param HeadlessInterface|\PHPUnit_Framework_Test $test */ protected function bootHeadless($test) { if (CIVICRM_UF !== 'UnitTests') { throw new \RuntimeException('HeadlessInterface requires CIVICRM_UF=UnitTests'); } // Hrm, this seems wrong. Shouldn't we be resetting the entire session? $session = \CRM_Core_Session::singleton(); $session->set('userID', NULL); $test->setUpHeadless(); $config = \CRM_Core_Config::singleton(TRUE, TRUE); // ugh, performance \CRM_Utils_System::flushCache(); \Civi::reset(); \CRM_Core_Session::singleton()->set('userID', NULL); if (property_exists($config->userPermissionClass, 'permissions')) { $config->userPermissionClass->permissions = NULL; } }