Skip to content

Commit

Permalink
Make domain_id optional in membership_type api.
Browse files Browse the repository at this point in the history
This is in support of #12439 & making domain_id optional
  • Loading branch information
eileenmcnaughton committed Jul 13, 2018
1 parent a866838 commit 5dd0058
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
3 changes: 1 addition & 2 deletions api/v3/MembershipType.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ function civicrm_api3_membership_type_create($params) {
* Array of parameters determined by getfields.
*/
function _civicrm_api3_membership_type_create_spec(&$params) {
// todo could set default here probably
$params['domain_id']['api.required'] = 1;
$params['domain_id']['api.default'] = CRM_Core_Config::domainID();
$params['member_of_contact_id']['api.required'] = 1;
$params['financial_type_id']['api.required'] = 1;
$params['name']['api.required'] = 1;
Expand Down
9 changes: 5 additions & 4 deletions tests/phpunit/api/v3/MembershipTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,9 @@ public function testCreate() {
}

/**
* Test update fails with no ID.
* Domain ID can be intuited..
*/
public function testUpdateWithoutId() {
public function testCreateWithoutDomainId() {
$params = array(
'name' => '60+ Membership',
'description' => 'people above 60 are given health instructions',
Expand All @@ -141,8 +141,9 @@ public function testUpdateWithoutId() {
'visibility' => 'public',
);

$membershipType = $this->callAPIFailure('membership_type', 'create', $params);
$this->assertEquals($membershipType['error_message'], 'Mandatory key(s) missing from params array: domain_id');
$membershipType = $this->callAPISuccess('membership_type', 'create', $params);
$domainID = $this->callAPISuccessGetValue('MembershipType', ['return' =>'domain_id', 'id' => $membershipType['id']]);
$this->assertEquals(CRM_Core_Config::domainID(), $domainID);
}

/**
Expand Down

0 comments on commit 5dd0058

Please sign in to comment.