3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.3 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
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 +--------------------------------------------------------------------+
28 require_once 'CiviTest/CiviSeleniumTestCase.php';
29 class WebTest_Contact_AdvanceSearchPaneTest
extends CiviSeleniumTestCase
{
31 protected function setUp() {
36 * Function to test individual pane seperatly.
38 function testIndividualPanes() {
39 // This is the path where our testing install resides.
40 // The rest of URL is defined in CiviSeleniumTestCase base class, in
42 $this->open($this->sboxPath
);
44 // Logging in. Remember to wait for page to load. In most cases,
45 // you can rely on 30000 as the value that allows your test to pass, however,
46 // sometimes your test might fail because of this. In such cases, it's better to pick one element
47 // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole
48 // page contents loaded and you can continue your test execution.
49 $this->webtestLogin();
51 // Get all default advance search panes.
52 $allpanes = $this->_advanceSearchPanes();
54 // Test Individual panes.
55 foreach (array_keys($allpanes) as $pane) {
56 // Go to the Advance Search
57 $this->openCiviPage('contact/search/advanced', 'reset=1');
59 // Select some fields from pane.
60 $this->_selectPaneFields($pane);
62 $this->click('_qf_Advanced_refresh');
64 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
66 // check the opened panes.
67 $this->_checkOpenedPanes(array($pane));
72 * Function to test by selecting all panes at a time.
74 function testAllPanes() {
75 // This is the path where our testing install resides.
76 // The rest of URL is defined in CiviSeleniumTestCase base class, in
78 $this->open($this->sboxPath
);
80 // Logging in. Remember to wait for page to load. In most cases,
81 // you can rely on 30000 as the value that allows your test to pass, however,
82 // sometimes your test might fail because of this. In such cases, it's better to pick one element
83 // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole
84 // page contents loaded and you can continue your test execution.
85 $this->webtestLogin();
87 // Get all default advance search panes.
88 $allpanes = $this->_advanceSearchPanes();
90 // Go to the Advance Search
91 $this->openCiviPage('contact/search/advanced', 'reset=1');
93 // Select some fields from all default panes.
94 foreach (array_keys($allpanes) as $pane) {
95 $this->_selectPaneFields($pane);
98 $this->click('_qf_Advanced_refresh');
100 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
102 // check all opened panes.
103 $this->_checkOpenedPanes(array_keys($allpanes));
106 function _checkOpenedPanes($openedPanes = array(
108 if (!$this->isTextPresent('No matches found')) {
109 $this->click('css=div.crm-advanced_search_form-accordion div.crm-accordion-header');
112 $allPanes = $this->_advanceSearchPanes();
114 foreach ($allPanes as $paneRef => $pane) {
115 if (in_array($paneRef, $openedPanes)) {
116 // assert for element present.
117 $this->waitForElementPresent("css=div.crm-accordion-wrapper div.crm-accordion-body {$pane['bodyLocator']}");
120 $this->assertTrue(!$this->isElementPresent("css=div.crm-accordion-wrapper div.crm-accordion-body {$pane['bodyLocator']}"));
125 function _selectPaneFields($paneRef, $selectFields = array(
127 $pane = $this->_advanceSearchPanes($paneRef);
129 $this->click("css=div.crm-accordion-wrapper {$pane['headerLocator']}");
130 $this->waitForElementPresent("css=div.crm-accordion-wrapper div.crm-accordion-body {$pane['bodyLocator']}");
132 foreach ($pane['fields'] as $fld => $field) {
133 if (!empty($selectFields) && !in_array($fld, $selectFields)) {
137 $fldLocator = isset($field['locator']) ?
$field['locator'] : '';
139 switch ($field['type']) {
141 $this->type($fldLocator, current($field['values']));
145 foreach ($field['values'] as $op) {
146 $this->select($fldLocator, 'label=' . $op);
151 foreach ($field['values'] as $op) {
152 if (!$this->isChecked($op)) {
159 foreach ($field['values'] as $op) {
165 $this->webtestFillDate($fldLocator, current($field['values']));
171 function _advanceSearchPanes($paneRef = NULL) {
172 static $_advance_search_panes;
174 if (!isset($_advance_search_panes) ||
empty($_advance_search_panes)) {
175 $_advance_search_panes = array(
178 'headerLocator' => 'div#location',
179 'bodyLocator' => 'select#country',
180 'title' => 'Address Fields',
185 'type' => 'checkbox',
186 'values' => array('location_type[1]', 'location_type[2]'),
191 'locator' => 'country',
192 'values' => array('United States'),
197 'locator' => 'state_province',
198 'values' => array('Alabama', 'California', 'New Jersey', 'New York'),
204 'headerLocator' => 'div#custom',
205 'bodyLocator' => 'div#constituent_information',
206 'title' => 'Custom Data',
212 'locator' => 'custom_2',
213 'values' => array('Single'),
219 'headerLocator' => 'div#activity',
220 'bodyLocator' => 'input#activity_contact_name',
221 'title' => 'Activities',
226 'type' => 'checkbox',
227 'values' => array('activity_type_id[6]', 'activity_type_id[3]', 'activity_type_id[5]', 'activity_type_id[7]'),
229 'Activity Subject' =>
232 'locator' => 'activity_subject',
233 'values' => array('Test Subject'),
237 'type' => 'checkbox',
238 'values' => array('activity_status[1]', 'activity_status[2]'),
244 'headerLocator' => 'div#relationship',
245 'bodyLocator' => 'select#relation_type_id',
246 'title' => 'Relationships',
252 'locator' => 'relation_type_id',
253 'values' => array('Employee of'),
258 'locator' => 'relation_target_name',
259 'values' => array('Test Contact'),
265 'headerLocator' => 'div#demographics',
266 'bodyLocator' => 'input#birth_date_low_display',
267 'title' => 'Demographics',
270 'Birth Date Range' =>
273 'locator' => 'birth_date_relative',
274 'values' => array('Choose Date Range'),
279 'locator' => 'birth_date_low',
280 'values' => array('10 September 1980'),
285 'locator' => 'birth_date_high',
286 'values' => array('10 September 2000'),
292 'headerLocator' => 'div#notes',
293 'bodyLocator' => 'input#note',
300 'locator' => 'css=div#notes-search input#note',
301 'values' => array('Test Note'),
307 'headerLocator' => 'div#changeLog',
308 'bodyLocator' => 'input#changed_by',
309 'title' => 'Change Log',
315 'locator' => 'changed_by',
316 'values' => array('Test User'),
322 'headerLocator' => 'div#CiviContribute',
323 'bodyLocator' => 'select#financial_type_id',
324 'title' => 'Contributions',
330 'locator' => 'contribution_amount_low',
331 'values' => array('10'),
336 'locator' => 'contribution_amount_high',
337 'values' => array('1000'),
342 'locator' => 'financial_type_id',
343 'values' => array('Donation'),
345 'Contribution Status' =>
347 'type' => 'checkbox',
348 'values' => array('contribution_status_id[1]', 'contribution_status_id[2]'),
354 'headerLocator' => 'div#CiviMember',
355 'bodyLocator' => 'input#member_source',
356 'title' => 'Memberships',
361 'type' => 'checkbox',
362 'values' => array('member_membership_type_id[1]', 'member_membership_type_id[2]'),
364 'Membership Status' =>
366 'type' => 'checkbox',
367 'values' => array('member_status_id[1]', 'member_status_id[2]'),
373 'headerLocator' => 'div#CiviEvent',
374 'bodyLocator' => 'input#event_name',
378 'Participant Status' =>
380 'type' => 'checkbox',
381 'values' => array('participant_status_id[1]', 'participant_status_id[2]'),
383 'Participant Role' =>
385 'type' => 'checkbox',
386 'values' => array('participant_role_id[1]', 'participant_role_id[2]'),
394 return $_advance_search_panes[$paneRef];
397 return $_advance_search_panes;