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