* @subpackage API_Member
*/
-
require_once 'CiviTest/CiviUnitTestCase.php';
/**
protected $_entity;
protected $_params;
-
+ /**
+ * Set up for tests.
+ */
public function setUp() {
- // Connect to the database.
parent::setUp();
$this->_apiversion = 3;
$this->_contactID = $this->individualCreate();
);
}
+ /**
+ * Clean up after tests.
+ *
+ * @throws \Exception
+ */
public function tearDown() {
$this->quickCleanup(array(
'civicrm_membership',
/**
* Test civicrm_membership_get with params not array.
+ *
* Gets treated as contact_id, memberships expected.
*/
public function testGetWithParamsMemberShipTypeId() {
'id' => $membership['id'],
));
$result = $membership['values'][$membership['id']];
- $this->assertEquals($result['contact_id'], $this->_contactID, "In line " . __LINE__);
- $this->assertEquals($result['membership_type_id'], $this->_membershipTypeID, "In line " . __LINE__);
- $this->assertEquals($result['status_id'], $this->_membershipStatusID, "In line " . __LINE__);
- $this->assertEquals($result['join_date'], '2009-01-21', "In line " . __LINE__);
- $this->assertEquals($result['start_date'], '2009-01-21', "In line " . __LINE__);
- $this->assertEquals($result['end_date'], '2009-12-21', "In line " . __LINE__);
- $this->assertEquals($result['source'], 'Payment', "In line " . __LINE__);
- $this->assertEquals($result['is_override'], 1, "In line " . __LINE__);
+ $this->assertEquals($result['contact_id'], $this->_contactID);
+ $this->assertEquals($result['membership_type_id'], $this->_membershipTypeID);
+ $this->assertEquals($result['status_id'], $this->_membershipStatusID);
+ $this->assertEquals($result['join_date'], '2009-01-21');
+ $this->assertEquals($result['start_date'], '2009-01-21');
+ $this->assertEquals($result['end_date'], '2009-12-21');
+ $this->assertEquals($result['source'], 'Payment');
+ $this->assertEquals($result['is_override'], 1);
$this->assertEquals($result['id'], $membership['id']);
}
}
/**
- * Check with complete array + custom field
+ * Check with complete array + custom field.
+ *
* Note that the test is written on purpose without any
* variables specific to participant so it can be replicated into other entities
* and / or moved to the automated test suite
$this->callAPISuccess('Membership', 'Delete', array(
'id' => $membership['id'],
));
- $this->assertEquals($result['join_date'], '2009-01-21', "In line " . __LINE__);
- $this->assertEquals($result['contact_id'], $this->_contactID, "In line " . __LINE__);
- $this->assertEquals($result['membership_type_id'], $this->_membershipTypeID, "In line " . __LINE__);
- $this->assertEquals($result['status_id'], $this->_membershipStatusID, "In line " . __LINE__);
+ $this->assertEquals($result['join_date'], '2009-01-21');
+ $this->assertEquals($result['contact_id'], $this->_contactID);
+ $this->assertEquals($result['membership_type_id'], $this->_membershipTypeID);
+ $this->assertEquals($result['status_id'], $this->_membershipStatusID);
- $this->assertEquals($result['start_date'], '2009-01-21', "In line " . __LINE__);
- $this->assertEquals($result['end_date'], '2009-12-21', "In line " . __LINE__);
- $this->assertEquals($result['source'], 'Payment', "In line " . __LINE__);
- $this->assertEquals($result['is_override'], 1, "In line " . __LINE__);
+ $this->assertEquals($result['start_date'], '2009-01-21');
+ $this->assertEquals($result['end_date'], '2009-12-21');
+ $this->assertEquals($result['source'], 'Payment');
+ $this->assertEquals($result['is_override'], 1);
}
);
$membership = $this->callAPISuccess('membership', 'get', $params);
- $this->assertEquals($membership['count'], 0, "In line " . __LINE__);
+ $this->assertEquals($membership['count'], 0);
}
/**
protected $_apiversion;
protected $_entity = 'MembershipType';
+ /**
+ * Set up for tests.
+ */
public function setUp() {
parent::setUp();
$this->useTransaction(TRUE);
$this->_contactID = $this->organizationCreate();
}
+ /**
+ * Get the membership without providing an ID.
+ *
+ * This should return an empty array but not an error.
+ */
public function testGetWithoutId() {
$params = array(
'name' => '60+ Membership',
'visibility' => 'public',
);
- $membershiptype = $this->callAPISuccess('membership_type', 'get', $params);
- $this->assertEquals($membershiptype['count'], 0);
+ $membershipType = $this->callAPISuccess('membership_type', 'get', $params);
+ $this->assertEquals($membershipType['count'], 0);
}
+ /**
+ * Test get works.
+ */
public function testGet() {
$id = $this->membershipTypeCreate(array('member_of_contact_id' => $this->_contactID));
$params = array(
'id' => $id,
);
- $membershiptype = $this->callAPIAndDocument('membership_type', 'get', $params, __FUNCTION__, __FILE__);
- $this->assertEquals($membershiptype['values'][$id]['name'], 'General');
- $this->assertEquals($membershiptype['values'][$id]['member_of_contact_id'], $this->_contactID);
- $this->assertEquals($membershiptype['values'][$id]['financial_type_id'], 1);
- $this->assertEquals($membershiptype['values'][$id]['duration_unit'], 'year');
- $this->assertEquals($membershiptype['values'][$id]['duration_interval'], '1');
- $this->assertEquals($membershiptype['values'][$id]['period_type'], 'rolling');
+ $membershipType = $this->callAPIAndDocument('membership_type', 'get', $params, __FUNCTION__, __FILE__);
+ $this->assertEquals($membershipType['values'][$id]['name'], 'General');
+ $this->assertEquals($membershipType['values'][$id]['member_of_contact_id'], $this->_contactID);
+ $this->assertEquals($membershipType['values'][$id]['financial_type_id'], 1);
+ $this->assertEquals($membershipType['values'][$id]['duration_unit'], 'year');
+ $this->assertEquals($membershipType['values'][$id]['duration_interval'], '1');
+ $this->assertEquals($membershipType['values'][$id]['period_type'], 'rolling');
$this->membershipTypeDelete($params);
}
'visibility' => 'public',
);
- $membershiptype = $this->callAPIFailure('membership_type', 'create', $params,
- 'Mandatory key(s) missing from params array: member_of_contact_id'
- );
+ $this->callAPIFailure('membership_type', 'create', $params, 'Mandatory key(s) missing from params array: member_of_contact_id');
}
public function testCreateWithoutNameandDomainIDandDurationUnit() {