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