3 +--------------------------------------------------------------------+
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2019 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
29 * Class CRM_Member_BAO_MembershipStatusTest
32 class CRM_Member_BAO_MembershipStatusTest
extends CiviUnitTestCase
{
34 public function setUp() {
39 * Check function add()
41 public function testAdd() {
47 $membershipStatus = CRM_Member_BAO_MembershipStatus
::add($params);
49 $result = $this->assertDBNotNull('CRM_Member_BAO_MembershipStatus', $membershipStatus->id
,
51 'Database check on updated membership status record.'
53 $this->assertEquals($result, 'pending', 'Verify membership status is_active.');
56 public function testRetrieve() {
59 'name' => 'testStatus',
63 $membershipStatus = CRM_Member_BAO_MembershipStatus
::add($params);
65 $result = CRM_Member_BAO_MembershipStatus
::retrieve($params, $defaults);
66 $this->assertEquals($result->name
, 'testStatus', 'Verify membership status name.');
67 CRM_Member_BAO_MembershipStatus
::del($membershipStatus->id
);
70 public function testPseudoConstantflush() {
72 'name' => 'testStatus',
75 $membershipStatus = CRM_Member_BAO_MembershipStatus
::add($params);
77 $result = CRM_Member_BAO_MembershipStatus
::retrieve($params, $defaults);
78 $this->assertEquals($result->name
, 'testStatus', 'Verify membership status name.');
79 $updateParams = array(
80 'id' => $membershipStatus->id
,
81 'name' => 'testStatus',
82 'label' => 'Changed Status',
85 $membershipStatus2 = CRM_Member_BAO_MembershipStatus
::add($updateParams);
86 $result = CRM_Member_PseudoConstant
::membershipStatus($membershipStatus->id
, NULL, 'label', FALSE, FALSE);
87 $this->assertEquals($result, 'Changed Status', 'Verify updated membership status label From PseudoConstant.');
88 CRM_Member_BAO_MembershipStatus
::del($membershipStatus->id
);
91 public function testSetIsActive() {
98 $membershipStatus = CRM_Member_BAO_MembershipStatus
::add($params);
99 $result = CRM_Member_BAO_MembershipStatus
::setIsActive($membershipStatus->id
, 0);
100 $this->assertEquals($result, TRUE, 'Verify membership status record updation.');
102 $isActive = $this->assertDBNotNull('CRM_Member_BAO_MembershipStatus', $membershipStatus->id
,
104 'Database check on updated membership status record.'
106 $this->assertEquals($isActive, 0, 'Verify membership status is_active.');
109 public function testGetMembershipStatus() {
115 $membershipStatus = CRM_Member_BAO_MembershipStatus
::add($params);
116 $result = CRM_Member_BAO_MembershipStatus
::getMembershipStatus($membershipStatus->id
);
117 $this->assertEquals($result['name'], 'pending', 'Verify membership status name.');
120 public function testDel() {
122 'name' => 'testStatus',
126 $membershipStatus = CRM_Member_BAO_MembershipStatus
::add($params);
127 CRM_Member_BAO_MembershipStatus
::del($membershipStatus->id
);
129 $result = CRM_Member_BAO_MembershipStatus
::retrieve($params, $defaults);
130 $this->assertEquals(empty($result), TRUE, 'Verify membership status record deletion.');
133 public function testGetMembershipStatusByDate() {
137 'start_event' => 'start_date',
138 'end_event' => 'end_date',
141 $membershipStatus = CRM_Member_BAO_MembershipStatus
::add($params);
142 $toDate = date('Ymd');
144 $result = CRM_Member_BAO_MembershipStatus
::getMembershipStatusByDate($toDate, $toDate, $toDate, 'today', TRUE, NULL, $params);
145 $this->assertEquals($result['name'], 'Current', 'Verify membership status record.');
148 public function testgetMembershipStatusCurrent() {
152 'is_current_member' => 1,
155 $membershipStatus = CRM_Member_BAO_MembershipStatus
::add($params);
156 $result = CRM_Member_BAO_MembershipStatus
::getMembershipStatusCurrent();
158 $this->assertEquals(empty($result), FALSE, 'Verify membership status records is_current_member.');