Refactor cache flush CRM-12464
authorColeman Watts <coleman@civicrm.org>
Tue, 30 Apr 2013 22:12:03 +0000 (15:12 -0700)
committerColeman Watts <coleman@civicrm.org>
Wed, 29 May 2013 21:49:49 +0000 (14:49 -0700)
----------------------------------------
* CRM-12464: Search improvements in 4.4
  http://issues.civicrm.org/jira/browse/CRM-12464

CRM/Core/PseudoConstant.php
tests/phpunit/CiviTest/CiviUnitTestCase.php
tests/phpunit/api/v3/AddressTest.php
tests/phpunit/api/v3/ConstantTest.php
tests/phpunit/api/v3/PhoneTest.php

index 6bd6d44bc5efe2be04548b5b33969ec5fe01c388..af97571dd107f2f7e2bf4e4abe7128358d29c876 100644 (file)
@@ -529,8 +529,8 @@ class CRM_Core_PseudoConstant {
    * @param boolean $name pseudoconstant to be flushed
    *
    */
-  public static function flush($name) {
-    if (isset(self::$$name)) {
+  public static function flush($name = 'cache') {
+    if (property_exists(self, $name)) {
       self::$$name = NULL;
     }
   }
index 4166b792b7f33cbe963876c3616e4c905b7b1434..021c725ae1baf06807b8c10af0763049c659f21c 100644 (file)
@@ -1442,7 +1442,7 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
     $locationType->copyValues($params);
     $locationType->save();
     // clear getfields cache
-    CRM_Core_PseudoConstant::flush('locationType');
+    CRM_Core_PseudoConstant::flush();
     civicrm_api('phone', 'getfields', array('version' => 3, 'cache_clear' => 1));
     return $locationType;
   }
index bfdeda5b7ce2f178bd6618868bd2c4ca2da57387..da6ecf27c1f0ab69449c20b25b639ea279bbd5fc 100644 (file)
@@ -47,7 +47,7 @@ class api_v3_AddressTest extends CiviUnitTestCase {
 
     $this->_contactID = $this->organizationCreate();
     $this->_locationType = $this->locationTypeCreate();
-    CRM_Core_PseudoConstant::flush('locationType');
+    CRM_Core_PseudoConstant::flush();
 
     $this->_params = array(
       'contact_id' => $this->_contactID,
index e54686cbdc496dac3b3cdd0032351173ba9ffe71..2d7a809e9e6295dafff0fde7f7c33951463b0ba0 100644 (file)
@@ -121,7 +121,7 @@ class api_v3_ConstantTest extends CiviUnitTestCase {
    */
   public function testLocationTypeGet() {
     // needed to get rid of cached values from previous tests
-    CRM_Core_PseudoConstant::flush('locationType');
+    CRM_Core_PseudoConstant::flush();
 
 
 
index 8ea4954cbf548a1867ca0df3de9f0a767dcf02bc..8260cf5be2cb9db8ef9af277432ce735008296d5 100644 (file)
@@ -49,7 +49,7 @@ class api_v3_PhoneTest extends CiviUnitTestCase {
     $this->_contactID    = $this->organizationCreate();
     $loc                 = $this->locationTypeCreate();
     $this->_locationType = $loc->id;
-    CRM_Core_PseudoConstant::flush('locationType');
+    CRM_Core_PseudoConstant::flush();
     $this->quickCleanup(array('civicrm_phone'));
     $this->_params = array(
       'contact_id' => $this->_contactID,