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';
30 * Class WebTest_Contact_SearchbyDateFilterTest
32 class WebTest_Contact_SearchbyDateFilterTest
extends CiviSeleniumTestCase
{
34 protected function setUp() {
39 * test individual pane seperatly.
41 function testAdvancedSearch() {
42 $this->webtestLogin();
44 // Get all default advance search panes.
45 $allpanes = $this->_advanceSearchPanesDateFilter();
47 // Test Individual panes.
48 foreach (array_keys($allpanes) as $pane) {
49 // Go to the Advance Search
50 $this->openCiviPage("contact/search/advanced", "reset=1");
52 // Select some fields from pane.
53 $this->_selectPaneFields($pane);
55 $this->click('_qf_Advanced_refresh');
57 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
58 // check the opened panes.
59 $this->_checkOpenedPanes(array($pane));
64 function testIndividualSearchPage(){
65 $this->webtestLogin();
67 $this->openCiviPage("contribute/search", "reset=1");
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());
77 $this->select("contribution_date_relative","value=ending.year");
79 $this->click("_qf_Search_refresh");
80 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
82 $this->openCiviPage("member/search", "reset=1");
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());
96 $this->openCiviPage("event/search", "reset=1");
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());
110 $this->openCiviPage("activity/search", "reset=1");
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());
124 $this->openCiviPage("pledge/search", "reset=1");
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());
141 $this->openCiviPage("mailing", "reset=1");
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());
157 * @param array $openedPanes
159 function _checkOpenedPanes($openedPanes = array(
161 if (!$this->isTextPresent('None found.')) {
162 $this->click('css=div.crm-advanced_search_form-accordion div.crm-accordion-header');
165 $allPanes = $this->_advanceSearchPanesDateFilter();
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']}");
173 $this->assertTrue(!$this->isElementPresent("css=div.crm-accordion-wrapper div.crm-accordion-body {$pane['bodyLocator']}"));
180 * @param array $selectFields
182 function _selectPaneFields($paneRef, $selectFields = array(
184 $pane = $this->_advanceSearchPanesDateFilter($paneRef);
186 $this->click("css=div.crm-accordion-wrapper {$pane['headerLocator']}");
187 $this->waitForElementPresent("css=div.crm-accordion-wrapper div.crm-accordion-body {$pane['bodyLocator']}");
189 foreach ($pane['fields'] as $fld => $field) {
190 if (!empty($selectFields) && !in_array($fld, $selectFields)) {
194 $fldLocator = isset($field['locator']) ?
$field['locator'] : '';
196 switch ($field['type']) {
198 $this->type($fldLocator, current($field['values']));
202 foreach ($field['values'] as $op) {
203 $this->select($fldLocator, 'label=' . $op);
208 foreach ($field['values'] as $op) {
209 if (!$this->isChecked($op)) {
216 foreach ($field['values'] as $op) {
222 $this->webtestFillDate($fldLocator, current($field['values']));
229 * @param null $paneRef
233 function _advanceSearchPanesDateFilter($paneRef = NULL) {
234 static $_advance_search_panes;
236 if (!isset($_advance_search_panes) ||
empty($_advance_search_panes)) {
237 $_advance_search_panes = array(
240 'headerLocator' => 'div#activity',
241 'bodyLocator' => 'select#activity_date_relative',
242 'title' => 'Activities',
248 'locator' => 'activity_date_relative',
249 'values' => array('This Year'),
255 'headerLocator' => 'div#demographics',
256 'bodyLocator' => 'input#birth_date_low_display',
257 'title' => 'Demographics',
263 'locator' => 'deceased_date_relative',
264 'values' => array('This Quarter'),
270 'headerLocator' => 'div#changeLog',
271 'bodyLocator' => 'input#changed_by',
272 'title' => 'Change Log',
275 'Modified Between' =>
278 'locator' => 'log_date_relative',
279 'values' => array('This Week'),
285 'headerLocator' => 'div#CiviMail',
286 'bodyLocator' => 'select#mailing_date_relative',
287 'title' => 'Mailings',
293 'locator' => 'mailing_date_relative',
294 'values' => array('Prior to Previous Quarter'),
301 'headerLocator' => 'div#CiviContribute',
302 'bodyLocator' => 'select#financial_type_id',
303 'title' => 'Contributions',
306 'Contribution Dates' =>
309 'locator' => 'contribution_date_relative',
310 'values' => array('This Day'),
316 'headerLocator' => 'div#CiviPledge',
317 'bodyLocator' => 'select#pledge_payment_date_relative',
318 'title' => 'Pledges',
321 'Contribution Dates' =>
324 'locator' => 'pledge_payment_date_relative',
325 'values' => array('Prior to Previous Month'),
331 'headerLocator' => 'div#CiviMember',
332 'bodyLocator' => 'input#member_source',
333 'title' => 'Memberships',
339 'locator' => 'member_join_date_relative',
340 'values' => array('Previous Year'),
347 'headerLocator' => 'div#CiviEvent',
348 'bodyLocator' => 'input#event_id',
355 'locator' => 'event_relative',
356 'values' => array('Previous Week'),
365 return $_advance_search_panes[$paneRef];
368 return $_advance_search_panes;