4 * File for the TestActivityType class
10 * This file is part of CiviCRM
12 * CiviCRM is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Affero General Public License
14 * as published by the Free Software Foundation; either version 3 of
15 * the License, or (at your option) any later version.
17 * CiviCRM is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU Affero General Public License for more details.
22 * You should have received a copy of the GNU Affero General Public
23 * License along with this program. If not, see
24 * <http://www.gnu.org/licenses/>.
27 require_once 'CiviTest/CiviUnitTestCase.php';
28 require_once 'CiviTest/Contact.php';
29 require_once 'CiviTest/Membership.php';
32 * Test CRM/Member/BAO Membership Log add , delete functions
36 class CRM_Member_BAO_MembershipLogTest
extends CiviUnitTestCase
{
42 'name' => 'MembershipLog Test',
43 'description' => 'Test all Membership Log methods.',
44 'group' => 'CiviCRM BAO Tests',
52 'contact_type_a' => 'Individual',
53 'contact_type_b' => 'Organization',
54 'name_a_b' => 'Test Employee of',
55 'name_b_a' => 'Test Employer of',
57 $this->_relationshipTypeId
= $this->relationshipTypeCreate($params);
58 $this->_orgContactID
= $this->organizationCreate();
59 $this->_financialTypeId
= 1;
62 'name' => 'test type',
63 'description' => NULL,
65 'duration_unit' => 'year',
66 'member_of_contact_id' => $this->_orgContactID
,
67 'period_type' => 'fixed',
68 'duration_interval' => 1,
69 'financial_type_id' => $this->_financialTypeId
,
70 'relationship_type_id' => $this->_relationshipTypeId
,
71 'visibility' => 'Public',
74 $membershipType = CRM_Member_BAO_MembershipType
::add($params, $ids);
75 $this->_membershipTypeID
= $membershipType->id
;
76 $this->_mebershipStatusID
= $this->membershipStatusCreate('test status');
80 * Tears down the fixture, for example, closes a network connection.
81 * This method is called after a test is executed.
85 $this->relationshipTypeDelete($this->_relationshipTypeId
);
86 $this->membershipTypeDelete(array('id' => $this->_membershipTypeID
));
87 $this->membershipStatusDelete($this->_mebershipStatusID
);
88 $this->contactDelete($this->_orgContactID
);
95 $contactId = Contact
::createIndividual();
98 'contact_id' => $contactId,
99 'membership_type_id' => $this->_membershipTypeID
,
100 'join_date' => date('Ymd',strtotime('2006-01-21')),
101 'start_date' => date('Ymd',strtotime('2006-01-21')),
102 'end_date' => date('Ymd',strtotime('2006-12-21')),
103 'source' => 'Payment',
105 'status_id' => $this->_mebershipStatusID
,
109 $membership = CRM_Member_BAO_Membership
::create($params, $ids);
110 $this->assertDBNotNull('CRM_Member_BAO_MembershipLog', $membership->id
,
111 'membership_id', 'id',
112 'Database checked on membershiplog record.'
115 $this->membershipDelete($membership->id
);
116 $this->contactDelete($contactId);
123 $contactId = Contact
::createIndividual();
126 'contact_id' => $contactId,
127 'membership_type_id' => $this->_membershipTypeID
,
128 'join_date' => date('Ymd',strtotime('2006-01-21')),
129 'start_date' => date('Ymd',strtotime('2006-01-21')),
130 'end_date' => date('Ymd',strtotime('2006-12-21')),
131 'source' => 'Payment',
133 'status_id' => $this->_mebershipStatusID
,
136 'userId' => $contactId,
138 $membership = CRM_Member_BAO_Membership
::create($params, $ids);
139 $membershipDelete = CRM_Member_BAO_MembershipLog
::del($membership->id
);
140 $this->assertDBNull('CRM_Member_BAO_MembershipLog', $membership->id
, 'membership_id',
141 'id', 'Database check for deleted membership log.'
144 $this->membershipDelete($membership->id
);
145 $this->contactDelete($contactId);
149 * Test resetmodified()
151 function testresetmodifiedId() {
152 $contactId = Contact
::createIndividual();
155 'contact_id' => $contactId,
156 'membership_type_id' => $this->_membershipTypeID
,
157 'join_date' => date('Ymd',strtotime('2006-01-21')),
158 'start_date' => date('Ymd',strtotime('2006-01-21')),
159 'end_date' => date('Ymd',strtotime('2006-12-21')),
160 'source' => 'Payment',
162 'status_id' => $this->_mebershipStatusID
,
165 'userId' => $contactId,
167 $membership = CRM_Member_BAO_Membership
::create($params, $ids);
168 $resetModifiedId = CRM_Member_BAO_MembershipLog
::resetModifiedID($contactId);
169 $this->assertDBNull('CRM_Member_BAO_MembershipLog', $contactId, 'modified_id',
170 'modified_id', 'Database check for NULL modified id.'
173 $this->membershipDelete($membership->id
);
174 $this->contactDelete($contactId);