From 5b1b8db2e3961cb023d35c03297d6515d4db0e34 Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Sat, 11 Feb 2017 01:38:21 -0500 Subject: [PATCH] CRM-20010 period_type should be required for parity with UI --- api/v3/MembershipType.php | 1 + tests/phpunit/CRM/Core/PseudoConstantTest.php | 1 + tests/phpunit/api/v3/ContributionTest.php | 1 + tests/phpunit/api/v3/MembershipTypeTest.php | 15 +++++++++++++++ 4 files changed, 18 insertions(+) diff --git a/api/v3/MembershipType.php b/api/v3/MembershipType.php index d1db1fec13..a8b29405c5 100644 --- a/api/v3/MembershipType.php +++ b/api/v3/MembershipType.php @@ -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; } diff --git a/tests/phpunit/CRM/Core/PseudoConstantTest.php b/tests/phpunit/CRM/Core/PseudoConstantTest.php index 89a6fdfb96..6f36779fa8 100644 --- a/tests/phpunit/CRM/Core/PseudoConstantTest.php +++ b/tests/phpunit/CRM/Core/PseudoConstantTest.php @@ -116,6 +116,7 @@ class CRM_Core_PseudoConstantTest extends CiviUnitTestCase { 'member_of_contact_id' => 1, 'duration_unit' => 'day', 'duration_interval' => 1, + 'period_type' => 'rolling', ); $result = civicrm_api3('membership_type', 'create', $api_params); diff --git a/tests/phpunit/api/v3/ContributionTest.php b/tests/phpunit/api/v3/ContributionTest.php index 64e3ac18ce..7b383de845 100644 --- a/tests/phpunit/api/v3/ContributionTest.php +++ b/tests/phpunit/api/v3/ContributionTest.php @@ -3213,6 +3213,7 @@ class api_v3_ContributionTest extends CiviUnitTestCase { 'financial_type_id' => "Member Dues", 'duration_unit' => "month", 'duration_interval' => 1, + 'period_type' => 'rolling', 'name' => "Standard Member", 'minimum_fee' => 100, )); diff --git a/tests/phpunit/api/v3/MembershipTypeTest.php b/tests/phpunit/api/v3/MembershipTypeTest.php index 5e45401900..81c2bf95b2 100644 --- a/tests/phpunit/api/v3/MembershipTypeTest.php +++ b/tests/phpunit/api/v3/MembershipTypeTest.php @@ -145,6 +145,21 @@ class api_v3_MembershipTypeTest extends CiviUnitTestCase { $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. */ -- 2.25.1