<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.3 |
+ | CiviCRM version 4.5 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013 |
+ | Copyright CiviCRM LLC (c) 2004-2014 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
+--------------------------------------------------------------------+
*/
-
require_once 'CiviTest/CiviSeleniumTestCase.php';
class WebTest_Contact_AdvanceSearchPrivacyOptionsTest extends CiviSeleniumTestCase {
}
function testSearchForPrivacyOptions() {
- // This is the path where our testing install resides.
- // The rest of URL is defined in CiviSeleniumTestCase base class, in
- // class attributes.
- $this->open($this->sboxPath);
-
- // Logging in. Remember to wait for page to load. In most cases,
- // you can rely on 30000 as the value that allows your test to pass, however,
- // sometimes your test might fail because of this. In such cases, it's better to pick one element
- // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole
- // page contents loaded and you can continue your test execution.
$this->webtestLogin();
$privacyOptions = array(
$this->click('_qf_Advanced_refresh');
$this->waitForPageToLoad($this->getTimeoutMsec());
-
if (!$this->_searchSortNameCriteria($contactsReffOptions['dn_phone_mail']['first_name'], $contactsReffOptions['dn_phone_mail']['last_name']) && $this->_searchSortNameCriteria($contactsReffOptions['dn_trade_sms']['first_name'], $contactsReffOptions['dn_trade_sms']['last_name'])) {
$assertCheck = TRUE;
}
$this->_addPrivacyCriteria('include', $privacyOptions['dn_trade_sms'], 'AND', $allPrivacyOptions);
$this->click('_qf_Advanced_refresh');
$this->waitForPageToLoad($this->getTimeoutMsec());
-
+
if (!$this->_searchSortNameCriteria($contactsReffOptions['dn_phone_mail']['first_name'], $contactsReffOptions['dn_phone_mail']['last_name']) && !$this->_searchSortNameCriteria($contactsReffOptions['dn_phone_email']['first_name'], $contactsReffOptions['dn_phone_email']['last_name']) && $this->_searchSortNameCriteria($contactsReffOptions['dn_trade_sms']['first_name'], $contactsReffOptions['dn_trade_sms']['last_name'])) {
$assertCheck = TRUE;
}
$this->assertTrue($assertCheck, 'Do not trade / sms assertion failed using criteria(include , AND )');
}
+ /**
+ * @param $inEx
+ * @param $privacyOptions
+ * @param $privacyOperator
+ * @param $allPrivacyOptions
+ */
function _addPrivacyCriteria($inEx, $privacyOptions, $privacyOperator, $allPrivacyOptions) {
$inExId = ($inEx == 'include') ? 'CIVICRM_QFID_2_privacy_toggle' : 'CIVICRM_QFID_1_privacy_toggle';
$this->click($inExId);
$this->select('privacy_operator', "{$privacyOperator}");
foreach ($privacyOptions as $privacyOption) {
$privacyOptionVal = $this->getOptionVal($privacyOption);
-
- if (!$this->isElementPresent("xpath=//ul[@id='crmasmList4']//li//span[text()='{$privacyOptionVal}']")) {
- $this->select('crmasmSelect4', "value={$privacyOption}");
- $this->waitForElementPresent("xpath=//ul[@id='crmasmList4']//li//span[text()='{$privacyOptionVal}']");
+
+ if (!$this->isElementPresent("xpath=//div[@id='s2id_privacy_options']//ul//li//div[text()='{$privacyOptionVal}']")) {
+ $this->select('privacy_options', "value={$privacyOption}");
+ $this->waitForElementPresent("xpath=//div[@id='s2id_privacy_options']//ul//li//div[text()='{$privacyOptionVal}']");
}
}
-
+
foreach ($allPrivacyOptions as $allPrivacyOption) {
if (!in_array($allPrivacyOption, $privacyOptions)) {
$privacyOptionVal = $this->getOptionVal($allPrivacyOption);
- if ($this->isElementPresent("xpath=//ul[@id='crmasmList4']//li//span[text()='{$privacyOptionVal}']")) {
- $this->click("xpath=//ul[@id='crmasmList4']//li//span[text()='{$privacyOptionVal}']/../a[@class='crmasmListItemRemove']");
+ if ($this->isElementPresent("xpath=//div[@id='s2id_privacy_options']//ul//li//div[text()='{$privacyOptionVal}']")) {
+ $this->click("xpath=//div[@id='s2id_privacy_options']//ul//li//div[text()='{$privacyOptionVal}']/../a[@class='select2-search-choice-close']");
}
}
}
}
-
+
+ /**
+ * @param $firstName
+ * @param $lastName
+ *
+ * @return bool
+ */
function _searchSortNameCriteria($firstName, $lastName) {
//type in the criteria
- $this->type("sort_name", "{$lastName}, {$firstName}");
- $this->click("_qf_Advanced_refresh");
+ $this->type("sort_name", "{$lastName}, {$firstName}");
+
+ $this->click("_qf_Advanced_refresh");
+
$this->waitForPageToLoad($this->getTimeoutMsec());
-
+
//return its presence
return $this->isElementPresent("xpath=//div[@class='crm-search-results']/table/tbody/tr/td[3]/a[text()='{$lastName}, {$firstName}']");
}
-
+
+ /**
+ * @param $privacyOption
+ *
+ * @return string
+ */
function getOptionVal($privacyOption) {
if ($privacyOption == 'do_not_phone') {
$privacyOptionVal = 'Do not phone';
return $privacyOptionVal;
}
+ /**
+ * @param $firstName
+ * @param $lastName
+ * @param $options
+ */
function _addIndividual($firstName, $lastName, $options) {
$this->openCiviPage('contact/add', 'reset=1&ct=Individual');
-
+
//fill in first name
$this->type("first_name", $firstName);
//Select preferred method for Privacy
$this->click("privacy_{$option}");
}
-
+
// Clicking save.
$this->click("_qf_Contact_upload_view");
$this->waitForPageToLoad($this->getTimeoutMsec());
- $this->assertElementContainsText('crm-notification-container', "{$firstName} {$lastName} has been created.");
+ $this->waitForText('crm-notification-container', "{$firstName} {$lastName} has been created.");
}
}