Merge pull request #4903 from colemanw/INFRA-132
[civicrm-core.git] / tests / phpunit / WebTest / Event / ParticipantSearchTest.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
39de6fd5 4 | CiviCRM version 4.6 |
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 27require_once 'CiviTest/CiviSeleniumTestCase.php';
e9479dcf
EM
28
29/**
30 * Class WebTest_Event_ParticipantSearchTest
31 */
6a488035
TO
32class WebTest_Event_ParticipantSearchTest extends CiviSeleniumTestCase {
33
34 protected function setUp() {
35 parent::setUp();
36 }
37
4cbe18b8
EM
38 /**
39 * @param $strings
40 */
00be9182 41 public function _checkStrings(&$strings) {
6a488035
TO
42 // search for elements
43 foreach ($strings as $string) {
44 $this->assertTrue($this->isTextPresent($string), "Could not find $string on page");
45 }
46 }
47
00be9182 48 public function testParticipantSearchForm() {
6a488035
TO
49 $this->webtestLogin();
50
51 // visit event search page
071a6d2e 52 $this->openCiviPage("event/search", "reset=1");
6a488035
TO
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
00be9182 71 public function testParticipantSearchForce() {
6a488035
TO
72 $this->webtestLogin();
73
74 // visit event search page
071a6d2e 75 $this->openCiviPage("event/search", "reset=1&force=1");
6a488035
TO
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
00be9182 82 public function testParticipantSearchEmpty() {
6a488035
TO
83 $this->webtestLogin();
84
85 // visit event search page
071a6d2e 86 $this->openCiviPage("event/search", "reset=1");
6a488035
TO
87
88 $crypticName = "foobardoogoo_" . md5(time());
89 $this->type("sort_name", $crypticName);
90
c3ad8633 91 $this->clickLink("_qf_Search_refresh");
6a488035
TO
92
93 $stringsToCheck = array(
94 'No matches found for',
95 'Name or Email LIKE',
96 $crypticName,
97 );
98
99 $this->_checkStrings($stringsToCheck);
100 }
101
00be9182 102 public function testParticipantSearchEventName() {
6a488035
TO
103 $this->webtestLogin();
104
105 // visit event search page
071a6d2e 106 $this->openCiviPage("event/search", "reset=1");
4cbbec00 107 $this->waitForElementPresent('_qf_Search_refresh');
6a488035
TO
108
109 $eventName = "Fall Fundraiser Dinner";
ed174dea 110 $this->select2("event_id", $eventName);
6a488035 111
87a7b760 112 $this->clickLink("_qf_Search_refresh", "search-status");
6a488035
TO
113
114 $stringsToCheck = array(
115 "Event = $eventName",
116 'Select Records:',
117 'Edit Search Criteria',
118 );
119
120 $this->_checkStrings($stringsToCheck);
121 }
122
00be9182 123 public function testParticipantSearchEventDate() {
6a488035
TO
124
125 $this->webtestLogin();
126
127 // visit event search page
071a6d2e 128 $this->openCiviPage("event/search", "reset=1");
6a488035
TO
129
130 $this->select('event_relative', "label=Choose Date Range");
131 $this->webtestFillDate('event_start_date_low', '-2 year');
132 $this->webtestFillDate('event_end_date_high', '+1 year');
133
c3ad8633 134 $this->clickLink("_qf_Search_refresh");
6a488035
TO
135
136 $stringsToCheck = array(
137 "Start Date - greater than or equal to",
138 '...AND...',
139 "End Date - less than or equal to",
140 'Select Records:',
141 'Edit Search Criteria',
142 );
143
144 $this->_checkStrings($stringsToCheck);
145 }
146
00be9182 147 public function testParticipantSearchEventDateAndType() {
6a488035
TO
148
149 $this->webtestLogin();
150
151 // visit event search page
071a6d2e 152 $this->openCiviPage("event/search", "reset=1");
6a488035 153
57c2bdf0 154 $eventTypeName = 'Fundraiser';
8fb46c61 155 $this->waitForElementPresent('event_type_id');
57c2bdf0 156 $this->select2("event_type_id", $eventTypeName);
6a488035
TO
157 $this->select('event_relative', "label=Choose Date Range");
158 $this->webtestFillDate('event_start_date_low', '-2 year');
159 $this->webtestFillDate('event_end_date_high', '+1 year');
160
4cbbec00 161 $this->click("_qf_Search_refresh");
63d14d48 162 $this->waitForElementPresent("xpath=//form[@id='Search']/div[3]/div/div[1]/div");
6a488035
TO
163
164 $stringsToCheck = array(
165 "Start Date - greater than or equal to",
166 '...AND...',
167 "End Date - less than or equal to",
168 "Event Type - $eventTypeName",
169 'Select Records:',
170 'Edit Search Criteria',
171 );
172
173 $this->_checkStrings($stringsToCheck);
174 }
175
00be9182 176 public function testParticipantSearchCustomField() {
6a488035
TO
177
178 $this->webtestLogin();
179
180 // visit event search page
071a6d2e 181 $this->openCiviPage("event/search", "reset=1");
6a488035 182
e739afc3 183 $this->select("css=select[data-crm-custom='Food_Preference:Soup_Selection']", 'Chicken Combo');
6a488035 184
c3ad8633 185 $this->clickLink("_qf_Search_refresh");
6a488035
TO
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
e739afc3 194 $this->select("css=select[data-crm-custom='Food_Preference:Soup_Selection']", 'Salmon Stew');
c3ad8633 195 $this->clickLink("_qf_Search_refresh");
6a488035
TO
196
197 $stringsToCheck = array("Soup Selection = Salmon Stew");
198
199 $this->_checkStrings($stringsToCheck);
200 }
201
00be9182 202 public 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']");
3e60ff7f 215 $this->waitForTextPresent("View Event Registration");
6a488035
TO
216
217 // ensure we get to particpant view
218 $stringsToCheck = array(
6a488035
TO
219 "Name",
220 "Event",
221 "Participant Role",
222 );
223
224 $this->_checkStrings($stringsToCheck);
225 }
226
00be9182 227 public function testParticipantSearchForceAndEdit() {
6a488035
TO
228
229 $this->webtestLogin();
230
231 // visit event search page
071a6d2e 232 $this->openCiviPage("event/search", "reset=1&force=1");
6a488035
TO
233
234 // assume generated DB
235 // there are participants
236 $this->assertTrue($this->isTextPresent("Select Records"), "A forced event search did not return any results");
237
238 $this->waitForElementPresent("xpath=id('participantSearch')/table/tbody/tr/td[11]/span/a[text()='Edit']");
239 $this->click("xpath=id('participantSearch')/table/tbody/tr/td[11]/span/a[text()='Edit']");
3e60ff7f 240 $this->waitForTextPresent("Edit Event Registration");
6a488035
TO
241
242 // ensure we get to particpant view
243 $stringsToCheck = array(
6a488035
TO
244 "Participant",
245 "Event",
246 "Participant Role",
247 );
248
249 $this->_checkStrings($stringsToCheck);
250 }
251}