\Civi - Use facade instead of Civi\Core\Container::singleton()
authorTim Otten <totten@civicrm.org>
Wed, 19 Aug 2015 06:19:27 +0000 (23:19 -0700)
committerTim Otten <totten@civicrm.org>
Thu, 17 Sep 2015 22:44:59 +0000 (15:44 -0700)
28 files changed:
CRM/Admin/Form/Job.php
CRM/Contact/BAO/GroupContactCache.php
CRM/Core/BAO/Cache.php
CRM/Core/Config.php
CRM/Core/DAO.php
CRM/Cxn/ApiRouter.php
CRM/Mailing/BAO/Mailing.php
CRM/Mailing/BAO/MailingJob.php
CRM/Mailing/Event/BAO/Forward.php
CRM/Mailing/Event/BAO/Reply.php
CRM/Mailing/Event/BAO/Resubscribe.php
CRM/Mailing/Event/BAO/Subscribe.php
CRM/Mailing/Event/BAO/Unsubscribe.php
CRM/Utils/Hook.php
CRM/Utils/Mail.php
Civi/Angular/Page/Main.php
Civi/Angular/Page/Modules.php
Civi/Core/Resolver.php
api/api.php
api/v3/Cxn.php
api/v3/Generic.php
api/v3/Generic/Getactions.php
api/v3/Job.php
bin/ContributionProcessor.php
tests/phpunit/CRM/Core/ManagedEntitiesTest.php
tests/phpunit/Civi/Core/ResolverTest.php
tests/phpunit/CiviTest/CiviUnitTestCase.php
tests/phpunit/api/v3/AttachmentTest.php

