Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
2fe49090 | 4 | | CiviCRM version 5 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
6b83d5bd | 6 | | Copyright CiviCRM LLC (c) 2004-2019 | |
6a488035 TO |
7 | +--------------------------------------------------------------------+ |
8 | | This file is a part of CiviCRM. | | |
9 | | | | |
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. | | |
13 | | | | |
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. | | |
18 | | | | |
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 | +--------------------------------------------------------------------+ | |
d25dd0ee | 26 | */ |
6a488035 | 27 | |
6a488035 TO |
28 | /** |
29 | * Test class for CRM_Event_BAO_ParticipantStatus BAO | |
30 | * | |
6c6e6187 | 31 | * @package CiviCRM |
acb109b7 | 32 | * @group headless |
6a488035 TO |
33 | */ |
34 | class CRM_Event_BAO_ParticipantStatusTest extends CiviUnitTestCase { | |
35 | ||
36 | /** | |
37 | * Sets up the fixture, for example, opens a network connection. | |
38 | * This method is called before a test is executed. | |
6a488035 TO |
39 | */ |
40 | protected function setUp() { | |
41 | parent::setUp(); | |
42 | } | |
43 | ||
44 | /** | |
45 | * Tears down the fixture, for example, closes a network connection. | |
46 | * This method is called after a test is executed. | |
6a488035 | 47 | */ |
6c6e6187 TO |
48 | protected function tearDown() { |
49 | } | |
6a488035 | 50 | |
6a488035 TO |
51 | /** |
52 | * create() and deleteParticipantStatusType() method | |
53 | */ | |
00be9182 | 54 | public function testCreateAndDelete() { |
6a488035 TO |
55 | |
56 | // create using required params | |
57 | $params = array( | |
58 | 'name' => 'testStatus', | |
59 | 'label' => 'testParticipant', | |
60 | 'class' => 'Positive', | |
61 | 'weight' => 13, | |
62 | 'visibility_id' => 1, | |
63 | ); | |
64 | ||
65 | $statusType = CRM_Event_BAO_ParticipantStatusType::create($params); | |
66 | // Checking for participant status type id in db. | |
67 | $statusTypeId = $this->assertDBNotNull('CRM_Event_DAO_ParticipantStatusType', $statusType->id, 'id', | |
68 | 'id', 'Check DB for status type id' | |
69 | ); | |
70 | ||
71 | CRM_Event_BAO_ParticipantStatusType::deleteParticipantStatusType($statusType->id); | |
72 | // Checking for participant status type id after delete. | |
73 | $statusTypeId = $this->assertDBNull('CRM_Event_DAO_ParticipantStatusType', $statusType->id, 'id', | |
74 | 'id', 'Check DB for status type id' | |
75 | ); | |
76 | } | |
77 | ||
78 | /** | |
79 | * add() method (add and edit modes of participant status type) | |
80 | */ | |
00be9182 | 81 | public function testAddStatusType() { |
6a488035 TO |
82 | |
83 | $params = array( | |
84 | 'name' => 'testStatus', | |
85 | 'label' => 'testParticipant', | |
86 | 'class' => 'Positive', | |
87 | 'is_active' => 1, | |
88 | 'is_counted' => 1, | |
89 | 'weight' => 13, | |
90 | 'visibility_id' => 1, | |
91 | ); | |
92 | ||
93 | // check for add participant status type | |
94 | $statusType = CRM_Event_BAO_ParticipantStatusType::add($params); | |
95 | foreach ($params as $param => $value) { | |
96 | $this->assertEquals($value, $statusType->$param); | |
97 | } | |
98 | ||
99 | $params = array( | |
100 | 'id' => $statusType->id, | |
101 | 'name' => 'testStatus', | |
102 | 'label' => 'testAlterParticipant', | |
103 | 'class' => 'Pending', | |
104 | 'is_active' => 0, | |
105 | 'is_counted' => 0, | |
106 | 'weight' => 14, | |
107 | 'visibility_id' => 2, | |
108 | ); | |
109 | ||
110 | // check for add participant status type | |
111 | $statusType = CRM_Event_BAO_ParticipantStatusType::add($params); | |
112 | foreach ($params as $param => $value) { | |
113 | $this->assertEquals($value, $statusType->$param); | |
114 | } | |
115 | } | |
116 | ||
117 | /** | |
100fef9d | 118 | * Retrieve() method of participant status type |
6a488035 | 119 | */ |
00be9182 | 120 | public function testRetrieveStatusType() { |
6a488035 TO |
121 | |
122 | $params = array( | |
123 | 'name' => 'testStatus', | |
124 | 'label' => 'testParticipant', | |
125 | 'class' => 'Positive', | |
126 | 'is_active' => 1, | |
127 | 'is_counted' => 1, | |
128 | 'weight' => 13, | |
129 | 'visibility_id' => 1, | |
130 | ); | |
131 | ||
132 | $statusType = CRM_Event_BAO_ParticipantStatusType::create($params); | |
133 | ||
134 | // retrieve status type | |
92915c55 TO |
135 | $retrieveParams = array('id' => $statusType->id); |
136 | $default = array(); | |
6a488035 TO |
137 | $retrieveStatusType = CRM_Event_BAO_ParticipantStatusType::retrieve($retrieveParams, $default); |
138 | ||
139 | // check on retrieve values | |
140 | foreach ($params as $param => $value) { | |
141 | $this->assertEquals($value, $retrieveStatusType->$param); | |
142 | } | |
143 | } | |
144 | ||
145 | /** | |
100fef9d | 146 | * SetIsActive() method of participant status type |
6a488035 | 147 | */ |
00be9182 | 148 | public function testSetIsActiveStatusType() { |
6a488035 TO |
149 | |
150 | $params = array( | |
151 | 'name' => 'testStatus', | |
152 | 'label' => 'testParticipant', | |
153 | 'class' => 'Positive', | |
154 | 'is_active' => 0, | |
155 | 'is_counted' => 1, | |
156 | 'weight' => 15, | |
157 | 'visibility_id' => 1, | |
158 | ); | |
159 | ||
160 | $statusType = CRM_Event_BAO_ParticipantStatusType::create($params); | |
161 | $isActive = 1; | |
162 | ||
163 | // set participant status type active | |
164 | CRM_Event_BAO_ParticipantStatusType::setIsActive($statusType->id, $isActive); | |
165 | ||
166 | // compare expected value in db | |
167 | $this->assertDBCompareValue('CRM_Event_DAO_ParticipantStatusType', $statusType->id, 'is_Active', | |
168 | 'id', $isActive, 'Check DB for is_Active value' | |
169 | ); | |
170 | } | |
96025800 | 171 | |
6a488035 | 172 | } |