Merge pull request #16766 from seamuslee001/5_23_2_release_notes
[civicrm-core.git] / tests / phpunit / CiviTest / CiviUnitTestCase.php
index d0a00f5820eb3cc74135a6e875c9c1710bdfb0d9..173c06e6e1ebf239ecc31515661961246b5db6ec 100644 (file)
@@ -1009,6 +1009,7 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase {
    *   Name-value pair for an event.
    *
    * @return array
+   * @throws \CRM_Core_Exception
    */
   public function eventCreate($params = []) {
     // if no contact was passed, make up a dummy event creator
@@ -1050,12 +1051,16 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase {
    *
    * @param array $options
    *
+   * @param string $key
+   *   Index for storing event ID in ids array.
+   *
    * @return array
    *
    * @throws \CRM_Core_Exception
    */
-  protected function eventCreatePaid($params, $options = [['name' => 'hundy', 'amount' => 100]]) {
+  protected function eventCreatePaid($params, $options = [['name' => 'hundy', 'amount' => 100]], $key = 'event') {
     $event = $this->eventCreate($params);
+    $this->ids['event'][$key] = (int) $event['id'];
     $this->priceSetID = $this->ids['PriceSet'][] = $this->eventPriceSetCreate(55, 0, 'Radio', $options);
     CRM_Price_BAO_PriceSet::addTo('civicrm_event', $event['id'], $this->priceSetID);
     $priceSet = CRM_Price_BAO_PriceSet::getSetDetail($this->priceSetID, TRUE, FALSE);
@@ -1284,10 +1289,7 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase {
    * @return int
    */
   public function smartGroupCreate($smartGroupParams = [], $groupParams = [], $contactType = 'Household') {
-    $smartGroupParams = array_merge([
-      'formValues' => ['contact_type' => ['IN' => [$contactType]]],
-    ],
-      $smartGroupParams);
+    $smartGroupParams = array_merge(['form_values' => ['contact_type' => ['IN' => [$contactType]]]], $smartGroupParams);
     $savedSearch = CRM_Contact_BAO_SavedSearch::create($smartGroupParams);
 
     $groupParams['saved_search_id'] = $savedSearch->id;
@@ -3025,7 +3027,6 @@ VALUES
       [
         'invoicing' => 1,
         'invoice_prefix' => 'INV_',
-        'credit_notes_prefix' => 'CN_',
         'due_date' => 10,
         'due_date_period' => 'days',
         'notes' => '',
@@ -3262,14 +3263,52 @@ VALUES
   /**
    * Set the separators for thousands and decimal points.
    *
+   * Use setMonetaryDecimalPoint and setMonetaryThousandSeparator instead
+   *
    * @param string $thousandSeparator
+   * @deprecated
    */
   protected function setCurrencySeparators($thousandSeparator) {
+    // Jaap Jansma: I do think the code below is a bit useless. It does an assumption
+    // that when the thousand separator is a comma, the decimal is point. It
+    // does not cater for a situation where the thousand separator is a [space]
+    // Latter is the Norwegian localization.
     Civi::settings()->set('monetaryThousandSeparator', $thousandSeparator);
     Civi::settings()
       ->set('monetaryDecimalPoint', ($thousandSeparator === ',' ? '.' : ','));
   }
 
+  /**
+   * Sets the thousand separator.
+   *
+   * If you use this function also set the decimal separator: setMonetaryDecimalSeparator
+   *
+   * @param $thousandSeparator
+   */
+  protected function setMonetaryThousandSeparator($thousandSeparator) {
+    Civi::settings()->set('monetaryThousandSeparator', $thousandSeparator);
+  }
+
+  /**
+   * Sets the decimal separator.
+   *
+   * If you use this function also set the thousand separator setMonetaryDecimalPoint
+   *
+   * @param $decimalPoint
+   */
+  protected function setMonetaryDecimalPoint($decimalPoint) {
+    Civi::settings()->set('monetaryDecimalPoint', $decimalPoint);
+  }
+
+  /**
+   * Sets the default currency.
+   *
+   * @param $currency
+   */
+  protected function setDefaultCurrency($currency) {
+    Civi::settings()->set('defaultCurrency', $currency);
+  }
+
   /**
    * Format money as it would be input.
    *