Merge pull request #7401 from sudhabisht/WebtesFix
authorDave Greenberg <dave@civicrm.org>
Mon, 7 Dec 2015 18:56:40 +0000 (10:56 -0800)
committerDave Greenberg <dave@civicrm.org>
Mon, 7 Dec 2015 18:56:40 +0000 (10:56 -0800)
Fixed test failure

14 files changed:
CRM/Admin/Form/Preferences.php
CRM/Admin/Form/Preferences/Contribute.php
CRM/Admin/Form/Preferences/Mailing.php
CRM/Admin/Form/Setting.php
CRM/Admin/Form/Setting/Smtp.php
CRM/Campaign/Form/Petition/Signature.php
CRM/Contribute/Form/Contribution.php
CRM/Contribute/Selector/Search.php
CRM/Core/Resources.php
CRM/Upgrade/Incremental/php/FourSeven.php
tests/phpunit/CRM/Core/BAO/SettingTest.php
tests/phpunit/CRM/Core/Payment/AuthorizeNetTest.php
tests/phpunit/CiviTest/CiviMailUtils.php
tests/phpunit/api/v3/TaxContributionPageTest.php

index d8e19ec4c80990b5ea3951680df90f185db02007..6b35849c9fada9e0f85adff8581700c6a0c3ec5b 100644 (file)
@@ -288,10 +288,7 @@ class CRM_Admin_Form_Preferences extends CRM_Core_Form {
     foreach ($this->_varNames as $groupName => $groupValues) {
       foreach ($groupValues as $settingName => $fieldValue) {
         $settingValue = isset($this->_config->$settingName) ? $this->_config->$settingName : NULL;
-        CRM_Core_BAO_Setting::setItem($settingValue,
-          $groupName,
-          $settingName
-        );
+        Civi::settings()->set($settingName, $settingValue);
       }
     }
     // Update any settings stored in dynamic js
index 0a5513cbd2b051261b22f9d7523d877f28a12e95..d3b1fc8c7982632f758804be2b2fbdfeb29efb47 100644 (file)
@@ -173,7 +173,7 @@ class CRM_Admin_Form_Preferences_Contribute extends CRM_Admin_Form_Preferences {
     $params = $this->controller->exportValues($this->_name);
     unset($params['qfKey']);
     unset($params['entryURL']);
-    $setInvoiceSettings = CRM_Core_BAO_Setting::setItem($params, CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME, 'contribution_invoice_settings');
+    Civi::settings()->set('contribution_invoice_settings', $params);
 
     // to set default value for 'Invoices / Credit Notes' checkbox on display preferences
     $values = CRM_Core_BAO_Setting::getItem("CiviCRM Preferences");
@@ -185,8 +185,7 @@ class CRM_Admin_Form_Preferences_Contribute extends CRM_Admin_Form_Preferences {
       $setInvoice = CRM_Core_DAO::VALUE_SEPARATOR .
         implode(CRM_Core_DAO::VALUE_SEPARATOR, array_keys($value)) .
         CRM_Core_DAO::VALUE_SEPARATOR;
-      CRM_Core_BAO_Setting::setItem($values['user_dashboard_options'] .
-        $setInvoice, 'CiviCRM Preferences', 'user_dashboard_options');
+      Civi::settings()->set('user_dashboard_options', $values['user_dashboard_options'] . $setInvoice);
     }
     else {
       $setting = explode(CRM_Core_DAO::VALUE_SEPARATOR, substr($values['user_dashboard_options'], 1, -1));
@@ -195,7 +194,7 @@ class CRM_Admin_Form_Preferences_Contribute extends CRM_Admin_Form_Preferences {
       $settingName = CRM_Core_DAO::VALUE_SEPARATOR .
         implode(CRM_Core_DAO::VALUE_SEPARATOR, array_values($setting)) .
         CRM_Core_DAO::VALUE_SEPARATOR;
-      CRM_Core_BAO_Setting::setItem($settingName, 'CiviCRM Preferences', 'user_dashboard_options');
+      Civi::settings()->set('user_dashboard_options', $settingName);
     }
     //CRM-16691: Changes made related to settings of 'CVV'.
     $settings = array_intersect_key($params, $this->_settings);
index 63bdb2072a244ce467cd9dfd144dd25d8ae75c72..1c41c07922e9ad546d30ac190bbee18577b1d341 100644 (file)
@@ -127,7 +127,7 @@ class CRM_Admin_Form_Preferences_Mailing extends CRM_Admin_Form_Preferences {
       if (!in_array($displayValue, $viewOptions)) {
         $existingViewOptions .= $displayValue . CRM_Core_DAO::VALUE_SEPARATOR;
 
-        CRM_Core_BAO_Setting::setItem($existingViewOptions, CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_view_options');
+        Civi::settings()->set('contact_view_options', $existingViewOptions);
         CRM_Core_Session::setStatus(ts('We have automatically enabled the Mailings tab for the Contact Summary screens
         so that you can view mailings sent to each contact.'), ts('Saved'), 'success');
       }
index 90b494806d31d690bc67452078692f9f5cf8b1a8..e1b743caade23df15400e02b37eecfba52f9fabd 100644 (file)
@@ -200,19 +200,13 @@ class CRM_Admin_Form_Setting extends CRM_Core_Form {
 
     // verify ssl peer option
     if (isset($params['verifySSL'])) {
-      CRM_Core_BAO_Setting::setItem($params['verifySSL'],
-        CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
-        'verifySSL'
-      );
+      Civi::settings()->set('verifySSL', $params['verifySSL']);
       unset($params['verifySSL']);
     }
 
     // force secure URLs
     if (isset($params['enableSSL'])) {
-      CRM_Core_BAO_Setting::setItem($params['enableSSL'],
-        CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
-        'enableSSL'
-      );
+      Civi::settings()->set('enableSSL', $params['enableSSL']);
       unset($params['enableSSL']);
     }
     $settings = array_intersect_key($params, $this->_settings);
index 1eb9661009dd694e4eb6bfadb7f8ef2bcb2b5998..84272a9583dacc0071ea3de16a96c8098e0e0e2c 100644 (file)
@@ -187,10 +187,7 @@ class CRM_Admin_Form_Setting_Smtp extends CRM_Admin_Form_Setting {
       $formValues['smtpPassword'] = CRM_Utils_Crypt::encrypt($formValues['smtpPassword']);
     }
 
-    CRM_Core_BAO_Setting::setItem($formValues,
-      CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME,
-      'mailing_backend'
-    );
+    Civi::settings()->set('mailing_backend', $formValues);
   }
 
   /**
index 23ed93be12f1b0f8d57c937dbb21a1c1db98b637..0693788fe0ee93d2d0df1d3fb564e6f0f102e948 100644 (file)
@@ -298,7 +298,7 @@ class CRM_Campaign_Form_Petition_Signature extends CRM_Core_Form {
     // add buttons
     $this->addButtons(array(
         array(
-          'type' => 'next',
+          'type' => 'upload',
           'name' => ts('Sign the Petition'),
           'isDefault' => TRUE,
         ),
index ced3745041c12d182281ea9eb1fbcfcc01fef5bc..f53b31e5f05f4e0c875edc645a98fdd4e3f479e4 100644 (file)
@@ -1622,7 +1622,7 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP
         || $params['contribution_status_id'] == CRM_Core_OptionGroup::getValue('contribution_status', 'Refunded', 'name')
       ) {
         if (CRM_Utils_System::isNull(CRM_Utils_Array::value('cancel_date', $params))) {
-          $params['cancel_date'] = date('Y-m-d');
+          $params['cancel_date'] = date('YmdHis');
         }
       }
       else {
index 06d96d025ca2a42f52b46ad4c56f5dc29d4ab061..bf931d8f42b173af249d77afe474382bbf5f0f1a 100644 (file)
@@ -338,6 +338,7 @@ class CRM_Contribute_Selector_Search extends CRM_Core_Selector_Base implements C
     $qfKey = $this->_key;
     $componentId = $componentContext = NULL;
     if ($this->_context != 'contribute') {
+      // @todo explain the significance of context & why we do not get these i that context.
       $qfKey = CRM_Utils_Request::retrieve('key', 'String', CRM_Core_DAO::$_nullObject);
       $componentId = CRM_Utils_Request::retrieve('id', 'Positive', CRM_Core_DAO::$_nullObject);
       $componentAction = CRM_Utils_Request::retrieve('action', 'String', CRM_Core_DAO::$_nullObject);
@@ -346,9 +347,17 @@ class CRM_Contribute_Selector_Search extends CRM_Core_Selector_Base implements C
       if (!$componentContext &&
         $this->_compContext
       ) {
+        // @todo explain when this condition might occur.
         $componentContext = $this->_compContext;
         $qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', CRM_Core_DAO::$_nullObject, NULL, FALSE, 'REQUEST');
       }
+      // CRM-17628 for some reason qfKey is not always set when searching from contribution search.
+      // as a result if the edit link is opened using right-click + open in new tab
+      // then the browser is not returned to the search results on save.
+      // This is an effort to getting the qfKey without, sadly, understanding the intent of those who came before me.
+      if (empty($qfKey)) {
+        $qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', CRM_Core_DAO::$_nullObject, NULL, FALSE, 'REQUEST');
+      }
     }
 
     // get all contribution status
index 08d6f05a0986982134675cb10faa6e106810e505..b9ff1e7f3ce77f72a046c6a265ad4f5e16cf9072 100644 (file)
@@ -557,7 +557,7 @@ class CRM_Core_Resources {
   public function setCacheCode($value) {
     $this->cacheCode = $value;
     if ($this->cacheCodeKey) {
-      CRM_Core_BAO_Setting::setItem($value, CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, $this->cacheCodeKey);
+      Civi::settings()->set($this->cacheCodeKey, $value);
     }
     return $this;
   }
index 5b64d18ab60f636e348d70d450b788b9f7b981a2..a33606c583e61f8ca5801aafdb01a5c7cec118eb 100644 (file)
@@ -134,7 +134,7 @@ class CRM_Upgrade_Incremental_php_FourSeven extends CRM_Upgrade_Incremental_Base
     // Previously a numeric value indicated one of 4 wysiwyg editors shipped in core, and no value indicated 'Textarea'
     // Now the options are "Textarea", "CKEditor", and the rest have been dropped from core.
     $newEditor = $editorID ? "CKEditor" : "Textarea";
-    CRM_Core_BAO_Setting::setItem($newEditor, CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'editor_id');
+    Civi::settings()->set('editor_id', $newEditor);
 
     return $editorID;
   }
index 48f140d5b8f7061e9c8a06adab337291f20c01bf..aeb3a040fac6b118d9457653f93ff59059f90f1e 100644 (file)
@@ -87,7 +87,7 @@ class CRM_Core_BAO_SettingTest extends CiviUnitTestCase {
     Civi::service('settings_manager')->useMandatory();
     $values = CRM_Core_BAO_Setting::getItem('Test Preferences');
     $this->assertEquals('/test/override', $values['overrideSetting']);
-    CRM_Core_BAO_Setting::setItem('/test/database', 'Test Preferences', 'databaseSetting');
+    Civi::settings()->set('databaseSetting', '/test/database');
     $values = CRM_Core_BAO_Setting::getItem('Test Preferences');
     $this->assertEquals('/test/override', $values['overrideSetting']);
     $this->assertEquals('/test/database', $values['databaseSetting']);
@@ -153,22 +153,14 @@ class CRM_Core_BAO_SettingTest extends CiviUnitTestCase {
 
     // set initial value
     $_testOnChange_hookCalls = array('count' => 0);
-    CRM_Core_BAO_Setting::setItem(
-      array('First', 'Value'),
-      'CiviCRM Preferences',
-      'onChangeExample'
-    );
+    Civi::settings()->set('onChangeExample', array('First', 'Value'));
     $this->assertEquals(1, $_testOnChange_hookCalls['count']);
     $this->assertEquals(array('First', 'Value'), $_testOnChange_hookCalls['newValue']);
     $this->assertEquals('List of Components', $_testOnChange_hookCalls['metadata']['title']);
 
     // change value
     $_testOnChange_hookCalls = array('count' => 0);
-    CRM_Core_BAO_Setting::setItem(
-      array('Second', 'Value'),
-      'CiviCRM Preferences',
-      'onChangeExample'
-    );
+    Civi::settings()->set('onChangeExample', array('Second', 'Value'));
     $this->assertEquals(1, $_testOnChange_hookCalls['count']);
     $this->assertEquals(array('First', 'Value'), $_testOnChange_hookCalls['oldValue']);
     $this->assertEquals(array('Second', 'Value'), $_testOnChange_hookCalls['newValue']);
index c766c4049992f03d026c91e4efd9e992ed198589..6803db78b936a3d70ef3eecf8bf0324dfd107bd3 100644 (file)
@@ -165,10 +165,10 @@ class CRM_Core_Payment_AuthorizeNetTest extends CiviUnitTestCase {
     );
 
     // turn verifySSL off
-    CRM_Core_BAO_Setting::setItem('0', CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'verifySSL');
+    Civi::settings()->set('verifySSL', '0');
     $this->doPayment($params);
     // turn verifySSL on
-    CRM_Core_BAO_Setting::setItem('0', CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'verifySSL');
+    Civi::settings()->set('verifySSL', '0');
 
     // if subscription was successful, processor_id / subscription-id must not be null
     $this->assertDBNotNull('CRM_Contribute_DAO_ContributionRecur', $recur->id, 'processor_id',
@@ -306,10 +306,10 @@ class CRM_Core_Payment_AuthorizeNetTest extends CiviUnitTestCase {
     $smarty->assign('subscriptionType', 'create');
 
     // turn verifySSL off
-    CRM_Core_BAO_Setting::setItem('0', CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'verifySSL');
+    Civi::settings()->set('verifySSL', '0');
     $this->doPayment($params);
     // turn verifySSL on
-    CRM_Core_BAO_Setting::setItem('0', CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'verifySSL');
+    Civi::settings()->set('verifySSL', '0');
 
     // if subscription was successful, processor_id / subscription-id must not be null
     $this->assertDBNotNull('CRM_Contribute_DAO_ContributionRecur', $recur->id, 'processor_id',
index ca3d7eb392ace7674676192cea11418a4a7bd09b..854974f18514c7e3c9b795fd9b04c164c11c6ab2 100644 (file)
@@ -106,10 +106,7 @@ class CiviMailUtils extends PHPUnit_Framework_TestCase {
       $this->_outBound_option = $mailingBackend['outBound_option'];
       $mailingBackend['outBound_option'] = CRM_Mailing_Config::OUTBOUND_OPTION_REDIRECT_TO_DB;
 
-      CRM_Core_BAO_Setting::setItem($mailingBackend,
-        CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME,
-        'mailing_backend'
-      );
+      Civi::settings()->set('mailing_backend', $mailingBackend);
 
       $mailingBackend = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME,
         'mailing_backend'
@@ -138,10 +135,7 @@ class CiviMailUtils extends PHPUnit_Framework_TestCase {
 
       $mailingBackend['outBound_option'] = $this->_outBound_option;
 
-      CRM_Core_BAO_Setting::setItem($mailingBackend,
-        CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME,
-        'mailing_backend'
-      );
+      Civi::settings()->set('mailing_backend', $mailingBackend);
     }
   }
 
index 51aab4e337f29a80db092b1877185539dd9c257f..90e48b54ae395f20384ca206ae67fb347c6cc0ce 100644 (file)
@@ -154,7 +154,7 @@ class api_v3_TaxContributionPageTest extends CiviUnitTestCase {
       'tax_term' => 'Sales Tax',
       'tax_display_settings' => 'Inclusive',
     );
-    $setInvoiceSettings = CRM_Core_BAO_Setting::setItem($contributeSetting, CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME, 'contribution_invoice_settings');
+    $setInvoiceSettings = Civi::settings()->set('contribution_invoice_settings', $contributeSetting);
 
     // Payment Processor
     $paymentProceParams = array(