Skip to content

Commit

Permalink
APIv4 - Fix output of membershipType auto_renew field.
Browse files Browse the repository at this point in the history
The field had been declared a "boolean" in the schema, which at a SQL level
is exactly the same as "tinyint" but it was resulting in incorrect API output.
  • Loading branch information
colemanw committed Jul 14, 2021
1 parent 1f3f8af commit 0525019
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions CRM/Member/DAO/MembershipType.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* Generated from xml/schema/CRM/Member/MembershipType.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
* (GenCodeChecksum:e989278865fbeabd9f3d6efc7271a2d1)
* (GenCodeChecksum:89dc1a77c01ca0255a2dad8637f5e835)
*/

/**
Expand Down Expand Up @@ -168,7 +168,7 @@ class CRM_Member_DAO_MembershipType extends CRM_Core_DAO {
/**
* 0 = No auto-renew option; 1 = Give option, but not required; 2 = Auto-renew required;
*
* @var bool
* @var int
*/
public $auto_renew;

Expand Down Expand Up @@ -557,7 +557,7 @@ public static function &fields() {
],
'auto_renew' => [
'name' => 'auto_renew',
'type' => CRM_Utils_Type::T_BOOLEAN,
'type' => CRM_Utils_Type::T_INT,
'title' => ts('Auto Renew'),
'description' => ts('0 = No auto-renew option; 1 = Give option, but not required; 2 = Auto-renew required;'),
'where' => 'civicrm_membership_type.auto_renew',
Expand Down
6 changes: 3 additions & 3 deletions tests/phpunit/CRM/Member/Form/MembershipRenewalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ public function testSubmitRecur(): void {
'id' => $this->membershipTypeAnnualFixedID,
'duration_unit' => 'month',
'duration_interval' => 1,
'auto_renew' => TRUE,
'auto_renew' => 1,
]);
$form = $this->getForm([
'contact_id' => $this->_individualId,
Expand Down Expand Up @@ -359,7 +359,7 @@ public function testSubmitRecurCompleteInstant(): void {
'id' => $this->membershipTypeAnnualFixedID,
'duration_unit' => 'month',
'duration_interval' => 1,
'auto_renew' => TRUE,
'auto_renew' => 1,
]);
$this->createLoggedInUser();
$form = $this->getForm(array_merge($this->getBaseSubmitParams(), ['is_recur' => 1, 'auto_renew' => '1']));
Expand Down Expand Up @@ -446,7 +446,7 @@ public function testSubmitRecurCompleteInstantWithMail(string $thousandSeparator
'id' => $this->membershipTypeAnnualFixedID,
'duration_unit' => 'month',
'duration_interval' => 1,
'auto_renew' => TRUE,
'auto_renew' => 1,
]);
$this->createLoggedInUser();
$form = $this->getForm(array_merge($this->getBaseSubmitParams(), [
Expand Down
4 changes: 2 additions & 2 deletions tests/phpunit/CRM/Member/Form/MembershipTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,7 @@ public function testSubmitRecur(): void {
'id' => $this->ids['membership_type']['AnnualFixed'],
'duration_unit' => 'month',
'duration_interval' => 1,
'auto_renew' => TRUE,
'auto_renew' => 1,
]);
$params = $this->getBaseSubmitParams();
// Change financial_type_id to test our override flows through to the line item.
Expand Down Expand Up @@ -1064,7 +1064,7 @@ public function testSubmitRecurCompleteInstant(): void {
'id' => $this->ids['membership_type']['AnnualFixed'],
'duration_unit' => 'month',
'duration_interval' => 1,
'auto_renew' => TRUE,
'auto_renew' => 1,
]);
$form = $this->getForm($this->getBaseSubmitParams());
$this->createLoggedInUser();
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/api/v3/ContributionPageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1088,7 +1088,7 @@ public function testSubmitMembershipPriceSetPaymentPaymentProcessorSeparatePayme
$dummyPP->setDoDirectPaymentResult(['payment_status_id' => 1, 'trxn_id' => 'create_first_success']);
$submitParams = array_merge($this->getSubmitParamsContributionPlusMembership(TRUE), [
'is_recur' => 1,
'auto_renew' => TRUE,
'auto_renew' => 1,
'frequency_interval' => 1,
'frequency_unit' => 'month',
]);
Expand Down
2 changes: 1 addition & 1 deletion xml/schema/Member/MembershipType.xml
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@
</field>
<field>
<name>auto_renew</name>
<type>boolean</type>
<type>tinyint</type>
<default>0</default>
<html>
<type>Radio</type>
Expand Down

0 comments on commit 0525019

Please sign in to comment.