Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
06a1bc01 | 4 | | CiviCRM version 4.5 | |
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 | 27 | require_once 'CiviTest/CiviSeleniumTestCase.php'; |
e9479dcf EM |
28 | |
29 | /** | |
30 | * Class WebTest_Event_ParticipantSearchTest | |
31 | */ | |
6a488035 TO |
32 | class WebTest_Event_ParticipantSearchTest extends CiviSeleniumTestCase { |
33 | ||
34 | protected function setUp() { | |
35 | parent::setUp(); | |
36 | } | |
37 | ||
4cbe18b8 EM |
38 | /** |
39 | * @param $strings | |
40 | */ | |
6a488035 TO |
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() { | |
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 | ||
71 | 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 | ||
82 | 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 | ||
102 | function testParticipantSearchEventName() { | |
6a488035 TO |
103 | $this->webtestLogin(); |
104 | ||
105 | // visit event search page | |
071a6d2e | 106 | $this->openCiviPage("event/search", "reset=1"); |
6a488035 TO |
107 | |
108 | $eventName = "Fall Fundraiser Dinner"; | |
ed174dea | 109 | $this->select2("event_id", $eventName); |
6a488035 | 110 | |
87a7b760 | 111 | $this->clickLink("_qf_Search_refresh", "search-status"); |
6a488035 TO |
112 | |
113 | $stringsToCheck = array( | |
114 | "Event = $eventName", | |
115 | 'Select Records:', | |
116 | 'Edit Search Criteria', | |
117 | ); | |
118 | ||
119 | $this->_checkStrings($stringsToCheck); | |
120 | } | |
121 | ||
122 | function testParticipantSearchEventDate() { | |
6a488035 TO |
123 | |
124 | $this->webtestLogin(); | |
125 | ||
126 | // visit event search page | |
071a6d2e | 127 | $this->openCiviPage("event/search", "reset=1"); |
6a488035 TO |
128 | |
129 | $this->select('event_relative', "label=Choose Date Range"); | |
130 | $this->webtestFillDate('event_start_date_low', '-2 year'); | |
131 | $this->webtestFillDate('event_end_date_high', '+1 year'); | |
132 | ||
c3ad8633 | 133 | $this->clickLink("_qf_Search_refresh"); |
6a488035 TO |
134 | |
135 | $stringsToCheck = array( | |
136 | "Start Date - greater than or equal to", | |
137 | '...AND...', | |
138 | "End Date - less than or equal to", | |
139 | 'Select Records:', | |
140 | 'Edit Search Criteria', | |
141 | ); | |
142 | ||
143 | $this->_checkStrings($stringsToCheck); | |
144 | } | |
145 | ||
146 | function testParticipantSearchEventDateAndType() { | |
6a488035 TO |
147 | |
148 | $this->webtestLogin(); | |
149 | ||
150 | // visit event search page | |
071a6d2e | 151 | $this->openCiviPage("event/search", "reset=1"); |
6a488035 TO |
152 | |
153 | $this->select('event_relative', "label=Choose Date Range"); | |
154 | $this->webtestFillDate('event_start_date_low', '-2 year'); | |
155 | $this->webtestFillDate('event_end_date_high', '+1 year'); | |
156 | ||
157 | $eventTypeName = 'Fundraiser'; | |
ed174dea | 158 | $this->select2("event_type_id", $eventTypeName); |
6a488035 | 159 | |
87a7b760 | 160 | $this->clickLink("_qf_Search_refresh", "search-status"); |
6a488035 TO |
161 | |
162 | $stringsToCheck = array( | |
163 | "Start Date - greater than or equal to", | |
164 | '...AND...', | |
165 | "End Date - less than or equal to", | |
166 | "Event Type - $eventTypeName", | |
167 | 'Select Records:', | |
168 | 'Edit Search Criteria', | |
169 | ); | |
170 | ||
171 | $this->_checkStrings($stringsToCheck); | |
172 | } | |
173 | ||
174 | function testParticipantSearchCustomField() { | |
6a488035 TO |
175 | |
176 | $this->webtestLogin(); | |
177 | ||
178 | // visit event search page | |
071a6d2e | 179 | $this->openCiviPage("event/search", "reset=1"); |
6a488035 | 180 | |
e739afc3 | 181 | $this->select("css=select[data-crm-custom='Food_Preference:Soup_Selection']", 'Chicken Combo'); |
6a488035 | 182 | |
c3ad8633 | 183 | $this->clickLink("_qf_Search_refresh"); |
6a488035 TO |
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 | ||
e739afc3 | 192 | $this->select("css=select[data-crm-custom='Food_Preference:Soup_Selection']", 'Salmon Stew'); |
c3ad8633 | 193 | $this->clickLink("_qf_Search_refresh"); |
6a488035 TO |
194 | |
195 | $stringsToCheck = array("Soup Selection = Salmon Stew"); | |
196 | ||
197 | $this->_checkStrings($stringsToCheck); | |
198 | } | |
199 | ||
200 | function testParticipantSearchForceAndView() { | |
6a488035 TO |
201 | |
202 | $this->webtestLogin(); | |
203 | ||
204 | // visit event search page | |
071a6d2e | 205 | $this->openCiviPage("event/search", "reset=1&force=1"); |
6a488035 TO |
206 | |
207 | // assume generated DB | |
208 | // there are participants | |
209 | $this->assertTrue($this->isTextPresent("Select Records"), "A forced event search did not return any results"); | |
210 | ||
211 | $this->waitForElementPresent("xpath=id('participantSearch')/table/tbody/tr/td[11]/span/a[text()='View']"); | |
212 | $this->click("xpath=id('participantSearch')/table/tbody/tr/td[11]/span/a[text()='View']"); | |
3e60ff7f | 213 | $this->waitForTextPresent("View Event Registration"); |
6a488035 TO |
214 | |
215 | // ensure we get to particpant view | |
216 | $stringsToCheck = array( | |
6a488035 TO |
217 | "Name", |
218 | "Event", | |
219 | "Participant Role", | |
220 | ); | |
221 | ||
222 | $this->_checkStrings($stringsToCheck); | |
223 | } | |
224 | ||
225 | function testParticipantSearchForceAndEdit() { | |
6a488035 TO |
226 | |
227 | $this->webtestLogin(); | |
228 | ||
229 | // visit event search page | |
071a6d2e | 230 | $this->openCiviPage("event/search", "reset=1&force=1"); |
6a488035 TO |
231 | |
232 | // assume generated DB | |
233 | // there are participants | |
234 | $this->assertTrue($this->isTextPresent("Select Records"), "A forced event search did not return any results"); | |
235 | ||
236 | $this->waitForElementPresent("xpath=id('participantSearch')/table/tbody/tr/td[11]/span/a[text()='Edit']"); | |
237 | $this->click("xpath=id('participantSearch')/table/tbody/tr/td[11]/span/a[text()='Edit']"); | |
3e60ff7f | 238 | $this->waitForTextPresent("Edit Event Registration"); |
6a488035 TO |
239 | |
240 | // ensure we get to particpant view | |
241 | $stringsToCheck = array( | |
6a488035 TO |
242 | "Participant", |
243 | "Event", | |
244 | "Participant Role", | |
245 | ); | |
246 | ||
247 | $this->_checkStrings($stringsToCheck); | |
248 | } | |
249 | } | |
250 |