Skip to content

Commit

Permalink
Fix retrieving standardized name for billing properties
Browse files Browse the repository at this point in the history
  • Loading branch information
mattwire committed Sep 23, 2021
1 parent 1823910 commit 8b72c69
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
7 changes: 6 additions & 1 deletion Civi/Payment/PropertyBag.php
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,12 @@ protected function handleLegacyPropNames($prop, $silent = FALSE) {
if ($newName === NULL && substr($prop, -2) === '-' . \CRM_Core_BAO_LocationType::getBilling()
&& isset(static::$propMap[substr($prop, 0, -2)])
) {
$newName = substr($prop, 0, -2);
$billingAddressProp = substr($prop, 0, -2);
$newName = static::$propMap[$billingAddressProp] ?? NULL;
if ($newName === TRUE) {
// Good, modern name.
return $billingAddressProp;
}
}

if ($newName === NULL) {
Expand Down
10 changes: 6 additions & 4 deletions tests/phpunit/Civi/Payment/PropertyBagTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -409,9 +409,10 @@ public function testEmpty() {
}

/**
*
* Data provider for testOtherParams
* $prop, $legacy_names, $valid_values, $invalid_values
*
* return array
*/
public function otherParamsDataProvider() {
$valid_bools = [['0' , FALSE], ['', FALSE], [0, FALSE], [FALSE, FALSE], [TRUE, TRUE], [1, TRUE], ['1', TRUE]];
Expand All @@ -420,13 +421,14 @@ public function otherParamsDataProvider() {
$valid_ints = [[123, 123], ['123', 123]];
$invalid_ints = [-1, 0, NULL, ''];
return [
['billingStreetAddress', [], $valid_strings_inc_null, []],
['billingStreetAddress', ['billing_street_address', 'street_address'], $valid_strings_inc_null, []],
['billingSupplementalAddress1', [], $valid_strings_inc_null, []],
['billingSupplementalAddress2', [], $valid_strings_inc_null, []],
['billingSupplementalAddress3', [], $valid_strings_inc_null, []],
['billingCity', [], $valid_strings_inc_null, []],
['billingPostalCode', [], $valid_strings_inc_null, []],
['billingCity', ['billing_city', 'city'], $valid_strings_inc_null, []],
['billingPostalCode', ['billing_postal_code', 'postal_code'], $valid_strings_inc_null, []],
['billingCounty', [], $valid_strings_inc_null, []],
['billingStateProvince', ['billing_state_province', 'state_province'], $valid_strings_inc_null, []],
['billingCountry', [], [['GB', 'GB'], ['NZ', 'NZ']], ['XX', '', NULL, 0]],
['contributionID', ['contribution_id'], $valid_ints, $invalid_ints],
['contributionRecurID', ['contribution_recur_id'], $valid_ints, $invalid_ints],
Expand Down

0 comments on commit 8b72c69

Please sign in to comment.