+--------------------------------------------------------------------+
| CiviCRM version 4.6 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2014 |
+ | Copyright CiviCRM LLC (c) 2004-2015 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
* Memberships expected.
*/
public function testGetOnlyActive() {
- $description = "Demonstrates use of 'filter' active_only' param";
+ $description = "Demonstrates use of 'filter' active_only' param.";
$this->_membershipID = $this->contactMembershipCreate($this->_params);
- $subfile = 'filterIsCurrent';
$params = array(
'contact_id' => $this->_contactID,
'active_only' => 1,
),
);
- $membership = $this->callAPIAndDocument('membership', 'get', $params, __FUNCTION__, __FILE__, $description, $subfile);
+ $membership = $this->callAPIAndDocument('membership', 'get', $params, __FUNCTION__, __FILE__, $description, 'FilterIsCurrent');
$this->assertEquals($membership['values'][$this->_membershipID]['status_id'], $this->_membershipStatusID);
$this->assertEquals($membership['values'][$this->_membershipID]['contact_id'], $this->_contactID);
$result = $this->callAPISuccess('membership', 'get', $params);
$this->assertEquals(0, $result['count']);
+ // Set up params for enable/disable checks
+ $relationship1 = $this->callAPISuccess('relationship', 'get', array('contact_id_a' => $memberContactId[1]));
+ $params = array(
+ 'contact_id' => $memberContactId[1],
+ 'membership_type_id' => $membershipTypeId,
+ );
+
+ // Deactivate relationship using create and assert membership is not inherited
+ $this->callAPISuccess('relationship', 'create', array('id' => $relationship1['id'], 'is_active' => 0));
+ $result = $this->callAPISuccess('membership', 'get', $params);
+ $this->assertEquals(0, $result['count']);
+
+ // Re-enable relationship using create and assert membership is inherited
+ $this->callAPISuccess('relationship', 'create', array('id' => $relationship1['id'], 'is_active' => 1));
+ $result = $this->callAPISuccess('membership', 'get', $params);
+ $this->assertEquals(1, $result['count']);
+
+ // Deactivate relationship using setvalue and assert membership is not inherited
+ $this->callAPISuccess('relationship', 'setvalue', array('id' => $relationship1['id'], 'field' => 'is_active', 'value' => 0));
+ $result = $this->callAPISuccess('membership', 'get', $params);
+ $this->assertEquals(0, $result['count']);
+
+ // Re-enable relationship using setvalue and assert membership is inherited
+ $this->callAPISuccess('relationship', 'setvalue', array('id' => $relationship1['id'], 'field' => 'is_active', 'value' => 1));
+ $result = $this->callAPISuccess('membership', 'get', $params);
+ $this->assertEquals(1, $result['count']);
+
+ // Delete relationship and assert membership is not inherited
+ $this->callAPISuccess('relationship', 'delete', array('id' => $relationship1['id']));
+ $result = $this->callAPISuccess('membership', 'get', $params);
+ $this->assertEquals(0, $result['count']);
+
// Tear down - reverse of creation to be safe
$this->contactDelete($memberContactId[2]);
$this->contactDelete($memberContactId[1]);
}
/**
- * If is_overide is passed in status must also be passed in
+ * If is_overide is passed in status must also be passed in.
*/
public function testCreateOverrideNoStatus() {
$params = $this->_params;
$params = $this->_params;
$params['custom_' . $ids['custom_field_id']] = "custom string";
- $result = $this->callAPIAndDocument($this->_entity, 'create', $params, __FUNCTION__, __FILE__);
+ $result = $this->callAPIAndDocument($this->_entity, 'create', $params, __FUNCTION__, __FILE__, NULL, 'CreateWithCustomData');
$check = $this->callAPISuccess($this->_entity, 'get', array(
'id' => $result['id'],
'contact_id' => $this->_contactID,
}
/**
- * Change custom field using update
+ * Change custom field using update.
*/
public function testUpdateWithCustom() {
$ids = $this->entityCustomGroupWithSingleFieldCreate(__FUNCTION__, __FILE__);
$params = $this->_params;
$params['custom_' . $ids['custom_field_id']] = "custom string";
- $result = $this->callAPIAndDocument($this->_entity, 'create', $params, __FUNCTION__, __FILE__);
+ $result = $this->callAPIAndDocument($this->_entity, 'create', $params, __FUNCTION__, __FILE__, NULL, 'UpdateCustomData');
$result = $this->callAPISuccess($this->_entity, 'create', array(
'id' => $result['id'],
'custom_' . $ids['custom_field_id'] => "new custom",
}
/**
- * Test civicrm_contact_memberships_create Invalid membership data
+ * Test civicrm_contact_memberships_create Invalid membership data.
* Error expected.
*/
public function testMembershipCreateInvalidMemData() {
}
/**
- * Test that if membership join date is not set it defaults to today
+ * Test that if membership join date is not set it defaults to today.
*/
public function testEmptyJoinDate() {
unset($this->_params['join_date'], $this->_params['is_override']);
}
/**
- * Test that if membership start date is not set it defaults to correct end date
+ * Test that if membership start date is not set it defaults to correct end date.
* - fixed
*/
public function testEmptyStartDateFixed() {
}
/**
- * Test that if membership end date is not set it defaults to correct end date
+ * Test that if membership end date is not set it defaults to correct end date.
* - rolling
*/
public function testEmptyEndDateFixed() {
}
/**
- * Test that if membership end date is not set it defaults to correct end date
+ * Test that if membership end date is not set it defaults to correct end date.
* - rolling
*/
public function testEmptyEndDateRolling() {