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/>.
28 * Test CRM/Member/BAO Membership Log add , delete functions
33 class CRM_Member_BAO_MembershipLogTest
extends CiviUnitTestCase
{
35 public function setUp() {
39 'contact_type_a' => 'Individual',
40 'contact_type_b' => 'Organization',
41 'name_a_b' => 'Test Employee of',
42 'name_b_a' => 'Test Employer of',
44 $this->_relationshipTypeId
= $this->relationshipTypeCreate($params);
45 $this->_orgContactID
= $this->organizationCreate();
46 $this->_financialTypeId
= 1;
49 'name' => 'test type',
50 'description' => NULL,
52 'duration_unit' => 'year',
53 'member_of_contact_id' => $this->_orgContactID
,
54 'period_type' => 'fixed',
55 'duration_interval' => 1,
56 'financial_type_id' => $this->_financialTypeId
,
57 'relationship_type_id' => $this->_relationshipTypeId
,
58 'visibility' => 'Public',
62 $membershipType = CRM_Member_BAO_MembershipType
::add($params, $ids);
63 $this->_membershipTypeID
= $membershipType->id
;
64 $this->_mebershipStatusID
= $this->membershipStatusCreate('test status');
68 * Tears down the fixture, for example, closes a network connection.
69 * This method is called after a test is executed.
71 public function tearDown() {
72 $this->relationshipTypeDelete($this->_relationshipTypeId
);
73 $this->membershipTypeDelete(array('id' => $this->_membershipTypeID
));
74 $this->membershipStatusDelete($this->_mebershipStatusID
);
75 $this->contactDelete($this->_orgContactID
);
81 public function testadd() {
82 $contactId = $this->individualCreate();
85 'contact_id' => $contactId,
86 'membership_type_id' => $this->_membershipTypeID
,
87 'join_date' => date('Ymd', strtotime('2006-01-21')),
88 'start_date' => date('Ymd', strtotime('2006-01-21')),
89 'end_date' => date('Ymd', strtotime('2006-12-21')),
90 'source' => 'Payment',
92 'status_id' => $this->_mebershipStatusID
,
96 $membership = CRM_Member_BAO_Membership
::create($params, $ids);
97 $this->assertDBNotNull('CRM_Member_BAO_MembershipLog', $membership->id
,
98 'membership_id', 'id',
99 'Database checked on membershiplog record.'
102 $this->membershipDelete($membership->id
);
103 $this->contactDelete($contactId);
109 public function testdel() {
110 $contactId = $this->individualCreate();
113 'contact_id' => $contactId,
114 'membership_type_id' => $this->_membershipTypeID
,
115 'join_date' => date('Ymd', strtotime('2006-01-21')),
116 'start_date' => date('Ymd', strtotime('2006-01-21')),
117 'end_date' => date('Ymd', strtotime('2006-12-21')),
118 'source' => 'Payment',
120 'status_id' => $this->_mebershipStatusID
,
123 'userId' => $contactId,
125 $membership = CRM_Member_BAO_Membership
::create($params, $ids);
126 $membershipDelete = CRM_Member_BAO_MembershipLog
::del($membership->id
);
127 $this->assertDBNull('CRM_Member_BAO_MembershipLog', $membership->id
, 'membership_id',
128 'id', 'Database check for deleted membership log.'
131 $this->membershipDelete($membership->id
);
132 $this->contactDelete($contactId);
136 * Test resetmodified()
138 public function testresetmodifiedId() {
139 $contactId = $this->individualCreate();
142 'contact_id' => $contactId,
143 'membership_type_id' => $this->_membershipTypeID
,
144 'join_date' => date('Ymd', strtotime('2006-01-21')),
145 'start_date' => date('Ymd', strtotime('2006-01-21')),
146 'end_date' => date('Ymd', strtotime('2006-12-21')),
147 'source' => 'Payment',
149 'status_id' => $this->_mebershipStatusID
,
152 'userId' => $contactId,
154 $membership = CRM_Member_BAO_Membership
::create($params, $ids);
155 $resetModifiedId = CRM_Member_BAO_MembershipLog
::resetModifiedID($contactId);
156 $this->assertDBNull('CRM_Member_BAO_MembershipLog', $contactId, 'modified_id',
157 'modified_id', 'Database check for NULL modified id.'
160 $this->membershipDelete($membership->id
);
161 $this->contactDelete($contactId);