index f489aeb1bfd9224ac6ba7f87f70fdbbc3fb283e8..013a564ce6fa64b3f8c76900aa2ae47c41740871 100644 (file)
@@ -119,7 +119,7 @@ class CRM_Admin_Form_Job extends CRM_Admin_Form {
     require_once 'api/api.php';
 
     /** @var \Civi\API\Kernel $apiKernel */
-    $apiKernel = \Civi\Core\Container::singleton()->get('civi_api_kernel');
+    $apiKernel = \Civi::service('civi_api_kernel');
     $apiRequest = \Civi\API\Request::create($fields['api_entity'], $fields['api_action'], array('version' => 3), NULL);
     try {
       $apiKernel->resolve($apiRequest);
index 7c31110c5a1036b68cdfff158607c96ae238a3b5..8bbaa3ff78d7f58837030bc022222d34ea648e64 100644 (file)
@@ -431,7 +431,7 @@ WHERE  id = %1
     }
 
     // grab a lock so other processes dont compete and do the same query
-    $lock = Civi\Core\Container::singleton()->get('lockManager')->acquire("data.core.group.{$groupID}");
+    $lock = Civi::service('lockManager')->acquire("data.core.group.{$groupID}");
     if (!$lock->isAcquired()) {
       // this can cause inconsistent results since we dont know if the other process
       // will fill up the cache before our calling routine needs it.
index 3f1bc9fb3d42b3071ade53da9ed73ce2566b4482..d6eb3d39ef9065bb79b020706f8d02189d01af5f 100644 (file)
@@ -153,7 +153,7 @@ class CRM_Core_BAO_Cache extends CRM_Core_DAO_Cache {
     // get a lock so that multiple ajax requests on the same page
     // dont trample on each other
     // CRM-11234
-    $lock = Civi\Core\Container::singleton()->get('lockManager')->acquire("cache.{$group}_{$path}._{$componentID}");
+    $lock = Civi::service('lockManager')->acquire("cache.{$group}_{$path}._{$componentID}");
     if (!$lock->isAcquired()) {
       CRM_Core_Error::fatal();
     }
index c78f37520ccb73ddcbb315e6157c4840b253a239..74be9981bc123b88d814b12afddbf4490163dfcf 100644 (file)
@@ -525,7 +525,7 @@ class CRM_Core_Config extends CRM_Core_Config_Variables {
    * @deprecated
    */
   public static function getMailer() {
-    return Civi\Core\Container::singleton()->get('pear_mail');
+    return Civi::service('pear_mail');
   }
 
   /**
index 6991d0d5ae656bc0af658f23b675ad810b37e4df..180cfba1845e58268d4f02eafdcf0edb20e12a34 100644 (file)
@@ -434,13 +434,13 @@ class CRM_Core_DAO extends DB_DataObject {
       $this->update();
 
       $event = new \Civi\Core\DAO\Event\PostUpdate($this);
-      \Civi\Core\Container::singleton()->get('dispatcher')->dispatch("DAO::post-update", $event);
+      \Civi::service('dispatcher')->dispatch("DAO::post-update", $event);
     }
     else {
       $this->insert();
 
       $event = new \Civi\Core\DAO\Event\PostUpdate($this);
-      \Civi\Core\Container::singleton()->get('dispatcher')->dispatch("DAO::post-insert", $event);
+      \Civi::service('dispatcher')->dispatch("DAO::post-insert", $event);
     }
     $this->free();
 
@@ -478,7 +478,7 @@ class CRM_Core_DAO extends DB_DataObject {
     $result = parent::delete($useWhere);
 
     $event = new \Civi\Core\DAO\Event\PostDelete($this, $result);
-    \Civi\Core\Container::singleton()->get('dispatcher')->dispatch("DAO::post-delete", $event);
+    \Civi::service('dispatcher')->dispatch("DAO::post-delete", $event);
 
     return $result;
   }
index 682be9d8ea11e634ad4595bd3096be31dfcc2828..5642a0a56efa60c1f7961622120667c7c319b632 100644 (file)
@@ -75,8 +75,7 @@ class CRM_Cxn_ApiRouter {
     }
 
     $whitelist = \Civi\API\WhitelistRule::createAll($cxn['perm']['api']);
-    Civi\Core\Container::singleton()
-      ->get('dispatcher')
+    \Civi::service('dispatcher')
       ->addSubscriber(new \Civi\API\Subscriber\WhitelistSubscriber($whitelist));
     CRM_Core_Config::singleton()->userPermissionTemp = new CRM_Core_Permission_Temp();
     if ($cxn['perm']['grant'] === '*') {
index be0727cf3476403a6228ef94f974fff4293e7bfe..27e00ee32122da1903081d928d56ffce47a96363 100644 (file)
@@ -2853,7 +2853,7 @@ WHERE  civicrm_mailing_job.id = %1
 
       // check if we are using global locks
       foreach ($lockArray as $lockID) {
-        $cronLock = Civi\Core\Container::singleton()->get('lockManager')->acquire("worker.mailing.send.{$lockID}");
+        $cronLock = Civi::service('lockManager')->acquire("worker.mailing.send.{$lockID}");
         if ($cronLock->isAcquired()) {
           $gotCronLock = TRUE;
           break;
index 4dee25c748fecaf009bdb6ddded5f411cd7ecb9f..6b51a925aab56546f43bddd5712a8c17319ee746 100644 (file)
@@ -136,7 +136,7 @@ class CRM_Mailing_BAO_MailingJob extends CRM_Mailing_DAO_MailingJob {
 
     while ($job->fetch()) {
       // still use job level lock for each child job
-      $lock = Civi\Core\Container::singleton()->get('lockManager')->acquire("data.mailing.job.{$job->id}");
+      $lock = Civi::service('lockManager')->acquire("data.mailing.job.{$job->id}");
       if (!$lock->isAcquired()) {
         continue;
       }
@@ -185,7 +185,7 @@ class CRM_Mailing_BAO_MailingJob extends CRM_Mailing_DAO_MailingJob {
 
       // Get the mailer
       if ($mode === NULL) {
-        $mailer = \Civi\Core\Container::singleton()->get('pear_mail');
+        $mailer = \Civi::service('pear_mail');
       }
       elseif ($mode == 'sms') {
         $mailer = CRM_SMS_Provider::singleton(array('mailing_id' => $job->mailing_id));
@@ -341,7 +341,7 @@ class CRM_Mailing_BAO_MailingJob extends CRM_Mailing_DAO_MailingJob {
     // X Number of child jobs
     while ($job->fetch()) {
       // still use job level lock for each child job
-      $lock = Civi\Core\Container::singleton()->get('lockManager')->acquire("data.mailing.job.{$job->id}");
+      $lock = Civi::service('lockManager')->acquire("data.mailing.job.{$job->id}");
       if (!$lock->isAcquired()) {
         continue;
       }
index ec6487f1d67d08aaea676d4b95a5246b31c5c093..4eca519539dce566b7ce9f20d91a3dd3386a444a 100644 (file)
@@ -172,7 +172,7 @@ class CRM_Mailing_Event_BAO_Forward extends CRM_Mailing_Event_DAO_Forward {
     $mailing_obj->find(TRUE);
 
     $config = CRM_Core_Config::singleton();
-    $mailer = \Civi\Core\Container::singleton()->get('pear_mail');
+    $mailer = \Civi::service('pear_mail');
 
     $recipient = NULL;
     $attachments = NULL;
index eae50e1c9839a5b3198be329a508f06cd0034546..989f73f94dbca2517e55fb4beb2e9e51b7c4f177 100644 (file)
@@ -201,7 +201,7 @@ class CRM_Mailing_Event_BAO_Reply extends CRM_Mailing_Event_DAO_Reply {
 
     CRM_Mailing_BAO_Mailing::addMessageIdHeader($h, 'r', $eq->job_id, $queue_id, $eq->hash);
     $config = CRM_Core_Config::singleton();
-    $mailer = \Civi\Core\Container::singleton()->get('pear_mail');
+    $mailer = \Civi::service('pear_mail');
 
     if (is_object($mailer)) {
       $errorScope = CRM_Core_TemporaryErrorScope::ignoreException();
@@ -293,7 +293,7 @@ class CRM_Mailing_Event_BAO_Reply extends CRM_Mailing_Event_DAO_Reply {
     $h = $message->headers($headers);
     CRM_Mailing_BAO_Mailing::addMessageIdHeader($h, 'a', $eq->job_id, queue_id, $eq->hash);
 
-    $mailer = \Civi\Core\Container::singleton()->get('pear_mail');
+    $mailer = \Civi::service('pear_mail');
     if (is_object($mailer)) {
       $errorScope = CRM_Core_TemporaryErrorScope::ignoreException();
       $mailer->send($to, $h, $b);
index ef3711e4489db4933826266aaae940c2e8f48543..7203f76bffb72c9b283d6585bf6af8d7b03d9e1d 100644 (file)
@@ -287,7 +287,7 @@ class CRM_Mailing_Event_BAO_Resubscribe {
     $b = CRM_Utils_Mail::setMimeParams($message);
     $h = $message->headers($headers);
 
-    $mailer = \Civi\Core\Container::singleton()->get('pear_mail');
+    $mailer = \Civi::service('pear_mail');
 
     if (is_object($mailer)) {
       $errorScope = CRM_Core_TemporaryErrorScope::ignoreException();
index 7d0acc4487b49cca163d16a07d8dd615c5aa590a..bf024c819e36560226358d6a2c2d07ce342b87f0 100644 (file)
@@ -291,7 +291,7 @@ SELECT     civicrm_email.id as email_id
       $this->id,
       $this->hash
     );
-    $mailer = \Civi\Core\Container::singleton()->get('pear_mail');
+    $mailer = \Civi::service('pear_mail');
 
     if (is_object($mailer)) {
       $errorScope = CRM_Core_TemporaryErrorScope::ignoreException();
index 4c105aae5077c38bf0cbbd9d8edbe61632d6e0d0..0be9d85dbe4cb7fdb8fec8bb246f071a6a14aa8c 100755 (executable)
@@ -406,7 +406,7 @@ WHERE  email = %2
     $b = CRM_Utils_Mail::setMimeParams($message);
     $h = $message->headers($headers);
 
-    $mailer = \Civi\Core\Container::singleton()->get('pear_mail');
+    $mailer = \Civi::service('pear_mail');
 
     if (is_object($mailer)) {
       $errorScope = CRM_Core_TemporaryErrorScope::ignoreException();
index 8d2ccc633b1998dee18df2621c36dc20d91db732..048f8d3c71393fd98f6fc7095917c7aa0c941026 100644 (file)
@@ -273,8 +273,8 @@ abstract class CRM_Utils_Hook {
    */
   public static function pre($op, $objectName, $id, &$params) {
     $event = new \Civi\Core\Event\PreEvent($op, $objectName, $id, $params);
-    \Civi\Core\Container::singleton()->get('dispatcher')->dispatch("hook_civicrm_pre", $event);
-    \Civi\Core\Container::singleton()->get('dispatcher')->dispatch("hook_civicrm_pre::$objectName", $event);
+    \Civi::service('dispatcher')->dispatch("hook_civicrm_pre", $event);
+    \Civi::service('dispatcher')->dispatch("hook_civicrm_pre::$objectName", $event);
     return self::singleton()
       ->invoke(4, $op, $objectName, $id, $params, self::$_nullObject, self::$_nullObject, 'civicrm_pre');
   }
@@ -297,8 +297,8 @@ abstract class CRM_Utils_Hook {
    */
   public static function post($op, $objectName, $objectId, &$objectRef) {
     $event = new \Civi\Core\Event\PostEvent($op, $objectName, $objectId, $objectRef);
-    \Civi\Core\Container::singleton()->get('dispatcher')->dispatch("hook_civicrm_post", $event);
-    \Civi\Core\Container::singleton()->get('dispatcher')->dispatch("hook_civicrm_post::$objectName", $event);
+    \Civi::service('dispatcher')->dispatch("hook_civicrm_post", $event);
+    \Civi::service('dispatcher')->dispatch("hook_civicrm_post::$objectName", $event);
     return self::singleton()
       ->invoke(4, $op, $objectName, $objectId, $objectRef, self::$_nullObject, self::$_nullObject, 'civicrm_post');
   }
@@ -1611,7 +1611,7 @@ abstract class CRM_Utils_Hook {
 
     // == 4.5+ ==
     $event = new \Civi\Core\Event\UnhandledExceptionEvent($exception, self::$_nullObject);
-    \Civi\Core\Container::singleton()->get('dispatcher')->dispatch("hook_civicrm_unhandled_exception", $event);
+    \Civi::service('dispatcher')->dispatch("hook_civicrm_unhandled_exception", $event);
   }
 
   /**
@@ -1861,7 +1861,7 @@ abstract class CRM_Utils_Hook {
    */
   public static function caseChange(\Civi\CCase\Analyzer $analyzer) {
     $event = new \Civi\CCase\Event\CaseChangeEvent($analyzer);
-    \Civi\Core\Container::singleton()->get('dispatcher')->dispatch("hook_civicrm_caseChange", $event);
+    \Civi::service('dispatcher')->dispatch("hook_civicrm_caseChange", $event);
 
     return self::singleton()->invoke(1, $angularModules,
       self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
index 37d304e3ed7c1271d1fb943a6ce740d50b9bcafb..7986f84eacdfc50239475a9590269556757f49c7 100644 (file)
@@ -260,7 +260,7 @@ class CRM_Utils_Mail {
 
     $to = array($params['toEmail']);
     $result = NULL;
-    $mailer = \Civi\Core\Container::singleton()->get('pear_mail');
+    $mailer = \Civi::service('pear_mail');
 
     // Mail_smtp and Mail_sendmail mailers require Bcc anc Cc emails
     // be included in both $to and $headers['Cc', 'Bcc']
index 09ccf0cab95eb583e2d00698fd338990e3ad2bae..2f945ebae7991b8562dfd726b0ba0af961df0607 100644 (file)
@@ -50,7 +50,7 @@ class Main extends \CRM_Core_Page {
   public function __construct($title = NULL, $mode = NULL, $res = NULL) {
     parent::__construct($title, $mode);
     $this->res = \CRM_Core_Resources::singleton();
-    $this->angular = \Civi\Core\Container::singleton()->get('angular');
+    $this->angular = \Civi::service('angular');
     $this->region = \CRM_Utils_Request::retrieve('snippet', 'String') ? 'ajax-snippet' : 'html-header';
   }
 
index 0190895d30dcde012161748275eb88a63d9a4d41..7526773bd2fc0200a7e17ee34554d3794e5d0cd9 100644 (file)
@@ -26,7 +26,7 @@ class Modules extends \CRM_Core_Page {
     /**
      * @var \Civi\Angular\Manager $angular
      */
-    $angular = \Civi\Core\Container::singleton()->get('angular');
+    $angular = \Civi::service('angular');
     $moduleNames = $this->parseModuleNames(\CRM_Utils_Request::retrieve('modules', 'String'), $angular);
 
     switch (\CRM_Utils_Request::retrieve('format', 'String')) {
index d76b5121645c1736eb183628942ac1b3716dc59d..6bb47fab6143d3e47538913f6c92b9f45d32ffe7 100644 (file)
@@ -72,11 +72,11 @@ class Resolver {
       switch ($url['scheme']) {
         case 'obj':
           // Object: Lookup in container.
-          return Container::singleton()->get($url['host']);
+          return \Civi::service($url['host']);
 
         case 'call':
           // Callback: Object/method in container.
-          $obj = Container::singleton()->get($url['host']);
+          $obj = \Civi::service($url['host']);
           return array($obj, ltrim($url['path'], '/'));
 
         case 'api3':
index 8b55d97347e26335c6a7e5a35d93db3ac4556a8d..e20c451d8f205a5e94ff8627d5da11049e0ccfdb 100644 (file)
@@ -20,7 +20,7 @@
  * @return array|int
  */
 function civicrm_api($entity, $action, $params, $extra = NULL) {
-  return \Civi\Core\Container::singleton()->get('civi_api_kernel')->run($entity, $action, $params, $extra);
+  return \Civi::service('civi_api_kernel')->run($entity, $action, $params, $extra);
 }
 
 /**
index 4080c2d1bf27a3be6bffcd2ad8f67a0a948c73cf..430446c8ece9cc3c3055d8d83f3bc2c1fcfcf821 100644 (file)
@@ -91,7 +91,7 @@ function civicrm_api3_cxn_register($params) {
 
   try {
     /** @var \Civi\Cxn\Rpc\RegistrationClient $client */
-    $client = \Civi\Core\Container::singleton()->get('cxn_reg_client');
+    $client = \Civi::service('cxn_reg_client');
     list($cxnId, $result) = $client->register($appMeta);
     CRM_Cxn_BAO_Cxn::updateAppMeta($appMeta);
   }
@@ -133,7 +133,7 @@ function civicrm_api3_cxn_unregister($params) {
   $appMeta = CRM_Cxn_BAO_Cxn::getAppMeta($cxnId);
 
   /** @var \Civi\Cxn\Rpc\RegistrationClient $client */
-  $client = \Civi\Core\Container::singleton()->get('cxn_reg_client');
+  $client = \Civi::service('cxn_reg_client');
   list($cxnId, $result) = $client->unregister($appMeta, CRM_Utils_Array::value('force', $params, FALSE));
 
   return $result;
@@ -240,7 +240,7 @@ function civicrm_api3_cxn_getlink($params) {
   }
 
   /** @var \Civi\Cxn\Rpc\RegistrationClient $client */
-  $client = \Civi\Core\Container::singleton()->get('cxn_reg_client');
+  $client = \Civi::service('cxn_reg_client');
   return $client->call($appMeta, 'Cxn', 'getlink', array(
     'page' => $params['page'],
   ));
index 70d2294d72404b3fcefcbffebca017355524574c..090970a584abdcf3b889e1f6383caadd4a5b344d 100644 (file)
@@ -170,7 +170,7 @@ function civicrm_api3_generic_getfields($apiRequest, $unique = TRUE) {
   // find any supplemental information
   $hypApiRequest = array('entity' => $apiRequest['entity'], 'action' => $action, 'version' => $apiRequest['version']);
   try {
-    list ($apiProvider, $hypApiRequest) = \Civi\Core\Container::singleton()->get('civi_api_kernel')->resolve($hypApiRequest);
+    list ($apiProvider, $hypApiRequest) = \Civi::service('civi_api_kernel')->resolve($hypApiRequest);
     if (isset($hypApiRequest['function'])) {
       $helper = '_' . $hypApiRequest['function'] . '_spec';
     }
index ce8fd8de2431b1d861bb153477a6b98a3051127c..97e752f1ca223881cccb6a13b5095ebbdae5f124 100644 (file)
@@ -39,7 +39,7 @@
  */
 function civicrm_api3_generic_getActions($apiRequest) {
   civicrm_api3_verify_mandatory($apiRequest, NULL, array('entity'));
-  $mfp = \Civi\Core\Container::singleton()->get('magic_function_provider');
+  $mfp = \Civi::service('magic_function_provider');
   $actions = $mfp->getActionNames($apiRequest['version'], $apiRequest['entity']);
   return civicrm_api3_create_success($actions, $apiRequest['params'], $apiRequest['entity'], 'getactions');
 }
index 7c6e2c179ebafa2eaf607584a84fee025bd70993..2d953119c86de4fd85f1f055a6516ac4b719f7d1 100644 (file)
@@ -178,7 +178,7 @@ function civicrm_api3_job_send_reminder($params) {
   // in that case (ie. makes it non-configurable via the UI). Another approach would be to set a default of 0
   // in the _spec function - but since that is a deprecated value it seems more contentious than this approach
   $params['rowCount'] = 0;
-  $lock = Civi\Core\Container::singleton()->get('lockManager')->acquire('worker.core.ActionSchedule');
+  $lock = Civi::service('lockManager')->acquire('worker.core.ActionSchedule');
   if (!$lock->isAcquired()) {
     return civicrm_api3_create_error('Could not acquire lock, another ActionSchedule process is running');
   }
@@ -354,7 +354,7 @@ function civicrm_api3_job_process_sms($params) {
  * @return array
  */
 function civicrm_api3_job_fetch_bounces($params) {
-  $lock = Civi\Core\Container::singleton()->get('lockManager')->acquire('worker.mailing.EmailProcessor');
+  $lock = Civi::service('lockManager')->acquire('worker.mailing.EmailProcessor');
   if (!$lock->isAcquired()) {
     return civicrm_api3_create_error('Could not acquire lock, another EmailProcessor process is running');
   }
@@ -377,7 +377,7 @@ function civicrm_api3_job_fetch_bounces($params) {
  * @return array
  */
 function civicrm_api3_job_fetch_activities($params) {
-  $lock = Civi\Core\Container::singleton()->get('lockManager')->acquire('worker.mailing.EmailProcessor');
+  $lock = Civi::service('lockManager')->acquire('worker.mailing.EmailProcessor');
   if (!$lock->isAcquired()) {
     return civicrm_api3_create_error('Could not acquire lock, another EmailProcessor process is running');
   }
@@ -430,7 +430,7 @@ function civicrm_api3_job_process_participant($params) {
  *   true if success, else false
  */
 function civicrm_api3_job_process_membership($params) {
-  $lock = Civi\Core\Container::singleton()->get('lockManager')->acquire('worker.member.UpdateMembership');
+  $lock = Civi::service('lockManager')->acquire('worker.member.UpdateMembership');
   if (!$lock->isAcquired()) {
     return civicrm_api3_create_error('Could not acquire lock, another Membership Processing process is running');
   }
@@ -627,7 +627,7 @@ function civicrm_api3_job_disable_expired_relationships($params) {
  * @throws \API_Exception
  */
 function civicrm_api3_job_group_rebuild($params) {
-  $lock = Civi\Core\Container::singleton()->get('lockManager')->acquire('worker.core.GroupRebuild');
+  $lock = Civi::service('lockManager')->acquire('worker.core.GroupRebuild');
   if (!$lock->isAcquired()) {
     throw new API_Exception('Could not acquire lock, another EmailProcessor process is running');
   }
index 5d007253d6047b318ee95da58a722ad0880d3a2e..538ac0dfd4aa2d90428deb2a265b35421a0c2092 100644 (file)
@@ -697,7 +697,7 @@ CRM_Utils_System::authenticateScript(TRUE);
 //log the execution of script
 CRM_Core_Error::debug_log_message('ContributionProcessor.php');
 
-$lock = Civi\Core\Container::singleton()->get('lockManager')->acquire('worker.contribute.CiviContributeProcessor');
+$lock = Civi::service('lockManager')->acquire('worker.contribute.CiviContributeProcessor');
 
 if ($lock->isAcquired()) {
   // try to unset any time limits
index 2f38ee2d903cbefe97ab6184b429560009b792c1..4977a05e8a5d802dd7e717db43496f6e533c7375 100644 (file)
@@ -55,14 +55,14 @@ class CRM_Core_ManagedEntitiesTest extends CiviUnitTestCase {
       ),
     );
 
-    $this->apiKernel = \Civi\Core\Container::singleton()->get('civi_api_kernel');
+    $this->apiKernel = \Civi::service('civi_api_kernel');
     $this->adhocProvider = new \Civi\API\Provider\AdhocProvider(3, 'CustomSearch');
     $this->apiKernel->registerApiProvider($this->adhocProvider);
   }
 
   public function tearDown() {
     parent::tearDown();
-    \Civi\Core\Container::singleton(TRUE);
+    \Civi::reset();
   }
 
   /**
index 2e63dfe04e808294cbd3e51d56848c603972eb4e..6e8f0d7fa7f670d8dacf6a5854c9384aeed97db0 100644 (file)
@@ -76,7 +76,7 @@ namespace Civi\Core {
      */
     public function testCall() {
       // Note: ResolverTestExampleService is implemented at the bottom of this file.
-      Container::singleton()->set('callbackTestService', new ResolverTestExampleService());
+      \Civi::container()->set('callbackTestService', new ResolverTestExampleService());
       $cb = $this->resolver->get('call://callbackTestService/ping');
       $expected = 'service dummy received foo';
       $actual = call_user_func($cb, 'foo');
@@ -116,7 +116,7 @@ namespace Civi\Core {
      */
     public function testObj() {
       // Note: ResolverTestExampleService is implemented at the bottom of this file.
-      Container::singleton()->set('callbackTestService', new ResolverTestExampleService());
+      \Civi::container()->set('callbackTestService', new ResolverTestExampleService());
       $obj = $this->resolver->get('obj://callbackTestService');
       $this->assertTrue($obj instanceof ResolverTestExampleService);
     }
index a8f17c3ea313cb01f5d37ee36b40b9e109b9464f..dc1c93ff1fefec215b58487899157e36a4c1ab1a 100755 (executable)
@@ -398,7 +398,7 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
 
     // initialize the object once db is loaded
     $config = CRM_Core_Config::singleton();
-    Civi\Core\Container::singleton(TRUE);
+    \Civi::reset();
 
     // when running unit tests, use mockup user framework
     $config->setUserFramework('UnitTests');
index a1b14aa7b2d1043e4d64be9a50b406b50927bdf8..ca23a703ca6a51b9ab2f5dd00ac2ae025596e63a 100644 (file)
@@ -62,7 +62,7 @@ class api_v3_AttachmentTest extends CiviUnitTestCase {
   protected function tearDown() {
     parent::tearDown();
     $this->cleanupFiles();
-    \Civi\Core\Container::singleton(TRUE);
+    \Civi::reset();
   }
 
   /**