3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
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. |
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. |
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 +--------------------------------------------------------------------+
27 require_once 'CiviTest/CiviSeleniumTestCase.php';
28 class WebTest_Contact_SearchbyDateFilterTest
extends CiviSeleniumTestCase
{
30 protected function setUp() {
35 * Function to test individual pane seperatly.
37 function testAdvancedSearch() {
38 $this->webtestLogin();
40 // Get all default advance search panes.
41 $allpanes = $this->_advanceSearchPanesDateFilter();
43 // Test Individual panes.
44 foreach (array_keys($allpanes) as $pane) {
45 // Go to the Advance Search
46 $this->openCiviPage("contact/search/advanced", "reset=1");
48 // Select some fields from pane.
49 $this->_selectPaneFields($pane);
51 $this->click('_qf_Advanced_refresh');
53 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
54 // check the opened panes.
55 $this->_checkOpenedPanes(array($pane));
60 function testIndividualSearchPage(){
61 $this->webtestLogin();
63 $this->openCiviPage("contribute/search", "reset=1");
64 $this->select("contribution_date_relative","value=previous_before.quarter");
65 $this->click("_qf_Search_refresh");
66 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
67 $this->select("contribution_date_relative","value=previous_2.quarter");
68 $this->click("_qf_Search_refresh");
69 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
70 $this->select("contribution_date_relative","value=earlier.quarter");
71 $this->click("_qf_Search_refresh");
72 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
73 $this->select("contribution_date_relative","value=ending.year");
75 $this->click("_qf_Search_refresh");
76 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
78 $this->openCiviPage("member/search", "reset=1");
79 $this->select("member_end_date_relative","value=previous_before.month");
80 $this->click("_qf_Search_refresh");
81 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
82 $this->select("member_end_date_relative","value=previous_2.month");
83 $this->click("_qf_Search_refresh");
84 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
85 $this->select("member_end_date_relative","value=earlier.month");
86 $this->click("_qf_Search_refresh");
87 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
88 $this->select("member_end_date_relative","value=ending.month");
89 $this->click("_qf_Search_refresh");
90 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
92 $this->openCiviPage("event/search", "reset=1");
93 $this->select("event_relative","value=previous_before.week");
94 $this->click("_qf_Search_refresh");
95 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
96 $this->select("event_relative","value=previous_2.week");
97 $this->click("_qf_Search_refresh");
98 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
99 $this->select("event_relative","value=earlier.week");
100 $this->click("_qf_Search_refresh");
101 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
102 $this->select("event_relative","value=ending.week");
103 $this->click("_qf_Search_refresh");
104 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
106 $this->openCiviPage("activity/search", "reset=1");
107 $this->select("activity_date_relative","value=previous_before.day");
108 $this->click("_qf_Search_refresh");
109 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
110 $this->select("activity_date_relative","value=previous_2.day");
111 $this->click("_qf_Search_refresh");
112 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
113 $this->select("activity_date_relative","value=earlier.day");
114 $this->click("_qf_Search_refresh");
115 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
116 $this->select("activity_date_relative","value=ending.quarter");
117 $this->click("_qf_Search_refresh");
118 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
120 $this->openCiviPage("pledge/search", "reset=1");
121 $this->select("pledge_payment_date_relative","value=greater.week");
122 $this->click("_qf_Search_refresh");
123 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
124 $this->click("xpath=//form[@id='Search']/div[2]/div/div");
125 $this->select("pledge_payment_date_relative","value=greater.day");
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.quarter");
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.month");
134 $this->click("_qf_Search_refresh");
135 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
137 $this->openCiviPage("mailing", "reset=1");
138 $this->select("mailing_relative","value=previous_before.year");
139 $this->click("_qf_Search_refresh");
140 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
141 $this->select("mailing_relative","value=previous_2.year");
142 $this->click("_qf_Search_refresh");
143 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
144 $this->select("mailing_relative","value=earlier.year");
145 $this->click("_qf_Search_refresh");
146 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
147 $this->select("mailing_relative","value=greater.year");
148 $this->click("_qf_Search_refresh");
149 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
153 * @param array $openedPanes
155 function _checkOpenedPanes($openedPanes = array(
157 if (!$this->isTextPresent('No matches found')) {
158 $this->click('css=div.crm-advanced_search_form-accordion div.crm-accordion-header');
161 $allPanes = $this->_advanceSearchPanesDateFilter();
163 foreach ($allPanes as $paneRef => $pane) {
164 if (in_array($paneRef, $openedPanes)) {
165 // assert for element present.
166 $this->waitForElementPresent("css=div.crm-accordion-wrapper div.crm-accordion-body {$pane['bodyLocator']}");
169 $this->assertTrue(!$this->isElementPresent("css=div.crm-accordion-wrapper div.crm-accordion-body {$pane['bodyLocator']}"));
176 * @param array $selectFields
178 function _selectPaneFields($paneRef, $selectFields = array(
180 $pane = $this->_advanceSearchPanesDateFilter($paneRef);
182 $this->click("css=div.crm-accordion-wrapper {$pane['headerLocator']}");
183 $this->waitForElementPresent("css=div.crm-accordion-wrapper div.crm-accordion-body {$pane['bodyLocator']}");
185 foreach ($pane['fields'] as $fld => $field) {
186 if (!empty($selectFields) && !in_array($fld, $selectFields)) {
190 $fldLocator = isset($field['locator']) ?
$field['locator'] : '';
192 switch ($field['type']) {
194 $this->type($fldLocator, current($field['values']));
198 foreach ($field['values'] as $op) {
199 $this->select($fldLocator, 'label=' . $op);
204 foreach ($field['values'] as $op) {
205 if (!$this->isChecked($op)) {
212 foreach ($field['values'] as $op) {
218 $this->webtestFillDate($fldLocator, current($field['values']));
225 * @param null $paneRef
229 function _advanceSearchPanesDateFilter($paneRef = NULL) {
230 static $_advance_search_panes;
232 if (!isset($_advance_search_panes) ||
empty($_advance_search_panes)) {
233 $_advance_search_panes = array(
236 'headerLocator' => 'div#activity',
237 'bodyLocator' => 'select#activity_date_relative',
238 'title' => 'Activities',
244 'locator' => 'activity_date_relative',
245 'values' => array('This Year'),
251 'headerLocator' => 'div#demographics',
252 'bodyLocator' => 'input#birth_date_low_display',
253 'title' => 'Demographics',
259 'locator' => 'deceased_date_relative',
260 'values' => array('This Quarter'),
266 'headerLocator' => 'div#changeLog',
267 'bodyLocator' => 'input#changed_by',
268 'title' => 'Change Log',
271 'Modified Between' =>
274 'locator' => 'log_date_relative',
275 'values' => array('This Week'),
281 'headerLocator' => 'div#CiviMail',
282 'bodyLocator' => 'select#mailing_date_relative',
283 'title' => 'Mailings',
289 'locator' => 'mailing_date_relative',
290 'values' => array('Prior to Previous Quarter'),
297 'headerLocator' => 'div#CiviContribute',
298 'bodyLocator' => 'select#financial_type_id',
299 'title' => 'Contributions',
302 'Contribution Dates' =>
305 'locator' => 'contribution_date_relative',
306 'values' => array('This Day'),
312 'headerLocator' => 'div#CiviPledge',
313 'bodyLocator' => 'select#pledge_payment_date_relative',
314 'title' => 'Pledges',
317 'Contribution Dates' =>
320 'locator' => 'pledge_payment_date_relative',
321 'values' => array('Prior to Previous Month'),
327 'headerLocator' => 'div#CiviMember',
328 'bodyLocator' => 'input#member_source',
329 'title' => 'Memberships',
335 'locator' => 'member_join_date_relative',
336 'values' => array('Previous Year'),
343 'headerLocator' => 'div#CiviEvent',
344 'bodyLocator' => 'input#event_id',
351 'locator' => 'event_relative',
352 'values' => array('Previous Week'),
361 return $_advance_search_panes[$paneRef];
364 return $_advance_search_panes;