Skip to content

Commit

Permalink
Merge pull request #21189 from eileenmcnaughton/541b
Browse files Browse the repository at this point in the history
dev/rc#14 handle api calls post schema change
  • Loading branch information
seamuslee001 authored Aug 20, 2021
2 parents db0aaf7 + a0552fd commit fc6f9f2
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 fc6f9f2

Please sign in to comment.