3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
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 public 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 public 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()) {
160 if (!$this->isTextPresent('None found.')) {
161 $this->click('css=div.crm-advanced_search_form-accordion div.crm-accordion-header');
164 $allPanes = $this->_advanceSearchPanesDateFilter();
166 foreach ($allPanes as $paneRef => $pane) {
167 if (in_array($paneRef, $openedPanes)) {
168 // assert for element present.
169 $this->waitForElementPresent("css=div.crm-accordion-wrapper div.crm-accordion-body {$pane['bodyLocator']}");
172 $this->assertTrue(!$this->isElementPresent("css=div.crm-accordion-wrapper div.crm-accordion-body {$pane['bodyLocator']}"));
179 * @param array $selectFields
181 function _selectPaneFields($paneRef, $selectFields = array()) {
182 $pane = $this->_advanceSearchPanesDateFilter($paneRef);
184 $this->click("css=div.crm-accordion-wrapper {$pane['headerLocator']}");
185 $this->waitForElementPresent("css=div.crm-accordion-wrapper div.crm-accordion-body {$pane['bodyLocator']}");
187 foreach ($pane['fields'] as $fld => $field) {
188 if (!empty($selectFields) && !in_array($fld, $selectFields)) {
192 $fldLocator = isset($field['locator']) ?
$field['locator'] : '';
194 switch ($field['type']) {
196 $this->type($fldLocator, current($field['values']));
200 foreach ($field['values'] as $op) {
201 $this->select($fldLocator, 'label=' . $op);
206 foreach ($field['values'] as $op) {
207 if (!$this->isChecked($op)) {
214 foreach ($field['values'] as $op) {
220 $this->webtestFillDate($fldLocator, current($field['values']));
227 * @param null $paneRef
231 public function _advanceSearchPanesDateFilter($paneRef = NULL) {
232 static $_advance_search_panes;
234 if (!isset($_advance_search_panes) ||
empty($_advance_search_panes)) {
235 $_advance_search_panes = array(
238 'headerLocator' => 'div#activity',
239 'bodyLocator' => 'select#activity_date_relative',
240 'title' => 'Activities',
246 'locator' => 'activity_date_relative',
247 'values' => array('This Year'),
253 'headerLocator' => 'div#demographics',
254 'bodyLocator' => 'input#birth_date_low_display',
255 'title' => 'Demographics',
261 'locator' => 'deceased_date_relative',
262 'values' => array('This Quarter'),
268 'headerLocator' => 'div#changeLog',
269 'bodyLocator' => 'input#changed_by',
270 'title' => 'Change Log',
273 'Modified Between' =>
276 'locator' => 'log_date_relative',
277 'values' => array('This Week'),
283 'headerLocator' => 'div#CiviMail',
284 'bodyLocator' => 'select#mailing_date_relative',
285 'title' => 'Mailings',
291 'locator' => 'mailing_date_relative',
292 'values' => array('Prior to Previous Quarter'),
299 'headerLocator' => 'div#CiviContribute',
300 'bodyLocator' => 'select#financial_type_id',
301 'title' => 'Contributions',
304 'Contribution Dates' =>
307 'locator' => 'contribution_date_relative',
308 'values' => array('Today'),
314 'headerLocator' => 'div#CiviPledge',
315 'bodyLocator' => 'select#pledge_payment_date_relative',
316 'title' => 'Pledges',
319 'Contribution Dates' =>
322 'locator' => 'pledge_payment_date_relative',
323 'values' => array('Prior to Previous Month'),
329 'headerLocator' => 'div#CiviMember',
330 'bodyLocator' => 'input#member_source',
331 'title' => 'Memberships',
337 'locator' => 'member_join_date_relative',
338 'values' => array('Previous Year'),
345 'headerLocator' => 'div#CiviEvent',
346 'bodyLocator' => 'input#event_id',
353 'locator' => 'event_relative',
354 'values' => array('Previous Week'),
363 return $_advance_search_panes[$paneRef];
366 return $_advance_search_panes;