copyright and version fixes
[civicrm-core.git] / tests / phpunit / WebTest / Event / ParticipantSearchTest.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
232624b1 4 | CiviCRM version 4.4 |
6a488035
TO
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
6a488035
TO
27require_once 'CiviTest/CiviSeleniumTestCase.php';
28class 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() {
6a488035
TO
42 $this->webtestLogin();
43
44 // visit event search page
071a6d2e 45 $this->openCiviPage("event/search", "reset=1");
6a488035
TO
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() {
6a488035
TO
65 $this->webtestLogin();
66
67 // visit event search page
071a6d2e 68 $this->openCiviPage("event/search", "reset=1&force=1");
6a488035
TO
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() {
6a488035
TO
76 $this->webtestLogin();
77
78 // visit event search page
071a6d2e 79 $this->openCiviPage("event/search", "reset=1");
6a488035
TO
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() {
6a488035
TO
97 $this->webtestLogin();
98
99 // visit event search page
071a6d2e 100 $this->openCiviPage("event/search", "reset=1");
6a488035
TO
101
102 $eventName = "Fall Fundraiser Dinner";
103 $this->type("event_name", $eventName);
104 $this->type("event_id", 1);
105
106 $this->click("_qf_Search_refresh");
107 $this->waitForPageToLoad($this->getTimeoutMsec());
108
109 $stringsToCheck = array(
110 "Event = $eventName",
111 'Select Records:',
112 'Edit Search Criteria',
113 );
114
115 $this->_checkStrings($stringsToCheck);
116 }
117
118 function testParticipantSearchEventDate() {
6a488035
TO
119
120 $this->webtestLogin();
121
122 // visit event search page
071a6d2e 123 $this->openCiviPage("event/search", "reset=1");
6a488035
TO
124
125 $this->select('event_relative', "label=Choose Date Range");
126 $this->webtestFillDate('event_start_date_low', '-2 year');
127 $this->webtestFillDate('event_end_date_high', '+1 year');
128
129 $this->click("_qf_Search_refresh");
130 $this->waitForPageToLoad($this->getTimeoutMsec());
131
132 $stringsToCheck = array(
133 "Start Date - greater than or equal to",
134 '...AND...',
135 "End Date - less than or equal to",
136 'Select Records:',
137 'Edit Search Criteria',
138 );
139
140 $this->_checkStrings($stringsToCheck);
141 }
142
143 function testParticipantSearchEventDateAndType() {
6a488035
TO
144
145 $this->webtestLogin();
146
147 // visit event search page
071a6d2e 148 $this->openCiviPage("event/search", "reset=1");
6a488035
TO
149
150 $this->select('event_relative', "label=Choose Date Range");
151 $this->webtestFillDate('event_start_date_low', '-2 year');
152 $this->webtestFillDate('event_end_date_high', '+1 year');
153
154 $eventTypeName = 'Fundraiser';
155 $this->type("event_type", $eventTypeName);
156 $this->type("event_type_id", 3);
157
6a488035
TO
158 $this->click("_qf_Search_refresh");
159 $this->waitForPageToLoad($this->getTimeoutMsec());
160
161 $stringsToCheck = array(
162 "Start Date - greater than or equal to",
163 '...AND...',
164 "End Date - less than or equal to",
165 "Event Type - $eventTypeName",
166 'Select Records:',
167 'Edit Search Criteria',
168 );
169
170 $this->_checkStrings($stringsToCheck);
171 }
172
173 function testParticipantSearchCustomField() {
6a488035
TO
174
175 $this->webtestLogin();
176
177 // visit event search page
071a6d2e 178 $this->openCiviPage("event/search", "reset=1");
6a488035
TO
179
180 $this->click("xpath=//div[@id='Food_Preference']/div[2]/table/tbody/tr/td[2]//label[contains(text(),'Chicken Combo')]");
181
182 $this->click("_qf_Search_refresh");
183 $this->waitForPageToLoad($this->getTimeoutMsec());
184
185 // note since this is generated data
186 // we are not sure if someone has this selection, so
187 // we are not testing for an empty record set
188 $stringsToCheck = array("Soup Selection = Chicken Combo");
189
190 $this->_checkStrings($stringsToCheck);
191
192 $this->click("xpath=//div[@id='Food_Preference']/div[2]/table/tbody/tr/td[2]//label[contains(text(),'Salmon Stew')]");
193 $this->click("_qf_Search_refresh");
194 $this->waitForPageToLoad($this->getTimeoutMsec());
195
196 $stringsToCheck = array("Soup Selection = Salmon Stew");
197
198 $this->_checkStrings($stringsToCheck);
199 }
200
201 function testParticipantSearchForceAndView() {
6a488035
TO
202
203 $this->webtestLogin();
204
205 // visit event search page
071a6d2e 206 $this->openCiviPage("event/search", "reset=1&force=1");
6a488035
TO
207
208 // assume generated DB
209 // there are participants
210 $this->assertTrue($this->isTextPresent("Select Records"), "A forced event search did not return any results");
211
212 $this->waitForElementPresent("xpath=id('participantSearch')/table/tbody/tr/td[11]/span/a[text()='View']");
213 $this->click("xpath=id('participantSearch')/table/tbody/tr/td[11]/span/a[text()='View']");
214 $this->waitForElementPresent("_qf_ParticipantView_cancel-bottom");
215
216 // ensure we get to particpant view
217 $stringsToCheck = array(
218 "View Participant",
219 "Event Registration",
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']");
241 $this->waitForElementPresent("_qf_Participant_cancel-bottom");
242
243 // ensure we get to particpant view
244 $stringsToCheck = array(
245 "Edit Event Registration",
246 "Participant",
247 "Event",
248 "Participant Role",
249 );
250
251 $this->_checkStrings($stringsToCheck);
252 }
253}
254