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