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
{
39 'name' => 'MembershipLog Test',
40 'description' => 'Test all Membership Log methods.',
41 'group' => 'CiviCRM BAO Tests',
49 'contact_type_a' => 'Individual',
50 'contact_type_b' => 'Organization',
51 'name_a_b' => 'Test Employee of',
52 'name_b_a' => 'Test Employer of',
54 $this->_relationshipTypeId
= $this->relationshipTypeCreate($params);
55 $this->_orgContactID
= $this->organizationCreate();
56 $this->_financialTypeId
= 1;
59 'name' => 'test type',
60 'description' => NULL,
62 'duration_unit' => 'year',
63 'member_of_contact_id' => $this->_orgContactID
,
64 'period_type' => 'fixed',
65 'duration_interval' => 1,
66 'financial_type_id' => $this->_financialTypeId
,
67 'relationship_type_id' => $this->_relationshipTypeId
,
68 'visibility' => 'Public',
71 $membershipType = CRM_Member_BAO_MembershipType
::add($params, $ids);
72 $this->_membershipTypeID
= $membershipType->id
;
73 $this->_mebershipStatusID
= $this->membershipStatusCreate('test status');
77 * Tears down the fixture, for example, closes a network connection.
78 * This method is called after a test is executed.
82 $this->relationshipTypeDelete($this->_relationshipTypeId
);
83 $this->membershipTypeDelete(array('id' => $this->_membershipTypeID
));
84 $this->membershipStatusDelete($this->_mebershipStatusID
);
85 $this->contactDelete($this->_orgContactID
);
92 $contactId = Contact
::createIndividual();
95 'contact_id' => $contactId,
96 'membership_type_id' => $this->_membershipTypeID
,
97 'join_date' => date('Ymd',strtotime('2006-01-21')),
98 'start_date' => date('Ymd',strtotime('2006-01-21')),
99 'end_date' => date('Ymd',strtotime('2006-12-21')),
100 'source' => 'Payment',
102 'status_id' => $this->_mebershipStatusID
,
106 $membership = CRM_Member_BAO_Membership
::create($params, $ids);
107 $this->assertDBNotNull('CRM_Member_BAO_MembershipLog', $membership->id
,
108 'membership_id', 'id',
109 'Database checked on membershiplog record.'
112 $this->membershipDelete($membership->id
);
113 $this->contactDelete($contactId);
120 $contactId = Contact
::createIndividual();
123 'contact_id' => $contactId,
124 'membership_type_id' => $this->_membershipTypeID
,
125 'join_date' => date('Ymd',strtotime('2006-01-21')),
126 'start_date' => date('Ymd',strtotime('2006-01-21')),
127 'end_date' => date('Ymd',strtotime('2006-12-21')),
128 'source' => 'Payment',
130 'status_id' => $this->_mebershipStatusID
,
133 'userId' => $contactId,
135 $membership = CRM_Member_BAO_Membership
::create($params, $ids);
136 $membershipDelete = CRM_Member_BAO_MembershipLog
::del($membership->id
);
137 $this->assertDBNull('CRM_Member_BAO_MembershipLog', $membership->id
, 'membership_id',
138 'id', 'Database check for deleted membership log.'
141 $this->membershipDelete($membership->id
);
142 $this->contactDelete($contactId);
146 * Test resetmodified()
148 function testresetmodifiedId() {
149 $contactId = Contact
::createIndividual();
152 'contact_id' => $contactId,
153 'membership_type_id' => $this->_membershipTypeID
,
154 'join_date' => date('Ymd',strtotime('2006-01-21')),
155 'start_date' => date('Ymd',strtotime('2006-01-21')),
156 'end_date' => date('Ymd',strtotime('2006-12-21')),
157 'source' => 'Payment',
159 'status_id' => $this->_mebershipStatusID
,
162 'userId' => $contactId,
164 $membership = CRM_Member_BAO_Membership
::create($params, $ids);
165 $resetModifiedId = CRM_Member_BAO_MembershipLog
::resetModifiedID($contactId);
166 $this->assertDBNull('CRM_Member_BAO_MembershipLog', $contactId, 'modified_id',
167 'modified_id', 'Database check for NULL modified id.'
170 $this->membershipDelete($membership->id
);
171 $this->contactDelete($contactId);