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
{
38 public function setUp() {
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.
74 public function tearDown() {
75 $this->relationshipTypeDelete($this->_relationshipTypeId
);
76 $this->membershipTypeDelete(array('id' => $this->_membershipTypeID
));
77 $this->membershipStatusDelete($this->_mebershipStatusID
);
78 $this->contactDelete($this->_orgContactID
);
84 public function testadd() {
85 $contactId = Contact
::createIndividual();
88 'contact_id' => $contactId,
89 'membership_type_id' => $this->_membershipTypeID
,
90 'join_date' => date('Ymd', strtotime('2006-01-21')),
91 'start_date' => date('Ymd', strtotime('2006-01-21')),
92 'end_date' => date('Ymd', strtotime('2006-12-21')),
93 'source' => 'Payment',
95 'status_id' => $this->_mebershipStatusID
,
99 $membership = CRM_Member_BAO_Membership
::create($params, $ids);
100 $this->assertDBNotNull('CRM_Member_BAO_MembershipLog', $membership->id
,
101 'membership_id', 'id',
102 'Database checked on membershiplog record.'
105 $this->membershipDelete($membership->id
);
106 $this->contactDelete($contactId);
112 public function testdel() {
113 $contactId = Contact
::createIndividual();
116 'contact_id' => $contactId,
117 'membership_type_id' => $this->_membershipTypeID
,
118 'join_date' => date('Ymd', strtotime('2006-01-21')),
119 'start_date' => date('Ymd', strtotime('2006-01-21')),
120 'end_date' => date('Ymd', strtotime('2006-12-21')),
121 'source' => 'Payment',
123 'status_id' => $this->_mebershipStatusID
,
126 'userId' => $contactId,
128 $membership = CRM_Member_BAO_Membership
::create($params, $ids);
129 $membershipDelete = CRM_Member_BAO_MembershipLog
::del($membership->id
);
130 $this->assertDBNull('CRM_Member_BAO_MembershipLog', $membership->id
, 'membership_id',
131 'id', 'Database check for deleted membership log.'
134 $this->membershipDelete($membership->id
);
135 $this->contactDelete($contactId);
139 * Test resetmodified()
141 public function testresetmodifiedId() {
142 $contactId = Contact
::createIndividual();
145 'contact_id' => $contactId,
146 'membership_type_id' => $this->_membershipTypeID
,
147 'join_date' => date('Ymd', strtotime('2006-01-21')),
148 'start_date' => date('Ymd', strtotime('2006-01-21')),
149 'end_date' => date('Ymd', strtotime('2006-12-21')),
150 'source' => 'Payment',
152 'status_id' => $this->_mebershipStatusID
,
155 'userId' => $contactId,
157 $membership = CRM_Member_BAO_Membership
::create($params, $ids);
158 $resetModifiedId = CRM_Member_BAO_MembershipLog
::resetModifiedID($contactId);
159 $this->assertDBNull('CRM_Member_BAO_MembershipLog', $contactId, 'modified_id',
160 'modified_id', 'Database check for NULL modified id.'
163 $this->membershipDelete($membership->id
);
164 $this->contactDelete($contactId);