Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
06a1bc01 | 4 | | CiviCRM version 4.5 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
06a1bc01 | 6 | | Copyright CiviCRM LLC (c) 2004-2014 | |
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 along with this program; if not, contact CiviCRM LLC | | |
21 | | at info[AT]civicrm[DOT]org. If you have questions about the | | |
22 | | GNU Affero General Public License or the licensing of CiviCRM, | | |
23 | | see the CiviCRM license FAQ at http://civicrm.org/licensing | | |
24 | +--------------------------------------------------------------------+ | |
25 | */ | |
26 | ||
6a488035 | 27 | require_once 'CiviTest/CiviSeleniumTestCase.php'; |
e9479dcf EM |
28 | |
29 | /** | |
30 | * Class WebTest_Event_ParticipantSearchTest | |
31 | */ | |
6a488035 TO |
32 | class WebTest_Event_ParticipantSearchTest extends CiviSeleniumTestCase { |
33 | ||
34 | protected function setUp() { | |
35 | parent::setUp(); | |
36 | } | |
37 | ||
4cbe18b8 EM |
38 | /** |
39 | * @param $strings | |
40 | */ | |
6a488035 TO |
41 | function _checkStrings(&$strings) { |
42 | // search for elements | |
43 | foreach ($strings as $string) { | |
44 | $this->assertTrue($this->isTextPresent($string), "Could not find $string on page"); | |
45 | } | |
46 | } | |
47 | ||
48 | function testParticipantSearchForm() { | |
6a488035 TO |
49 | $this->webtestLogin(); |
50 | ||
51 | // visit event search page | |
071a6d2e | 52 | $this->openCiviPage("event/search", "reset=1"); |
6a488035 TO |
53 | |
54 | $stringsToCheck = array( | |
55 | 'Participant Name', | |
56 | 'Event Name', | |
57 | 'Event Dates', | |
58 | 'Participant Status', | |
59 | 'Participant Role', | |
60 | 'Participant is a Test?', | |
61 | 'Participant is Pay Later?', | |
62 | 'Fee Level', | |
63 | 'Fee Amount', | |
64 | // check that the custom data is also there | |
65 | 'Food Preference', | |
66 | 'Soup Selection', | |
67 | ); | |
68 | $this->_checkStrings($stringsToCheck); | |
69 | } | |
70 | ||
71 | function testParticipantSearchForce() { | |
6a488035 TO |
72 | $this->webtestLogin(); |
73 | ||
74 | // visit event search page | |
071a6d2e | 75 | $this->openCiviPage("event/search", "reset=1&force=1"); |
6a488035 TO |
76 | |
77 | // assume generated DB | |
78 | // there are participants | |
79 | $this->assertTrue($this->isTextPresent("Select Records"), "A forced event search did not return any results"); | |
80 | } | |
81 | ||
82 | function testParticipantSearchEmpty() { | |
6a488035 TO |
83 | $this->webtestLogin(); |
84 | ||
85 | // visit event search page | |
071a6d2e | 86 | $this->openCiviPage("event/search", "reset=1"); |
6a488035 TO |
87 | |
88 | $crypticName = "foobardoogoo_" . md5(time()); | |
89 | $this->type("sort_name", $crypticName); | |
90 | ||
c3ad8633 | 91 | $this->clickLink("_qf_Search_refresh"); |
6a488035 TO |
92 | |
93 | $stringsToCheck = array( | |
94 | 'No matches found for', | |
95 | 'Name or Email LIKE', | |
96 | $crypticName, | |
97 | ); | |
98 | ||
99 | $this->_checkStrings($stringsToCheck); | |
100 | } | |
101 | ||
102 | function testParticipantSearchEventName() { | |
6a488035 TO |
103 | $this->webtestLogin(); |
104 | ||
105 | // visit event search page | |
071a6d2e | 106 | $this->openCiviPage("event/search", "reset=1"); |
4cbbec00 | 107 | $this->waitForElementPresent('_qf_Search_refresh'); |
6a488035 TO |
108 | |
109 | $eventName = "Fall Fundraiser Dinner"; | |
ed174dea | 110 | $this->select2("event_id", $eventName); |
6a488035 | 111 | |
87a7b760 | 112 | $this->clickLink("_qf_Search_refresh", "search-status"); |
6a488035 TO |
113 | |
114 | $stringsToCheck = array( | |
115 | "Event = $eventName", | |
116 | 'Select Records:', | |
117 | 'Edit Search Criteria', | |
118 | ); | |
119 | ||
120 | $this->_checkStrings($stringsToCheck); | |
121 | } | |
122 | ||
123 | function testParticipantSearchEventDate() { | |
6a488035 TO |
124 | |
125 | $this->webtestLogin(); | |
126 | ||
127 | // visit event search page | |
071a6d2e | 128 | $this->openCiviPage("event/search", "reset=1"); |
6a488035 TO |
129 | |
130 | $this->select('event_relative', "label=Choose Date Range"); | |
131 | $this->webtestFillDate('event_start_date_low', '-2 year'); | |
132 | $this->webtestFillDate('event_end_date_high', '+1 year'); | |
133 | ||
c3ad8633 | 134 | $this->clickLink("_qf_Search_refresh"); |
6a488035 TO |
135 | |
136 | $stringsToCheck = array( | |
137 | "Start Date - greater than or equal to", | |
138 | '...AND...', | |
139 | "End Date - less than or equal to", | |
140 | 'Select Records:', | |
141 | 'Edit Search Criteria', | |
142 | ); | |
143 | ||
144 | $this->_checkStrings($stringsToCheck); | |
145 | } | |
146 | ||
147 | function testParticipantSearchEventDateAndType() { | |
6a488035 TO |
148 | |
149 | $this->webtestLogin(); | |
150 | ||
151 | // visit event search page | |
071a6d2e | 152 | $this->openCiviPage("event/search", "reset=1"); |
6a488035 | 153 | |
57c2bdf0 | 154 | $eventTypeName = 'Fundraiser'; |
8fb46c61 | 155 | $this->waitForElementPresent('event_type_id'); |
57c2bdf0 | 156 | $this->select2("event_type_id", $eventTypeName); |
6a488035 TO |
157 | $this->select('event_relative', "label=Choose Date Range"); |
158 | $this->webtestFillDate('event_start_date_low', '-2 year'); | |
159 | $this->webtestFillDate('event_end_date_high', '+1 year'); | |
160 | ||
6a488035 | 161 | |
4cbbec00 RK |
162 | $this->click("_qf_Search_refresh"); |
163 | $this->waitForElementPresent("search-status"); | |
6a488035 TO |
164 | |
165 | $stringsToCheck = array( | |
166 | "Start Date - greater than or equal to", | |
167 | '...AND...', | |
168 | "End Date - less than or equal to", | |
169 | "Event Type - $eventTypeName", | |
170 | 'Select Records:', | |
171 | 'Edit Search Criteria', | |
172 | ); | |
173 | ||
174 | $this->_checkStrings($stringsToCheck); | |
175 | } | |
176 | ||
177 | function testParticipantSearchCustomField() { | |
6a488035 TO |
178 | |
179 | $this->webtestLogin(); | |
180 | ||
181 | // visit event search page | |
071a6d2e | 182 | $this->openCiviPage("event/search", "reset=1"); |
6a488035 | 183 | |
e739afc3 | 184 | $this->select("css=select[data-crm-custom='Food_Preference:Soup_Selection']", 'Chicken Combo'); |
6a488035 | 185 | |
c3ad8633 | 186 | $this->clickLink("_qf_Search_refresh"); |
6a488035 TO |
187 | |
188 | // note since this is generated data | |
189 | // we are not sure if someone has this selection, so | |
190 | // we are not testing for an empty record set | |
191 | $stringsToCheck = array("Soup Selection = Chicken Combo"); | |
192 | ||
193 | $this->_checkStrings($stringsToCheck); | |
194 | ||
e739afc3 | 195 | $this->select("css=select[data-crm-custom='Food_Preference:Soup_Selection']", 'Salmon Stew'); |
c3ad8633 | 196 | $this->clickLink("_qf_Search_refresh"); |
6a488035 TO |
197 | |
198 | $stringsToCheck = array("Soup Selection = Salmon Stew"); | |
199 | ||
200 | $this->_checkStrings($stringsToCheck); | |
201 | } | |
202 | ||
203 | function testParticipantSearchForceAndView() { | |
6a488035 TO |
204 | |
205 | $this->webtestLogin(); | |
206 | ||
207 | // visit event search page | |
071a6d2e | 208 | $this->openCiviPage("event/search", "reset=1&force=1"); |
6a488035 TO |
209 | |
210 | // assume generated DB | |
211 | // there are participants | |
212 | $this->assertTrue($this->isTextPresent("Select Records"), "A forced event search did not return any results"); | |
213 | ||
214 | $this->waitForElementPresent("xpath=id('participantSearch')/table/tbody/tr/td[11]/span/a[text()='View']"); | |
215 | $this->click("xpath=id('participantSearch')/table/tbody/tr/td[11]/span/a[text()='View']"); | |
3e60ff7f | 216 | $this->waitForTextPresent("View Event Registration"); |
6a488035 TO |
217 | |
218 | // ensure we get to particpant view | |
219 | $stringsToCheck = array( | |
6a488035 TO |
220 | "Name", |
221 | "Event", | |
222 | "Participant Role", | |
223 | ); | |
224 | ||
225 | $this->_checkStrings($stringsToCheck); | |
226 | } | |
227 | ||
228 | function testParticipantSearchForceAndEdit() { | |
6a488035 TO |
229 | |
230 | $this->webtestLogin(); | |
231 | ||
232 | // visit event search page | |
071a6d2e | 233 | $this->openCiviPage("event/search", "reset=1&force=1"); |
6a488035 TO |
234 | |
235 | // assume generated DB | |
236 | // there are participants | |
237 | $this->assertTrue($this->isTextPresent("Select Records"), "A forced event search did not return any results"); | |
238 | ||
239 | $this->waitForElementPresent("xpath=id('participantSearch')/table/tbody/tr/td[11]/span/a[text()='Edit']"); | |
240 | $this->click("xpath=id('participantSearch')/table/tbody/tr/td[11]/span/a[text()='Edit']"); | |
3e60ff7f | 241 | $this->waitForTextPresent("Edit Event Registration"); |
6a488035 TO |
242 | |
243 | // ensure we get to particpant view | |
244 | $stringsToCheck = array( | |
6a488035 TO |
245 | "Participant", |
246 | "Event", | |
247 | "Participant Role", | |
248 | ); | |
249 | ||
250 | $this->_checkStrings($stringsToCheck); | |
251 | } | |
252 | } | |
253 |