Skip to content

Commit

Permalink
dev/rc#14 handle api calls post schema change
Browse files Browse the repository at this point in the history
  • Loading branch information
eileenmcnaughton committed Aug 20, 2021
1 parent db0aaf7 commit a0552fd
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
4 changes: 4 additions & 0 deletions api/v3/utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -2059,6 +2059,10 @@ function _civicrm_api3_swap_out_aliases(&$apiRequest, $fields) {
*/
function _civicrm_api3_validate_integer(&$params, $fieldName, &$fieldInfo, $entity) {
list($fieldValue, $op) = _civicrm_api3_field_value_check($params, $fieldName);
if ($fieldName === 'auto_renew' && $fieldValue === TRUE) {
// https://lab.civicrm.org/dev/rc/-/issues/14
$fieldValue = 1;
}
if (strpos($op, 'NULL') !== FALSE || strpos($op, 'EMPTY') !== FALSE) {
return;
}
Expand Down
18 changes: 18 additions & 0 deletions tests/phpunit/api/v3/MembershipTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,24 @@ public function testMemberTypePeriodTypeRequired($version) {
]);
}

/**
* Test that auto renew = TRUE still works post schema change.
*
* https://lab.civicrm.org/dev/rc/-/issues/14
*/
public function testCreateMembershipTypeAutoRenewBool(): void {
$this->callAPISuccess('MembershipType', 'create', [
'member_of_contact_id' => 1,
'financial_type_id' => 'Member Dues',
'duration_unit' => 'year',
'duration_interval' => 1,
'period_type' => 'rolling',
'minimum_fee' => 1,
'name' => 'gen',
'auto_renew' => TRUE,
]);
}

/**
* Test update.
*
Expand Down

0 comments on commit a0552fd

Please sign in to comment.