Merge pull request #12027 from jitendrapurohit/core-75
[civicrm-core.git] / tests / phpunit / WebTest / Event / ParticipantSearchTest.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
2fe49090 4 | CiviCRM version 5 |
6a488035 5 +--------------------------------------------------------------------+
8c9251b3 6 | Copyright CiviCRM LLC (c) 2004-2018 |
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 +--------------------------------------------------------------------+
e70a7fc0 25 */
6a488035 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 108
f75b8467 109 $eventName = "Rain-forest Cup Youth Soccer Tournament";
195986f2 110 $this->waitForElementPresent("event_id");
ed174dea 111 $this->select2("event_id", $eventName);
6a488035 112
38653166 113 $this->click("_qf_Search_refresh");
114 $this->waitForPageToLoad($this->getTimeoutMsec());
6a488035
TO
115
116 $stringsToCheck = array(
117 "Event = $eventName",
118 'Select Records:',
119 'Edit Search Criteria',
120 );
6a488035
TO
121 $this->_checkStrings($stringsToCheck);
122 }
123
00be9182 124 public function testParticipantSearchEventDate() {
6a488035
TO
125
126 $this->webtestLogin();
127
128 // visit event search page
071a6d2e 129 $this->openCiviPage("event/search", "reset=1");
6a488035
TO
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
c3ad8633 135 $this->clickLink("_qf_Search_refresh");
6a488035
TO
136
137 $stringsToCheck = array(
138 "Start Date - greater than or equal to",
139 '...AND...',
140 "End Date - less than or equal to",
141 'Select Records:',
142 'Edit Search Criteria',
143 );
144
145 $this->_checkStrings($stringsToCheck);
146 }
147
00be9182 148 public function testParticipantSearchEventDateAndType() {
a49e5dea 149 $this->markTestSkipped('Skipping for now as it works fine locally.');
6a488035
TO
150 $this->webtestLogin();
151
152 // visit event search page
071a6d2e 153 $this->openCiviPage("event/search", "reset=1");
6a488035 154
57c2bdf0 155 $eventTypeName = 'Fundraiser';
8fb46c61 156 $this->waitForElementPresent('event_type_id');
57c2bdf0 157 $this->select2("event_type_id", $eventTypeName);
195986f2 158 $this->waitForElementPresent('event_relative');
6a488035
TO
159 $this->select('event_relative', "label=Choose Date Range");
160 $this->webtestFillDate('event_start_date_low', '-2 year');
161 $this->webtestFillDate('event_end_date_high', '+1 year');
162
4cbbec00 163 $this->click("_qf_Search_refresh");
38653166 164 $this->waitForPageToLoad($this->getTimeoutMsec());
63d14d48 165 $this->waitForElementPresent("xpath=//form[@id='Search']/div[3]/div/div[1]/div");
6a488035
TO
166
167 $stringsToCheck = array(
168 "Start Date - greater than or equal to",
169 '...AND...',
170 "End Date - less than or equal to",
752b08dc 171 "Event Type = $eventTypeName",
6a488035
TO
172 'Select Records:',
173 'Edit Search Criteria',
174 );
175
176 $this->_checkStrings($stringsToCheck);
177 }
178
00be9182 179 public function testParticipantSearchCustomField() {
a90dac23 180 $this->markTestSkipped('Skipping for now as it works fine locally.');
6a488035
TO
181 $this->webtestLogin();
182
183 // visit event search page
071a6d2e 184 $this->openCiviPage("event/search", "reset=1");
6a488035 185
e739afc3 186 $this->select("css=select[data-crm-custom='Food_Preference:Soup_Selection']", 'Chicken Combo');
6a488035 187
c3ad8633 188 $this->clickLink("_qf_Search_refresh");
6a488035
TO
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
1788aac5 193 $stringsToCheck = array("Soup Selection In Chicken Combo");
6a488035
TO
194
195 $this->_checkStrings($stringsToCheck);
196
e739afc3 197 $this->select("css=select[data-crm-custom='Food_Preference:Soup_Selection']", 'Salmon Stew');
c3ad8633 198 $this->clickLink("_qf_Search_refresh");
6a488035 199
1788aac5 200 $stringsToCheck = array("Soup Selection In Salmon Stew");
6a488035
TO
201
202 $this->_checkStrings($stringsToCheck);
203 }
204
00be9182 205 public function testParticipantSearchForceAndView() {
6a488035
TO
206
207 $this->webtestLogin();
208
209 // visit event search page
071a6d2e 210 $this->openCiviPage("event/search", "reset=1&force=1");
6a488035
TO
211
212 // assume generated DB
213 // there are participants
214 $this->assertTrue($this->isTextPresent("Select Records"), "A forced event search did not return any results");
215
216 $this->waitForElementPresent("xpath=id('participantSearch')/table/tbody/tr/td[11]/span/a[text()='View']");
217 $this->click("xpath=id('participantSearch')/table/tbody/tr/td[11]/span/a[text()='View']");
3e60ff7f 218 $this->waitForTextPresent("View Event Registration");
6a488035
TO
219
220 // ensure we get to particpant view
221 $stringsToCheck = array(
6a488035
TO
222 "Name",
223 "Event",
224 "Participant Role",
225 );
226
227 $this->_checkStrings($stringsToCheck);
228 }
229
00be9182 230 public 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']");
94b3c290 243 $this->waitForElementPresent("xpath=//button//span[contains(text(),'Save')]");
6a488035
TO
244
245 // ensure we get to particpant view
246 $stringsToCheck = array(
6a488035
TO
247 "Participant",
248 "Event",
249 "Participant Role",
250 );
251
252 $this->_checkStrings($stringsToCheck);
253 }
96025800 254
6a488035 255}