//check dependencies
$check = FALSE;
$status = array();
- $dependancy = array(
+ $dependency = array(
'Membership' => 'membership_type_id',
'MembershipBlock' => 'membership_type_default',
);
- foreach ($dependancy as $name => $field) {
+ foreach ($dependency as $name => $field) {
$baoString = 'CRM_Member_BAO_' . $name;
$dao = new $baoString();
$dao->$field = $membershipTypeId;
}
}
- $membershipDates = array();
-
- $dates = array(
- 'start_date' => 'startDate',
- 'end_date' => 'endDate',
- 'join_date' => 'joinDate',
+ $membershipDates = array(
+ 'start_date' => CRM_Utils_Date::customFormat($startDate, '%Y%m%d'),
+ 'end_date' => CRM_Utils_Date::customFormat($endDate, '%Y%m%d'),
+ 'join_date' => CRM_Utils_Date::customFormat($joinDate, '%Y%m%d'),
);
- foreach ($dates as $varName => $valName) {
- $membershipDates[$varName] = CRM_Utils_Date::customFormat($$valName, '%Y%m%d');
- }
return $membershipDates;
}
'visibility' => 'public',
);
- $membershiptype = $this->callAPIAndDocument('membership_type', 'create', $params, __FUNCTION__, __FILE__);
- $this->assertNotNull($membershiptype['values']);
- $this->membershipTypeDelete(array('id' => $membershiptype['id']));
+ $membershipType = $this->callAPIAndDocument('membership_type', 'create', $params, __FUNCTION__, __FILE__);
+ $this->assertNotNull($membershipType['values']);
+ $this->membershipTypeDelete(array('id' => $membershipType['id']));
}
+ /**
+ * Test mandatory parameter check.
+ */
public function testUpdateWithEmptyParams() {
- $params = array();
- $membershiptype = $this->callAPIFailure('membership_type', 'create', $params);
- $this->assertEquals($membershiptype['error_message'],
- 'Mandatory key(s) missing from params array: domain_id, member_of_contact_id, financial_type_id, duration_unit, duration_interval, name'
- );
+ $this->callAPIFailure('membership_type', 'create', array());
}
+ /**
+ * Test update fails with no ID.
+ */
public function testUpdateWithoutId() {
$params = array(
'name' => '60+ Membership',
'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->callAPIFailure('membership_type', 'create', $params);
+ $this->assertEquals($membershipType['error_message'], 'Mandatory key(s) missing from params array: domain_id');
}
public function testUpdate() {
$this->getAndCheck($params, $id, $this->_entity);
}
+ /**
+ * Test for failure when id is not valid.
+ */
public function testDeleteNotExists() {
$params = array(
'id' => 'doesNotExist',
);
- $membershiptype = $this->callAPIFailure('membership_type', 'delete', $params,
- 'Error while deleting membership type. id : ' . $params['id']
- );
+ $this->callAPIFailure('membership_type', 'delete', $params,
+ 'Error while deleting membership type. id : ' . $params['id']
+ );
}
public function testDelete() {
'id' => $membershipTypeID,
);
- $result = $this->callAPIAndDocument('membership_type', 'delete', $params, __FUNCTION__, __FILE__);
+ $this->callAPIAndDocument('membership_type', 'delete', $params, __FUNCTION__, __FILE__);
}
}