3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.3 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
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());
152 function _checkOpenedPanes($openedPanes = array(
154 if (!$this->isTextPresent('No matches found')) {
155 $this->click('css=div.crm-advanced_search_form-accordion div.crm-accordion-header');
158 $allPanes = $this->_advanceSearchPanesDateFilter();
160 foreach ($allPanes as $paneRef => $pane) {
161 if (in_array($paneRef, $openedPanes)) {
162 // assert for element present.
163 $this->waitForElementPresent("css=div.crm-accordion-wrapper div.crm-accordion-body {$pane['bodyLocator']}");
166 $this->assertTrue(!$this->isElementPresent("css=div.crm-accordion-wrapper div.crm-accordion-body {$pane['bodyLocator']}"));
171 function _selectPaneFields($paneRef, $selectFields = array(
173 $pane = $this->_advanceSearchPanesDateFilter($paneRef);
175 $this->click("css=div.crm-accordion-wrapper {$pane['headerLocator']}");
176 $this->waitForElementPresent("css=div.crm-accordion-wrapper div.crm-accordion-body {$pane['bodyLocator']}");
178 foreach ($pane['fields'] as $fld => $field) {
179 if (!empty($selectFields) && !in_array($fld, $selectFields)) {
183 $fldLocator = isset($field['locator']) ?
$field['locator'] : '';
185 switch ($field['type']) {
187 $this->type($fldLocator, current($field['values']));
191 foreach ($field['values'] as $op) {
192 $this->select($fldLocator, 'label=' . $op);
197 foreach ($field['values'] as $op) {
198 if (!$this->isChecked($op)) {
205 foreach ($field['values'] as $op) {
211 $this->webtestFillDate($fldLocator, current($field['values']));
217 function _advanceSearchPanesDateFilter($paneRef = NULL) {
218 static $_advance_search_panes;
220 if (!isset($_advance_search_panes) ||
empty($_advance_search_panes)) {
221 $_advance_search_panes = array(
224 'headerLocator' => 'div#activity',
225 'bodyLocator' => 'select#activity_date_relative',
226 'title' => 'Activities',
232 'locator' => 'activity_date_relative',
233 'values' => array('This Year'),
239 'headerLocator' => 'div#demographics',
240 'bodyLocator' => 'input#birth_date_low_display',
241 'title' => 'Demographics',
247 'locator' => 'deceased_date_relative',
248 'values' => array('This Quarter'),
254 'headerLocator' => 'div#changeLog',
255 'bodyLocator' => 'input#changed_by',
256 'title' => 'Change Log',
259 'Modified Between' =>
262 'locator' => 'log_date_relative',
263 'values' => array('This Week'),
269 'headerLocator' => 'div#CiviMail',
270 'bodyLocator' => 'select#mailing_date_relative',
271 'title' => 'Mailings',
277 'locator' => 'mailing_date_relative',
278 'values' => array('Prior to Previous Quarter'),
285 'headerLocator' => 'div#CiviContribute',
286 'bodyLocator' => 'select#financial_type_id',
287 'title' => 'Contributions',
290 'Contribution Dates' =>
293 'locator' => 'contribution_date_relative',
294 'values' => array('This Day'),
300 'headerLocator' => 'div#CiviPledge',
301 'bodyLocator' => 'select#pledge_payment_date_relative',
302 'title' => 'Pledges',
305 'Contribution Dates' =>
308 'locator' => 'pledge_payment_date_relative',
309 'values' => array('Prior to Previous Month'),
315 'headerLocator' => 'div#CiviMember',
316 'bodyLocator' => 'input#member_source',
317 'title' => 'Memberships',
323 'locator' => 'member_join_date_relative',
324 'values' => array('Previous Year'),
331 'headerLocator' => 'div#CiviEvent',
332 'bodyLocator' => 'input#event_name',
339 'locator' => 'event_relative',
340 'values' => array('Previous Week'),
349 return $_advance_search_panes[$paneRef];
352 return $_advance_search_panes;