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
32 class CRM_Member_BAO_MembershipLogTest
extends CiviUnitTestCase
{
34 public function setUp() {
38 'contact_type_a' => 'Individual',
39 'contact_type_b' => 'Organization',
40 'name_a_b' => 'Test Employee of',
41 'name_b_a' => 'Test Employer of',
43 $this->_relationshipTypeId
= $this->relationshipTypeCreate($params);
44 $this->_orgContactID
= $this->organizationCreate();
45 $this->_financialTypeId
= 1;
48 'name' => 'test type',
49 'description' => NULL,
51 'duration_unit' => 'year',
52 'member_of_contact_id' => $this->_orgContactID
,
53 'period_type' => 'fixed',
54 'duration_interval' => 1,
55 'financial_type_id' => $this->_financialTypeId
,
56 'relationship_type_id' => $this->_relationshipTypeId
,
57 'visibility' => 'Public',
61 $membershipType = CRM_Member_BAO_MembershipType
::add($params, $ids);
62 $this->_membershipTypeID
= $membershipType->id
;
63 $this->_mebershipStatusID
= $this->membershipStatusCreate('test status');
67 * Tears down the fixture, for example, closes a network connection.
68 * This method is called after a test is executed.
70 public function tearDown() {
71 $this->relationshipTypeDelete($this->_relationshipTypeId
);
72 $this->membershipTypeDelete(array('id' => $this->_membershipTypeID
));
73 $this->membershipStatusDelete($this->_mebershipStatusID
);
74 $this->contactDelete($this->_orgContactID
);
80 public function testadd() {
81 $contactId = Contact
::createIndividual();
84 'contact_id' => $contactId,
85 'membership_type_id' => $this->_membershipTypeID
,
86 'join_date' => date('Ymd', strtotime('2006-01-21')),
87 'start_date' => date('Ymd', strtotime('2006-01-21')),
88 'end_date' => date('Ymd', strtotime('2006-12-21')),
89 'source' => 'Payment',
91 'status_id' => $this->_mebershipStatusID
,
95 $membership = CRM_Member_BAO_Membership
::create($params, $ids);
96 $this->assertDBNotNull('CRM_Member_BAO_MembershipLog', $membership->id
,
97 'membership_id', 'id',
98 'Database checked on membershiplog record.'
101 $this->membershipDelete($membership->id
);
102 $this->contactDelete($contactId);
108 public function testdel() {
109 $contactId = Contact
::createIndividual();
112 'contact_id' => $contactId,
113 'membership_type_id' => $this->_membershipTypeID
,
114 'join_date' => date('Ymd', strtotime('2006-01-21')),
115 'start_date' => date('Ymd', strtotime('2006-01-21')),
116 'end_date' => date('Ymd', strtotime('2006-12-21')),
117 'source' => 'Payment',
119 'status_id' => $this->_mebershipStatusID
,
122 'userId' => $contactId,
124 $membership = CRM_Member_BAO_Membership
::create($params, $ids);
125 $membershipDelete = CRM_Member_BAO_MembershipLog
::del($membership->id
);
126 $this->assertDBNull('CRM_Member_BAO_MembershipLog', $membership->id
, 'membership_id',
127 'id', 'Database check for deleted membership log.'
130 $this->membershipDelete($membership->id
);
131 $this->contactDelete($contactId);
135 * Test resetmodified()
137 public function testresetmodifiedId() {
138 $contactId = Contact
::createIndividual();
141 'contact_id' => $contactId,
142 'membership_type_id' => $this->_membershipTypeID
,
143 'join_date' => date('Ymd', strtotime('2006-01-21')),
144 'start_date' => date('Ymd', strtotime('2006-01-21')),
145 'end_date' => date('Ymd', strtotime('2006-12-21')),
146 'source' => 'Payment',
148 'status_id' => $this->_mebershipStatusID
,
151 'userId' => $contactId,
153 $membership = CRM_Member_BAO_Membership
::create($params, $ids);
154 $resetModifiedId = CRM_Member_BAO_MembershipLog
::resetModifiedID($contactId);
155 $this->assertDBNull('CRM_Member_BAO_MembershipLog', $contactId, 'modified_id',
156 'modified_id', 'Database check for NULL modified id.'
159 $this->membershipDelete($membership->id
);
160 $this->contactDelete($contactId);