3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2015 |
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
{
37 protected function setUp() {
42 * test individual pane seperatly.
44 public function testAdvancedSearch() {
45 $this->webtestLogin();
47 // Get all default advance search panes.
48 $allpanes = $this->_advanceSearchPanesDateFilter();
50 // Test Individual panes.
51 foreach (array_keys($allpanes) as $pane) {
52 // Go to the Advance Search
53 $this->openCiviPage("contact/search/advanced", "reset=1");
55 // Select some fields from pane.
56 $this->_selectPaneFields($pane);
58 $this->click('_qf_Advanced_refresh');
60 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
61 // check the opened panes.
62 $this->_checkOpenedPanes(array($pane));
67 public function testIndividualSearchPage() {
68 $this->webtestLogin();
70 $this->openCiviPage("contribute/search", "reset=1");
71 $this->select("contribution_date_relative", "value=previous_before.quarter");
72 $this->click("_qf_Search_refresh");
73 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
74 $this->select("contribution_date_relative", "value=previous_2.quarter");
75 $this->click("_qf_Search_refresh");
76 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
77 $this->select("contribution_date_relative", "value=earlier.quarter");
78 $this->click("_qf_Search_refresh");
79 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
80 $this->select("contribution_date_relative", "value=ending.year");
82 $this->click("_qf_Search_refresh");
83 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
85 $this->openCiviPage("member/search", "reset=1");
86 $this->select("member_end_date_relative", "value=previous_before.month");
87 $this->click("_qf_Search_refresh");
88 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
89 $this->select("member_end_date_relative", "value=previous_2.month");
90 $this->click("_qf_Search_refresh");
91 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
92 $this->select("member_end_date_relative", "value=earlier.month");
93 $this->click("_qf_Search_refresh");
94 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
95 $this->select("member_end_date_relative", "value=ending.month");
96 $this->click("_qf_Search_refresh");
97 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
99 $this->openCiviPage("event/search", "reset=1");
100 $this->select("event_relative", "value=previous_before.week");
101 $this->click("_qf_Search_refresh");
102 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
103 $this->select("event_relative", "value=previous_2.week");
104 $this->click("_qf_Search_refresh");
105 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
106 $this->select("event_relative", "value=earlier.week");
107 $this->click("_qf_Search_refresh");
108 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
109 $this->select("event_relative", "value=ending.week");
110 $this->click("_qf_Search_refresh");
111 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
113 $this->openCiviPage("activity/search", "reset=1");
114 $this->select("activity_date_relative", "value=previous_before.day");
115 $this->click("_qf_Search_refresh");
116 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
117 $this->select("activity_date_relative", "value=previous_2.day");
118 $this->click("_qf_Search_refresh");
119 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
120 $this->select("activity_date_relative", "value=earlier.day");
121 $this->click("_qf_Search_refresh");
122 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
123 $this->select("activity_date_relative", "value=ending.quarter");
124 $this->click("_qf_Search_refresh");
125 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
127 $this->openCiviPage("pledge/search", "reset=1");
128 $this->select("pledge_payment_date_relative", "value=greater.week");
129 $this->click("_qf_Search_refresh");
130 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
131 $this->click("xpath=//form[@id='Search']/div[2]/div/div");
132 $this->select("pledge_payment_date_relative", "value=greater.day");
133 $this->click("_qf_Search_refresh");
134 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
135 $this->click("xpath=//form[@id='Search']/div[2]/div/div");
136 $this->select("pledge_payment_date_relative", "value=greater.quarter");
137 $this->click("_qf_Search_refresh");
138 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
139 $this->click("xpath=//form[@id='Search']/div[2]/div/div");
140 $this->select("pledge_payment_date_relative", "value=greater.month");
141 $this->click("_qf_Search_refresh");
142 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
144 $this->openCiviPage("mailing", "reset=1");
145 $this->select("mailing_relative", "value=previous_before.year");
146 $this->click("_qf_Search_refresh");
147 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
148 $this->select("mailing_relative", "value=previous_2.year");
149 $this->click("_qf_Search_refresh");
150 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
151 $this->select("mailing_relative", "value=earlier.year");
152 $this->click("_qf_Search_refresh");
153 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
154 $this->select("mailing_relative", "value=greater.year");
155 $this->click("_qf_Search_refresh");
156 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
160 * @param array $openedPanes
162 public function _checkOpenedPanes($openedPanes = array()) {
163 if (!$this->isTextPresent('None found.')) {
164 $this->click('css=div.crm-advanced_search_form-accordion div.crm-accordion-header');
167 $allPanes = $this->_advanceSearchPanesDateFilter();
169 foreach ($allPanes as $paneRef => $pane) {
170 if (in_array($paneRef, $openedPanes)) {
171 // assert for element present.
172 $this->waitForElementPresent("css=div.crm-accordion-wrapper div.crm-accordion-body {$pane['bodyLocator']}");
175 $this->assertTrue(!$this->isElementPresent("css=div.crm-accordion-wrapper div.crm-accordion-body {$pane['bodyLocator']}"));
182 * @param array $selectFields
184 public function _selectPaneFields($paneRef, $selectFields = array()) {
185 $pane = $this->_advanceSearchPanesDateFilter($paneRef);
187 $this->click("css=div.crm-accordion-wrapper {$pane['headerLocator']}");
188 $this->waitForElementPresent("css=div.crm-accordion-wrapper div.crm-accordion-body {$pane['bodyLocator']}");
190 foreach ($pane['fields'] as $fld => $field) {
191 if (!empty($selectFields) && !in_array($fld, $selectFields)) {
195 $fldLocator = isset($field['locator']) ?
$field['locator'] : '';
197 switch ($field['type']) {
199 $this->type($fldLocator, current($field['values']));
203 foreach ($field['values'] as $op) {
204 $this->select($fldLocator, 'label=' . $op);
209 foreach ($field['values'] as $op) {
210 if (!$this->isChecked($op)) {
217 foreach ($field['values'] as $op) {
223 $this->webtestFillDate($fldLocator, current($field['values']));
230 * @param null $paneRef
234 public function _advanceSearchPanesDateFilter($paneRef = NULL) {
235 static $_advance_search_panes;
237 if (!isset($_advance_search_panes) ||
empty($_advance_search_panes)) {
238 $_advance_search_panes = array(
240 'headerLocator' => 'div#activity',
241 'bodyLocator' => 'select#activity_date_relative',
242 'title' => 'Activities',
244 'Activity Dates' => array(
246 'locator' => 'activity_date_relative',
247 'values' => array('This Year'),
251 'demographics' => array(
252 'headerLocator' => 'div#demographics',
253 'bodyLocator' => 'input#birth_date_low',
254 'title' => 'Demographics',
256 'Deceased Dates' => array(
258 'locator' => 'deceased_date_relative',
259 'values' => array('This Quarter'),
263 'change_log' => array(
264 'headerLocator' => 'div#changeLog',
265 'bodyLocator' => 'input#changed_by',
266 'title' => 'Change Log',
268 'Modified Between' => array(
270 'locator' => 'log_date_relative',
271 'values' => array('This Week'),
276 'headerLocator' => 'div#CiviMail',
277 'bodyLocator' => 'select#mailing_date_relative',
278 'title' => 'Mailings',
280 'Mailing Date' => array(
282 'locator' => 'mailing_date_relative',
283 'values' => array('Prior to Previous Quarter'),
287 'contribution' => array(
288 'headerLocator' => 'div#CiviContribute',
289 'bodyLocator' => 'select#financial_type_id',
290 'title' => 'Contributions',
292 'Date Received' => array(
294 'locator' => 'contribution_date_relative',
295 'values' => array('Today'),
300 'headerLocator' => 'div#CiviPledge',
301 'bodyLocator' => 'select#pledge_payment_date_relative',
302 'title' => 'Pledges',
304 'Date Received' => array(
306 'locator' => 'pledge_payment_date_relative',
307 'values' => array('Prior to Previous Month'),
311 'membership' => array(
312 'headerLocator' => 'div#CiviMember',
313 'bodyLocator' => 'input#member_source',
314 'title' => 'Memberships',
316 'Member Since' => array(
318 'locator' => 'member_join_date_relative',
319 'values' => array('Previous Year'),
325 'headerLocator' => 'div#CiviEvent',
326 'bodyLocator' => 'input#event_id',
329 'Event Dates' => array(
331 'locator' => 'event_relative',
332 'values' => array('Previous Week'),
341 return $_advance_search_panes[$paneRef];
344 return $_advance_search_panes;