Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
CiviCRM Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Development
CiviCRM Core
Commits
30fe58ec
Unverified
Commit
30fe58ec
authored
3 years ago
by
Monish Deb
Committed by
GitHub
3 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #20627 from demeritcowboy/currency-fixation
financial#175
- Unable to remove a currency once added
parents
cdb0dde2
ddfe0227
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
CRM/Core/OptionGroup.php
+6
-3
6 additions, 3 deletions
CRM/Core/OptionGroup.php
tests/phpunit/CRM/Admin/Form/Setting/LocalizationTest.php
+28
-0
28 additions, 0 deletions
tests/phpunit/CRM/Admin/Form/Setting/LocalizationTest.php
with
34 additions
and
3 deletions
CRM/Core/OptionGroup.php
+
6
−
3
View file @
30fe58ec
...
...
@@ -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,
...
...
This diff is collapsed.
Click to expand it.
tests/phpunit/CRM/Admin/Form/Setting/LocalizationTest.php
0 → 100644
+
28
−
0
View file @
30fe58ec
<?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.
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment