Commit | Line | Data |
---|---|---|
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 | 27 | require_once 'CiviTest/CiviSeleniumTestCase.php'; |
e9479dcf EM |
28 | |
29 | /** | |
30 | * Class WebTest_Contact_SearchbyDateFilterTest | |
31 | */ | |
6a488035 TO |
32 | class WebTest_Contact_SearchbyDateFilterTest extends CiviSeleniumTestCase { |
33 | ||
34 | protected function setUp() { | |
35 | parent::setUp(); | |
36 | } | |
37 | ||
38 | /* | |
c490a46a | 39 | * test individual pane seperatly. |
6a488035 | 40 | */ |
00be9182 | 41 | public function testAdvancedSearch() { |
6a488035 TO |
42 | $this->webtestLogin(); |
43 | ||
44 | // Get all default advance search panes. | |
45 | $allpanes = $this->_advanceSearchPanesDateFilter(); | |
46 | ||
47 | // Test Individual panes. | |
48 | foreach (array_keys($allpanes) as $pane) { | |
49 | // Go to the Advance Search | |
071a6d2e | 50 | $this->openCiviPage("contact/search/advanced", "reset=1"); |
6a488035 TO |
51 | |
52 | // Select some fields from pane. | |
53 | $this->_selectPaneFields($pane); | |
54 | ||
55 | $this->click('_qf_Advanced_refresh'); | |
56 | ||
57 | $this->waitForPageToLoad(2 * $this->getTimeoutMsec()); | |
58 | // check the opened panes. | |
59 | $this->_checkOpenedPanes(array($pane)); | |
60 | } | |
76e86fd8 | 61 | |
6a488035 TO |
62 | } |
63 | ||
9b873358 | 64 | public function testIndividualSearchPage() { |
6a488035 TO |
65 | $this->webtestLogin(); |
66 | ||
071a6d2e | 67 | $this->openCiviPage("contribute/search", "reset=1"); |
6c6e6187 | 68 | $this->select("contribution_date_relative", "value=previous_before.quarter"); |
6a488035 TO |
69 | $this->click("_qf_Search_refresh"); |
70 | $this->waitForPageToLoad(2 * $this->getTimeoutMsec()); | |
6c6e6187 | 71 | $this->select("contribution_date_relative", "value=previous_2.quarter"); |
6a488035 TO |
72 | $this->click("_qf_Search_refresh"); |
73 | $this->waitForPageToLoad(2 * $this->getTimeoutMsec()); | |
6c6e6187 | 74 | $this->select("contribution_date_relative", "value=earlier.quarter"); |
6a488035 TO |
75 | $this->click("_qf_Search_refresh"); |
76 | $this->waitForPageToLoad(2 * $this->getTimeoutMsec()); | |
6c6e6187 | 77 | $this->select("contribution_date_relative", "value=ending.year"); |
76e86fd8 | 78 | |
6a488035 TO |
79 | $this->click("_qf_Search_refresh"); |
80 | $this->waitForPageToLoad(2 * $this->getTimeoutMsec()); | |
071a6d2e CW |
81 | |
82 | $this->openCiviPage("member/search", "reset=1"); | |
6c6e6187 | 83 | $this->select("member_end_date_relative", "value=previous_before.month"); |
6a488035 TO |
84 | $this->click("_qf_Search_refresh"); |
85 | $this->waitForPageToLoad(2 * $this->getTimeoutMsec()); | |
6c6e6187 | 86 | $this->select("member_end_date_relative", "value=previous_2.month"); |
6a488035 TO |
87 | $this->click("_qf_Search_refresh"); |
88 | $this->waitForPageToLoad(2 * $this->getTimeoutMsec()); | |
6c6e6187 | 89 | $this->select("member_end_date_relative", "value=earlier.month"); |
6a488035 TO |
90 | $this->click("_qf_Search_refresh"); |
91 | $this->waitForPageToLoad(2 * $this->getTimeoutMsec()); | |
6c6e6187 | 92 | $this->select("member_end_date_relative", "value=ending.month"); |
6a488035 TO |
93 | $this->click("_qf_Search_refresh"); |
94 | $this->waitForPageToLoad(2 * $this->getTimeoutMsec()); | |
071a6d2e CW |
95 | |
96 | $this->openCiviPage("event/search", "reset=1"); | |
6c6e6187 | 97 | $this->select("event_relative", "value=previous_before.week"); |
6a488035 TO |
98 | $this->click("_qf_Search_refresh"); |
99 | $this->waitForPageToLoad(2 * $this->getTimeoutMsec()); | |
6c6e6187 | 100 | $this->select("event_relative", "value=previous_2.week"); |
6a488035 TO |
101 | $this->click("_qf_Search_refresh"); |
102 | $this->waitForPageToLoad(2 * $this->getTimeoutMsec()); | |
6c6e6187 | 103 | $this->select("event_relative", "value=earlier.week"); |
6a488035 TO |
104 | $this->click("_qf_Search_refresh"); |
105 | $this->waitForPageToLoad(2 * $this->getTimeoutMsec()); | |
6c6e6187 | 106 | $this->select("event_relative", "value=ending.week"); |
6a488035 TO |
107 | $this->click("_qf_Search_refresh"); |
108 | $this->waitForPageToLoad(2 * $this->getTimeoutMsec()); | |
071a6d2e CW |
109 | |
110 | $this->openCiviPage("activity/search", "reset=1"); | |
6c6e6187 | 111 | $this->select("activity_date_relative", "value=previous_before.day"); |
6a488035 TO |
112 | $this->click("_qf_Search_refresh"); |
113 | $this->waitForPageToLoad(2 * $this->getTimeoutMsec()); | |
6c6e6187 | 114 | $this->select("activity_date_relative", "value=previous_2.day"); |
6a488035 TO |
115 | $this->click("_qf_Search_refresh"); |
116 | $this->waitForPageToLoad(2 * $this->getTimeoutMsec()); | |
6c6e6187 | 117 | $this->select("activity_date_relative", "value=earlier.day"); |
6a488035 TO |
118 | $this->click("_qf_Search_refresh"); |
119 | $this->waitForPageToLoad(2 * $this->getTimeoutMsec()); | |
6c6e6187 | 120 | $this->select("activity_date_relative", "value=ending.quarter"); |
6a488035 TO |
121 | $this->click("_qf_Search_refresh"); |
122 | $this->waitForPageToLoad(2 * $this->getTimeoutMsec()); | |
071a6d2e CW |
123 | |
124 | $this->openCiviPage("pledge/search", "reset=1"); | |
6c6e6187 | 125 | $this->select("pledge_payment_date_relative", "value=greater.week"); |
6a488035 TO |
126 | $this->click("_qf_Search_refresh"); |
127 | $this->waitForPageToLoad(2 * $this->getTimeoutMsec()); | |
128 | $this->click("xpath=//form[@id='Search']/div[2]/div/div"); | |
6c6e6187 | 129 | $this->select("pledge_payment_date_relative", "value=greater.day"); |
6a488035 TO |
130 | $this->click("_qf_Search_refresh"); |
131 | $this->waitForPageToLoad(2 * $this->getTimeoutMsec()); | |
132 | $this->click("xpath=//form[@id='Search']/div[2]/div/div"); | |
6c6e6187 | 133 | $this->select("pledge_payment_date_relative", "value=greater.quarter"); |
6a488035 TO |
134 | $this->click("_qf_Search_refresh"); |
135 | $this->waitForPageToLoad(2 * $this->getTimeoutMsec()); | |
136 | $this->click("xpath=//form[@id='Search']/div[2]/div/div"); | |
6c6e6187 | 137 | $this->select("pledge_payment_date_relative", "value=greater.month"); |
6a488035 TO |
138 | $this->click("_qf_Search_refresh"); |
139 | $this->waitForPageToLoad(2 * $this->getTimeoutMsec()); | |
071a6d2e CW |
140 | |
141 | $this->openCiviPage("mailing", "reset=1"); | |
6c6e6187 | 142 | $this->select("mailing_relative", "value=previous_before.year"); |
6a488035 TO |
143 | $this->click("_qf_Search_refresh"); |
144 | $this->waitForPageToLoad(2 * $this->getTimeoutMsec()); | |
6c6e6187 | 145 | $this->select("mailing_relative", "value=previous_2.year"); |
6a488035 TO |
146 | $this->click("_qf_Search_refresh"); |
147 | $this->waitForPageToLoad(2 * $this->getTimeoutMsec()); | |
6c6e6187 | 148 | $this->select("mailing_relative", "value=earlier.year"); |
6a488035 TO |
149 | $this->click("_qf_Search_refresh"); |
150 | $this->waitForPageToLoad(2 * $this->getTimeoutMsec()); | |
6c6e6187 | 151 | $this->select("mailing_relative", "value=greater.year"); |
6a488035 TO |
152 | $this->click("_qf_Search_refresh"); |
153 | $this->waitForPageToLoad(2 * $this->getTimeoutMsec()); | |
154 | } | |
155 | ||
4cbe18b8 EM |
156 | /** |
157 | * @param array $openedPanes | |
158 | */ | |
6c6e6187 | 159 | function _checkOpenedPanes($openedPanes = array()) { |
1eba7e53 | 160 | if (!$this->isTextPresent('None found.')) { |
6a488035 TO |
161 | $this->click('css=div.crm-advanced_search_form-accordion div.crm-accordion-header'); |
162 | } | |
163 | ||
164 | $allPanes = $this->_advanceSearchPanesDateFilter(); | |
165 | ||
166 | foreach ($allPanes as $paneRef => $pane) { | |
167 | if (in_array($paneRef, $openedPanes)) { | |
168 | // assert for element present. | |
169 | $this->waitForElementPresent("css=div.crm-accordion-wrapper div.crm-accordion-body {$pane['bodyLocator']}"); | |
170 | } | |
171 | else { | |
172 | $this->assertTrue(!$this->isElementPresent("css=div.crm-accordion-wrapper div.crm-accordion-body {$pane['bodyLocator']}")); | |
173 | } | |
174 | } | |
175 | } | |
176 | ||
4cbe18b8 EM |
177 | /** |
178 | * @param $paneRef | |
179 | * @param array $selectFields | |
180 | */ | |
6c6e6187 | 181 | function _selectPaneFields($paneRef, $selectFields = array()) { |
6a488035 TO |
182 | $pane = $this->_advanceSearchPanesDateFilter($paneRef); |
183 | ||
184 | $this->click("css=div.crm-accordion-wrapper {$pane['headerLocator']}"); | |
185 | $this->waitForElementPresent("css=div.crm-accordion-wrapper div.crm-accordion-body {$pane['bodyLocator']}"); | |
186 | ||
187 | foreach ($pane['fields'] as $fld => $field) { | |
188 | if (!empty($selectFields) && !in_array($fld, $selectFields)) { | |
189 | continue; | |
190 | } | |
191 | ||
192 | $fldLocator = isset($field['locator']) ? $field['locator'] : ''; | |
193 | ||
194 | switch ($field['type']) { | |
195 | case 'text': | |
196 | $this->type($fldLocator, current($field['values'])); | |
197 | break; | |
198 | ||
199 | case 'select': | |
200 | foreach ($field['values'] as $op) { | |
201 | $this->select($fldLocator, 'label=' . $op); | |
202 | } | |
203 | break; | |
204 | ||
205 | case 'checkbox': | |
206 | foreach ($field['values'] as $op) { | |
207 | if (!$this->isChecked($op)) { | |
208 | $this->click($op); | |
209 | } | |
210 | } | |
211 | break; | |
212 | ||
213 | case 'radio': | |
214 | foreach ($field['values'] as $op) { | |
215 | $this->click($op); | |
216 | } | |
217 | break; | |
218 | ||
219 | case 'date': | |
220 | $this->webtestFillDate($fldLocator, current($field['values'])); | |
221 | break; | |
222 | } | |
223 | } | |
224 | } | |
225 | ||
4cbe18b8 EM |
226 | /** |
227 | * @param null $paneRef | |
228 | * | |
229 | * @return array | |
230 | */ | |
00be9182 | 231 | public function _advanceSearchPanesDateFilter($paneRef = NULL) { |
6a488035 TO |
232 | static $_advance_search_panes; |
233 | ||
234 | if (!isset($_advance_search_panes) || empty($_advance_search_panes)) { | |
235 | $_advance_search_panes = array( | |
236 | 'activity' => | |
237 | array( | |
238 | 'headerLocator' => 'div#activity', | |
da2fd2e8 | 239 | 'bodyLocator' => 'select#activity_date_relative', |
6a488035 TO |
240 | 'title' => 'Activities', |
241 | 'fields' => | |
242 | array( | |
243 | 'Activity Dates' => | |
244 | array( | |
245 | 'type' => 'select', | |
246 | 'locator' => 'activity_date_relative', | |
247 | 'values' => array('This Year'), | |
248 | ), | |
249 | ), | |
250 | ), | |
251 | 'demographics' => | |
252 | array( | |
253 | 'headerLocator' => 'div#demographics', | |
254 | 'bodyLocator' => 'input#birth_date_low_display', | |
255 | 'title' => 'Demographics', | |
256 | 'fields' => | |
257 | array( | |
258 | 'Deceased Dates' => | |
259 | array( | |
260 | 'type' => 'select', | |
261 | 'locator' => 'deceased_date_relative', | |
262 | 'values' => array('This Quarter'), | |
263 | ), | |
264 | ), | |
265 | ), | |
266 | 'change_log' => | |
267 | array( | |
268 | 'headerLocator' => 'div#changeLog', | |
269 | 'bodyLocator' => 'input#changed_by', | |
270 | 'title' => 'Change Log', | |
271 | 'fields' => | |
272 | array( | |
273 | 'Modified Between' => | |
274 | array( | |
275 | 'type' => 'select', | |
276 | 'locator' => 'log_date_relative', | |
277 | 'values' => array('This Week'), | |
278 | ), | |
279 | ), | |
280 | ), | |
281 | 'mailing' => | |
282 | array( | |
283 | 'headerLocator' => 'div#CiviMail', | |
284 | 'bodyLocator' => 'select#mailing_date_relative', | |
285 | 'title' => 'Mailings', | |
286 | 'fields' => | |
287 | array( | |
288 | 'Mailing Date' => | |
289 | array( | |
290 | 'type' => 'select', | |
291 | 'locator' => 'mailing_date_relative', | |
292 | 'values' => array('Prior to Previous Quarter'), | |
293 | ), | |
294 | ), | |
295 | ), | |
76e86fd8 | 296 | |
6a488035 TO |
297 | 'contribution' => |
298 | array( | |
299 | 'headerLocator' => 'div#CiviContribute', | |
300 | 'bodyLocator' => 'select#financial_type_id', | |
301 | 'title' => 'Contributions', | |
302 | 'fields' => | |
303 | array( | |
304 | 'Contribution Dates' => | |
305 | array( | |
306 | 'type' => 'select', | |
307 | 'locator' => 'contribution_date_relative', | |
88a6f4b3 | 308 | 'values' => array('Today'), |
6a488035 TO |
309 | ), |
310 | ), | |
311 | ), | |
312 | 'pledge' => | |
313 | array( | |
314 | 'headerLocator' => 'div#CiviPledge', | |
315 | 'bodyLocator' => 'select#pledge_payment_date_relative', | |
316 | 'title' => 'Pledges', | |
317 | 'fields' => | |
318 | array( | |
319 | 'Contribution Dates' => | |
320 | array( | |
321 | 'type' => 'select', | |
322 | 'locator' => 'pledge_payment_date_relative', | |
323 | 'values' => array('Prior to Previous Month'), | |
324 | ), | |
325 | ), | |
326 | ), | |
327 | 'membership' => | |
328 | array( | |
329 | 'headerLocator' => 'div#CiviMember', | |
330 | 'bodyLocator' => 'input#member_source', | |
331 | 'title' => 'Memberships', | |
332 | 'fields' => | |
333 | array( | |
334 | 'Member Since' => | |
335 | array( | |
336 | 'type' => 'select', | |
337 | 'locator' => 'member_join_date_relative', | |
338 | 'values' => array('Previous Year'), | |
339 | ), | |
76e86fd8 | 340 | |
6a488035 TO |
341 | ), |
342 | ), | |
343 | 'event' => | |
344 | array( | |
345 | 'headerLocator' => 'div#CiviEvent', | |
b5e4fcd9 | 346 | 'bodyLocator' => 'input#event_id', |
6a488035 TO |
347 | 'title' => 'Events', |
348 | 'fields' => | |
349 | array( | |
350 | 'Event Dates' => | |
351 | array( | |
352 | 'type' => 'select', | |
353 | 'locator' => 'event_relative', | |
354 | 'values' => array('Previous Week'), | |
355 | ), | |
356 | ), | |
357 | ), | |
76e86fd8 | 358 | |
6a488035 TO |
359 | ); |
360 | } | |
361 | ||
362 | if ($paneRef) { | |
363 | return $_advance_search_panes[$paneRef]; | |
364 | } | |
365 | ||
366 | return $_advance_search_panes; | |
367 | } | |
368 | } |