3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2015 |
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 * Test individual pane seperatly.
41 public 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 * Test by selecting all panes at a time.
67 public 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 public function _checkOpenedPanes($openedPanes = array()) {
93 if (!$this->isTextPresent('None found.')) {
94 $this->click('css=div.crm-advanced_search_form-accordion div.crm-accordion-header');
97 $allPanes = $this->_advanceSearchPanes();
99 foreach ($allPanes as $paneRef => $pane) {
100 if (in_array($paneRef, $openedPanes)) {
101 // assert for element present.
102 $this->waitForElementPresent("css=div.crm-accordion-wrapper div.crm-accordion-body {$pane['bodyLocator']}");
105 $this->assertTrue(!$this->isElementPresent("css=div.crm-accordion-wrapper div.crm-accordion-body {$pane['bodyLocator']}"));
112 * @param array $selectFields
114 public function _selectPaneFields($paneRef, $selectFields = array()) {
115 $pane = $this->_advanceSearchPanes($paneRef);
117 $this->click("css=div.crm-accordion-wrapper {$pane['headerLocator']}");
118 $this->waitForElementPresent("css=div.crm-accordion-wrapper div.crm-accordion-body {$pane['bodyLocator']}");
120 foreach ($pane['fields'] as $fld => $field) {
121 if (!empty($selectFields) && !in_array($fld, $selectFields)) {
125 $fldLocator = isset($field['locator']) ?
$field['locator'] : '';
127 switch ($field['type']) {
129 $this->type($fldLocator, current($field['values']));
133 foreach ($field['values'] as $op) {
134 $this->select($fldLocator, 'label=' . $op);
139 foreach ($field['values'] as $op) {
140 if (!$this->isChecked($op)) {
147 foreach ($field['values'] as $op) {
153 foreach ($field['values'] as $op) {
154 $this->waitForElementPresent($fldLocator);
155 $this->multiselect2($fldLocator, $op);
160 $this->webtestFillDate($fldLocator, current($field['values']));
167 * @param null $paneRef
171 public function _advanceSearchPanes($paneRef = NULL) {
172 static $_advance_search_panes;
174 if (!isset($_advance_search_panes) ||
empty($_advance_search_panes)) {
175 $_advance_search_panes = array(
177 'headerLocator' => 'div#location',
178 'bodyLocator' => 'select#country',
179 'title' => 'Address Fields',
181 'Location Type' => array(
182 'type' => 'multiselect2',
183 'locator' => 'location_type',
184 'values' => array(array('Home', 'Work')),
188 'locator' => 'country',
189 'values' => array('UNITED STATES'),
192 'type' => 'multiselect2',
193 'locator' => 'state_province',
195 array('Alabama', 'California', 'New Jersey', 'New York'),
201 'headerLocator' => 'div#custom',
202 'bodyLocator' => 'div#constituent_information',
203 'title' => 'Custom Data',
205 'Marital Status' => array(
207 'locator' => 'custom_2',
208 'values' => array('Single'),
213 'headerLocator' => 'div#activity',
214 'bodyLocator' => 'input#activity_subject',
215 'title' => 'Activities',
217 'Activity Type' => array(
218 'type' => 'multiselect2',
219 'locator' => 'activity_type_id',
220 'values' => array(array('Contribution', 'Email', 'Event Registration', 'Membership Signup')),
222 'Activity Subject' => array(
224 'locator' => 'activity_subject',
225 'values' => array('Test Subject'),
227 'Activity Status' => array(
228 'type' => 'multiselect2',
229 'locator' => 'status_id',
230 'values' => array(array('Scheduled', 'Completed')),
234 'relationship' => array(
235 'headerLocator' => 'div#relationship',
236 'bodyLocator' => 'select#relation_type_id',
237 'title' => 'Relationships',
239 'Relation Type' => array(
241 'locator' => 'relation_type_id',
242 'values' => array('Employee of'),
244 'Relation Target' => array(
246 'locator' => 'relation_target_name',
247 'values' => array('Test Contact'),
251 'demographics' => array(
252 'headerLocator' => 'div#demographics',
253 'bodyLocator' => 'input#birth_date_low',
254 'title' => 'Demographics',
256 'Birth Date Range' => array(
258 'locator' => 'birth_date_relative',
259 'values' => array('Choose Date Range'),
261 'Birth Date from' => array(
263 'locator' => 'birth_date_low',
264 'values' => array('10 September 1980'),
266 'Birth Date to' => array(
268 'locator' => 'birth_date_high',
269 'values' => array('10 September 2000'),
274 'headerLocator' => 'div#notes',
275 'bodyLocator' => 'input#note',
280 'locator' => 'css=div#notes-search input#note',
281 'values' => array('Test Note'),
285 'change_log' => array(
286 'headerLocator' => 'div#changeLog',
287 'bodyLocator' => 'input#changed_by',
288 'title' => 'Change Log',
290 'Modified By' => array(
292 'locator' => 'changed_by',
293 'values' => array('Test User'),
297 'contribution' => array(
298 'headerLocator' => 'div#CiviContribute',
299 'bodyLocator' => 'select#financial_type_id',
300 'title' => 'Contributions',
302 'Amount from' => array(
304 'locator' => 'contribution_amount_low',
305 'values' => array('10'),
307 'Amount to' => array(
309 'locator' => 'contribution_amount_high',
310 'values' => array('1000'),
312 'Financial Type' => array(
314 'locator' => 'financial_type_id',
315 'values' => array('Donation'),
317 'Contribution Status' => array(
318 'type' => 'multiselect2',
319 'locator' => 'contribution_status_id',
320 'values' => array(array('Completed', 'Pending')),
324 'membership' => array(
325 'headerLocator' => 'div#CiviMember',
326 'bodyLocator' => 'input#member_source',
327 'title' => 'Memberships',
329 'Membership Type' => array(
330 'type' => 'multiselect2',
331 'locator' => 'membership_type_id',
332 'values' => array(array('General', 'Student')),
334 'Membership Status' => array(
335 'type' => 'multiselect2',
336 'locator' => 'membership_status_id',
337 'values' => array(array('New', 'Current')),
342 'headerLocator' => 'div#CiviEvent',
343 'bodyLocator' => 'input#event_id',
346 'Participant Status' => array(
347 'type' => 'multiselect2',
348 'locator' => 'participant_status_id',
349 'values' => array(array('Registered', 'Attended')),
351 'Participant Role' => array(
352 'type' => 'multiselect2',
353 'locator' => 'participant_role_id',
354 'values' => array(array('Attendee', 'Volunteer')),
362 return $_advance_search_panes[$paneRef];
365 return $_advance_search_panes;