<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.5 |
+ | CiviCRM version 4.6 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2014 |
+--------------------------------------------------------------------+
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
-*/
+ */
require_once 'CiviTest/CiviUnitTestCase.php';
* Class CRM_Member_BAO_MembershipTest
*/
class CRM_Member_BAO_MembershipTest extends CiviUnitTestCase {
- /**
- * @return array
- */
- function get_info() {
- return array(
- 'name' => 'Membership BAOs',
- 'description' => 'Test all Member_BAO_Membership methods.',
- 'group' => 'CiviCRM BAO Tests',
- );
- }
- function setUp() {
+ public function setUp() {
parent::setUp();
// FIXME: something NULLs $GLOBALS['_HTML_QuickForm_registered_rules'] when the tests are ran all together
$GLOBALS['_HTML_QuickForm_registered_rules'] = array(
/**
* Tears down the fixture, for example, closes a network connection.
* This method is called after a test is executed.
- *
*/
- function tearDown() {
- $this->membershipTypeDelete( array( 'id' => $this->_membershipTypeID ) );
- $this->membershipStatusDelete( $this->_membershipStatusID );
- Contact::delete( $this->_contactID );
+ public function tearDown() {
+ $this->membershipTypeDelete(array('id' => $this->_membershipTypeID));
+ $this->membershipStatusDelete($this->_membershipStatusID);
+ Contact::delete($this->_contactID);
- $this->_contactID = $this->_membershipStatusID = $this->_membershipTypeID = null;
+ $this->_contactID = $this->_membershipStatusID = $this->_membershipTypeID = NULL;
}
- function testCreate() {
+ public function testCreate() {
$contactId = Contact::createIndividual();
$params = array(
'contact_id' => $contactId,
'membership_type_id' => $this->_membershipTypeID,
- 'join_date' => date('Ymd',strtotime('2006-01-21')),
- 'start_date' => date('Ymd',strtotime('2006-01-21')),
- 'end_date' => date('Ymd',strtotime('2006-12-21')),
+ 'join_date' => date('Ymd', strtotime('2006-01-21')),
+ 'start_date' => date('Ymd', strtotime('2006-01-21')),
+ 'end_date' => date('Ymd', strtotime('2006-12-21')),
'source' => 'Payment',
'is_override' => 1,
'status_id' => $this->_membershipStatusID,
$params = array(
'contact_id' => $contactId,
'membership_type_id' => $this->_membershipTypeID,
- 'join_date' => date('Ymd',strtotime('2006-01-21')),
- 'start_date' => date('Ymd',strtotime('2006-01-21')),
- 'end_date' => date('Ymd',strtotime('2006-12-21')),
+ 'join_date' => date('Ymd', strtotime('2006-01-21')),
+ 'start_date' => date('Ymd', strtotime('2006-01-21')),
+ 'end_date' => date('Ymd', strtotime('2006-12-21')),
'source' => 'Payment',
'is_override' => 1,
'status_id' => $this->_membershipStatusID,
Contact::delete($contactId);
}
- function testGetValues() {
+ public function testGetValues() {
// $this->markTestSkipped( 'causes mysterious exit, needs fixing!' );
// Calculate membership dates based on the current date
$now = time();
Contact::delete($contactId);
}
- function testRetrieve() {
+ public function testRetrieve() {
$contactId = Contact::createIndividual();
$params = array(
'contact_id' => $contactId,
'membership_type_id' => $this->_membershipTypeID,
- 'join_date' => date('Ymd',strtotime('2006-01-21')),
- 'start_date' => date('Ymd',strtotime('2006-01-21')),
- 'end_date' => date('Ymd',strtotime('2006-12-21')),
+ 'join_date' => date('Ymd', strtotime('2006-01-21')),
+ 'start_date' => date('Ymd', strtotime('2006-01-21')),
+ 'end_date' => date('Ymd', strtotime('2006-12-21')),
'source' => 'Payment',
'is_override' => 1,
'status_id' => $this->_membershipStatusID,
$this->contactDelete($contactId);
}
- function testActiveMembers() {
+ public function testActiveMembers() {
$contactId = Contact::createIndividual();
$params = array(
'contact_id' => $contactId,
'membership_type_id' => $this->_membershipTypeID,
- 'join_date' => date('Ymd',strtotime('2006-01-21')),
- 'start_date' => date('Ymd',strtotime('2006-01-21')),
- 'end_date' => date('Ymd',strtotime('2006-12-21')),
+ 'join_date' => date('Ymd', strtotime('2006-01-21')),
+ 'start_date' => date('Ymd', strtotime('2006-01-21')),
+ 'end_date' => date('Ymd', strtotime('2006-12-21')),
'source' => 'Payment',
'is_override' => 1,
'status_id' => $this->_membershipStatusID,
$params = array(
'contact_id' => $contactId,
'membership_type_id' => $this->_membershipTypeID,
- 'join_date' => date('Ymd',strtotime('2006-01-21')),
- 'start_date' => date('Ymd',strtotime('2006-01-21')),
- 'end_date' => date('Ymd',strtotime('2006-12-21')),
+ 'join_date' => date('Ymd', strtotime('2006-01-21')),
+ 'start_date' => date('Ymd', strtotime('2006-01-21')),
+ 'end_date' => date('Ymd', strtotime('2006-12-21')),
'source' => 'PaySource',
'is_override' => 1,
'status_id' => $this->_membershipStatusID,
Contact::delete($contactId);
}
- function testDeleteMembership() {
+ public function testDeleteMembership() {
$contactId = Contact::createIndividual();
$params = array(
'contact_id' => $contactId,
'membership_type_id' => $this->_membershipTypeID,
- 'join_date' => date('Ymd',strtotime('2006-01-21')),
- 'start_date' => date('Ymd',strtotime('2006-01-21')),
- 'end_date' => date('Ymd',strtotime('2006-12-21')),
+ 'join_date' => date('Ymd', strtotime('2006-01-21')),
+ 'start_date' => date('Ymd', strtotime('2006-01-21')),
+ 'end_date' => date('Ymd', strtotime('2006-12-21')),
'source' => 'Payment',
'is_override' => 1,
'status_id' => $this->_membershipStatusID,
Contact::delete($contactId);
}
- function testGetContactMembership() {
+ public function testGetContactMembership() {
$contactId = Contact::createIndividual();
$params = array(
'contact_id' => $contactId,
'membership_type_id' => $this->_membershipTypeID,
- 'join_date' => date('Ymd',strtotime('2006-01-21')),
- 'start_date' => date('Ymd',strtotime('2006-01-21')),
- 'end_date' => date('Ymd',strtotime('2006-12-21')),
+ 'join_date' => date('Ymd', strtotime('2006-01-21')),
+ 'start_date' => date('Ymd', strtotime('2006-01-21')),
+ 'end_date' => date('Ymd', strtotime('2006-12-21')),
'source' => 'Payment',
'is_override' => 1,
'status_id' => $this->_membershipStatusID,
/**
- * Get the contribution
+ * Get the contribution.
* page id from the membership record
*/
- function testgetContributionPageId() {
+ public function testgetContributionPageId() {
$contactId = Contact::createIndividual();
$params = array(
'contact_id' => $contactId,
'membership_type_id' => $this->_membershipTypeID,
- 'join_date' => date('Ymd',strtotime('2006-01-21')),
- 'start_date' => date('Ymd',strtotime('2006-01-21')),
- 'end_date' => date('Ymd',strtotime('2006-12-21')),
+ 'join_date' => date('Ymd', strtotime('2006-01-21')),
+ 'start_date' => date('Ymd', strtotime('2006-01-21')),
+ 'end_date' => date('Ymd', strtotime('2006-12-21')),
'source' => 'Payment',
'is_override' => 1,
'status_id' => $this->_membershipStatusID,
$ids = array();
CRM_Member_BAO_Membership::create($params, $ids);
-
$membershipId = $this->assertDBNotNull('CRM_Member_BAO_Membership', $contactId, 'id',
'contact_id', 'Database check for created membership.'
);
$this->membershipDelete($membershipId);
Contact::delete($contactId);
}
+
/**
* Get membership joins/renewals
* for a specified membership
* type.
- *
*/
- function testgetMembershipStarts() {
+ public function testgetMembershipStarts() {
$contactId = Contact::createIndividual();
$params = array(
'contact_id' => $contactId,
'membership_type_id' => $this->_membershipTypeID,
- 'join_date' => date('Ymd',strtotime('2006-01-21')),
- 'start_date' => date('Ymd',strtotime('2006-01-21')),
- 'end_date' => date('Ymd',strtotime('2006-12-21')),
+ 'join_date' => date('Ymd', strtotime('2006-01-21')),
+ 'start_date' => date('Ymd', strtotime('2006-01-21')),
+ 'end_date' => date('Ymd', strtotime('2006-12-21')),
'source' => 'Payment',
'is_override' => 1,
'status_id' => $this->_membershipStatusID,
/**
* Get a count of membership for a specified membership type,
* optionally for a specified date.
- *
*/
- function testGetMembershipCount() {
+ public function testGetMembershipCount() {
$contactId = Contact::createIndividual();
$params = array(
'contact_id' => $contactId,
'membership_type_id' => $this->_membershipTypeID,
- 'join_date' => date('Ymd',strtotime('2006-01-21')),
- 'start_date' => date('Ymd',strtotime('2006-01-21')),
- 'end_date' => date('Ymd',strtotime('2006-12-21')),
+ 'join_date' => date('Ymd', strtotime('2006-01-21')),
+ 'start_date' => date('Ymd', strtotime('2006-01-21')),
+ 'end_date' => date('Ymd', strtotime('2006-12-21')),
'source' => 'Payment',
'is_override' => 1,
'status_id' => $this->_membershipStatusID,
/**
* Take sort name of contact during
* batch update member via profile
- *
*/
- function testsortName() {
+ public function testsortName() {
$contactId = Contact::createIndividual();
$params = array(
'contact_id' => $contactId,
'membership_type_id' => $this->_membershipTypeID,
- 'join_date' => date('Ymd',strtotime('2006-01-21')),
- 'start_date' => date('Ymd',strtotime('2006-01-21')),
- 'end_date' => date('Ymd',strtotime('2006-12-21')),
+ 'join_date' => date('Ymd', strtotime('2006-01-21')),
+ 'start_date' => date('Ymd', strtotime('2006-01-21')),
+ 'end_date' => date('Ymd', strtotime('2006-12-21')),
'source' => 'Payment',
'is_override' => 1,
'status_id' => $this->_membershipStatusID,
}
/**
- * Delete related memberships
- *
+ * Delete related memberships.
*/
- function testdeleteRelatedMemberships() {
+ public function testdeleteRelatedMemberships() {
$contactId = Contact::createIndividual();
$params = array(
'contact_id' => $contactId,
'membership_type_id' => $this->_membershipTypeID,
- 'join_date' => date('Ymd',strtotime('2006-01-21')),
- 'start_date' => date('Ymd',strtotime('2006-01-21')),
- 'end_date' => date('Ymd',strtotime('2006-12-21')),
+ 'join_date' => date('Ymd', strtotime('2006-01-21')),
+ 'start_date' => date('Ymd', strtotime('2006-01-21')),
+ 'end_date' => date('Ymd', strtotime('2006-12-21')),
'source' => 'Payment',
'is_override' => 1,
'status_id' => $this->_membershipStatusID,
}
/**
- * Renew membership with change in membership type
- *
+ * Renew membership with change in membership type.
*/
- function testRenewMembership() {
+ public function testRenewMembership() {
$contactId = Contact::createIndividual();
- $joinDate = $startDate = date("Ymd", strtotime(date("Ymd") . " -6 month"));
- $endDate = date("Ymd", strtotime($joinDate . " +1 year -1 day"));
+ $joinDate = $startDate = date("Ymd", strtotime(date("Ymd") . " -6 month"));
+ $endDate = date("Ymd", strtotime($joinDate . " +1 year -1 day"));
$params = array(
'contact_id' => $contactId,
'membership_type_id' => $this->_membershipTypeID,
'is_override' => 1,
'status_id' => $this->_membershipStatusID,
);
- $ids = array();
- $membership = CRM_Member_BAO_Membership::create($params, $ids);
+ $ids = array();
+ $membership = CRM_Member_BAO_Membership::create($params, $ids);
$membershipId = $this->assertDBNotNull('CRM_Member_BAO_Membership', $contactId, 'id',
'contact_id', 'Database check for created membership.'
);
$config = CRM_Core_Config::singleton();
$config->keyDisable = TRUE;
- $membershipRenewal = new CRM_Core_Form;
- $membershipRenewal->controller = new CRM_Core_Controller;
+ $membershipRenewal = new CRM_Core_Form();
+ $membershipRenewal->controller = new CRM_Core_Controller();
$isTestMembership = 0;
- $MembershipRenew =
- CRM_Member_BAO_Membership::renewMembershipFormWrapper(
- $contactId,
- $this->_membershipTypeID,
- $isTestMembership,
- $membershipRenewal,
- NULL,
- NULL
- );
+ $MembershipRenew = CRM_Member_BAO_Membership::renewMembershipFormWrapper(
+ $contactId,
+ $this->_membershipTypeID,
+ $isTestMembership,
+ $membershipRenewal,
+ NULL,
+ NULL
+ );
$endDate = date("Y-m-d", strtotime($membership->end_date . " +1 year"));
$this->assertDBNotNull('CRM_Member_BAO_MembershipLog',
}
/**
- * Renew stale membership
- *
+ * Renew stale membership.
*/
- function testStaleMembership() {
- $statusId = 3;
+ public function testStaleMembership() {
+ $statusId = 3;
$contactId = Contact::createIndividual();
- $joinDate = $startDate = date("Ymd", strtotime(date("Ymd") . " -1 year -15 days"));
- $endDate = date("Ymd", strtotime($joinDate . " +1 year -1 day"));
- $params = array(
+ $joinDate = $startDate = date("Ymd", strtotime(date("Ymd") . " -1 year -15 days"));
+ $endDate = date("Ymd", strtotime($joinDate . " +1 year -1 day"));
+ $params = array(
'contact_id' => $contactId,
'membership_type_id' => $this->_membershipTypeID,
'join_date' => $joinDate,
$config = CRM_Core_Config::singleton();
$config->keyDisable = TRUE;
- $membershipRenewal = new CRM_Core_Form;
- $membershipRenewal->controller = new CRM_Core_Controller;
+ $membershipRenewal = new CRM_Core_Form();
+ $membershipRenewal->controller = new CRM_Core_Controller();
$MembershipRenew = CRM_Member_BAO_Membership::renewMembershipFormWrapper($contactId, $this->_membershipTypeID, $isTestMembership = 0, $membershipRenewal, NULL, NULL);
$this->assertDBNotNull('CRM_Member_BAO_MembershipLog',
$this->membershipDelete($membershipId);
Contact::delete($contactId);
}
-}
-
+}