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 'contact_type_a' => 'Individual',
43 'contact_type_b' => 'Organization',
44 'name_a_b' => 'Test Employee of',
45 'name_b_a' => 'Test Employer of',
47 $this->_relationshipTypeId
= $this->relationshipTypeCreate($params);
48 $this->_orgContactID
= $this->organizationCreate();
49 $this->_financialTypeId
= 1;
52 'name' => 'test type',
53 'description' => NULL,
55 'duration_unit' => 'year',
56 'member_of_contact_id' => $this->_orgContactID
,
57 'period_type' => 'fixed',
58 'duration_interval' => 1,
59 'financial_type_id' => $this->_financialTypeId
,
60 'relationship_type_id' => $this->_relationshipTypeId
,
61 'visibility' => 'Public',
65 $membershipType = CRM_Member_BAO_MembershipType
::add($params, $ids);
66 $this->_membershipTypeID
= $membershipType->id
;
67 $this->_mebershipStatusID
= $this->membershipStatusCreate('test status');
71 * Tears down the fixture, for example, closes a network connection.
72 * This method is called after a test is executed.
76 $this->relationshipTypeDelete($this->_relationshipTypeId
);
77 $this->membershipTypeDelete(array('id' => $this->_membershipTypeID
));
78 $this->membershipStatusDelete($this->_mebershipStatusID
);
79 $this->contactDelete($this->_orgContactID
);
86 $contactId = Contact
::createIndividual();
89 'contact_id' => $contactId,
90 'membership_type_id' => $this->_membershipTypeID
,
91 'join_date' => date('Ymd',strtotime('2006-01-21')),
92 'start_date' => date('Ymd',strtotime('2006-01-21')),
93 'end_date' => date('Ymd',strtotime('2006-12-21')),
94 'source' => 'Payment',
96 'status_id' => $this->_mebershipStatusID
,
100 $membership = CRM_Member_BAO_Membership
::create($params, $ids);
101 $this->assertDBNotNull('CRM_Member_BAO_MembershipLog', $membership->id
,
102 'membership_id', 'id',
103 'Database checked on membershiplog record.'
106 $this->membershipDelete($membership->id
);
107 $this->contactDelete($contactId);
114 $contactId = Contact
::createIndividual();
117 'contact_id' => $contactId,
118 'membership_type_id' => $this->_membershipTypeID
,
119 'join_date' => date('Ymd',strtotime('2006-01-21')),
120 'start_date' => date('Ymd',strtotime('2006-01-21')),
121 'end_date' => date('Ymd',strtotime('2006-12-21')),
122 'source' => 'Payment',
124 'status_id' => $this->_mebershipStatusID
,
127 'userId' => $contactId,
129 $membership = CRM_Member_BAO_Membership
::create($params, $ids);
130 $membershipDelete = CRM_Member_BAO_MembershipLog
::del($membership->id
);
131 $this->assertDBNull('CRM_Member_BAO_MembershipLog', $membership->id
, 'membership_id',
132 'id', 'Database check for deleted membership log.'
135 $this->membershipDelete($membership->id
);
136 $this->contactDelete($contactId);
140 * Test resetmodified()
142 function testresetmodifiedId() {
143 $contactId = Contact
::createIndividual();
146 'contact_id' => $contactId,
147 'membership_type_id' => $this->_membershipTypeID
,
148 'join_date' => date('Ymd',strtotime('2006-01-21')),
149 'start_date' => date('Ymd',strtotime('2006-01-21')),
150 'end_date' => date('Ymd',strtotime('2006-12-21')),
151 'source' => 'Payment',
153 'status_id' => $this->_mebershipStatusID
,
156 'userId' => $contactId,
158 $membership = CRM_Member_BAO_Membership
::create($params, $ids);
159 $resetModifiedId = CRM_Member_BAO_MembershipLog
::resetModifiedID($contactId);
160 $this->assertDBNull('CRM_Member_BAO_MembershipLog', $contactId, 'modified_id',
161 'modified_id', 'Database check for NULL modified id.'
164 $this->membershipDelete($membership->id
);
165 $this->contactDelete($contactId);