Webtest Fix 4.5
[civicrm-core.git] / tests / phpunit / WebTest / Event / ParticipantSearchTest.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
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 require_once 'CiviTest/CiviSeleniumTestCase.php';
28
29 /**
30 * Class WebTest_Event_ParticipantSearchTest
31 */
32 class WebTest_Event_ParticipantSearchTest extends CiviSeleniumTestCase {
33
34 protected function setUp() {
35 parent::setUp();
36 }
37
38 /**
39 * @param $strings
40 */
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() {
49 $this->webtestLogin();
50
51 // visit event search page
52 $this->openCiviPage("event/search", "reset=1");
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() {
72 $this->webtestLogin();
73
74 // visit event search page
75 $this->openCiviPage("event/search", "reset=1&force=1");
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() {
83 $this->webtestLogin();
84
85 // visit event search page
86 $this->openCiviPage("event/search", "reset=1");
87
88 $crypticName = "foobardoogoo_" . md5(time());
89 $this->type("sort_name", $crypticName);
90
91 $this->click("_qf_Search_refresh");
92 $this->waitForPageToLoad($this->getTimeoutMsec());
93
94 $stringsToCheck = array(
95 'No matches found for',
96 'Name or Email LIKE',
97 $crypticName,
98 );
99
100 $this->_checkStrings($stringsToCheck);
101 }
102
103 function testParticipantSearchEventName() {
104 $this->webtestLogin();
105
106 // visit event search page
107 $this->openCiviPage("event/search", "reset=1");
108
109 $eventName = "Fall Fundraiser Dinner";
110 $this->select2("event_id", $eventName);
111
112 $this->click("_qf_Search_refresh");
113 $this->waitForPageToLoad($this->getTimeoutMsec());
114
115 $stringsToCheck = array(
116 "Event = $eventName",
117 'Select Records:',
118 'Edit Search Criteria',
119 );
120
121 $this->_checkStrings($stringsToCheck);
122 }
123
124 function testParticipantSearchEventDate() {
125
126 $this->webtestLogin();
127
128 // visit event search page
129 $this->openCiviPage("event/search", "reset=1");
130
131 $this->select('event_relative', "label=Choose Date Range");
132 $this->webtestFillDate('event_start_date_low', '-2 year');
133 $this->webtestFillDate('event_end_date_high', '+1 year');
134
135 $this->click("_qf_Search_refresh");
136 $this->waitForPageToLoad($this->getTimeoutMsec());
137
138 $stringsToCheck = array(
139 "Start Date - greater than or equal to",
140 '...AND...',
141 "End Date - less than or equal to",
142 'Select Records:',
143 'Edit Search Criteria',
144 );
145
146 $this->_checkStrings($stringsToCheck);
147 }
148
149 function testParticipantSearchEventDateAndType() {
150
151 $this->webtestLogin();
152
153 // visit event search page
154 $this->openCiviPage("event/search", "reset=1");
155
156 $this->select('event_relative', "label=Choose Date Range");
157 $this->webtestFillDate('event_start_date_low', '-2 year');
158 $this->webtestFillDate('event_end_date_high', '+1 year');
159
160 $eventTypeName = 'Fundraiser';
161 $this->select2("event_type_id", $eventTypeName);
162
163 $this->click("_qf_Search_refresh");
164 $this->waitForPageToLoad($this->getTimeoutMsec());
165
166 $stringsToCheck = array(
167 "Start Date - greater than or equal to",
168 '...AND...',
169 "End Date - less than or equal to",
170 "Event Type - $eventTypeName",
171 'Select Records:',
172 'Edit Search Criteria',
173 );
174
175 $this->_checkStrings($stringsToCheck);
176 }
177
178 function testParticipantSearchCustomField() {
179
180 $this->webtestLogin();
181
182 // visit event search page
183 $this->openCiviPage("event/search", "reset=1");
184
185 $this->select("xpath=//div[@id='Food_Preference']/div[2]/table/tbody/tr/td[2]//select", 'Chicken Combo');
186
187 $this->click("_qf_Search_refresh");
188 $this->waitForPageToLoad($this->getTimeoutMsec());
189
190 // note since this is generated data
191 // we are not sure if someone has this selection, so
192 // we are not testing for an empty record set
193 $stringsToCheck = array("Soup Selection = Chicken Combo");
194
195 $this->_checkStrings($stringsToCheck);
196
197 $this->select("xpath=//div[@id='Food_Preference']/div[2]/table/tbody/tr/td[2]//select", 'Salmon Stew');
198 $this->click("_qf_Search_refresh");
199 $this->waitForPageToLoad($this->getTimeoutMsec());
200
201 $stringsToCheck = array("Soup Selection = Salmon Stew");
202
203 $this->_checkStrings($stringsToCheck);
204 }
205
206 function testParticipantSearchForceAndView() {
207
208 $this->webtestLogin();
209
210 // visit event search page
211 $this->openCiviPage("event/search", "reset=1&force=1");
212
213 // assume generated DB
214 // there are participants
215 $this->assertTrue($this->isTextPresent("Select Records"), "A forced event search did not return any results");
216
217 $this->waitForElementPresent("xpath=id('participantSearch')/table/tbody/tr/td[11]/span/a[text()='View']");
218 $this->click("xpath=id('participantSearch')/table/tbody/tr/td[11]/span/a[text()='View']");
219 $this->waitForTextPresent("View Event Registration");
220
221 // ensure we get to particpant view
222 $stringsToCheck = array(
223 "Name",
224 "Event",
225 "Participant Role",
226 );
227
228 $this->_checkStrings($stringsToCheck);
229 }
230
231 function testParticipantSearchForceAndEdit() {
232
233 $this->webtestLogin();
234
235 // visit event search page
236 $this->openCiviPage("event/search", "reset=1&force=1");
237
238 // assume generated DB
239 // there are participants
240 $this->assertTrue($this->isTextPresent("Select Records"), "A forced event search did not return any results");
241
242 $this->waitForElementPresent("xpath=id('participantSearch')/table/tbody/tr/td[11]/span/a[text()='Edit']");
243 $this->click("xpath=id('participantSearch')/table/tbody/tr/td[11]/span/a[text()='Edit']");
244 $this->waitForTextPresent("Edit Event Registration");
245
246 // ensure we get to particpant view
247 $stringsToCheck = array(
248 "Participant",
249 "Event",
250 "Participant Role",
251 );
252
253 $this->_checkStrings($stringsToCheck);
254 }
255 }
256