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';
28 class WebTest_Contact_AdvanceSearchPaneTest
extends CiviSeleniumTestCase
{
30 protected function setUp() {
35 * Function to test individual pane seperatly.
37 function testIndividualPanes() {
38 $this->webtestLogin();
40 // Get all default advance search panes.
41 $allpanes = $this->_advanceSearchPanes();
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());
55 // check the opened panes.
56 $this->_checkOpenedPanes(array($pane));
61 * Function to test by selecting all panes at a time.
63 function testAllPanes() {
64 $this->webtestLogin();
66 // Get all default advance search panes.
67 $allpanes = $this->_advanceSearchPanes();
69 // Go to the Advance Search
70 $this->openCiviPage('contact/search/advanced', 'reset=1');
72 // Select some fields from all default panes.
73 foreach (array_keys($allpanes) as $pane) {
74 $this->_selectPaneFields($pane);
77 $this->click('_qf_Advanced_refresh');
79 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
81 // check all opened panes.
82 $this->_checkOpenedPanes(array_keys($allpanes));
85 function _checkOpenedPanes($openedPanes = array(
87 if (!$this->isTextPresent('No matches found')) {
88 $this->click('css=div.crm-advanced_search_form-accordion div.crm-accordion-header');
91 $allPanes = $this->_advanceSearchPanes();
93 foreach ($allPanes as $paneRef => $pane) {
94 if (in_array($paneRef, $openedPanes)) {
95 // assert for element present.
96 $this->waitForElementPresent("css=div.crm-accordion-wrapper div.crm-accordion-body {$pane['bodyLocator']}");
99 $this->assertTrue(!$this->isElementPresent("css=div.crm-accordion-wrapper div.crm-accordion-body {$pane['bodyLocator']}"));
104 function _selectPaneFields($paneRef, $selectFields = array(
106 $pane = $this->_advanceSearchPanes($paneRef);
108 $this->click("css=div.crm-accordion-wrapper {$pane['headerLocator']}");
109 $this->waitForElementPresent("css=div.crm-accordion-wrapper div.crm-accordion-body {$pane['bodyLocator']}");
111 foreach ($pane['fields'] as $fld => $field) {
112 if (!empty($selectFields) && !in_array($fld, $selectFields)) {
116 $fldLocator = isset($field['locator']) ?
$field['locator'] : '';
118 switch ($field['type']) {
120 $this->type($fldLocator, current($field['values']));
124 foreach ($field['values'] as $op) {
125 $this->select($fldLocator, 'label=' . $op);
130 foreach ($field['values'] as $op) {
131 if (!$this->isChecked($op)) {
138 foreach ($field['values'] as $op) {
144 $this->webtestFillDate($fldLocator, current($field['values']));
150 function _advanceSearchPanes($paneRef = NULL) {
151 static $_advance_search_panes;
153 if (!isset($_advance_search_panes) ||
empty($_advance_search_panes)) {
154 $_advance_search_panes = array(
157 'headerLocator' => 'div#location',
158 'bodyLocator' => 'select#country',
159 'title' => 'Address Fields',
164 'type' => 'checkbox',
165 'values' => array('location_type[1]', 'location_type[2]'),
170 'locator' => 'country',
171 'values' => array('United States'),
176 'locator' => 'state_province',
177 'values' => array('Alabama', 'California', 'New Jersey', 'New York'),
183 'headerLocator' => 'div#custom',
184 'bodyLocator' => 'div#constituent_information',
185 'title' => 'Custom Data',
191 'locator' => 'custom_2',
192 'values' => array('Single'),
198 'headerLocator' => 'div#activity',
199 'bodyLocator' => 'input#activity_subject',
200 'title' => 'Activities',
205 'type' => 'checkbox',
206 'values' => array('activity_type_id[6]', 'activity_type_id[3]', 'activity_type_id[5]', 'activity_type_id[7]'),
208 'Activity Subject' =>
211 'locator' => 'activity_subject',
212 'values' => array('Test Subject'),
216 'type' => 'checkbox',
217 'values' => array('activity_status[1]', 'activity_status[2]'),
223 'headerLocator' => 'div#relationship',
224 'bodyLocator' => 'select#relation_type_id',
225 'title' => 'Relationships',
231 'locator' => 'relation_type_id',
232 'values' => array('Employee of'),
237 'locator' => 'relation_target_name',
238 'values' => array('Test Contact'),
244 'headerLocator' => 'div#demographics',
245 'bodyLocator' => 'input#birth_date_low_display',
246 'title' => 'Demographics',
249 'Birth Date Range' =>
252 'locator' => 'birth_date_relative',
253 'values' => array('Choose Date Range'),
258 'locator' => 'birth_date_low',
259 'values' => array('10 September 1980'),
264 'locator' => 'birth_date_high',
265 'values' => array('10 September 2000'),
271 'headerLocator' => 'div#notes',
272 'bodyLocator' => 'input#note',
279 'locator' => 'css=div#notes-search input#note',
280 'values' => array('Test Note'),
286 'headerLocator' => 'div#changeLog',
287 'bodyLocator' => 'input#changed_by',
288 'title' => 'Change Log',
294 'locator' => 'changed_by',
295 'values' => array('Test User'),
301 'headerLocator' => 'div#CiviContribute',
302 'bodyLocator' => 'select#financial_type_id',
303 'title' => 'Contributions',
309 'locator' => 'contribution_amount_low',
310 'values' => array('10'),
315 'locator' => 'contribution_amount_high',
316 'values' => array('1000'),
322 'locator' => 'financial_type_id',
323 'values' => array('Donation'),
325 'Contribution Status' =>
327 'type' => 'checkbox',
328 'values' => array('contribution_status_id[1]', 'contribution_status_id[2]'),
334 'headerLocator' => 'div#CiviMember',
335 'bodyLocator' => 'input#member_source',
336 'title' => 'Memberships',
341 'type' => 'checkbox',
342 'values' => array('member_membership_type_id[1]', 'member_membership_type_id[2]'),
344 'Membership Status' =>
346 'type' => 'checkbox',
347 'values' => array('member_status_id[1]', 'member_status_id[2]'),
353 'headerLocator' => 'div#CiviEvent',
354 'bodyLocator' => 'input#event_id',
358 'Participant Status' =>
360 'type' => 'checkbox',
361 'values' => array('participant_status_id[1]', 'participant_status_id[2]'),
363 'Participant Role' =>
365 'type' => 'checkbox',
366 'values' => array('participant_role_id[1]', 'participant_role_id[2]'),
374 return $_advance_search_panes[$paneRef];
377 return $_advance_search_panes;