3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2016 |
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->markTestSkipped('Skipping for now as it works fine locally.');
46 $this->webtestLogin();
48 // Get all default advance search panes.
49 $allpanes = $this->_advanceSearchPanesDateFilter();
51 // Test Individual panes.
52 foreach (array_keys($allpanes) as $pane) {
53 // Go to the Advance Search
54 $this->openCiviPage("contact/search/advanced", "reset=1");
56 // Select some fields from pane.
57 $this->_selectPaneFields($pane);
59 $this->click('_qf_Advanced_refresh');
61 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
62 // check the opened panes.
63 $this->_checkOpenedPanes(array($pane));
68 public function testIndividualSearchPage() {
69 $this->webtestLogin();
71 $this->openCiviPage("contribute/search", "reset=1");
72 $this->select("contribution_date_relative", "value=previous_before.quarter");
73 $this->click("_qf_Search_refresh");
74 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
75 $this->select("contribution_date_relative", "value=previous_2.quarter");
76 $this->click("_qf_Search_refresh");
77 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
78 $this->select("contribution_date_relative", "value=earlier.quarter");
79 $this->click("_qf_Search_refresh");
80 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
81 $this->select("contribution_date_relative", "value=ending.year");
83 $this->click("_qf_Search_refresh");
84 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
86 $this->openCiviPage("member/search", "reset=1");
87 $this->select("member_end_date_relative", "value=previous_before.month");
88 $this->click("_qf_Search_refresh");
89 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
90 $this->select("member_end_date_relative", "value=previous_2.month");
91 $this->click("_qf_Search_refresh");
92 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
93 $this->select("member_end_date_relative", "value=earlier.month");
94 $this->click("_qf_Search_refresh");
95 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
96 $this->select("member_end_date_relative", "value=ending.month");
97 $this->click("_qf_Search_refresh");
98 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
100 $this->openCiviPage("event/search", "reset=1");
101 $this->select("event_relative", "value=previous_before.week");
102 $this->click("_qf_Search_refresh");
103 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
104 $this->select("event_relative", "value=previous_2.week");
105 $this->click("_qf_Search_refresh");
106 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
107 $this->select("event_relative", "value=earlier.week");
108 $this->click("_qf_Search_refresh");
109 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
110 $this->select("event_relative", "value=ending.week");
111 $this->click("_qf_Search_refresh");
112 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
114 $this->openCiviPage("activity/search", "reset=1");
115 $this->select("activity_date_relative", "value=previous_before.day");
116 $this->click("_qf_Search_refresh");
117 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
118 $this->select("activity_date_relative", "value=previous_2.day");
119 $this->click("_qf_Search_refresh");
120 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
121 $this->select("activity_date_relative", "value=earlier.day");
122 $this->click("_qf_Search_refresh");
123 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
124 $this->select("activity_date_relative", "value=ending.quarter");
125 $this->click("_qf_Search_refresh");
126 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
128 $this->openCiviPage("pledge/search", "reset=1");
129 $this->select("pledge_payment_date_relative", "value=greater.week");
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.day");
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.quarter");
138 $this->click("_qf_Search_refresh");
139 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
140 $this->click("xpath=//form[@id='Search']/div[2]/div/div");
141 $this->select("pledge_payment_date_relative", "value=greater.month");
142 $this->click("_qf_Search_refresh");
143 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
145 $this->openCiviPage("mailing", "reset=1");
146 $this->select("mailing_relative", "value=previous_before.year");
147 $this->click("_qf_Search_refresh");
148 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
149 $this->select("mailing_relative", "value=previous_2.year");
150 $this->click("_qf_Search_refresh");
151 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
152 $this->select("mailing_relative", "value=earlier.year");
153 $this->click("_qf_Search_refresh");
154 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
155 $this->select("mailing_relative", "value=greater.year");
156 $this->click("_qf_Search_refresh");
157 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
161 * @param array $openedPanes
163 public function _checkOpenedPanes($openedPanes = array()) {
164 if (!$this->isTextPresent('None found.')) {
165 $this->click('css=div.crm-advanced_search_form-accordion div.crm-accordion-header');
168 $allPanes = $this->_advanceSearchPanesDateFilter();
170 foreach ($allPanes as $paneRef => $pane) {
171 if (in_array($paneRef, $openedPanes)) {
172 // assert for element present.
173 $this->waitForElementPresent("css=div.crm-accordion-wrapper div.crm-accordion-body {$pane['bodyLocator']}");
176 $this->assertTrue(!$this->isElementPresent("css=div.crm-accordion-wrapper div.crm-accordion-body {$pane['bodyLocator']}"));
183 * @param array $selectFields
185 public function _selectPaneFields($paneRef, $selectFields = array()) {
186 $pane = $this->_advanceSearchPanesDateFilter($paneRef);
188 $this->click("css=div.crm-accordion-wrapper {$pane['headerLocator']}");
189 $this->waitForElementPresent("css=div.crm-accordion-wrapper div.crm-accordion-body {$pane['bodyLocator']}");
191 foreach ($pane['fields'] as $fld => $field) {
192 if (!empty($selectFields) && !in_array($fld, $selectFields)) {
196 $fldLocator = isset($field['locator']) ?
$field['locator'] : '';
198 switch ($field['type']) {
200 $this->type($fldLocator, current($field['values']));
204 foreach ($field['values'] as $op) {
205 $this->select($fldLocator, 'label=' . $op);
210 foreach ($field['values'] as $op) {
211 if (!$this->isChecked($op)) {
218 foreach ($field['values'] as $op) {
224 $this->webtestFillDate($fldLocator, current($field['values']));
231 * @param null $paneRef
235 public function _advanceSearchPanesDateFilter($paneRef = NULL) {
236 static $_advance_search_panes;
238 if (!isset($_advance_search_panes) ||
empty($_advance_search_panes)) {
239 $_advance_search_panes = array(
241 'headerLocator' => 'div#activity',
242 'bodyLocator' => 'select#activity_date_relative',
243 'title' => 'Activities',
245 'Activity Dates' => array(
247 'locator' => 'activity_date_relative',
248 'values' => array('This Year'),
252 'demographics' => array(
253 'headerLocator' => 'div#demographics',
254 'bodyLocator' => 'input#birth_date_low',
255 'title' => 'Demographics',
257 'Deceased Dates' => array(
259 'locator' => 'deceased_date_relative',
260 'values' => array('This Quarter'),
264 'change_log' => array(
265 'headerLocator' => 'div#changeLog',
266 'bodyLocator' => 'input#changed_by',
267 'title' => 'Change Log',
269 'Modified Between' => array(
271 'locator' => 'log_date_relative',
272 'values' => array('This Week'),
277 'headerLocator' => 'div#CiviMail',
278 'bodyLocator' => 'select#mailing_date_relative',
279 'title' => 'Mailings',
281 'Mailing Date' => array(
283 'locator' => 'mailing_date_relative',
284 'values' => array('Prior to Previous Quarter'),
288 'contribution' => array(
289 'headerLocator' => 'div#CiviContribute',
290 'bodyLocator' => 'select#financial_type_id',
291 'title' => 'Contributions',
293 'Date Received' => array(
295 'locator' => 'contribution_date_relative',
296 'values' => array('Today'),
301 'headerLocator' => 'div#CiviPledge',
302 'bodyLocator' => 'select#pledge_payment_date_relative',
303 'title' => 'Pledges',
305 'Date Received' => array(
307 'locator' => 'pledge_payment_date_relative',
308 'values' => array('Prior to Previous Month'),
312 'membership' => array(
313 'headerLocator' => 'div#CiviMember',
314 'bodyLocator' => 'input#member_source',
315 'title' => 'Memberships',
317 'Member Since' => array(
319 'locator' => 'member_join_date_relative',
320 'values' => array('Previous Year'),
326 'headerLocator' => 'div#CiviEvent',
327 'bodyLocator' => 'input#event_id',
330 'Event Dates' => array(
332 'locator' => 'event_relative',
333 'values' => array('Previous Week'),
342 return $_advance_search_panes[$paneRef];
345 return $_advance_search_panes;