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_AdvanceSearchPaneTest
32 class WebTest_Contact_AdvanceSearchPaneTest
extends CiviSeleniumTestCase
{
34 protected function setUp() {
39 * Function to test individual pane seperatly.
41 function testIndividualPanes() {
42 $this->webtestLogin();
44 // Get all default advance search panes.
45 $allpanes = $this->_advanceSearchPanes();
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());
59 // check the opened panes.
60 $this->_checkOpenedPanes(array($pane));
65 * Function to test by selecting all panes at a time.
67 function testAllPanes() {
68 $this->webtestLogin();
70 // Get all default advance search panes.
71 $allpanes = $this->_advanceSearchPanes();
73 // Go to the Advance Search
74 $this->openCiviPage('contact/search/advanced', 'reset=1');
76 // Select some fields from all default panes.
77 foreach (array_keys($allpanes) as $pane) {
78 $this->_selectPaneFields($pane);
81 $this->click('_qf_Advanced_refresh');
83 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
85 // check all opened panes.
86 $this->_checkOpenedPanes(array_keys($allpanes));
90 * @param array $openedPanes
92 function _checkOpenedPanes($openedPanes = array(
94 if (!$this->isTextPresent('No matches found')) {
95 $this->click('css=div.crm-advanced_search_form-accordion div.crm-accordion-header');
98 $allPanes = $this->_advanceSearchPanes();
100 foreach ($allPanes as $paneRef => $pane) {
101 if (in_array($paneRef, $openedPanes)) {
102 // assert for element present.
103 $this->waitForElementPresent("css=div.crm-accordion-wrapper div.crm-accordion-body {$pane['bodyLocator']}");
106 $this->assertTrue(!$this->isElementPresent("css=div.crm-accordion-wrapper div.crm-accordion-body {$pane['bodyLocator']}"));
113 * @param array $selectFields
115 function _selectPaneFields($paneRef, $selectFields = array(
117 $pane = $this->_advanceSearchPanes($paneRef);
119 $this->click("css=div.crm-accordion-wrapper {$pane['headerLocator']}");
120 $this->waitForElementPresent("css=div.crm-accordion-wrapper div.crm-accordion-body {$pane['bodyLocator']}");
122 foreach ($pane['fields'] as $fld => $field) {
123 if (!empty($selectFields) && !in_array($fld, $selectFields)) {
127 $fldLocator = isset($field['locator']) ?
$field['locator'] : '';
129 switch ($field['type']) {
131 $this->type($fldLocator, current($field['values']));
135 foreach ($field['values'] as $op) {
136 $this->select($fldLocator, 'label=' . $op);
141 foreach ($field['values'] as $op) {
142 if (!$this->isChecked($op)) {
149 foreach ($field['values'] as $op) {
155 foreach ($field['values'] as $op) {
156 $this->waitForVisible($fldLocator);
157 $this->multiselect2($fldLocator, $op);
162 $this->webtestFillDate($fldLocator, current($field['values']));
169 * @param null $paneRef
173 function _advanceSearchPanes($paneRef = NULL) {
174 static $_advance_search_panes;
176 if (!isset($_advance_search_panes) ||
empty($_advance_search_panes)) {
177 $_advance_search_panes = array(
180 'headerLocator' => 'div#location',
181 'bodyLocator' => 'select#country',
182 'title' => 'Address Fields',
187 'type' => 'multiselect2',
188 'locator' => 'location_type',
189 'values' => array(array('Home', 'Work')),
194 'locator' => 'country',
195 'values' => array('United States'),
199 'type' => 'multiselect2',
200 'locator' => 'state_province',
201 'values' => array(array('Alabama', 'California', 'New Jersey', 'New York')),
207 'headerLocator' => 'div#custom',
208 'bodyLocator' => 'div#constituent_information',
209 'title' => 'Custom Data',
215 'locator' => 'custom_2',
216 'values' => array('Single'),
222 'headerLocator' => 'div#activity',
223 'bodyLocator' => 'input#activity_subject',
224 'title' => 'Activities',
229 'type' => 'checkbox',
230 'values' => array('activity_type_id[6]', 'activity_type_id[3]', 'activity_type_id[5]', 'activity_type_id[7]'),
232 'Activity Subject' =>
235 'locator' => 'activity_subject',
236 'values' => array('Test Subject'),
240 'type' => 'checkbox',
241 'values' => array('activity_status[1]', 'activity_status[2]'),
247 'headerLocator' => 'div#relationship',
248 'bodyLocator' => 'select#relation_type_id',
249 'title' => 'Relationships',
255 'locator' => 'relation_type_id',
256 'values' => array('Employee of'),
261 'locator' => 'relation_target_name',
262 'values' => array('Test Contact'),
268 'headerLocator' => 'div#demographics',
269 'bodyLocator' => 'input#birth_date_low_display',
270 'title' => 'Demographics',
273 'Birth Date Range' =>
276 'locator' => 'birth_date_relative',
277 'values' => array('Choose Date Range'),
282 'locator' => 'birth_date_low',
283 'values' => array('10 September 1980'),
288 'locator' => 'birth_date_high',
289 'values' => array('10 September 2000'),
295 'headerLocator' => 'div#notes',
296 'bodyLocator' => 'input#note',
303 'locator' => 'css=div#notes-search input#note',
304 'values' => array('Test Note'),
310 'headerLocator' => 'div#changeLog',
311 'bodyLocator' => 'input#changed_by',
312 'title' => 'Change Log',
318 'locator' => 'changed_by',
319 'values' => array('Test User'),
325 'headerLocator' => 'div#CiviContribute',
326 'bodyLocator' => 'select#financial_type_id',
327 'title' => 'Contributions',
333 'locator' => 'contribution_amount_low',
334 'values' => array('10'),
339 'locator' => 'contribution_amount_high',
340 'values' => array('1000'),
346 'locator' => 'financial_type_id',
347 'values' => array('Donation'),
349 'Contribution Status' =>
351 'type' => 'checkbox',
352 'values' => array('contribution_status_id[1]', 'contribution_status_id[2]'),
358 'headerLocator' => 'div#CiviMember',
359 'bodyLocator' => 'input#member_source',
360 'title' => 'Memberships',
365 'type' => 'checkbox',
366 'values' => array('member_membership_type_id[1]', 'member_membership_type_id[2]'),
368 'Membership Status' =>
370 'type' => 'checkbox',
371 'values' => array('member_status_id[1]', 'member_status_id[2]'),
377 'headerLocator' => 'div#CiviEvent',
378 'bodyLocator' => 'input#event_id',
382 'Participant Status' =>
384 'type' => 'checkbox',
385 'values' => array('participant_status_id[1]', 'participant_status_id[2]'),
387 'Participant Role' =>
389 'type' => 'checkbox',
390 'values' => array('participant_role_id[1]', 'participant_role_id[2]'),
398 return $_advance_search_panes[$paneRef];
401 return $_advance_search_panes;