示例#1
0
 /**
  *  Common teardown functions for all unit tests.
  */
 protected function tearDown()
 {
     error_reporting(E_ALL & ~E_NOTICE);
     CRM_Utils_Hook::singleton()->reset();
     $this->hookClass->reset();
     $session = CRM_Core_Session::singleton();
     $session->set('userID', NULL);
     if ($this->tx) {
         $this->tx->rollback()->commit();
         $this->tx = NULL;
         CRM_Core_Transaction::forceRollbackIfEnabled();
         \Civi\Core\Transaction\Manager::singleton(TRUE);
     } else {
         CRM_Core_Transaction::forceRollbackIfEnabled();
         \Civi\Core\Transaction\Manager::singleton(TRUE);
         $tablesToTruncate = array('civicrm_contact', 'civicrm_uf_match');
         $this->quickCleanup($tablesToTruncate);
         $this->createDomainContacts();
     }
     $this->cleanTempDirs();
     $this->unsetExtensionSystem();
 }
示例#2
0
 /**
  * Add a transaction callback.
  *
  * Note: It's conceivable to add callbacks to the main/overall transaction
  * (aka $manager->getBaseFrame()) or to the innermost nested transaction
  * (aka $manager->getFrame()). addCallback() has been used in the past to
  * work-around deadlocks. This may or may not be necessary now -- but it
  * seems more consistent (for b/c purposes) to attach callbacks to the
  * main/overall transaction.
  *
  * Pre-condition: isActive()
  *
  * @param int $phase
  *   A constant; one of: self::PHASE_{PRE,POST}_{COMMIT,ROLLBACK}.
  * @param string $callback
  *   A PHP callback.
  * @param mixed $params
  *   Optional values to pass to callback.
  *          See php manual call_user_func_array for details.
  * @param int $id
  */
 public static function addCallback($phase, $callback, $params = NULL, $id = NULL)
 {
     $frame = \Civi\Core\Transaction\Manager::singleton()->getBaseFrame();
     $frame->addCallback($phase, $callback, $params, $id);
 }