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