Skip to content
Snippets Groups Projects
Unverified Commit 30fe58ec authored by Monish Deb's avatar Monish Deb Committed by GitHub
Browse files

Merge pull request #20627 from demeritcowboy/currency-fixation

financial#175 - Unable to remove a currency once added
parents cdb0dde2 ddfe0227
Branches
Tags
No related merge requests found
......@@ -466,6 +466,12 @@ WHERE v.option_group_id = g.id
* the option group ID
*/
public static function createAssoc($groupName, &$values, &$defaultID, $groupTitle = NULL) {
// @TODO: This causes a problem in multilingual
// (https://github.com/civicrm/civicrm-core/pull/17228), but is needed in
// order to be able to remove currencies once added.
if (!CRM_Core_I18n::isMultiLingual()) {
self::deleteAssoc($groupName);
}
if (!empty($values)) {
$group = new CRM_Core_DAO_OptionGroup();
$group->name = $groupName;
......@@ -552,11 +558,8 @@ ORDER BY v.weight
/**
* @param string $groupName
* @param string $operator
*
* @deprecated
*/
public static function deleteAssoc($groupName, $operator = "=") {
CRM_Core_Error::deprecatedFunctionWarning('unused function');
$query = "
DELETE g, v
FROM civicrm_option_group g,
......
<?php
/**
* @group headless
*/
class CRM_Admin_Form_Setting_LocalizationTest extends CiviUnitTestCase {
/**
* Test adding and removing a currency.
*/
public function testUpdateCurrencies() {
CRM_Admin_Form_Setting_Localization::updateEnabledCurrencies(['USD', 'CAD'], 'USD');
CRM_Core_OptionGroup::flushAll();
$currencies = array_keys(CRM_Core_OptionGroup::values('currencies_enabled'));
$this->assertEquals(['CAD', 'USD'], $currencies, 'Unable to add a currency.');
// Now try to remove it.
CRM_Admin_Form_Setting_Localization::updateEnabledCurrencies(['USD'], 'USD');
CRM_Core_OptionGroup::flushAll();
$currencies = array_keys(CRM_Core_OptionGroup::values('currencies_enabled'));
$this->assertEquals(['USD'], $currencies, 'Unable to remove a currency.');
// Note in the form there's code to prevent removing the default. The
// function we're testing here isn't the full form so we're not testing
// that.
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment