/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.5 |
+ | CiviCRM version 4.6 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2014 |
+--------------------------------------------------------------------+
protected $_apiversion;
protected $_entity = 'MembershipType';
-
- /**
- * @return array
- */
- function get_info() {
- return array(
- 'name' => 'MembershipType Create',
- 'description' => 'Test all Membership Type Create API methods.',
- 'group' => 'CiviCRM API Tests',
- );
- }
-
- function setUp() {
+ public function setUp() {
parent::setUp();
+ $this->useTransaction(TRUE);
$this->_apiversion = 3;
$this->_contactID = $this->organizationCreate(NULL);
}
- function tearDown() {
- $tablesToTruncate = array('civicrm_contact');
- $this->quickCleanup($tablesToTruncate);
- }
-
- function testGetWithoutId() {
+ public function testGetWithoutId() {
$params = array(
'name' => '60+ Membership',
'description' => 'people above 60 are given health instructions',
$this->assertEquals($membershiptype['count'], 0);
}
- function testGet() {
+ public function testGet() {
$id = $this->membershipTypeCreate(array('member_of_contact_id' => $this->_contactID));
$params = array(
}
///////////////// civicrm_membership_type_create methods
- function testCreateWithEmptyParams() {
+ public function testCreateWithEmptyParams() {
$membershiptype = $this->callAPIFailure('membership_type', 'create', array());
$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'
);
}
- function testCreateWithoutMemberOfContactId() {
+ public function testCreateWithoutMemberOfContactId() {
$params = array(
'name' => '60+ Membership',
'description' => 'people above 60 are given health instructions',
);
}
- function testCreateWithoutContributionTypeId() {
+ public function testCreateWithoutContributionTypeId() {
$params = array(
'name' => '70+ Membership',
'description' => 'people above 70 are given health instructions',
'duration_unit' => 'month',
'duration_interval' => '10',
'period_type' => 'rolling',
- 'visibility' => 'public', );
+ 'visibility' => 'public', );
$membershiptype = $this->callAPIFailure('membership_type', 'create', $params);
$this->assertEquals($membershiptype['error_message'],
'Mandatory key(s) missing from params array: financial_type_id'
);
}
- function testCreateWithoutDurationUnit() {
+ public function testCreateWithoutDurationUnit() {
$params = array(
'name' => '80+ Membership',
'description' => 'people above 80 are given health instructions',
'domain_id' => '1',
'minimum_fee' => '200',
'duration_interval' => '10',
- 'visibility' => 'public', );
+ 'visibility' => 'public', );
$membershiptype = $this->callAPIFailure('membership_type', 'create', $params);
$this->assertEquals($membershiptype['error_message'],
);
}
- function testCreateWithoutDurationInterval() {
+ public function testCreateWithoutDurationInterval() {
$params = array(
'name' => '70+ Membership',
'description' => 'people above 70 are given health instructions',
'minimum_fee' => '200',
'duration_unit' => 'month',
'period_type' => 'rolling',
- 'visibility' => 'public', );
+ 'visibility' => 'public', );
$membershiptype = $this->callAPIFailure('membership_type', 'create', $params);
$this->assertEquals($membershiptype['error_message'],
'Mandatory key(s) missing from params array: financial_type_id, duration_interval'
);
}
- function testCreateWithoutNameandDomainIDandDurationUnit() {
+ public function testCreateWithoutNameandDomainIDandDurationUnit() {
$params = array(
'description' => 'people above 50 are given health instructions',
'member_of_contact_id' => $this->_contactID,
'minimum_fee' => '200',
'duration_interval' => '10',
'period_type' => 'rolling',
- 'visibility' => 'public', );
+ 'visibility' => 'public', );
$membershiptype = $this->callAPIFailure('membership_type', 'create', $params);
$this->assertEquals($membershiptype['error_message'],
);
}
- function testCreateWithoutName() {
+ public function testCreateWithoutName() {
$params = array(
'description' => 'people above 50 are given health instructions',
'member_of_contact_id' => $this->_contactID,
'duration_unit' => 'month',
'duration_interval' => '10',
'period_type' => 'rolling',
- 'visibility' => 'public', );
+ 'visibility' => 'public', );
$membershiptype = $this->callAPIFailure('membership_type', 'create', $params);
$this->assertEquals($membershiptype['error_message'], 'Mandatory key(s) missing from params array: name');
}
- function testCreate() {
+ public function testCreate() {
$params = array(
'name' => '40+ Membership',
'description' => 'people above 40 are given health instructions',
}
- function testUpdateWithEmptyParams() {
+ public function testUpdateWithEmptyParams() {
$params = array();
$membershiptype = $this->callAPIFailure('membership_type', 'create', $params);
$this->assertEquals($membershiptype['error_message'],
);
}
- function testUpdateWithoutId() {
+ public function testUpdateWithoutId() {
$params = array(
'name' => '60+ Membership',
'description' => 'people above 60 are given health instructions',
'duration_unit' => 'month',
'duration_interval' => '10',
'period_type' => 'rolling',
- 'visibility' => 'public', );
+ 'visibility' => 'public', );
$membershiptype = $this->callAPIFailure('membership_type', 'create', $params);
$this->assertEquals($membershiptype['error_message'], 'Mandatory key(s) missing from params array: domain_id');
}
- function testUpdate() {
+ public function testUpdate() {
$id = $this->membershipTypeCreate(array('member_of_contact_id' => $this->_contactID, 'financial_type_id' => 2));
$newMembOrgParams = array(
'organization_name' => 'New membership organisation',
'contact_type' => 'Organization',
- 'visibility' => 1, );
+ 'visibility' => 1, );
// create a new contact to update this membership type to
$newMembOrgID = $this->organizationCreate($newMembOrgParams);
'duration_unit' => 'month',
'duration_interval' => '10',
'period_type' => 'fixed',
- 'domain_id' => 1, );
+ 'domain_id' => 1, );
$this->callAPISuccess('membership_type', 'update', $params);
$this->getAndCheck($params, $id, $this->_entity);
}
- function testDeleteNotExists() {
+ public function testDeleteNotExists() {
$params = array(
'id' => 'doesNotExist',
);
);
}
- function testDelete() {
+ public function testDelete() {
$orgID = $this->organizationCreate(NULL);
$membershipTypeID = $this->membershipTypeCreate(array('member_of_contact_id' => $orgID));
$params = array(
$result = $this->callAPIAndDocument('membership_type', 'delete', $params, __FUNCTION__, __FILE__);
}
}
-