Skip to content

Commit

Permalink
Merge pull request civicrm#9829 from h-c-c/CRM-20010
Browse files Browse the repository at this point in the history
CRM-20010 period_type should be required for parity with UI
  • Loading branch information
eileenmcnaughton authored Feb 15, 2017
2 parents 87cb674 + ad4aff4 commit db26a15
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions api/v3/MembershipType.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ function _civicrm_api3_membership_type_create_spec(&$params) {
$params['name']['api.required'] = 1;
$params['duration_unit']['api.required'] = 1;
$params['duration_interval']['api.required'] = 1;
$params['period_type']['api.required'] = 1;
$params['is_active']['api.default'] = 1;
}

Expand Down
1 change: 1 addition & 0 deletions tests/phpunit/CRM/Core/PseudoConstantTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ public function testOptionValues() {
'member_of_contact_id' => 1,
'duration_unit' => 'day',
'duration_interval' => 1,
'period_type' => 'rolling',
);
$result = civicrm_api3('membership_type', 'create', $api_params);

Expand Down
1 change: 1 addition & 0 deletions tests/phpunit/api/v3/ContributionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3213,6 +3213,7 @@ protected function setUpAutoRenewMembership($generalParams = array(), $recurPara
'financial_type_id' => "Member Dues",
'duration_unit' => "month",
'duration_interval' => 1,
'period_type' => 'rolling',
'name' => "Standard Member",
'minimum_fee' => 100,
));
Expand Down
15 changes: 15 additions & 0 deletions tests/phpunit/api/v3/MembershipTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,21 @@ public function testUpdateWithoutId() {
$this->assertEquals($membershipType['error_message'], 'Mandatory key(s) missing from params array: domain_id');
}

/**
* CRM-20010 Tests period_type is required for MemberType create
*/
public function testMemberTypePeriodiTypeRequired() {
$this->callAPIFailure('MembershipType', 'create', array(
'domain_id' => "Default Domain Name",
'member_of_contact_id' => 1,
'financial_type_id' => "Member Dues",
'duration_unit' => "month",
'duration_interval' => 1,
'name' => "Standard Member",
'minimum_fee' => 100,
));
}

/**
* Test update.
*/
Expand Down

0 comments on commit db26a15

Please sign in to comment.