Merge pull request #11183 from jmcclelland/CRM-18048
[civicrm-core.git] / tests / phpunit / CiviTest / CiviUnitTestCase.php
index 13a6a96f8b5eb1cad40e65f6674b12c7ca6fdf2f..3b09fa937584f8df463456ddca86c5f3b2b4b973 100644 (file)
@@ -64,11 +64,6 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
    */
   private static $dbInit = FALSE;
 
-  /**
-   * Does the current setup support ONLY_FULL_GROUP_BY mode
-   */
-  protected $_supportFullGroupBy;
-
   /**
    *  Database connection.
    *
@@ -296,8 +291,6 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
     //  Get and save a connection to the database
     $this->_dbconn = $this->getConnection();
 
-    $this->_supportFullGroupBy = CRM_Utils_SQL::supportsFullGroupBy();
-
     // reload database before each test
     //        $this->_populateDB();
 
@@ -559,7 +552,7 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
     $expectedValue, $message
   ) {
     $value = CRM_Core_DAO::getFieldValue($daoName, $searchValue, $returnColumn, $searchColumn, TRUE);
-    $this->assertEquals($value, $expectedValue, $message);
+    $this->assertEquals($expectedValue, $value, $message);
   }
 
   /**
@@ -2098,10 +2091,6 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
 
     $params = array_merge($defaults, $params);
 
-    if (strlen($params['title']) > 13) {
-      $params['title'] = substr($params['title'], 0, 13);
-    }
-
     //have a crack @ deleting it first in the hope this will prevent derailing our tests
     $this->callAPISuccess('custom_group', 'get', array(
       'title' => $params['title'],
@@ -2594,6 +2583,8 @@ AND    ( TABLE_NAME LIKE 'civicrm_value_%' )
     $var = TRUE;
     CRM_Member_BAO_Membership::createRelatedMemberships($var, $var, TRUE);
     $this->disableTaxAndInvoicing();
+    $this->setCurrencySeparators(',');
+    CRM_Core_PseudoConstant::flush('taxRates');
     System::singleton()->flushProcessors();
   }
 
@@ -3092,7 +3083,6 @@ AND    ( TABLE_NAME LIKE 'civicrm_value_%' )
     if (!$isProfile) {
       //flush cache
       CRM_ACL_BAO_Cache::resetCache();
-      CRM_Contact_BAO_Group::getPermissionClause(TRUE);
       CRM_ACL_API::groupPermission('whatever', 9999, NULL, 'civicrm_saved_search', NULL, NULL, TRUE);
     }
   }
@@ -3572,7 +3562,6 @@ AND    ( TABLE_NAME LIKE 'civicrm_value_%' )
   protected function setPermissions($permissions) {
     CRM_Core_Config::singleton()->userPermissionClass->permissions = $permissions;
     $this->flushFinancialTypeStatics();
-    CRM_Contact_BAO_Group::getPermissionClause(TRUE);
   }
 
   /**
@@ -3952,4 +3941,35 @@ AND    ( TABLE_NAME LIKE 'civicrm_value_%' )
     return $form;
   }
 
+  /**
+   * Get possible thousand separators.
+   *
+   * @return array
+   */
+  public function getThousandSeparators() {
+    return array(array('.'), array(','));
+  }
+
+  /**
+   * Set the separators for thousands and decimal points.
+   *
+   * @param string $thousandSeparator
+   */
+  protected function setCurrencySeparators($thousandSeparator) {
+    Civi::settings()->set('monetaryThousandSeparator', $thousandSeparator);
+    Civi::settings()
+      ->set('monetaryDecimalPoint', ($thousandSeparator === ',' ? '.' : ','));
+  }
+
+  /**
+   * Format money as it would be input.
+   *
+   * @param string $amount
+   *
+   * @return string
+   */
+  protected function formatMoneyInput($amount) {
+    return CRM_Utils_Money::format($amount, NULL, '%a');
+  }
+
 }