They were extremely hard to maintain when we were maintaining them, now they have been unmaitained so
long that they would take more work to get functional than starting from scratch.
They make grepping harder
+++ /dev/null
-<?php
-
-/**
- * This is a variant of CiviSeleniumSettings which autopopulates
- * using data from $_ENV.
- */
-class CiviSeleniumSettings {
- public $publicSandbox = FALSE;
- public $browser = '*firefox';
- public $sandboxURL;
- public $sandboxPATH;
- public $username;
- public $password;
- public $adminUsername;
- public $adminPassword;
- public $adminApiKey;
- public $siteKey;
- public $UFemail = 'noreply@civicrm.org';
- public $cookies;
-
- public function __construct() {
- $required = array();
- foreach (array('CMS_URL', 'ADMIN_USER', 'ADMIN_PASS', 'DEMO_USER', 'DEMO_PASS') as $key) {
- if (empty($GLOBALS['_CV'][$key])) {
- $required[] = $key;
- }
- }
- if (!empty($required)) {
- throw new RuntimeException("CiviSeleniumSettings failed to find required values from cv: "
- . implode(' ', $required));
- }
-
- $path = parse_url($GLOBALS['_CV']['CMS_URL'], PHP_URL_PATH);
- $this->sandboxURL = substr($GLOBALS['_CV']['CMS_URL'], 0, strlen($GLOBALS['_CV']['CMS_URL']) - strlen($path));
- $this->sandboxPATH = $path;
- $this->fullSandboxPath = $GLOBALS['_CV']['CMS_URL'];
- $this->adminUsername = $GLOBALS['_CV']['ADMIN_USER'];
- $this->adminPassword = $GLOBALS['_CV']['ADMIN_PASS'];
- $this->username = $GLOBALS['_CV']['DEMO_USER'];
- $this->password = $GLOBALS['_CV']['DEMO_PASS'];
- $this->siteKey = CIVICRM_SITE_KEY;
- $this->adminApiKey = md5('apikeyadmin' . $GLOBALS['_CV']['CMS_DB_DSN'] . CIVICRM_SITE_KEY);
- $this->cookies = array();
- }
-
- // /**
- // * @return array
- // */
- // function createConstCookie() {
- // global $civibuild;
- // $now = time();
- // $civiConsts = array(
- // 'CIVICRM_DSN' => CIVICRM_DSN,
- // 'CIVICRM_UF_DSN' => CIVICRM_UF_DSN,
- // 'ts' => $now,
- // 'sig' => md5(implode(';;', array(CIVICRM_DSN, CIVICRM_UF_DSN, $civibuild['SITE_TOKEN'], $now))),
- // );
- //
- // return array(
- // 'name' => 'civiConsts',
- // 'value' => urlencode(json_encode($civiConsts)),
- // );
- // }
-
-}
+++ /dev/null
-<?php
-
-class CiviSeleniumSettings {
-
- var $publicSandbox = false;
-
- var $browser = '*firefox';
-
- /**
- * @var string SeleniumRC host name
- */
- var $rcHost = 'localhost';
-
- /**
- * @var int SeleniumRC port number
- */
- var $rcPort = 4444;
-
- var $sandboxURL = 'http://devel.drupal.tests.dev.civicrm.org';
-
- var $sandboxPATH = '';
-
- var $username = 'demo';
-
- var $password = 'demo';
-
- var $adminUsername = 'USERNAME';
-
- var $adminPassword = 'PASSWORD';
-
- var $adminApiKey = NULL; // civicrm_contact.api_key for admin
-
- var $UFemail = 'noreply@civicrm.org';
-
- /**
- * @var string site API key
- */
- var $siteKey = NULL;
-
- /**
- * @var int seconds
- */
- var $timeout = 30;
-
- /**
- * @var array
- * @see CiviSeleniumTestCase::setCookies
- */
- var $cookies = array();
-
- /**
- * @var int|NULL seconds to wait for SeleniumRC to become available
- *
- * If you have custom scripts which launch Selenium and PHPUnit in tandem, then
- * Selenium may initialize somewhat slowly. Set $serverStartupTimeOut to wait
- * for Selenium to startup. If you launch Selenium independently or otherwise
- * prefer to fail immediately, then leave the default value NULL.
- */
- var $serverStartupTimeOut = NULL;
-
- function __construct() {
- $this->fullSandboxPath = $this->sandboxURL . $this->sandboxPATH;
- // $this->cookies[] = array(
- // 'name' => 'mycookie',
- // 'value' => 'myvalue',
- // 'path' => '/',
- // 'max_age' => 24*60*60,
- // );;
- }
-
-}
-?>
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License and the CiviCRM Licensing Exception along |
- | with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-define('CIVICRM_WEBTEST', 1);
-
-/**
- * Base class for CiviCRM Selenium tests
- *
- * Common functions for unit tests
- * @package CiviCRM
- */
-class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
-
- // Current logged-in user
- protected $loggedInAs = NULL;
-
- private $settingCache;
-
- /**
- * Constructor.
- *
- * Because we are overriding the parent class constructor, we
- * need to show the same arguments as exist in the constructor of
- * PHPUnit_Framework_TestCase, since
- * PHPUnit_Framework_TestSuite::createTest() creates a
- * ReflectionClass of the Test class and checks the constructor
- * of that class to decide how to set up the test.
- *
- * @param string $name
- * @param array $data
- * @param string $dataName
- * @param array $browser
- */
- public function __construct($name = NULL, array$data = array(), $dataName = '', array$browser = array()) {
- parent::__construct($name, $data, $dataName, $browser);
- $this->loggedInAs = NULL;
-
- $this->settings = new CiviSeleniumSettings();
- if (property_exists($this->settings, 'serverStartupTimeOut') && $this->settings->serverStartupTimeOut) {
- global $CiviSeleniumTestCase_polled;
- if (!$CiviSeleniumTestCase_polled) {
- $CiviSeleniumTestCase_polled = TRUE;
- CRM_Utils_Network::waitForServiceStartup(
- $this->drivers[0]->getHost(),
- $this->drivers[0]->getPort(),
- $this->settings->serverStartupTimeOut
- );
- }
- }
-
- // autoload
- require_once 'CRM/Core/ClassLoader.php';
- CRM_Core_ClassLoader::singleton()->register();
-
- // also initialize a connection to the db
- // FIXME: not necessary for most tests, consider moving into functions that need this
- $config = CRM_Core_Config::singleton();
- }
-
- protected function setUp() {
- $this->setBrowser($this->settings->browser);
- // Make sure that below strings have path separator at the end
- $this->setBrowserUrl($this->settings->sandboxURL);
- $this->sboxPath = $this->settings->sandboxPATH;
- if (property_exists($this->settings, 'rcHost') && $this->settings->rcHost) {
- $this->setHost($this->settings->rcHost);
- }
- if (property_exists($this->settings, 'rcPort') && $this->settings->rcPort) {
- $this->setPort($this->settings->rcPort);
- }
- $this->settingCache = array();
- }
-
- /**
- * @return string
- */
- protected function prepareTestSession() {
- $result = parent::prepareTestSession();
-
- // Set any cookies required by local installation
- // Note: considered doing this in setUp(), but the Selenium session wasn't yet initialized.
- if (property_exists($this->settings, 'cookies')) {
- // We don't really care about this page, but it seems we need
- // to open a page before setting a cookie.
- $this->open($this->sboxPath);
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->setCookies($this->settings->cookies);
- }
- return $result;
- }
-
- /**
- * @param array $cookies
- * Each item is an Array with keys:
- * - name: string
- * - value: string; note that RFC's don't define particular encoding scheme, so
- * you must pick one yourself and pre-encode; does not allow values with
- * commas, semicolons, or whitespace
- * - path: string; default: '/'
- * - max_age: int; default: 1 week (7*24*60*60)
- */
- protected function setCookies($cookies) {
- foreach ($cookies as $cookie) {
- if (!isset($cookie['path'])) {
- $cookie['path'] = '/';
- }
- if (!isset($cookie['max_age'])) {
- $cookie['max_age'] = 7 * 24 * 60 * 60;
- }
- $this->deleteCookie($cookie['name'], $cookie['path']);
- $optionExprs = array();
- foreach ($cookie as $key => $value) {
- if ($key != 'name' && $key != 'value') {
- $optionExprs[] = "$key=$value";
- }
- }
- $this->createCookie("{$cookie['name']}={$cookie['value']}", implode(', ', $optionExprs));
- }
- }
-
- protected function tearDown() {
- }
-
- /**
- * Authenticate as drupal user.
- * @param $user : (str) the key 'user' or 'admin', or a literal username
- * @param $pass : (str) if $user is a literal username and not 'user' or 'admin', supply the password
- */
- public function webtestLogin($user = 'user', $pass = NULL) {
- // If already logged in as correct user, do nothing
- if ($this->loggedInAs === $user) {
- return;
- }
- // If we are logged in as a different user, log out first
- if ($this->loggedInAs) {
- $this->webtestLogout();
- }
- $this->open("{$this->sboxPath}user");
- // Lookup username & password if not supplied
- $username = $user;
- if ($pass === NULL) {
- $pass = $user == 'admin' ? $this->settings->adminPassword : $this->settings->password;
- $username = $user == 'admin' ? $this->settings->adminUsername : $this->settings->username;
- }
- // Make sure login form is available
- $this->waitForElementPresent('edit-submit');
- $this->type('edit-name', $username);
- $this->type('edit-pass', $pass);
- $this->click('edit-submit');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->loggedInAs = $user;
- }
-
- public function webtestLogout() {
- if ($this->loggedInAs) {
- $this->open($this->sboxPath . "user/logout");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- }
- $this->loggedInAs = NULL;
- }
-
- /**
- * Open an internal path beginning with 'civicrm/'
- *
- * @param string $url
- * omit the 'civicrm/' it will be added for you.
- * @param string|array $args
- * optional url arguments.
- * @param $waitFor
- * Page element to wait for - using this is recommended to ensure the document is fully loaded.
- *
- * Although it doesn't seem to do much now, using this function is recommended for
- * opening all civi pages, and using the $args param is also strongly encouraged
- * This will make it much easier to run webtests in other CMSs in the future
- */
- public function openCiviPage($url, $args = NULL, $waitFor = 'civicrm-footer') {
- // Construct full url with args
- // This could be extended in future to work with other CMS style urls
- if ($args) {
- if (is_array($args)) {
- $sep = '?';
- foreach ($args as $key => $val) {
- $url .= $sep . $key . '=' . $val;
- $sep = '&';
- }
- }
- else {
- $url .= "?$args";
- }
- }
- $this->open("{$this->sboxPath}civicrm/$url");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->checkForErrorsOnPage();
- if ($waitFor) {
- $this->waitForElementPresent($waitFor);
- }
- }
-
- /**
- * Click on a link or button.
- * Wait for the page to load
- * Wait for an element to be present
- * @param $element
- * @param string $waitFor
- * @param bool $waitForPageLoad
- */
- public function clickLink($element, $waitFor = 'civicrm-footer', $waitForPageLoad = TRUE) {
- $this->click($element);
- // conditional wait for page load e.g for ajax form save
- if ($waitForPageLoad) {
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->checkForErrorsOnPage();
- }
- if ($waitFor) {
- $this->waitForElementPresent($waitFor);
- }
- }
-
- /**
- * Click a link or button and wait for an ajax dialog to load.
- * @param string $element
- * @param string $waitFor
- */
- public function clickPopupLink($element, $waitFor = NULL) {
- $this->clickAjaxLink($element, 'css=.ui-dialog');
- if ($waitFor) {
- $this->waitForElementPresent($waitFor);
- }
- }
-
- /**
- * Click a link or button and wait for ajax content to load or refresh.
- * @param string $element
- * @param string $waitFor
- */
- public function clickAjaxLink($element, $waitFor = NULL) {
- $this->click($element);
- if ($waitFor) {
- $this->waitForElementPresent($waitFor);
- }
- $this->waitForAjaxContent();
- }
-
- /**
- * Force a link to open full-page, even if it would normally open in a popup
- * @note: works with links only, not buttons
- * @param string $element
- * @param string $waitFor
- */
- public function clickLinkSuppressPopup($element, $waitFor = 'civicrm-footer') {
- $link = $this->getAttribute($element . '@href');
- $this->open($link);
- $this->waitForPageToLoad($this->getTimeoutMsec());
- if ($waitFor) {
- $this->waitForElementPresent($waitFor);
- }
- }
-
- /**
- * Wait for all ajax snippets to finish loading.
- */
- public function waitForAjaxContent() {
- $this->waitForElementNotPresent('css=.blockOverlay');
- // Some ajax calls happen in pairs (e.g. submit a popup form then refresh the underlying content)
- // So we'll wait a sec and recheck to see if any more stuff is loading
- sleep(1);
- if ($this->isElementPresent('css=.blockOverlay')) {
- $this->waitForAjaxContent();
- }
- }
-
- /**
- * Call the API on the local server.
- * (kind of defeats the point of a webtest - see CRM-11889)
- * @param $entity
- * @param $action
- * @param $params
- * @return array|int
- */
- public function webtest_civicrm_api($entity, $action, $params) {
- if (!isset($params['version'])) {
- $params['version'] = 3;
- }
-
- $result = civicrm_api($entity, $action, $params);
- $this->assertAPISuccess($result);
- return $result;
- }
-
- /**
- * Call the API on the remote server using the AJAX endpoint.
- *
- * @see CRM-11889
- * @param $entity
- * @param $action
- * @param array $params
- * @return mixed
- */
- public function rest_civicrm_api($entity, $action, $params = array()) {
- $params += array(
- 'version' => 3,
- );
- static $reqId = 0;
- $reqId++;
-
- $jsCmd = '
- setTimeout(function(){
- CRM.api3("@entity", "@action", @params).then(function(a){
- cj("<textarea>").css("display", "none").prop("id","crmajax@reqId").val(JSON.stringify(a)).appendTo("body");
- });
- }, 500);
- ';
- $jsArgs = array(
- '@entity' => $entity,
- '@action' => $action,
- '@params' => json_encode($params),
- '@reqId' => $reqId,
- );
- $js = strtr($jsCmd, $jsArgs);
- $this->runScript($js);
- $this->waitForElementPresent("crmajax{$reqId}");
- $result = json_decode($this->getValue("crmajax{$reqId}"), TRUE);
- $this->runScript("cj('#crmajax{$reqId}').remove();");
- return $result;
- }
-
- /**
- * @param string $option_group_name
- *
- * @return array|int
- */
- public function webtestGetFirstValueForOptionGroup($option_group_name) {
- $result = $this->webtest_civicrm_api("OptionValue", "getvalue", array(
- 'option_group_name' => $option_group_name,
- 'option.limit' => 1,
- 'return' => 'value',
- ));
- return $result;
- }
-
- /**
- * @return mixed
- */
- public function webtestGetValidCountryID() {
- static $_country_id;
- if (is_null($_country_id)) {
- $_country_id = Civi::settings()->get('defaultContactCountry');
- }
- return $_country_id;
- }
-
- /**
- * @param $entity
- *
- * @return mixed|null
- */
- public function webtestGetValidEntityID($entity) {
- // michaelmcandrew: would like to use getvalue but there is a bug
- // for e.g. group where option.limit not working at the moment CRM-9110
- $result = $this->webtest_civicrm_api($entity, "get", array('option.limit' => 1, 'return' => 'id'));
- if (!empty($result['values'])) {
- return current(array_keys($result['values']));
- }
- return NULL;
- }
-
- /**
- * @param string $field
- * @return mixed
- */
- public function webtestGetSetting($field) {
- if (!isset($this->settingCache[$field])) {
- $result = $this->webtest_civicrm_api("Setting", "getsingle", array(
- 'return' => $field,
- ));
- $this->settingCache[$field] = $result[$field];
- }
- return $this->settingCache[$field];
- }
-
- /**
- * override this since the built in function doesn't work with the new phpunit.
- * @param string $element
- * @param string $text
- */
- public function waitForText($element, $text) {
- $this->waitForTextPresent($text);
- $this->assertElementContainsText($element, $text);
- }
-
- /**
- * Ensures the required CiviCRM components are enabled.
- * @param $components
- */
- public function enableComponents($components) {
- $this->openCiviPage("admin/setting/component", "reset=1", "_qf_Component_next-bottom");
- $enabledComponents = $this->getSelectOptions("enableComponents-t");
- $added = FALSE;
- foreach ((array) $components as $comp) {
- if (!in_array($comp, $enabledComponents)) {
- $this->addSelection("enableComponents-f", "label=$comp");
- $this->click("//option[@value='$comp']");
- $this->click("add");
- $added = TRUE;
- }
- }
- if ($added) {
- $this->clickLink("_qf_Component_next-bottom");
- $this->checkCRMAlert("Saved");
- }
- }
-
- /**
- * Ensures the required currencies are enabled.
- * @param $currencies
- */
- public function enableCurrency($currencies) {
- $this->openCiviPage("admin/setting/localization", "reset=1", "_qf_Localization_next-bottom");
- $enabledCurrency = $this->getSelectOptions("currencyLimit-t");
- foreach ($enabledCurrency as $k => $val) {
- $enabledCurrency[$k] = substr($val, 0, 3);
- }
- $added = FALSE;
- foreach ((array) $currencies as $curr) {
- if (!in_array($curr, $enabledCurrency)) {
- $this->addSelection("currencyLimit-f", "value=$curr");
- $this->click("//option[@value='$curr']");
- $this->click("add");
- $added = TRUE;
- }
- }
- if ($added) {
- $this->clickLink("_qf_Localization_next-bottom");
- }
- }
-
- /**
- * Add a contact with the given first and last names and either a given email.
- * (when specified), a random email (when true) or no email (when unspecified or null).
- *
- * @param string $fname
- * Contact’s first name.
- * @param string $lname
- * Contact’s last name.
- * @param mixed $email
- * Contact’s email (when string) or random email (when true) or no email (when null).
- * @param string $contactSubtype
- *
- * @return string|null
- * either a string with the (either generated or provided) email or null (if no email)
- */
- public function webtestAddContact($fname = 'Anthony', $lname = 'Anderson', $email = NULL, $contactSubtype = NULL) {
- $args = 'reset=1&ct=Individual';
- if ($contactSubtype) {
- $args .= "&cst={$contactSubtype}";
- }
- $this->openCiviPage('contact/add', $args, '_qf_Contact_upload_view-bottom');
- $this->type('first_name', $fname);
- $this->type('last_name', $lname);
- if ($email === TRUE) {
- $email = substr(sha1(rand()), 0, 7) . '@example.org';
- }
- if ($email) {
- $this->type('email_1_email', $email);
- }
- $this->clickLink('_qf_Contact_upload_view-bottom');
- return $email;
- }
-
- /**
- * @param string $householdName
- * @param null $email
- *
- * @return null|string
- */
- public function webtestAddHousehold($householdName = "Smith's Home", $email = NULL) {
- $this->openCiviPage("contact/add", "reset=1&ct=Household");
- $this->click('household_name');
- $this->type('household_name', $householdName);
-
- if ($email === TRUE) {
- $email = substr(sha1(rand()), 0, 7) . '@example.org';
- }
- if ($email) {
- $this->type('email_1_email', $email);
- }
-
- $this->clickLink('_qf_Contact_upload_view');
- return $email;
- }
-
- /**
- * @param string $organizationName
- * @param null $email
- * @param null $contactSubtype
- *
- * @return null|string
- */
- public function webtestAddOrganization($organizationName = "Organization XYZ", $email = NULL, $contactSubtype = NULL) {
- $args = 'reset=1&ct=Organization';
- if ($contactSubtype) {
- $args .= "&cst={$contactSubtype}";
- }
- $this->openCiviPage('contact/add', $args, '_qf_Contact_upload_view-bottom');
- $this->click('organization_name');
- $this->type('organization_name', $organizationName);
-
- if ($email === TRUE) {
- $email = substr(sha1(rand()), 0, 7) . '@example.org';
- }
- if ($email) {
- $this->type('email_1_email', $email);
- }
- $this->clickLink('_qf_Contact_upload_view');
- return $email;
- }
-
- /**
- * @param $sortName
- * @param string $fieldName
- */
- public function webtestFillAutocomplete($sortName, $fieldName = 'contact_id') {
- $this->select2($fieldName, $sortName);
- //$this->assertContains($sortName, $this->getValue($fieldName), "autocomplete expected $sortName but didn’t find it in " . $this->getValue($fieldName));
- }
-
- /**
- * @param $sortName
- */
- public function webtestOrganisationAutocomplete($sortName) {
- $this->clickAt("//*[@id='contact_id']/../div/a");
- $this->waitForElementPresent("//*[@id='select2-drop']/div/input");
- $this->keyDown("//*[@id='select2-drop']/div/input", " ");
- $this->type("//*[@id='select2-drop']/div/input", $sortName);
- $this->typeKeys("//*[@id='select2-drop']/div/input", $sortName);
- $this->waitForElementPresent("//*[@class='select2-result-label']");
- $this->clickAt("//*[@class='select2-results']/li[1]");
- //$this->assertContains($sortName, $this->getValue('contact_1'), "autocomplete expected $sortName but didn’t find it in " . $this->getValue('contact_1'));
- }
-
- /**
- * 1. By default, when no strtotime arg is specified, sets date to "now + 1 month"
- * 2. Does not set time. For setting both date and time use webtestFillDateTime() method.
- * 3. Examples of $strToTime arguments -
- * webtestFillDate('start_date',"now")
- * webtestFillDate('start_date',"10 September 2000")
- * webtestFillDate('start_date',"+1 day")
- * webtestFillDate('start_date',"+1 week")
- * webtestFillDate('start_date',"+1 week 2 days 4 hours 2 seconds")
- * webtestFillDate('start_date',"next Thursday")
- * webtestFillDate('start_date',"last Monday")
- * @param $dateElement
- * @param null $strToTimeArgs
- */
- public function webtestFillDate($dateElement, $strToTimeArgs = NULL, $multiselect = FALSE) {
- $timeStamp = strtotime($strToTimeArgs ? $strToTimeArgs : '+1 month');
-
- $year = date('Y', $timeStamp);
- // -1 ensures month number is inline with calender widget's month
- $mon = date('n', $timeStamp) - 1;
- $day = date('j', $timeStamp);
-
- if (!$multiselect) {
- $this->click("xpath=//input[@id='{$dateElement}']/following-sibling::input");
- }
- $this->waitForElementPresent("css=div#ui-datepicker-div.ui-datepicker div.ui-datepicker-header div.ui-datepicker-title select.ui-datepicker-month");
- $this->select("css=div#ui-datepicker-div.ui-datepicker div.ui-datepicker-header div.ui-datepicker-title select.ui-datepicker-month", "value=$mon");
- $this->select("css=div#ui-datepicker-div div.ui-datepicker-header div.ui-datepicker-title select.ui-datepicker-year", "value=$year");
- $this->click("link=$day");
- }
-
- /**
- * 1. set both date and time.
- * @param $dateElement
- * @param null $strToTimeArgs
- */
- public function webtestFillDateTime($dateElement, $strToTimeArgs = NULL) {
- $this->webtestFillDate($dateElement, $strToTimeArgs);
-
- $timeStamp = strtotime($strToTimeArgs ? $strToTimeArgs : '+1 month');
- $hour = date('h', $timeStamp);
- $min = date('i', $timeStamp);
- $meri = date('A', $timeStamp);
-
- $this->type("{$dateElement}_time", "{$hour}:{$min}{$meri}");
- }
-
- /**
- * Verify that given label/value pairs are in *sibling* td cells somewhere on the page.
- *
- * @param array $expected
- * Array of key/value pairs (like Status/Registered) to be checked.
- * @param string $xpathPrefix
- * Pass in an xpath locator to "get to" the desired table or tables. Will be prefixed to xpath.
- * table path. Include leading forward slashes (e.g. "//div[@id='activity-content']").
- * @param string $tableId
- * Pass in the id attribute of a table to be verified if you want to only check a specific table.
- * on the web page.
- */
- public function webtestVerifyTabularData($expected, $xpathPrefix = NULL, $tableId = NULL) {
- $tableLocator = "";
- if ($tableId) {
- $tableLocator = "[@id='$tableId']";
- }
- foreach ($expected as $label => $value) {
- //assertContains() accepts param as string
- $value = "$value";
- if ($xpathPrefix) {
- $this->waitForElementPresent("xpath=//table{$tableLocator}/tbody/tr/td{$xpathPrefix}[text()='{$label}']/../following-sibling::td");
- $this->assertElementContainsText("xpath=//table{$tableLocator}/tbody/tr/td{$xpathPrefix}[text()='{$label}']/../following-sibling::td", $value);
- }
- else {
- $this->waitForElementPresent("xpath=//table{$tableLocator}/tbody/tr/td[text()='{$label}']/following-sibling::td");
- $this->assertElementContainsText("xpath=//table{$tableLocator}/tbody/tr/td[text()='{$label}']/following-sibling::td", $value);
- }
- }
- }
-
- /**
- * Types text into a ckEditor rich text field in a form.
- *
- * @param string $fieldName
- * Form field name (as assigned by PHP buildForm class).
- * @param string $text
- * Text to type into the field.
- * @param string $editor
- * Which text editor (valid values are 'CKEditor', 'TinyMCE').
- *
- * @param bool $compressed
- * @throws \PHPUnit_Framework_AssertionFailedError
- */
- public function fillRichTextField($fieldName, $text = 'Typing this text into editor.', $editor = 'CKEditor', $compressed = FALSE) {
- // make sure cursor focuses on the field
- $this->fireEvent($fieldName, 'focus');
- if ($editor == 'CKEditor') {
- if ($compressed) {
- $this->click("xpath=//textarea[@id='{$fieldName}']/../div[1]");
- }
- $this->waitForElementPresent("xpath=//div[@id='cke_{$fieldName}']//iframe");
- $this->runScript("CKEDITOR.instances['{$fieldName}'].setData('<p>{$text}</p>');");
- }
- elseif ($editor == 'TinyMCE') {
- $this->waitForElementPresent("xpath=//iframe[@id='{$fieldName}_ifr']");
- $this->runScript("tinyMCE.activeEditor.setContent('<p>{$text}</p>');");
- }
- else {
- $this->fail("Unknown editor value: $editor, failing (in CiviSeleniumTestCase::fillRichTextField ...");
- }
- $this->selectFrame('relative=top');
- }
-
- /**
- * Types option label and name into a table of multiple choice options.
- * (for price set fields of type select, radio, or checkbox)
- * TODO: extend for custom field multiple choice table input
- *
- * @param array $options
- * Form field name (as assigned by PHP buildForm class).
- * @param array $validateStrings
- * Appends label and name strings to this array so they can be validated later.
- *
- * @return void
- */
- public function addMultipleChoiceOptions($options, &$validateStrings) {
- foreach ($options as $oIndex => $oValue) {
- $validateStrings[] = $oValue['label'];
- $validateStrings[] = $oValue['amount'];
- if (!empty($oValue['membership_type_id'])) {
- $this->select("membership_type_id_{$oIndex}", "value={$oValue['membership_type_id']}");
- }
- if (!empty($oValue['financial_type_id'])) {
- $this->select("option_financial_type_id_{$oIndex}", "label={$oValue['financial_type_id']}");
- }
- $this->type("option_label_{$oIndex}", $oValue['label']);
- $this->type("option_amount_{$oIndex}", $oValue['amount']);
- $this->click('link=add another choice');
- }
- }
-
- /**
- * Use a contact EntityRef field to add a new contact.
- * @param string $field
- * Selector.
- * @param string $contactType
- * @return array
- * Array of contact attributes (id, names, email)
- */
- public function createDialogContact($field = 'contact_id', $contactType = 'Individual') {
- $selectId = 's2id_' . $this->getAttribute($field . '@id');
- $this->clickAt("xpath=//div[@id='$selectId']/a");
- $this->clickAjaxLink("xpath=//li[@class='select2-no-results']//a[contains(text(), 'New $contactType')]", '_qf_Edit_next');
-
- $name = substr(sha1(rand()), 0, rand(6, 8));
- $params = array();
- if ($contactType == 'Individual') {
- $params['first_name'] = "$name $contactType";
- $params['last_name'] = substr(sha1(rand()), 0, rand(5, 9));
- }
- else {
- $params[strtolower($contactType) . '_name'] = "$name $contactType";
- }
- foreach ($params as $param => $val) {
- $this->type($param, $val);
- }
- $this->type('email-Primary', $params['email'] = "{$name}@example.com");
- $this->clickAjaxLink('_qf_Edit_next');
-
- $this->waitForText("xpath=//div[@id='$selectId']", "$name");
-
- $params['sort_name'] = $contactType == 'Individual' ? $params['last_name'] . ', ' . $params['first_name'] : "$name $contactType";
- $params['display_name'] = $contactType == 'Individual' ? $params['first_name'] . ' ' . $params['last_name'] : $params['sort_name'];
- $params['id'] = $this->getValue($field);
- return $params;
- }
-
- /**
- * @deprecated in favor of createDialogContact
- * @param string $fname
- * @param string $lname
- * @param string $email
- * @param int $type
- * @param string $selectId
- * @param int $row
- * @param string $prefix
- */
- public function webtestNewDialogContact(
- $fname = 'Anthony', $lname = 'Anderson', $email = 'anthony@anderson.biz',
- $type = 4, $selectId = 's2id_contact_id', $row = 1, $prefix = '') {
- // 4 - Individual profile
- // 5 - Organization profile
- // 6 - Household profile
- $profile = array('4' => 'New Individual', '5' => 'New Organization', '6' => 'New Household');
- $this->clickAt("xpath=//div[@id='$selectId']/a");
- $this->clickPopupLink("xpath=//li[@class='select2-no-results']//a[contains(text(),' $profile[$type]')]", '_qf_Edit_next');
-
- switch ($type) {
- case 4:
- $this->type('first_name', $fname);
- $this->type('last_name', $lname);
- break;
-
- case 5:
- $this->type('organization_name', $fname);
- break;
-
- case 6:
- $this->type('household_name', $fname);
- break;
- }
-
- $this->type('email-Primary', $email);
- $this->clickAjaxLink('_qf_Edit_next');
-
- // Is new contact created?
- if ($lname) {
- $this->waitForText("xpath=//div[@id='$selectId']", "$lname, $fname");
- }
- else {
- $this->waitForText("xpath=//div[@id='$selectId']", "$fname");
- }
- }
-
- /**
- * Generic function to check that strings are present in the page.
- *
- * @strings array array of strings or a single string
- *
- * @param $strings
- * @return void
- */
- public function assertStringsPresent($strings) {
- foreach ((array) $strings as $string) {
- $this->assertTrue($this->isTextPresent($string), "Could not find $string on page");
- }
- }
-
- /**
- * Generic function to parse a URL string into it's elements.extract a variable value from a string (url)
- *
- * @url string url to parse or retrieve current url if null
- *
- * @param null $url
- * @return array
- * returns an associative array containing any of the various components
- * of the URL that are present. Querystring elements are returned in sub-array (elements.queryString)
- * http://php.net/manual/en/function.parse-url.php
- */
- public function parseURL($url = NULL) {
- if (!$url) {
- $url = $this->getLocation();
- }
-
- $elements = parse_url($url);
- if (!empty($elements['query'])) {
- $elements['queryString'] = array();
- parse_str($elements['query'], $elements['queryString']);
- }
- return $elements;
- }
-
- /**
- * Returns a single argument from the url query.
- * @param $arg
- * @param null $url
- * @return null
- */
- public function urlArg($arg, $url = NULL) {
- $elements = $this->parseURL($url);
- return isset($elements['queryString'][$arg]) ? $elements['queryString'][$arg] : NULL;
- }
-
- /**
- * Define a payment processor for use by a webtest. Default is to create Dummy processor
- * which is useful for testing online public forms (online contribution pages and event registration)
- *
- * @param string $processorName
- * Name assigned to new processor.
- * @param string $processorType
- * Name for processor type (e.g. PayPal, Dummy, etc.).
- * @param array $processorSettings
- * Array of fieldname => value for required settings for the processor.
- *
- * @param string $financialAccount
- * @throws PHPUnit_Framework_AssertionFailedError
- * @return int
- */
- public function webtestAddPaymentProcessor($processorName = 'Test Processor', $processorType = 'Dummy', $processorSettings = NULL, $financialAccount = 'Deposit Bank Account') {
- if (!$processorName) {
- $this->fail("webTestAddPaymentProcessor requires $processorName.");
- }
- // Ensure we are logged in as admin before we proceed
- $this->webtestLogin('admin');
-
- if ($processorName === 'Test Processor') {
- // Use the default test processor, no need to create a new one
- $this->openCiviPage('admin/paymentProcessor', 'action=update&id=1&reset=1', '_qf_PaymentProcessor_cancel-bottom');
- $this->check('is_default');
- $this->select('financial_account_id', "label={$financialAccount}");
- $this->clickLink('_qf_PaymentProcessor_next-bottom');
- return 1;
- }
-
- if ($processorType == 'Dummy') {
- $processorSettings = array(
- 'user_name' => 'dummy',
- 'url_site' => 'http://dummy.com',
- 'test_user_name' => 'dummytest',
- 'test_url_site' => 'http://dummytest.com',
- );
- }
- elseif ($processorType == 'AuthNet') {
- // FIXME: we 'll need to make a new separate account for testing
- $processorSettings = array(
- //dummy live username/password are passed to bypass processor validation on live credential
- 'user_name' => '3HcY62mY',
- 'password' => '69943NrwaQA92b8J',
- 'test_user_name' => '5ULu56ex',
- 'password' => '7ARxW575w736eF5p',
- 'test_password' => '7ARxW575w736eF5p',
- );
- }
- elseif ($processorType == 'PayPal') {
- $processorSettings = array(
- 'test_user_name' => '559999327053114',
- 'user_name' => '559999327053114',
- 'test_password' => 'R2zv2g60-A7GXKJYl0nR0g',
- 'test_signature' => 'R2zv2g60-A7GXKJYl0nR0g',
- 'password' => 'R2zv2g60-A7GXKJYl0nR0g',
- 'signature' => 'R2zv2g60-A7GXKJYl0nR0g',
- );
- }
- elseif ($processorType == 'PayPal_Standard') {
- $processorSettings = array(
- 'user_name' => 'V18ki@9r5Bf.org',
- 'test_user_name' => 'V18ki@9r5Bf.org',
- );
- }
- elseif (empty($processorSettings)) {
- $this->fail("webTestAddPaymentProcessor requires $processorSettings array if processorType is not Dummy.");
- }
- $pid = CRM_Core_DAO::getFieldValue("CRM_Financial_DAO_PaymentProcessorType", $processorType, "id", "name");
- if (empty($pid)) {
- $this->fail("$processorType processortype not found.");
- }
- $this->openCiviPage('admin/paymentProcessor', 'action=add&reset=1&pp=' . $pid, 'name');
- $this->type('name', $processorName);
- $this->select('financial_account_id', "label={$financialAccount}");
- foreach ($processorSettings as $f => $v) {
- $this->type($f, $v);
- }
-
- // Save
- $this->clickLink('_qf_PaymentProcessor_next-bottom');
-
- $this->waitForTextPresent($processorName);
-
- // Get payment processor id
- $paymentProcessorLink = $this->getAttribute("xpath=//table[@class='selector row-highlight']//tbody//tr/td[text()='{$processorName}']/../td[7]/span/a[1]@href");
- return $this->urlArg('id', $paymentProcessorLink);
- }
-
- public function webtestAddCreditCardDetails() {
- $this->waitForElementPresent('credit_card_type');
- $this->select('credit_card_type', 'label=Visa');
- $this->type('credit_card_number', '4807731747657838');
- $this->type('cvv2', '123');
- $this->select('credit_card_exp_date[M]', 'label=Feb');
- $this->select('credit_card_exp_date[Y]', 'label=2019');
- }
-
- /**
- * @param null $firstName
- * @param null $middleName
- * @param null $lastName
- *
- * @return array
- */
- public function webtestAddBillingDetails($firstName = NULL, $middleName = NULL, $lastName = NULL) {
- if (!$firstName) {
- $firstName = 'John';
- }
-
- if (!$middleName) {
- $middleName = 'Apple';
- }
-
- if (!$lastName) {
- $lastName = 'Smith_' . substr(sha1(rand()), 0, 7);
- }
-
- $this->type('billing_first_name', $firstName);
- $this->type('billing_middle_name', $middleName);
- $this->type('billing_last_name', $lastName);
-
- $this->type('billing_street_address-5', '234 Lincoln Ave');
- $this->type('billing_city-5', 'San Bernadino');
- $this->select2('billing_country_id-5', 'UNITED STATES');
- $this->select2('billing_state_province_id-5', 'California');
- $this->type('billing_postal_code-5', '93245');
-
- return array($firstName, $middleName, $lastName);
- }
-
- /**
- * @param $fieldLocator
- * @param null $filePath
- *
- * @return null|string
- */
- public function webtestAttachFile($fieldLocator, $filePath = NULL) {
- if (!$filePath) {
- $filePath = '/tmp/testfile_' . substr(sha1(rand()), 0, 7) . '.txt';
- $fp = @fopen($filePath, 'w');
- fwrite($fp, 'Test file created by selenium test.');
- @fclose($fp);
- }
-
- $this->assertTrue(file_exists($filePath), 'Not able to locate file: ' . $filePath);
-
- $this->attachFile($fieldLocator, "file://{$filePath}");
-
- return $filePath;
- }
-
- /**
- * @param $headers
- * @param $rows
- * @param null $filePath
- *
- * @return null|string
- */
- public function webtestCreateCSV($headers, $rows, $filePath = NULL) {
- if (!$filePath) {
- $filePath = '/tmp/testcsv_' . substr(sha1(rand()), 0, 7) . '.csv';
- }
-
- $data = '"' . implode('", "', $headers) . '"' . "\r\n";
-
- foreach ($rows as $row) {
- $temp = array();
- foreach ($headers as $field => $header) {
- $temp[$field] = isset($row[$field]) ? '"' . $row[$field] . '"' : '""';
- }
- $data .= implode(', ', $temp) . "\r\n";
- }
-
- $fp = @fopen($filePath, 'w');
- @fwrite($fp, $data);
- @fclose($fp);
-
- $this->assertTrue(file_exists($filePath), 'Not able to locate file: ' . $filePath);
-
- return $filePath;
- }
-
- /**
- * Create new relationship type w/ user specified params or default.
- *
- * @param array $params
- * array of required params.
- *
- * @return array
- * array of saved params values.
- */
- public function webtestAddRelationshipType($params = array()) {
- $this->openCiviPage("admin/reltype", "reset=1&action=add");
-
- //build the params if not passed.
- if (!is_array($params) || empty($params)) {
- $params = array(
- 'label_a_b' => 'Test Relationship Type A - B -' . rand(),
- 'label_b_a' => 'Test Relationship Type B - A -' . rand(),
- 'contact_types_a' => 'Individual',
- 'contact_types_b' => 'Individual',
- 'description' => 'Test Relationship Type Description',
- );
- }
- //make sure we have minimum required params.
- if (!isset($params['label_a_b']) || empty($params['label_a_b'])) {
- $params['label_a_b'] = 'Test Relationship Type A - B -' . rand();
- }
-
- //start the form fill.
- $this->type('label_a_b', $params['label_a_b']);
- $this->type('label_b_a', $params['label_b_a']);
- $this->select('contact_types_a', "value={$params['contact_type_a']}");
- $this->select('contact_types_b', "value={$params['contact_type_b']}");
- $this->type('description', $params['description']);
-
- //save the data.
- $this->click('_qf_RelationshipType_next-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- //does data saved.
- $this->assertTrue($this->isTextPresent('The Relationship Type has been saved.'),
- "Status message didn't show up after saving!"
- );
-
- $this->openCiviPage("admin/reltype", "reset=1");
-
- //validate data on selector.
- $data = $params;
- if (isset($data['description'])) {
- unset($data['description']);
- }
- $this->assertStringsPresent($data);
-
- return $params;
- }
-
- /**
- * Create new online contribution page w/ user specified params or defaults.
- * FIXME: this function take an absurd number of params - very unwieldy :(
- *
- * @param null $hash
- * @param null $rand
- * @param null $pageTitle
- * @param array $processor
- * @param bool $amountSection
- * @param bool $payLater
- * @param bool $onBehalf
- * @param bool $pledges
- * @param bool $recurring
- * @param bool $membershipTypes
- * @param int $memPriceSetId
- * @param bool $friend
- * @param int $profilePreId
- * @param int $profilePostId
- * @param bool $premiums
- * @param bool $widget
- * @param bool $pcp
- * @param bool $isAddPaymentProcessor
- * @param bool $isPcpApprovalNeeded
- * @param bool $isSeparatePayment
- * @param bool $honoreeSection
- * @param bool $allowOtherAmount
- * @param bool $isConfirmEnabled
- * @param string $financialType
- * @param bool $fixedAmount
- * @param bool $membershipsRequired
- *
- * @return null
- * of newly created online contribution page.
- */
- public function webtestAddContributionPage(
- $hash = NULL,
- $rand = NULL,
- $pageTitle = NULL,
- $processor = array('Test Processor' => 'Dummy'),
- $amountSection = TRUE,
- $payLater = TRUE,
- $onBehalf = TRUE,
- $pledges = TRUE,
- $recurring = FALSE,
- $membershipTypes = TRUE,
- $memPriceSetId = NULL,
- $friend = TRUE,
- $profilePreId = 1,
- $profilePostId = 7,
- $premiums = TRUE,
- $widget = TRUE,
- $pcp = TRUE,
- $isAddPaymentProcessor = TRUE,
- $isPcpApprovalNeeded = FALSE,
- $isSeparatePayment = FALSE,
- $honoreeSection = TRUE,
- $allowOtherAmount = TRUE,
- $isConfirmEnabled = TRUE,
- $financialType = 'Donation',
- $fixedAmount = TRUE,
- $membershipsRequired = TRUE,
- $isPledgeStart = FALSE
- ) {
- if (!$hash) {
- $hash = substr(sha1(rand()), 0, 7);
- }
- if (!$pageTitle) {
- $pageTitle = 'Donate Online ' . $hash;
- }
-
- if (!$rand) {
- $rand = 2 * rand(2, 50);
- }
-
- // Create a new payment processor if requested
- if ($isAddPaymentProcessor) {
- while (list($processorName, $processorType) = each($processor)) {
- $this->webtestAddPaymentProcessor($processorName, $processorType);
- }
- }
-
- // go to the New Contribution Page page
- $this->openCiviPage('admin/contribute', 'action=add&reset=1');
-
- // fill in step 1 (Title and Settings)
- $this->type('title', $pageTitle);
-
- //to select financial type
- $this->select('financial_type_id', "label={$financialType}");
-
- if ($onBehalf) {
- $this->click('is_organization');
- $this->select("xpath=//*[@class='crm-contribution-onbehalf_profile_id']//span[@class='crm-profile-selector-select']//select", 'label=On Behalf Of Organization');
- $this->type('for_organization', "On behalf $hash");
-
- if ($onBehalf == 'required') {
- $this->click('CIVICRM_QFID_2_4');
- }
- elseif ($onBehalf == 'optional') {
- $this->click('CIVICRM_QFID_1_2');
- }
- }
-
- $this->fillRichTextField('intro_text', 'This is introductory message for ' . $pageTitle, 'CKEditor');
- $this->fillRichTextField('footer_text', 'This is footer message for ' . $pageTitle, 'CKEditor');
-
- $this->type('goal_amount', 10 * $rand);
-
- // FIXME: handle Start/End Date/Time
- if ($honoreeSection) {
- $this->click('honor_block_is_active');
- $this->type('honor_block_title', "Honoree Section Title $hash");
- $this->type('honor_block_text', "Honoree Introductory Message $hash");
- $this->click("//*[@id='s2id_soft_credit_types']/ul");
- $this->waitForElementPresent("//*[@id='select2-drop']/ul");
- $this->waitForElementPresent("//*[@class='select2-result-label']");
- $this->clickAt("//*[@class='select2-results']/li[1]");
- }
-
- // is confirm enabled? it starts out enabled, so uncheck it if false
- if (!$isConfirmEnabled) {
- $this->click("id=is_confirm_enabled");
- }
-
- // Submit form
- $this->clickLink('_qf_Settings_next', "_qf_Amount_next-bottom");
-
- // Get contribution page id
- $pageId = $this->urlArg('id');
-
- // fill in step 2 (Processor, Pay Later, Amounts)
- if (!empty($processor)) {
- reset($processor);
- while (list($processorName) = each($processor)) {
- // select newly created processor
- $xpath = "xpath=//label[text() = '{$processorName}']/preceding-sibling::input[1]";
- $this->assertTrue($this->isTextPresent($processorName));
- $this->check($xpath);
- }
- }
-
- if ($amountSection && !$memPriceSetId) {
- if ($payLater) {
- $this->click('is_pay_later');
- $this->type('pay_later_text', "Pay later label $hash");
- $this->fillRichTextField('pay_later_receipt', "Pay later instructions $hash");
- }
-
- if ($pledges) {
- $this->click('is_pledge_active');
- $this->click('pledge_frequency_unit[week]');
- $this->click('is_pledge_interval');
- $this->type('initial_reminder_day', 3);
- $this->type('max_reminders', 2);
- $this->type('additional_reminder_day', 1);
- if ($isPledgeStart) {
- $this->webtestFillDate('pledge_start_date', '+1 month');
- }
- }
- elseif ($recurring) {
- $this->click('is_recur');
- $this->click("is_recur_interval");
- $this->click("is_recur_installments");
- }
- if ($allowOtherAmount) {
-
- $this->click('is_allow_other_amount');
-
- // there shouldn't be minimums and maximums on test contribution forms unless you specify it
- //$this->type('min_amount', $rand / 2);
- //$this->type('max_amount', $rand * 10);
- }
- if ($fixedAmount || !$allowOtherAmount) {
- $this->type('label_1', "Label $hash");
- $this->type('value_1', "$rand");
- }
- $this->click('CIVICRM_QFID_1_4');
- }
- else {
- $this->click('amount_block_is_active');
- }
-
- $this->click('_qf_Amount_next');
- $this->waitForElementPresent('_qf_Amount_next-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $text = "'Amount' information has been saved.";
- $this->assertTrue($this->isTextPresent($text), 'Missing text: ' . $text);
-
- if ($memPriceSetId || (($membershipTypes === TRUE) || (is_array($membershipTypes) && !empty($membershipTypes)))) {
- // go to step 3 (memberships)
- $this->click('link=Memberships');
- $this->waitForElementPresent('_qf_MembershipBlock_submit_savenext');
-
- // fill in step 3 (Memberships)
- $this->click('member_is_active');
- $this->waitForElementPresent('displayFee');
- $this->type('new_title', "Title - New Membership $hash");
- $this->type('renewal_title', "Title - Renewals $hash");
-
- if ($memPriceSetId) {
- $this->click('member_price_set_id');
- $this->select('member_price_set_id', "value={$memPriceSetId}");
- }
- else {
- if ($membershipTypes === TRUE) {
- $membershipTypes = array(array('id' => 2, 'name' => 'Student', 'default' => 1));
- }
-
- // FIXME: handle Introductory Message - New Memberships/Renewals
- foreach ($membershipTypes as $mType) {
- $this->click("membership_type_{$mType['id']}");
- if (array_key_exists('default', $mType)) {
- $this->click("xpath=//label[text() = '$mType[name]']/parent::td/parent::tr/td[2]/input");
- }
- if (array_key_exists('auto_renew', $mType)) {
- $this->select("auto_renew_{$mType['id']}", "label=Give option");
- }
- }
- if ($membershipsRequired) {
- $this->click('is_required');
- }
- if ($isSeparatePayment) {
- $this->click('is_separate_payment');
- }
- }
- $this->clickLink('_qf_MembershipBlock_next', '_qf_MembershipBlock_next-bottom');
- $text = "'MembershipBlock' information has been saved.";
- $this->isTextPresent($text);
- }
-
- // go to step 4 (thank-you and receipting)
- $this->click('link=Receipt');
- $this->waitForElementPresent('_qf_ThankYou_next-bottom');
-
- // fill in step 4
- $this->type('thankyou_title', "Thank-you Page Title $hash");
- // FIXME: handle Thank-you Message/Page Footer
- $this->type('receipt_from_name', "Receipt From Name $hash");
- $this->type('receipt_from_email', "$hash@example.org");
- $this->type('receipt_text', "Receipt Message $hash");
- $this->type('cc_receipt', "$hash@example.net");
- $this->type('bcc_receipt', "$hash@example.com");
-
- $this->click('_qf_ThankYou_next');
- $this->waitForElementPresent('_qf_ThankYou_next-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $text = "'ThankYou' information has been saved.";
- $this->assertTrue($this->isTextPresent($text), 'Missing text: ' . $text);
-
- if ($friend) {
- // fill in step 5 (Tell a Friend)
- $this->click('link=Tell a Friend');
- $this->waitForElementPresent('_qf_Contribute_next-bottom');
- $this->click('tf_is_active');
- $this->type('tf_title', "TaF Title $hash");
- $this->type('intro', "TaF Introduction $hash");
- $this->type('suggested_message', "TaF Suggested Message $hash");
- $this->type('general_link', "TaF Info Page Link $hash");
- $this->type('tf_thankyou_title', "TaF Thank-you Title $hash");
- $this->type('tf_thankyou_text', "TaF Thank-you Message $hash");
-
- //$this->click('_qf_Contribute_next');
- $this->click('_qf_Contribute_next-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $text = "'Friend' information has been saved.";
- $this->assertTrue($this->isTextPresent($text), 'Missing text: ' . $text);
- }
-
- if ($profilePreId || $profilePostId) {
- // fill in step 6 (Include Profiles)
- $this->click('css=li#tab_custom a');
- $this->waitForElementPresent('_qf_Custom_next-bottom');
-
- if ($profilePreId) {
- $this->select('css=tr.crm-contribution-contributionpage-custom-form-block-custom_pre_id span.crm-profile-selector-select select', "value={$profilePreId}");
- }
-
- if ($profilePostId) {
- $this->select('css=tr.crm-contribution-contributionpage-custom-form-block-custom_post_id span.crm-profile-selector-select select', "value={$profilePostId}");
- }
-
- $this->click('_qf_Custom_next-bottom');
- //$this->waitForElementPresent('_qf_Custom_next-bottom');
-
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $text = "'Custom' information has been saved.";
- $this->assertTrue($this->isTextPresent($text), 'Missing text: ' . $text);
- }
-
- if ($premiums) {
- // fill in step 7 (Premiums)
- $this->click('link=Premiums');
- $this->waitForElementPresent('_qf_Premium_next-bottom');
- $this->click('premiums_active');
- $this->type('premiums_intro_title', "Prem Title $hash");
- $this->type('premiums_intro_text', "Prem Introductory Message $hash");
- $this->type('premiums_contact_email', "$hash@example.info");
- $this->type('premiums_contact_phone', rand(100000000, 999999999));
- $this->click('premiums_display_min_contribution');
- $this->type('premiums_nothankyou_label', 'No thank-you');
- $this->click('_qf_Premium_next');
- $this->waitForElementPresent('_qf_Premium_next-bottom');
-
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $text = "'Premium' information has been saved.";
- $this->assertTrue($this->isTextPresent($text), 'Missing text: ' . $text);
- $this->openCiviPage("admin/contribute/premium", "reset=1&action=update&id={$pageId}");
- $this->waitForAjaxContent();
- $this->waitForElementPresent('_qf_Premium_cancel-bottom');
- $this->click("xpath=//div[@class='messages status no-popup']/a[text()='add one']");
- $this->waitForElementPresent('_qf_AddProduct_cancel-bottom');
- $this->select('product_id', "value=1");
- $this->select('financial_type_id', "value=1");
- $this->click('_qf_AddProduct_next-bottom');
- $this->waitForElementPresent('_qf_Premium_cancel-bottom');
- $this->click('_qf_Premium_next-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- }
-
- if ($widget) {
- // fill in step 8 (Widget Settings)
- $this->click('link=Widgets');
- $this->waitForElementPresent('_qf_Widget_next-bottom');
- $this->click('is_active');
- $this->type('url_logo', "URL to Logo Image $hash");
- $this->type('button_title', "Button Title $hash");
- // Type About text in ckEditor (fieldname, text to type, editor)
- $this->fillRichTextField('about', 'This is for ' . $pageTitle, 'CKEditor');
-
- $this->click('_qf_Widget_next');
- $this->waitForElementPresent('_qf_Widget_next-bottom');
-
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $text = "'Widget' information has been saved.";
- $this->assertTrue($this->isTextPresent($text), 'Missing text: ' . $text);
- }
-
- if ($pcp) {
- // fill in step 9 (Enable Personal Campaign Pages)
- $this->click('link=Personal Campaigns');
- $this->waitForElementPresent('_qf_Contribute_next-bottom');
- $this->click('pcp_active');
- if (!$isPcpApprovalNeeded) {
- $this->click('is_approval_needed');
- }
- $this->type('notify_email', "$hash@example.name");
- $this->select('supporter_profile_id', 'value=2');
- $this->type('tellfriend_limit', 7);
- $this->type('link_text', "'Create Personal Campaign Page' link text $hash");
-
- $this->click('_qf_Contribute_next-bottom');
- //$this->waitForElementPresent('_qf_PCP_next-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $text = "'Pcp' information has been saved.";
- $this->assertTrue($this->isTextPresent($text), 'Missing text: ' . $text);
- }
-
- return $pageId;
- }
-
- /**
- * Update default strict rule.
- *
- * @param string $contactType
- * @param array $fields
- * Fields to be set for strict rule.
- * @param int $threshold
- * Rule's threshold value.
- */
- public function webtestStrictDedupeRuleDefault($contactType = 'Individual', $fields = array(), $threshold = 10) {
- // set default strict rule.
- $strictRuleId = 4;
- if ($contactType == 'Organization') {
- $strictRuleId = 5;
- }
- elseif ($contactType == 'Household') {
- $strictRuleId = 6;
- }
-
- // Default dedupe fields for each Contact type.
- if (empty($fields)) {
- $fields = array('civicrm_email.email' => 10);
- if ($contactType == 'Organization') {
- $fields = array(
- 'civicrm_contact.organization_name' => 10,
- 'civicrm_email.email' => 10,
- );
- }
- elseif ($contactType == 'Household') {
- $fields = array(
- 'civicrm_contact.household_name' => 10,
- 'civicrm_email.email' => 10,
- );
- }
- }
-
- $this->openCiviPage('contact/deduperules', "action=update&id=$strictRuleId", '_qf_DedupeRules_next-bottom');
-
- $count = 0;
- foreach ($fields as $field => $weight) {
- $this->select("where_{$count}", "value={$field}");
- $this->type("length_{$count}", '');
- $this->type("weight_{$count}", $weight);
- $count++;
- }
-
- if ($count > 4) {
- $this->type('threshold', $threshold);
- // click save
- $this->click('_qf_DedupeRules_next-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- return;
- }
-
- for ($i = $count; $i <= 4; $i++) {
- $this->select("where_{$i}", 'label=- none -');
- $this->type("length_{$i}", '');
- $this->type("weight_{$i}", '');
- }
-
- $this->type('threshold', $threshold);
-
- // click save
- $this->click('_qf_DedupeRules_next-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- }
-
- /**
- * @param string $period_type
- * @param int $duration_interval
- * @param string $duration_unit
- * @param string $auto_renew
- * @param int $minimumFee
- * @param string $financialType
- *
- * @return array
- */
- public function webtestAddMembershipType($period_type = 'rolling', $duration_interval = 1, $duration_unit = 'year', $auto_renew = 'no', $minimumFee = 100, $financialType = 'Member Dues') {
- $membershipTitle = substr(sha1(rand()), 0, 7);
- $membershipOrg = $membershipTitle . ' memorg';
- $this->webtestAddOrganization($membershipOrg, TRUE);
-
- $title = 'Membership Type ' . substr(sha1(rand()), 0, 7);
- $memTypeParams = array(
- 'membership_type' => $title,
- 'member_of_contact' => $membershipOrg,
- 'financial_type' => $financialType,
- 'period_type' => $period_type,
- );
-
- $this->openCiviPage("admin/member/membershipType/add", "action=add&reset=1", '_qf_MembershipType_cancel-bottom');
-
- $this->type('name', $memTypeParams['membership_type']);
-
- // if auto_renew optional or required - a valid payment processor must be created first (e.g Auth.net)
- // select the radio first since the element id changes after membership org search results are loaded
- switch ($auto_renew) {
- case 'optional':
- $this->click("xpath=//table[@class='form-layout-compressed']/tbody/tr[6]/td/label[contains(text(), 'Auto-renew Option')]/../../td[2]/label[contains(text(), 'Give option, but not required')]");
- break;
-
- case 'required':
- $this->click("xpath=//table[@class='form-layout-compressed']/tbody/tr[6]/td/label[contains(text(), 'Auto-renew Option')]/../../td[2]/label[contains(text(), 'Auto-renew required')]");
- break;
-
- default:
- //check if for the element presence (the Auto renew options can be absent when proper payment processor not configured)
- if ($this->isElementPresent("xpath=//div[@id='membership_type_form']//table/tbody/tr[6]/td/label[contains(text(), 'Auto-renew Option')]/../../td[2]/label[contains(text(), 'No auto-renew option')]")) {
- $this->click("xpath=//table[@class='form-layout-compressed']/tbody/tr[6]/td/label[contains(text(), 'Auto-renew Option')]/../../td[2]/label[contains(text(), 'No auto-renew option')]");
- }
- break;
- }
-
- $this->select2('member_of_contact_id', $membershipTitle);
-
- $this->type('minimum_fee', $minimumFee);
- $this->select('financial_type_id', "label={$memTypeParams['financial_type']}");
-
- $this->type('duration_interval', $duration_interval);
- $this->waitForElementPresent('duration_unit');
- $this->select('duration_unit', "label={$duration_unit}");
- $this->waitForElementPresent('period_type');
- $this->select('period_type', "value={$period_type}");
-
- $this->click('_qf_MembershipType_upload-bottom');
- $this->waitForElementPresent('link=Add Membership Type');
- $this->assertTrue($this->isTextPresent("The membership type '$title' has been saved."));
-
- return $memTypeParams;
- }
-
- /**
- * @param null $groupName
- * @param null $parentGroupName
- *
- * @return null|string
- */
- public function WebtestAddGroup($groupName = NULL, $parentGroupName = NULL) {
- $this->openCiviPage('group/add', 'reset=1', '_qf_Edit_upload-bottom');
-
- // fill group name
- if (!$groupName) {
- $groupName = 'group_' . substr(sha1(rand()), 0, 7);
- }
- $this->type('title', $groupName);
-
- // fill description
- $this->type('description', 'Adding new group.');
-
- // check Access Control
- $this->click('group_type[1]');
-
- // check Mailing List
- $this->click('group_type[2]');
-
- // select Visibility as Public Pages
- $this->select('visibility', 'value=Public Pages');
-
- // select parent group
- if ($parentGroupName) {
- $this->select('parents', "*$parentGroupName");
- }
-
- // Clicking save.
- $this->click('_qf_Edit_upload-bottom');
-
- // Is status message correct?
- $this->waitForText('crm-notification-container', "The Group '$groupName' has been saved.");
- return $groupName;
- }
-
- /**
- * @param string $activityType
- *
- * @return null
- */
- public function WebtestAddActivity($activityType = "Meeting") {
- // Adding Adding contact with randomized first name for test testContactContextActivityAdd
- // We're using Quick Add block on the main page for this.
- $firstName1 = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName1, "Summerson", $firstName1 . "@summerson.name");
- $firstName2 = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName2, "Anderson", $firstName2 . "@anderson.name");
-
- $this->click("css=li#tab_activity a");
-
- // waiting for the activity dropdown to show up
- $this->waitForElementPresent("other_activity");
-
- // Select the activity type from the activity dropdown
- $this->select("other_activity", "label=Meeting");
-
- $this->waitForElementPresent("_qf_Activity_upload-bottom");
- $this->waitForElementPresent("s2id_target_contact_id");
-
- $this->assertTrue($this->isTextPresent("Anderson, " . $firstName2), "Contact not found in line " . __LINE__);
-
- // Typing contact's name into the field (using typeKeys(), not type()!)...
- $this->select2("assignee_contact_id", $firstName1, TRUE);
-
- // ...and verifying if the page contains properly formatted display name for chosen contact.
- $this->assertTrue($this->isTextPresent("Summerson, " . $firstName1), "Contact not found in line " . __LINE__);
-
- // Putting the contents into subject field - assigning the text to variable, it'll come in handy later
- $subject = "This is subject of test activity being added through activity tab of contact summary screen.";
- // For simple input fields we can use field id as selector
- $this->type("subject", $subject);
- $this->type("location", "Some location needs to be put in this field.");
-
- $this->webtestFillDateTime('activity_date_time', '+1 month 11:10PM');
-
- // Setting duration.
- $this->type("duration", "30");
-
- // Putting in details.
- $this->type("details", "Really brief details information.");
-
- // Making sure that status is set to Scheduled (using value, not label).
- $this->select("status_id", "value=1");
-
- // Setting priority.
- $this->select("priority_id", "value=1");
-
- // Scheduling follow-up.
- $this->click("css=.crm-activity-form-block-schedule_followup div.crm-accordion-header");
- $this->select("followup_activity_type_id", "value=1");
- $this->webtestFillDateTime('followup_date', '+2 month 11:10PM');
- $this->type("followup_activity_subject", "This is subject of schedule follow-up activity");
-
- // Clicking save.
- $this->click("_qf_Activity_upload-bottom");
- $this->waitForElementPresent("xpath=//div[@id='crm-notification-container']");
-
- // Is status message correct?
- $this->waitForText('crm-notification-container', "Activity '$subject' has been saved.");
-
- $this->waitForElementPresent("xpath=//div[@class='dataTables_wrapper no-footer']//table/tbody/tr[2]/td[8]/span/a[text()='View']");
-
- // click through to the Activity view screen
- $this->clickLinkSuppressPopup("xpath=//div[@class='dataTables_wrapper no-footer']//table/tbody/tr[2]/td[8]/span/a[text()='View']", '_qf_Activity_cancel-bottom');
-
- // parse URL to grab the activity id
- // pass id back to any other tests that call this class
- return $this->urlArg('id');
- }
-
- /**
- * @return bool
- */
- public static function checkDoLocalDBTest() {
- if (defined('CIVICRM_WEBTEST_LOCAL_DB') &&
- CIVICRM_WEBTEST_LOCAL_DB
- ) {
- require_once 'tests/phpunit/CiviTest/CiviDBAssert.php';
- return TRUE;
- }
- return FALSE;
- }
-
- /**
- * Generic function to compare expected values after an api call to retrieved.
- * DB values.
- *
- * @param string $daoName
- * DAO Name of object we're evaluating.
- * @param int $id
- * Id of object
- * @param array $match
- * Associative array of field name => expected value. Empty if asserting
- * that a DELETE occurred
- * @param bool $delete
- * are we checking that a DELETE action occurred?
- */
- public function assertDBState($daoName, $id, $match, $delete = FALSE) {
- if (self::checkDoLocalDBTest()) {
- CiviDBAssert::assertDBState($this, $daoName, $id, $match, $delete);
- }
- }
-
- /**
- * Request a record from the DB by seachColumn+searchValue. Success if a record is found.
- * @param string $daoName
- * @param string $searchValue
- * @param string $returnColumn
- * @param string $searchColumn
- * @param string $message
- */
- public function assertDBNotNull($daoName, $searchValue, $returnColumn, $searchColumn, $message) {
- if (self::checkDoLocalDBTest()) {
- CiviDBAssert::assertDBNotNull($this, $daoName, $searchValue, $returnColumn, $searchColumn, $message);
- }
- }
-
- /**
- * Request a record from the DB by searchColumn+searchValue. Success if returnColumn value is NULL.
- * @param string $daoName
- * @param string $searchValue
- * @param string $returnColumn
- * @param string $searchColumn
- * @param string $message
- */
- public function assertDBNull($daoName, $searchValue, $returnColumn, $searchColumn, $message) {
- if (self::checkDoLocalDBTest()) {
- CiviDBAssert::assertDBNull($this, $daoName, $searchValue, $returnColumn, $searchColumn, $message);
- }
- }
-
- /**
- * Request a record from the DB by id. Success if row not found.
- * @param string $daoName
- * @param int $id
- * @param string $message
- */
- public function assertDBRowNotExist($daoName, $id, $message) {
- if (self::checkDoLocalDBTest()) {
- CiviDBAssert::assertDBRowNotExist($this, $daoName, $id, $message);
- }
- }
-
- /**
- * Compare all values in a single retrieved DB record to an array of expected values.
- * @param string $daoName
- * @param array $searchParams
- * @param $expectedValues
- */
- public function assertDBCompareValues($daoName, $searchParams, $expectedValues) {
- if (self::checkDoLocalDBTest()) {
- CiviDBAssert::assertDBCompareValues($this, $daoName, $searchParams, $expectedValues);
- }
- }
-
- /**
- * @param $expected
- * @param $actual
- * @param string $message
- */
- public function assertType($expected, $actual, $message = '') {
- $this->assertInternalType($expected, $actual, $message);
- }
-
- /**
- * Add new Financial Account.
- * @param $financialAccountTitle
- * @param bool $financialAccountDescription
- * @param bool $accountingCode
- * @param bool $firstName
- * @param bool $financialAccountType
- * @param bool $taxDeductible
- * @param bool $isActive
- * @param bool $isTax
- * @param bool $taxRate
- * @param bool $isDefault
- */
- public function _testAddFinancialAccount(
- $financialAccountTitle,
- $financialAccountDescription = FALSE,
- $accountingCode = FALSE,
- $firstName = FALSE,
- $financialAccountType = FALSE,
- $taxDeductible = FALSE,
- $isActive = FALSE,
- $isTax = FALSE,
- $taxRate = FALSE,
- $isDefault = FALSE
- ) {
-
- $this->openCiviPage("admin/financial/financialAccount", "reset=1");
-
- $this->click("link=Add Financial Account");
- $this->waitForElementPresent('_qf_FinancialAccount_cancel-botttom');
-
- // Financial Account Name
- $this->type('name', $financialAccountTitle);
-
- // Financial Description
- if ($financialAccountDescription) {
- $this->type('description', $financialAccountDescription);
- }
-
- //Accounting Code
- if ($accountingCode) {
- $this->type('accounting_code', $accountingCode);
- }
-
- // Autofill Organization
- if ($firstName) {
- $this->webtestOrganisationAutocomplete($firstName);
- }
-
- // Financial Account Type
- if ($financialAccountType) {
- $this->select('financial_account_type_id', "label={$financialAccountType}");
- }
-
- // Is Tax Deductible
- if ($taxDeductible) {
- $this->check('is_deductible');
- }
- else {
- $this->uncheck('is_deductible');
- }
- // Is Active
- if (!$isActive) {
- $this->check('is_active');
- }
- else {
- $this->uncheck('is_active');
- }
- // Is Tax
- if ($isTax) {
- $this->check('is_tax');
- }
- else {
- $this->uncheck('is_tax');
- }
- // Tax Rate
- if ($taxRate) {
- $this->type('tax_rate', $taxRate);
- }
-
- // Set Default
- if ($isDefault) {
- $this->check('is_default');
- }
- else {
- $this->uncheck('is_default');
- }
- $this->click('_qf_FinancialAccount_next-botttom');
- }
-
- /**
- * Edit Financial Account.
- * @param $editfinancialAccount
- * @param bool $financialAccountTitle
- * @param bool $financialAccountDescription
- * @param bool $accountingCode
- * @param bool $firstName
- * @param bool $financialAccountType
- * @param bool $taxDeductible
- * @param bool $isActive
- * @param bool $isTax
- * @param bool $taxRate
- * @param bool $isDefault
- */
- public function _testEditFinancialAccount(
- $editfinancialAccount,
- $financialAccountTitle = FALSE,
- $financialAccountDescription = FALSE,
- $accountingCode = FALSE,
- $firstName = FALSE,
- $financialAccountType = FALSE,
- $taxDeductible = FALSE,
- $isActive = TRUE,
- $isTax = FALSE,
- $taxRate = FALSE,
- $isDefault = FALSE
- ) {
- if ($firstName) {
- $this->openCiviPage("admin/financial/financialAccount", "reset=1");
- }
-
- $this->waitForElementPresent("xpath=//table/tbody//tr/td[1]/div[text()='{$editfinancialAccount}']/../../td[9]/span/a[text()='Edit']");
- $this->clickLink("xpath=//table/tbody//tr/td[1]/div[text()='{$editfinancialAccount}']/../../td[9]/span/a[text()='Edit']", '_qf_FinancialAccount_cancel-botttom', FALSE);
-
- // Change Financial Account Name
- if ($financialAccountTitle) {
- $this->type('name', $financialAccountTitle);
- }
-
- // Financial Description
- if ($financialAccountDescription) {
- $this->type('description', $financialAccountDescription);
- }
-
- //Accounting Code
- if ($accountingCode) {
- $this->type('accounting_code', $accountingCode);
- }
-
- // Autofill Edit Organization
- if ($firstName) {
- $this->webtestOrganisationAutocomplete($firstName);
- }
-
- // Financial Account Type
- if ($financialAccountType) {
- $this->select('financial_account_type_id', "label={$financialAccountType}");
- }
-
- // Is Tax Deductible
- if ($taxDeductible) {
- $this->check('is_deductible');
- }
- else {
- $this->uncheck('is_deductible');
- }
-
- // Is Tax
- if ($isTax) {
- $this->check('is_tax');
- }
- else {
- $this->uncheck('is_tax');
- }
-
- // Tax Rate
- if ($taxRate) {
- $this->type('tax_rate', $taxRate);
- }
-
- // Set Default
- if ($isDefault) {
- $this->check('is_default');
- }
- else {
- $this->uncheck('is_default');
- }
-
- // Is Active
- if ($isActive) {
- $this->check('is_active');
- }
- else {
- $this->uncheck('is_active');
- }
- $this->click('_qf_FinancialAccount_next-botttom');
- $this->waitForElementPresent('link=Add Financial Account');
- }
-
- /**
- * @param $setTitle
- * @param $usedFor
- * @param $setHelp
- * @param null $financialType
- */
- public function _testAddSet($setTitle, $usedFor, $setHelp, $financialType = NULL) {
- $this->openCiviPage("admin/price", "reset=1&action=add", '_qf_Set_next-bottom');
-
- // Enter Priceset fields (Title, Used For ...)
- $this->type('title', $setTitle);
- if ($usedFor == 'Event') {
- $this->check('extends_1');
- }
- elseif ($usedFor == 'Contribution') {
- $this->check('extends_2');
- }
-
- if ($financialType) {
- $this->select("financial_type_id", "label={$financialType}");
- }
- $this->type('help_pre', $setHelp);
-
- $this->assertChecked('is_active', 'Verify that Is Active checkbox is set.');
- $this->clickLink('_qf_Set_next-bottom');
- }
-
- /**
- * @param $fields
- * @param $validateString
- * @param $financialType
- * @param bool $dateSpecificFields
- */
- public function _testAddPriceFields(&$fields, &$validateString, $financialType, $dateSpecificFields = FALSE) {
- $validateStrings[] = $financialType;
- $sid = $this->urlArg('sid');
- $this->openCiviPage('admin/price/field', "reset=1&action=add&sid=$sid", 'label');
- foreach ($fields as $label => $type) {
- $validateStrings[] = $label;
-
- $this->type('label', $label);
- $this->select('html_type', "value={$type}");
-
- switch ($type) {
- case 'Text':
- $validateStrings[] = '525.00';
- $this->type('price', '525.00');
- if ($dateSpecificFields == TRUE) {
- $this->webtestFillDateTime('active_on', '+1 week');
- }
- else {
- $this->check('is_required');
- }
- break;
-
- case 'Select':
- $options = array(
- 1 => array(
- 'label' => 'Chicken',
- 'amount' => '30.00',
- ),
- 2 => array(
- 'label' => 'Vegetarian',
- 'amount' => '25.00',
- ),
- );
- $this->addMultipleChoiceOptions($options, $validateStrings);
- if ($dateSpecificFields == TRUE) {
- $this->webtestFillDateTime('expire_on', '-1 week');
- }
- break;
-
- case 'Radio':
- $options = array(
- 1 => array(
- 'label' => 'Yes',
- 'amount' => '50.00',
- ),
- 2 => array(
- 'label' => 'No',
- 'amount' => '0',
- ),
- );
- $this->addMultipleChoiceOptions($options, $validateStrings);
- $this->check('is_required');
- if ($dateSpecificFields == TRUE) {
- $this->webtestFillDateTime('active_on', '-1 week');
- }
- break;
-
- case 'CheckBox':
- $options = array(
- 1 => array(
- 'label' => 'First Night',
- 'amount' => '15.00',
- ),
- 2 => array(
- 'label' => 'Second Night',
- 'amount' => '15.00',
- ),
- );
- $this->addMultipleChoiceOptions($options, $validateStrings);
- if ($dateSpecificFields == TRUE) {
- $this->webtestFillDateTime('expire_on', '+1 week');
- }
- break;
-
- default:
- break;
- }
- $this->select('financial_type_id', "label={$financialType}");
- $this->clickLink('_qf_Field_next_new-bottom', '_qf_Field_next-bottom', FALSE);
- $this->waitForText('crm-notification-container', "Price Field '$label' has been saved.");
- }
- }
-
- /**
- * Delete Financial Account.
- * @param $financialAccountTitle
- */
- public function _testDeleteFinancialAccount($financialAccountTitle) {
- $this->click("xpath=//table/tbody//tr/td[1]/div[text()='{$financialAccountTitle}']/../../td[9]/span/a[text()='Delete']");
- $this->waitForElementPresent('_qf_FinancialAccount_next-botttom');
- $this->click('_qf_FinancialAccount_next-botttom');
- $this->waitForElementPresent('link=Add Financial Account');
- $this->waitForText('crm-notification-container', "Selected Financial Account has been deleted.");
- }
-
- /**
- * Verify data after ADD and EDIT.
- * @param $verifyData
- */
- public function _assertFinancialAccount($verifyData) {
- foreach ($verifyData as $key => $expectedValue) {
- $actualValue = $this->getValue($key);
- if ($key == 'parent_financial_account') {
- $this->assertTrue((bool) preg_match("/^{$expectedValue}/", $actualValue));
- }
- else {
- $this->assertEquals($expectedValue, $actualValue);
- }
- }
- }
-
- /**
- * @param $verifySelectFieldData
- */
- public function _assertSelectVerify($verifySelectFieldData) {
- foreach ($verifySelectFieldData as $key => $expectedvalue) {
- $actualvalue = $this->getSelectedLabel($key);
- $this->assertEquals($expectedvalue, $actualvalue);
- }
- }
-
- /**
- * @param $financialType
- * @param string $option
- */
- public function addeditFinancialType($financialType, $option = 'new') {
- $this->openCiviPage("admin/financial/financialType", "reset=1");
-
- if ($option == 'Delete') {
- $this->click("xpath=id('ltype')/div/table/tbody/tr/td[1]/div[text()='$financialType[name]']/../../td[7]/span[2]");
- $this->waitForElementPresent("css=span.btn-slide-active");
- $this->click("xpath=id('ltype')/div/table/tbody/tr/td[1]/div[text()='$financialType[name]']/../../td[7]/span[2]/ul/li[2]/a");
- $this->waitForElementPresent("_qf_FinancialType_next");
- $this->click("_qf_FinancialType_next");
- $this->waitForElementPresent("newFinancialType");
- $this->waitForText('crm-notification-container', 'Selected financial type has been deleted.');
- return;
- }
- if ($option == 'new') {
- $this->click("link=Add Financial Type");
- }
- else {
- $this->click("xpath=id('ltype')/div/table/tbody/tr/td[1]/div[text()='$financialType[oldname]']/../../td[7]/span/a[text()='Edit']");
- }
- $this->waitForElementPresent("name");
- $this->type('name', $financialType['name']);
- if ($option == 'new') {
- $this->type('description', $financialType['name'] . ' description');
- }
-
- if ($financialType['is_reserved']) {
- $this->check('is_reserved');
- }
- else {
- $this->uncheck('is_reserved');
- }
-
- if ($financialType['is_deductible']) {
- $this->check('is_deductible');
- }
- else {
- $this->uncheck('is_deductible');
- }
-
- $this->click('_qf_FinancialType_next');
- if ($option == 'new') {
- $text = "Your Financial \"{$financialType['name']}\" Type has been created, along with a corresponding income account \"{$financialType['name']}\". That income account, along with standard financial accounts \"Accounts Receivable\", \"Banking Fees\" and \"Premiums\" have been linked to the financial type. You may edit or replace those relationships here.";
- }
- else {
- $text = "The financial type \"{$financialType['name']}\" has been updated.";
- }
- $this->checkCRMAlert($text);
- }
-
- /**
- * Give the specified permissions.
- * Note: this function logs in as 'admin' (logging out if necessary)
- * @param $permission
- */
- public function changePermissions($permission) {
- $this->webtestLogin('admin');
- $this->open("{$this->sboxPath}admin/people/permissions");
- $this->waitForElementPresent('edit-submit');
- foreach ((array) $permission as $perm) {
- $this->check($perm);
- }
- $this->click('edit-submit');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->assertTrue($this->isTextPresent('The changes have been saved.'));
- }
-
- /**
- * @param $profileTitle
- * @param $profileFields
- */
- public function addProfile($profileTitle, $profileFields) {
- $this->openCiviPage('admin/uf/group', "reset=1");
-
- $this->clickLink('link=Add Profile', '_qf_Group_cancel-bottom');
- $this->type('title', $profileTitle);
- $this->clickLink('_qf_Group_next-bottom');
-
- $this->waitForText('crm-notification-container', "Your CiviCRM Profile '{$profileTitle}' has been added. You can add fields to this profile now.");
-
- foreach ($profileFields as $field) {
- $this->waitForElementPresent('field_name_0');
- $this->click("id=field_name_0");
- $this->select("id=field_name_0", "label=" . $field['type']);
- $this->waitForElementPresent('field_name_1');
- $this->click("id=field_name_1");
- $this->select("id=field_name_1", "label=" . $field['name']);
- $this->waitForElementPresent('label');
- $this->type("id=label", $field['label']);
- $this->click("id=_qf_Field_next_new-top");
- $this->waitForElementPresent("xpath=//select[@id='field_name_1'][@style='display: none;']");
- //$this->assertTrue($this->isTextPresent("Your CiviCRM Profile Field '" . $field['name'] . "' has been saved to '" . $profileTitle . "'. You can add another profile field."));
- }
- }
-
- /**
- * @param string $name
- * @param $sku
- * @param $amount
- * @param $price
- * @param $cost
- * @param $financialType
- */
- public function addPremium($name, $sku, $amount, $price, $cost, $financialType) {
- $this->waitForElementPresent("_qf_ManagePremiums_upload-bottom");
- $this->type("name", $name);
- $this->type("sku", $sku);
- $this->click("CIVICRM_QFID_noImage_16");
- $this->type("min_contribution", $amount);
- $this->type("price", $price);
- $this->type("cost", $cost);
- if ($financialType) {
- $this->select("financial_type_id", "label={$financialType}");
- }
- $this->click("_qf_ManagePremiums_upload-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- }
-
- /**
- * @param $label
- * @param $financialAccount
- */
- public function addPaymentInstrument($label, $financialAccount) {
- $this->openCiviPage('admin/options/payment_instrument', 'action=add&reset=1', "_qf_Options_next-bottom");
- $this->type("label", $label);
- $this->type("value", "value" . $label);
- $this->select("financial_account_id", "value=$financialAccount");
- $this->click("_qf_Options_next-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- }
-
- /**
- * Ensure we have a default mailbox set up for CiviMail.
- */
- public function setupDefaultMailbox() {
- $this->openCiviPage('admin/mailSettings', 'action=update&id=1&reset=1');
- // Check if it hasn't already been set up
- if (!$this->getSelectedValue('protocol')) {
- $this->type('name', 'Test Domain');
- $this->select('protocol', "IMAP");
- $this->type('server', 'localhost');
- $this->type('domain', 'example.com');
- $this->clickLink('_qf_MailSettings_next-top');
- }
- }
-
- /**
- * Determine the default time-out in milliseconds.
- *
- * @return string, timeout expressed in milliseconds
- */
- public function getTimeoutMsec() {
- // note: existing local versions of CiviSeleniumSettings may not declare $timeout, so use @
- $timeout = ($this->settings && @$this->settings->timeout) ? ($this->settings->timeout * 1000) : 30000;
- return (string) $timeout; // don't know why, but all our old code used a string
- }
-
- /**
- * CRM-12378
- * checks custom fields rendering / loading properly on the fly WRT entity passed as parameter
- *
- *
- * @param array $customSets
- * Custom sets i.e entity wise sets want to be created and checked.
- * e.g $customSets = array(array('entity' => 'Contribution', 'subEntity' => 'Donation',
- * 'triggerElement' => $triggerElement))
- * array $triggerElement: the element which is responsible for custom group to load
- *
- * which uses the entity info as its selection value
- * @param array $pageUrl
- * The url which on which the ajax custom group load takes place.
- * @param string $beforeTriggering
- * @return void
- */
- public function customFieldSetLoadOnTheFlyCheck($customSets, $pageUrl, $beforeTriggering = NULL) {
- // FIXME: Testing a theory that these failures have something to do with permissions
- $this->webtestLogin('admin');
-
- //add the custom set
- $return = $this->addCustomGroupField($customSets);
-
- // FIXME: Hack to ensure caches are properly cleared
- if (TRUE) {
- $userName = $this->loggedInAs;
- $this->webtestLogout();
- $this->webtestLogin($userName);
- }
-
- $this->openCiviPage($pageUrl['url'], $pageUrl['args']);
-
- // FIXME: Try to find out what the heck is going on with these tests
- $this->waitForAjaxContent();
- $this->checkForErrorsOnPage();
-
- foreach ($return as $values) {
- foreach ($values as $entityType => $customData) {
- //initiate necessary variables
- list($entity, $entityData) = explode('_', $entityType);
- $elementType = CRM_Utils_Array::value('type', $customData['triggerElement'], 'select');
- $elementName = CRM_Utils_Array::value('name', $customData['triggerElement']);
- if (is_callable($beforeTriggering)) {
- call_user_func($beforeTriggering);
- }
- if ($elementType == 'select') {
- //reset the select box, so triggering of ajax only happens
- //WRT input of value in this function
- $this->select($elementName, "index=0");
- }
- if (!empty($entityData)) {
- if ($elementType == 'select') {
- $this->select($elementName, "label=regexp:{$entityData}");
- }
- elseif ($elementType == 'checkbox') {
- $val = explode(',', $entityData);
- foreach ($val as $v) {
- $checkId = $this->getAttribute("xpath=//label[text()='{$v}']/@for");
- $this->check($checkId);
- }
- }
- elseif ($elementType == 'select2') {
- $this->select2($elementName, $entityData);
- }
- }
- // FIXME: Try to find out what the heck is going on with these tests
- $this->waitForAjaxContent();
- $this->checkForErrorsOnPage();
-
- //checking for proper custom data which is loading through ajax
- $this->waitForElementPresent("css=.custom-group-{$customData['cgtitle']}");
- $this->assertElementPresent("xpath=//div[contains(@class, 'custom-group-{$customData['cgtitle']}')]/div[contains(@class, 'crm-accordion-body')]/table/tbody/tr/td[2]/input",
- "The on the fly custom group field is not present for entity : {$entity} => {$entityData}");
- }
- }
- }
-
- /**
- * @param $customSets
- *
- * @return array
- */
- public function addCustomGroupField($customSets) {
- $return = array();
- foreach ($customSets as $customSet) {
- $this->openCiviPage("admin/custom/group", "action=add&reset=1");
-
- //fill custom group title
- $customGroupTitle = "webtest_for_ajax_cd" . substr(sha1(rand()), 0, 4);
- $this->click("title");
- $this->type("title", $customGroupTitle);
-
- //custom group extends
- $this->click("extends_0");
- $this->select("extends_0", "value={$customSet['entity']}");
- if (!empty($customSet['subEntity'])) {
- $this->addSelection("extends_1", "label={$customSet['subEntity']}");
- }
-
- // Don't collapse
- $this->uncheck('collapse_display');
-
- // Save
- $this->click('_qf_Group_next-bottom');
-
- //Is custom group created?
- $this->waitForText('crm-notification-container', "Your custom field set '{$customGroupTitle}' has been added.");
-
- $gid = $this->urlArg('gid');
- $this->waitForTextPresent("{$customGroupTitle} - New Field");
-
- $fieldLabel = "custom_field_for_{$customSet['entity']}_{$customSet['subEntity']}" . substr(sha1(rand()), 0, 4);
- $this->waitForElementPresent('label');
- $this->type('label', $fieldLabel);
- $this->click('_qf_Field_done-bottom');
-
- $this->waitForText('crm-notification-container', $fieldLabel);
- $this->waitForAjaxContent();
-
- $customGroupTitle = preg_replace('/\s/', '_', trim($customGroupTitle));
- $return[] = array(
- "{$customSet['entity']}_{$customSet['subEntity']}" => array(
- 'cgtitle' => $customGroupTitle,
- 'gid' => $gid,
- 'triggerElement' => $customSet['triggerElement'],
- ),
- );
-
- // Go home for a sec to give time for caches to clear
- $this->openCiviPage('');
- }
- return $return;
- }
-
- /**
- * Type and select first occurrence of autocomplete.
- *
- * @param $fieldName
- * @param string $labels
- * @param bool $multiple
- * @param bool $xpath
- */
- public function select2($fieldName, $labels, $multiple = FALSE, $xpath = FALSE) {
- // In the case of chainSelect, wait for options to load
- $this->waitForElementNotPresent('css=select.loading');
- if ($multiple) {
- foreach ((array) $labels as $label) {
- $this->clickAt("//*[@id='$fieldName']/../div/ul/li");
- $this->keyDown("//*[@id='$fieldName']/../div/ul/li//input", " ");
- $this->type("//*[@id='$fieldName']/../div/ul/li//input", $label);
- $this->typeKeys("//*[@id='$fieldName']/../div/ul/li//input", $label);
- $this->waitForElementPresent("//*[@class='select2-result-label']");
- $this->clickAt("//*[contains(@class,'select2-result-selectable')]/div[contains(@class, 'select2-result-label')]");
- }
- }
- else {
- if ($xpath) {
- $this->clickAt($fieldName);
- }
- else {
- $this->clickAt("//*[@id='$fieldName']/../div/a");
- }
- $this->waitForElementPresent("//*[@id='select2-drop']/div/input");
- $this->keyDown("//*[@id='select2-drop']/div/input", " ");
- $this->type("//*[@id='select2-drop']/div/input", $labels);
- $this->typeKeys("//*[@id='select2-drop']/div/input", $labels);
- $this->waitForElementPresent("//*[@class='select2-result-label']");
- $this->clickAt("//*[contains(@class,'select2-result-selectable')]/div[contains(@class, 'select2-result-label')]");
- }
- // Wait a sec for select2 to update the original element
- sleep(1);
- }
-
- /**
- * Select multiple options.
- * @param $fieldId
- * @param $options
- * @param $isDate if multiple date is to be selected from datepicker
- */
- public function multiselect2($fieldId, $options, $isDate = FALSE) {
- // In the case of chainSelect, wait for options to load
- $this->waitForElementNotPresent('css=select.loading');
- foreach ($options as $value) {
- if ($isDate) {
- $this->clickAt("xpath=//*[@id='$fieldId']/../div/ul//li/input");
- $this->webtestFillDate($fieldId, $value, TRUE);
- }
- else {
- $this->clickAt("xpath=//*[@id='$fieldId']/../div/ul//li/input");
- $this->waitForElementPresent("xpath=//ul[@class='select2-results']");
- $this->clickAt("xpath=//ul[@class='select2-results']//li/div[text()='$value']");
- $this->assertElementContainsText("xpath=//*[@id='$fieldId']/preceding-sibling::div[1]/", $value);
- }
- }
- // Wait a sec for select2 to update the original element
- sleep(1);
- }
-
- /**
- * Check for unobtrusive status message as set by CRM.status
- * @param null $text
- */
- public function checkCRMStatus($text = NULL) {
- $this->waitForElementPresent("css=.crm-status-box-outer.status-success");
- if ($text) {
- $this->assertElementContainsText("css=.crm-status-box-outer.status-success", $text);
- }
- }
-
- /**
- * Check for obtrusive status message as set by CRM.alert
- * @param $text
- * @param string $type
- */
- public function checkCRMAlert($text, $type = 'success') {
- $this->waitForElementPresent("css=div.ui-notify-message.$type");
- $this->waitForText("css=div.ui-notify-message.$type", $text);
- // We got the message, now let's close it so the webtest doesn't get confused by lots of open alerts
- $this->click('css=.ui-notify-cross');
- }
-
- /**
- * Enable or disable Pop-ups via Display Preferences
- * @param bool $enabled
- */
- public function enableDisablePopups($enabled = TRUE) {
- $this->openCiviPage('admin/setting/preferences/display', 'reset=1');
- $isChecked = $this->isChecked('ajaxPopupsEnabled');
- if (($isChecked && !$enabled) || (!$isChecked && $enabled)) {
- $this->click('ajaxPopupsEnabled');
- }
- if ($enabled) {
- $this->assertChecked('ajaxPopupsEnabled');
- }
- else {
- $this->assertNotChecked('ajaxPopupsEnabled');
- }
- $this->clickLink("_qf_Display_next-bottom");
- }
-
- /**
- * Attempt to get information about what went wrong if we encounter an error when loading a page.
- */
- public function checkForErrorsOnPage() {
- foreach (array('Access denied', 'Page not found') as $err) {
- if ($this->isElementPresent("xpath=//h1[contains(., '$err')]")) {
- $this->fail("'$err' encountered at " . $this->getLocation() . "\nwhile logged in as '{$this->loggedInAs}'");
- }
- }
- if ($this->isElementPresent("xpath=//span[text()='Sorry but we are not able to provide this at the moment.']")) {
- $msg = '"Fatal Error" encountered at ' . $this->getLocation();
- if ($this->isElementPresent('css=div.crm-section.crm-error-message')) {
- $msg .= "\nError Message: " . $this->getText('css=div.crm-section.crm-error-message');
- }
- $this->fail($msg);
- }
- }
-
- /**
- * @return array
- * Contact record (per APIv3).
- */
- public function webtestGetLoggedInContact() {
- $result = $this->rest_civicrm_api('Contact', 'get', array(
- 'id' => 'user_contact_id',
- ));
- $this->assertAPISuccess($result, 'Load logged-in contact');
- return CRM_Utils_Array::first($result['values']);
- }
-
- public function assertAPISuccess($apiResult, $prefix = '') {
- if (!empty($prefix)) {
- $prefix .= ': ';
- }
- $errorMessage = empty($apiResult['error_message']) ? '' : " " . $apiResult['error_message'];
-
- if (!empty($apiResult['debug_information'])) {
- $errorMessage .= "\n " . print_r($apiResult['debug_information'], TRUE);
- }
- if (!empty($apiResult['trace'])) {
- $errorMessage .= "\n" . print_r($apiResult['trace'], TRUE);
- }
- $this->assertFalse(civicrm_error($apiResult), $prefix . $errorMessage);
- //$this->assertEquals(0, $apiResult['is_error']);
- }
-
- /**
- * Add a pledge
- *
- * @return array
- */
- public function webtestStandalonePledgeAdd() {
- $this->webtestLogin();
-
- $this->openCiviPage('pledge/add', 'reset=1&context=standalone', '_qf_Pledge_upload');
-
- // create new contact using dialog
- $contact = $this->createDialogContact();
-
- $this->type('amount', '100');
- $this->type('installments', '10');
- $this->select('frequency_unit', 'value=week');
- $this->type('frequency_day', '2');
-
- $this->webtestFillDate('acknowledge_date', 'now');
- $this->waitForElementPresent('contribution_page_id');
- $this->select('contribution_page_id', 'value=3');
- $this->waitForAjaxContent();
-
- //PaymentReminders
- $this->click('PaymentReminders');
- $this->waitForElementPresent('additional_reminder_day');
- $this->type('initial_reminder_day', '4');
- $this->type('max_reminders', '2');
- $this->type('additional_reminder_day', '4');
-
- $this->click('_qf_Pledge_upload-bottom');
-
- $this->waitForText('crm-notification-container', "Pledge has been recorded and the payment schedule has been created.");
-
- // verify if Pledge is created
- $this->waitForElementPresent("xpath=//div[@class='view-content']//table//tbody/tr[1]/td[10]/span/a[text()='View']");
-
- //click through to the Pledge view screen
- $this->click("xpath=//div[@class='view-content']//table//tbody/tr[1]/td[10]/span/a[text()='View']");
- $this->waitForElementPresent('_qf_PledgeView_next-bottom');
- $pledgeDate = date('F jS, Y', strtotime('now'));
-
- $this->webtestVerifyTabularData(array(
- 'Pledge By' => $contact['display_name'],
- 'Total Pledge Amount' => '$ 100.00',
- 'To be paid in' => '10 installments of $ 10.00 every 1 week(s)',
- 'Payments are due on the' => '2 day of the period',
- 'Pledge Made' => $pledgeDate,
- 'Financial Type' => 'Donation',
- 'Pledge Status' => 'Pending',
- 'Initial Reminder Day' => '4 days prior to schedule date',
- 'Maximum Reminders Send' => 2,
- 'Send additional reminders' => '4 days after the last one sent',
- )
- );
- $this->clickLink('_qf_PledgeView_next-bottom', "xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[1]/a", FALSE);
- $this->waitForAjaxContent();
- $this->click("xpath=//form[@class='CRM_Pledge_Form_Search crm-search-form']//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[1]/a");
- $this->waitForElementPresent("xpath=//form[@class='CRM_Pledge_Form_Search crm-search-form']//div[@class='view-content']//table//tbody/tr[2]/td/div/table/tbody/tr[2]/td[8]/a[text()='Record Payment']");
- return $contact;
- }
-
- /**
- * Add a contact via profile
- */
- public function webtestAddViaCreateProfile() {
- $this->webtestLogin();
-
- $this->openCiviPage('profile/create', 'reset=1&gid=1', '_qf_Edit_next');
-
- $firstName = 'Jo' . substr(sha1(rand()), 0, 4);
- $lastName = 'Ad' . substr(sha1(rand()), 0, 7);
-
- //contact details section
- //fill in first name
- $this->type("first_name", $firstName);
-
- //fill in last name
- $this->type("last_name", $lastName);
-
- //address section
- $this->waitForElementPresent('street_address-1');
- $this->type("street_address-1", "902C El Camino Way SW");
- $this->waitForElementPresent('city-1');
- $this->type("city-1", "Dumfries");
- $this->type("postal_code-1", "1234");
- $this->assertSelected('country-1', "UNITED STATES");
- $this->select("state_province-1", "value=1019");
-
- // Clicking save.
- $this->click("_qf_Edit_next");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->assertElementContainsText('css=.msg-text', "Your information has been saved.");
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_ACL_AssignUsersToRolesTest
- */
-class WebTest_ACL_AssignUsersToRolesTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testAssignUsersToRoles() {
-
- $this->webtestLogin();
-
- $this->openCiviPage("group/add", "reset=1");
- $groupTitle = "testGroup" . substr(sha1(rand()), 0, 4);
- $this->type("title", $groupTitle);
- $this->click("group_type[1]");
- $this->click("_qf_Edit_upload-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->waitForText('crm-notification-container', "The Group '{$groupTitle}' has been saved.");
-
- $this->openCiviPage("admin/options/acl_role", "action=add&reset=1", "_qf_Options_cancel-bottom");
-
- $label = "TestAclRole" . substr(sha1(rand()), 0, 4);
- $this->type("label", $label);
- $this->type("value", "Acl value" . $label);
- $this->click("_qf_Options_next-bottom");
-
- $this->waitForText('crm-notification-container', "The ACL Role '{$label}' has been saved.");
-
- $this->openCiviPage("acl/entityrole", "action=add&reset=1");
-
- $this->select("acl_role_id", "label=" . $label);
- $this->select("entity_id", "label={$groupTitle}");
-
- $this->clickLink("_qf_EntityRole_next-botttom");
-
- $this->openCiviPage("acl", "action=add&reset=1");
- $this->click("group_id");
- $this->select("group_id", "label={$groupTitle}");
- $this->select("operation", "label=View");
- $this->select("entity_id", "label={$label}");
- $this->type("name", "describe {$label}");
- $this->clickLink("_qf_ACL_next-bottom");
- }
-
- /**
- * Check ACL for Smart Groups and Profiles.
- */
- public function testACLforSmartGroupsAndProfiles() {
- $this->webtestLogin();
-
- //Create role
- $role = 'role' . substr(sha1(rand()), 0, 7);
- $this->open($this->sboxPath . "admin/people/permissions/roles");
- $this->waitForAjaxContent();
- $this->type("edit-name", $role);
- $this->click("edit-add");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->open($this->sboxPath . "admin/people/permissions/roles");
- $this->waitForElementPresent("xpath=//table[@id='user-roles']/tbody//tr/td[1][text()='{$role}']");
- $roleURL = explode('/', $this->getAttribute("xpath=//table[@id='user-roles']/tbody//tr/td[1][text()='{$role}']/../td[4]/a[text()='edit permissions']/@href"));
- $roleId = end($roleURL);
-
- //create user with roleId
- $this->open($this->sboxPath . "admin/people/create");
- $this->waitForElementPresent("edit-submit");
- $user = "TestUser" . substr(sha1(rand()), 0, 4);
- $this->type("edit-name", $user);
- $emailId = substr(sha1(rand()), 0, 7) . '@web.com';
- $this->type("edit-mail", $emailId);
- $this->type("edit-pass-pass1", "Test12345");
- $this->type("edit-pass-pass2", "Test12345");
- $role = "edit-roles-" . $roleId;
- $this->check("name=roles[$roleId] value={$roleId}");
- $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
- $lastName = 'An' . substr(sha1(rand()), 0, 7);
- $this->type("first_name", $firstName);
- $this->type("last_name", $lastName);
- $this->click("edit-submit");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $permissions = array("edit-{$roleId}-access-civicrm");
- $this->changePermissions($permissions);
-
- //Create group and add your user's contact to that group
- $this->openCiviPage("group/add", "reset=1");
- $groupTitle = "testGroup" . substr(sha1(rand()), 0, 4);
- $this->type("title", $groupTitle);
- $this->click("group_type[1]");
- $this->click("_qf_Edit_upload-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForText('crm-notification-container', "The Group '{$groupTitle}' has been saved.");
- $this->waitForElementPresent("_qf_Basic_refresh");
- $this->type('sort_name', $firstName);
- $this->click('_qf_Basic_refresh');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForElementPresent("_qf_Basic_next_action");
- $this->assertTrue($this->isElementPresent("xpath=//table[@class='selector row-highlight']/tbody/tr/td[3]/a[text()='{$lastName}, {$firstName}']"));
- $this->click("xpath=//table[@class='selector row-highlight']/tbody//tr/td[1]/input[@type='checkbox']");
- $this->click('_qf_Basic_next_action');
- $this->waitForElementPresent("_qf_AddToGroup_back-bottom");
- $this->click('_qf_AddToGroup_next-bottom');
- $this->waitForText('crm-notification-container', "1 contact added to group");
-
- //create Smart Group
- $this->openCiviPage('contact/search/advanced', 'reset=1');
- $this->click("location");
- $this->waitForElementPresent("country");
- $this->select("country", "UNITED STATES");
- $this->clickLink("_qf_Advanced_refresh");
- $this->waitForElementPresent("task");
- $this->click('radio_ts', 'ts_all');
- $this->click('task');
- $this->select('task', 'label=Group - create smart group');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $smartGroupTitle = "SmartGroup" . substr(sha1(rand()), 0, 4);
- $this->type("title", $smartGroupTitle);
- $this->clickLink("_qf_SaveSearch_next-bottom");
- $this->waitForText('crm-notification-container', "Your smart group has been saved as '$smartGroupTitle'");
-
- //Create ACL role
- $this->openCiviPage("admin/options/acl_role", "reset=1", "xpath=//a[@class='button new-option']");
- $this->click("xpath=//a[@class='button new-option']");
- $label = "TestAclRole" . substr(sha1(rand()), 0, 4);
- $this->waitForElementPresent("label");
- $this->type("label", $label);
- $this->click("_qf_Options_next-bottom");
- $this->waitForText('crm-notification-container', "The ACL Role '{$label}' has been saved.");
-
- // Assign group to ACL role created
- $this->openCiviPage("acl/entityrole", "reset=1", 'newACL');
- $this->click('newACL');
- $this->waitForElementPresent("acl_role_id");
- $this->select("acl_role_id", "label=" . $label);
- $this->waitForAjaxContent();
- $this->select("entity_id", "label={$groupTitle}");
- $this->clickLink("_qf_EntityRole_next-botttom", 'newACL', FALSE);
-
- //Create ACL granting 'Edit' access on smart group to the role
- $this->waitForAjaxContent();
- $this->openCiviPage("acl", "reset=1");
- $this->click('newACL');
- $this->waitForElementPresent("group_id");
- $this->select("group_id", "label={$smartGroupTitle}");
- $this->select("operation", "label=Edit");
- $this->waitForAjaxContent();
- $this->select("entity_id", "label={$label}");
- $this->type("name", "describe {$label}");
- $this->clickLink("_qf_ACL_next-bottom", 'newACL', FALSE);
-
- //ACL granting edit permission on events.
- $this->waitForAjaxContent();
- $this->click('newACL');
- $this->waitForElementPresent('name');
- $this->type("name", "Edit All Events $label");
- $this->select("entity_id", "label={$label}");
- $this->waitForAjaxContent();
- $this->select("operation", "label=Edit");
- $this->click("xpath=//label[contains(text(), 'Events')]");
- $this->select("event_id", "value=0");
- $this->clickLink("_qf_ACL_next-bottom", 'newACL', FALSE);
-
- $this->webtestLogin($user, 'Test12345');
- $this->openCiviPage('event/manage/registration', 'reset=1&action=update&id=3');
- //ensure all the three buttons are not displayed
- $this->waitForElementPresent('registration_screen');
- $this->verifyElementNotPresent("xpath=//div[@id='registration_screen']/table[2]/tbody/tr/td[2]/div/div/button[contains(text(), 'Edit')]");
- $this->verifyElementNotPresent("xpath=//div[@id='registration_screen']/table[2]/tbody/tr/td[2]/div/div//button[contains(text(), 'Copy')]");
- $this->verifyElementNotPresent("xpath=//div[@id='registration_screen']/table[2]/tbody/tr/td[2]/div/div//button[contains(text(), 'Create')]");
- $this->webtestLogout();
-
- $this->webtestLogin();
-
- //Create ACL granting Edit permission on Profiles
- $this->openCiviPage("acl", "reset=1", 'newACL');
- $this->click('newACL');
- $this->waitForElementPresent('name');
- $this->type("name", "Edit All Profiles $label");
- $this->select("entity_id", "label={$label}");
- $this->select("operation", "label=Edit");
- $this->click("xpath=//label[contains(text(), 'A profile')]");
- $this->select("uf_group_id", "value=0");
- $this->clickLink("_qf_ACL_next-bottom", 'newACL', FALSE);
-
- //Login as your role user and do Find Contacts
- $this->webtestLogin($user, 'Test12345');
- $this->openCiviPage('contact/search/advanced', 'reset=1');
- $this->click("location");
- $this->waitForElementPresent("country");
- $this->select("country", "UNITED STATES");
- $this->clickLink("_qf_Advanced_refresh");
- $this->waitForElementPresent("xpath=//div[@class='crm-search-results']");
- $this->assertElementNotContainsText("xpath=//form[@id='Advanced']/div[3]/div/div", "No matches found for");
- $this->verifyText("xpath=//div[@class='crm-search-results']//table/tbody/tr[1]/td[8]", 'UNITED STATES');
-
- $this->checkEditOnEventProfile();
- }
-
- /**
- * CRM-16776 - Check Profile Edit on Events with 'manage event profile' permission.
- */
- public function testEventProfilePermission() {
- $this->webtestLogin();
-
- //create new role
- $role = 'role' . substr(sha1(rand()), 0, 7);
- $this->open($this->sboxPath . "admin/people/permissions/roles");
-
- $this->waitForAjaxContent();
- $this->type("edit-name", $role);
- $this->click("edit-add");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->open($this->sboxPath . "admin/people/permissions/roles");
- $this->waitForElementPresent("xpath=//table[@id='user-roles']/tbody//tr/td[1][text()='{$role}']");
- $roleId = explode('/', $this->getAttribute("xpath=//table[@id='user-roles']/tbody//tr/td[1][text()='{$role}']/../td[4]/a[text()='edit permissions']/@href"));
- $roleId = end($roleId);
-
- $this->open($this->sboxPath . "admin/people/create");
- $this->waitForElementPresent("edit-submit");
- $name = "TestUser" . substr(sha1(rand()), 0, 4);
- $this->type("edit-name", $name);
- $emailId = substr(sha1(rand()), 0, 7) . '@web.com';
- $this->type("edit-mail", $emailId);
- $this->type("edit-pass-pass1", "Test12345");
- $this->type("edit-pass-pass2", "Test12345");
- $role = "edit-roles-" . $roleId;
- $this->check("name=roles[$roleId] value={$roleId}");
-
- //Add profile Details
- $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
- $lastName = 'An' . substr(sha1(rand()), 0, 7);
- $this->type("first_name", $firstName);
- $this->type("last_name", $lastName);
-
- $this->click("edit-submit");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $permissions = array("edit-{$roleId}-access-civicrm", "edit-{$roleId}-edit-all-events", "edit-{$roleId}-manage-event-profiles");
- $this->changePermissions($permissions);
- $this->webtestLogout();
- $this->webtestLogin($name, 'Test12345');
- $this->checkEditOnEventProfile();
- }
-
- /**
- * Check Profile Edit on OnlineRegistration Tab
- */
- public function checkEditOnEventProfile() {
- $this->openCiviPage('event/manage/registration', 'reset=1&action=update&id=3');
- //ensure all the three buttons are displayed
- $this->waitForElementPresent("xpath=//div[@id='registration_screen']/table[2]/tbody/tr/td[2]/div/div/button[contains(text(), 'Edit')]");
- $this->waitForElementPresent("xpath=//div[@id='registration_screen']/table[2]/tbody/tr/td[2]/div/div//button[contains(text(), 'Copy')]");
- $this->waitForElementPresent("xpath=//div[@id='registration_screen']/table[2]/tbody/tr/td[2]/div/div//button[contains(text(), 'Create')]");
-
- $this->click("xpath=//div[@id='registration_screen']/table[2]/tbody/tr/td[2]/div/div/button[contains(text(), 'Edit')]");
- $this->waitForAjaxContent();
- $this->waitForElementPresent("//div[@class='crm-designer-fields-region']");
- if ($this->isElementPresent("xpath=//span[@class='crm-designer-label'][contains(text(), 'City')]")) {
- $this->click("xpath=//span[@class='crm-designer-label'][contains(text(), 'City')]/../../span//a[@title='Remove']");
- $this->waitForElementNotPresent("xpath=//span[@class='crm-designer-label'][contains(text(), 'City')]");
- }
- else {
- $this->click("xpath=//li[@class='crm-designer-palette-section jstree-closed']/a[contains(text(), 'Individual')]");
- $this->waitForAjaxContent();
- $this->doubleClick("xpath=//a[contains(text(), 'Individual')]/../ul//li/a[contains(text(), 'City')]");
- $this->waitForAjaxContent();
- }
- $this->click("xpath=//button/span[contains(text(), 'Save')]");
- $this->waitForElementPresent("crm-notification-container");
- $this->assertElementNotContainsText("crm-notification-container", 'API permission check failed for UFGroup/create call; insufficient permission: require administer CiviCRM');
- $this->click("_qf_Registration_upload-top");
- $this->waitForTextPresent("'Online Registration' information has been saved.");
- }
-
- /**
- * CRM-16777: Allow to add schedule reminder for event through ACLs 'edit' permission
- */
- public function testACLforReminders() {
- $this->webtestLogin('admin');
-
- //Details for ACLUser1
- $ACLrole1 = 'ACLrole1' . substr(sha1(rand()), 0, 7);
- $ACLUser1 = "ACLUser1" . substr(sha1(rand()), 0, 4);
- $emailId1 = substr(sha1(rand()), 0, 7) . '@web.com';
-
- //create ACLrole1 (with 'Access CiviCRM' and 'Access CiviEvent' permissions only).
- $this->open($this->sboxPath . "admin/people/permissions/roles");
- $this->type("edit-name", $ACLrole1);
- $this->waitForElementPresent("edit-add");
- $this->click("edit-add");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->open($this->sboxPath . "admin/people/permissions/roles");
- $this->waitForElementPresent("xpath=//table[@id='user-roles']/tbody//tr/td[1][text()='{$ACLrole1}']");
- $roleId = explode("people/permissions/", $this->getAttribute("xpath=//table[@id='user-roles']/tbody//tr/td[1][text()='{$ACLrole1}']/../td[4]/a[text()='edit permissions']/@href"));
- $permissions = array(
- "edit-{$roleId[1]}-access-civicrm",
- "edit-{$roleId[1]}-access-civievent",
- );
- $this->changePermissions($permissions);
-
- //Create ACLUser1
- $this->open($this->sboxPath . "admin/people/create");
- $this->waitForElementPresent("edit-submit");
- $this->type("edit-name", $ACLUser1);
- $this->type("edit-mail", $emailId1);
- $this->type("edit-pass-pass1", "Test12345");
- $this->type("edit-pass-pass2", "Test12345");
- $this->click("xpath=//div[@class='form-item form-type-checkboxes form-item-roles']/div//div/label[contains(text(), '{$ACLrole1}')]");
- $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
- $lastName = 'An' . substr(sha1(rand()), 0, 7);
- $this->type("first_name", $firstName);
- $this->type("last_name", $lastName);
- $this->type("street_address-1", "902C El Camino Way SW");
- $this->type("city-1", "Dumfries");
- $this->type("postal_code-1", "1234");
- $this->select("state_province-1", "value=1019");
- $this->click("edit-submit");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- //Create group and add contact.
- $this->openCiviPage('group/add', 'reset=1', '_qf_Edit_upload-bottom');
- $groupTitle = 'ACLGroup' . substr(sha1(rand()), 0, 7);
- $this->type("title", $groupTitle);
- $this->click("group_type_1");
- $this->click("_qf_Edit_upload-bottom");
- $this->waitForElementPresent('_qf_Basic_refresh');
- $this->type("sort_name", $firstName);
- $this->click('_qf_Basic_refresh');
- $this->waitForElementPresent('toggleSelect');
- $this->click('_qf_Basic_next_action');
- $this->waitForElementPresent('_qf_AddToGroup_back-bottom');
- $this->click('_qf_AddToGroup_next-bottom');
- $this->waitForTextPresent("1 contact added to group");
-
- //Add the ACLs
- $this->openCiviPage("admin/options/acl_role", "action=add&reset=1", "_qf_Options_cancel-bottom");
- $label = "TestAclRole" . substr(sha1(rand()), 0, 4);
- $this->type("label", $label);
- $this->type("value", "Acl value" . $label);
- $this->click("_qf_Options_next-bottom");
- $this->waitForText('crm-notification-container', "The ACL Role '{$label}' has been saved.");
- $this->waitForAjaxContent();
- $this->openCiviPage("acl/entityrole", "action=add&reset=1");
- $this->waitForAjaxContent();
- $this->select("acl_role_id", "label=" . $label);
- $this->waitForAjaxContent();
- $this->select("entity_id", "label={$groupTitle}");
- $this->clickLink("_qf_EntityRole_next-botttom");
- $this->openCiviPage("acl", "action=add&reset=1");
- $this->type("name", "Edit Events{$label}");
- $this->select("operation", "label=Edit");
- $this->select("entity_id", "label={$label}");
- $this->waitForElementPresent("xpath=//tr[@class='crm-acl-form-block-object_type']/td[2]/label[contains(text(), 'Events')]");
- $this->click("xpath=//tr[@class='crm-acl-form-block-object_type']/td[2]/label[contains(text(), 'Events')]");
- $this->select("event_id", "label=All Events");
- $this->clickLink("_qf_ACL_next-bottom");
- $this->webtestLogout();
- $this->webtestLogin($ACLUser1, 'Test12345');
-
- //Add scheduled reminder
- $this->openCiviPage("event/manage/reminder", "reset=1&action=browse&setTab=1&id=1");
- $reminderTitle = "Fall Fundraiser Dinner" . substr(sha1(rand()), 0, 4);
- $this->waitForElementPresent('newScheduleReminder');
- $this->click("newScheduleReminder");
- $this->waitForElementPresent("_qf_ScheduleReminders_next-bottom");
- $this->type("title", $reminderTitle);
- $this->select('entity', 'label=Registered');
- $this->select('start_action_offset', 'label=1');
- $this->select('start_action_condition', 'label=after');
- $this->click('is_repeat');
- $this->select('repetition_frequency_interval', 'label=2');
- $this->select('end_date', 'label=Event End Date');
- $this->click('recipient');
- $this->select('recipient', 'label=Participant Role');
- $subject = 'subject' . substr(sha1(rand()), 0, 4);
- $this->type('subject', $subject);
- $this->fillRichTextField("html_message", "This is the test HTML version here!!!", 'CKEditor');
- $this->type("text_message", "This is the test text version here!!!");
- $this->click('_qf_ScheduleReminders_next-bottom');
- $this->webtestLogout();
-
- //Disable the ACLs
- $this->webtestLogin('admin');
- $this->openCiviPage("acl", "reset=1");
- $this->waitForAjaxContent();
- $this->click("xpath=//div[contains(text(), 'Edit Events{$label}')]/../../td[7]/span/a[2][contains(text(), 'Disable')]");
- $this->waitForTextPresent("Are you sure you want to disable this ACL?");
- $this->click("xpath=//button//span[contains(text(), 'Yes')]");
-
- //Login with same test-user created above
- $this->webtestLogin($ACLUser1, 'Test12345');
- $this->openCiviPage("event/manage", "reset=1");
- $this->waitForElementPresent("xpath=//div[@id='event_status_id']/div[@class='dataTables_wrapper no-footer']");
- $this->verifyText("xpath=//div[@id='event_status_id']/div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td", "None found.");
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-/**
- * Description of AddRecurringActivityTest
- *
- * @author Priyanka
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Activity_AddRecurringActivityTest
- */
-class WebTest_Activity_AddRecurringActivityTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testRecurringActivity() {
- $this->webtestLogin();
-
- //Adding new contact
- $contact1 = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact("$contact1", "Karan", $contact1 . "@exampleone.com");
- $contact2 = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact("$contact2", "Jane", $contact2 . "@exampletwo.com");
-
- //Lets create an activity and add repeat configuration
- $this->openCiviPage("activity", "?reset=1&action=add&context=standalone", '_qf_Activity_cancel-bottom');
- $this->select("activity_type_id", "value=1");
-
- //Add a new contact
- $this->click("xpath=//div[@id='s2id_target_contact_id']/ul/li/input");
- $this->keyDown("xpath=//div[@id='s2id_target_contact_id']/ul/li/input", " ");
- $this->type("xpath=//div[@id='s2id_target_contact_id']/ul/li/input", $contact1);
- $this->typeKeys("xpath=//div[@id='s2id_target_contact_id']/ul/li/input", $contact1);
-
- // ...waiting for drop down with results to show up...
- $this->waitForElementPresent("xpath=//div[@class='select2-result-label']");
-
- // ...need to use mouseDownAt on first result (which is a li element), click does not work
- $this->clickAt("xpath=//div[@class='select2-result-label']");
- $this->waitForText("xpath=//div[@id='s2id_target_contact_id']", "$contact1");
- $this->assertElementContainsText("xpath=//div[@id='s2id_target_contact_id']", "Karan, $contact1", 'Contact not found in line ' . __LINE__);
-
- //Assigned To field
- $this->click("xpath=//div[@id='s2id_assignee_contact_id']/ul/li/input");
- $this->keyDown("xpath=//div[@id='s2id_assignee_contact_id']/ul/li/input", " ");
- $this->type("xpath=//div[@id='s2id_assignee_contact_id']/ul/li/input", $contact2);
- $this->typeKeys("xpath=//div[@id='s2id_assignee_contact_id']/ul/li/input", $contact2);
-
- // ...waiting for drop down with results to show up...
- $this->waitForElementPresent("xpath=//div[@class='select2-result-label']");
-
- //..need to use mouseDownAt on first result (which is a li element), click does not work
- $this->clickAt("xpath=//div[@class='select2-result-label']");
-
- // ...again, waiting for the box with contact name to show up...
- $this->waitForText("xpath=//div[@id='s2id_assignee_contact_id']", "$contact2");
-
- // ...and verifying if the page contains properly formatted display name for chosen contact.
- $this->assertElementContainsText("xpath=//div[@id='s2id_assignee_contact_id']", "Jane, $contact2", 'Contact not found in line ' . __LINE__);
-
- if ($this->isTextPresent("A copy of this activity will be emailed to each Assignee.")) {
- $isAssigneeNotificationEnabled = TRUE;
- }
-
- $subject = "Test activity recursion " . substr(sha1(rand()), 0, 7);
- $this->type("subject", $subject);
- $this->type("duration", "30");
-
- //Lets configure recursion for activity
- $this->click("css=.crm-activity-form-block-recurring_activity div.crm-accordion-header");
- $this->click('repetition_frequency_unit');
- $this->select('repetition_frequency_unit', 'label=month');
- $this->click('repetition_frequency_interval');
- $this->select('repetition_frequency_interval', 'label=1');
- $this->click('CIVICRM_QFID_1_repeats_by');
- $this->click('limit_to');
- $this->select('limit_to', 'label=26');
- $this->click('CIVICRM_QFID_1_ends');
-
- $occurrences = rand(3, 5);
- if (!$occurrences) {
- $occurrences = 3;
- }
- $this->type('start_action_offset', $occurrences);
- $this->click('_qf_Activity_upload-bottom');
- $this->waitForTextPresent('A repeating set will be created with the following dates.');
-
- $this->click("xpath=//div[@class='ui-dialog-buttonset']/button/span[text()='Continue']");
- $this->waitForPageToLoad();
-
- //Lets go to search screen and see if the records new activities are created()
- $this->openCiviPage("activity/search", "?reset=1", '_qf_Search_refresh');
- $this->type('activity_subject', $subject);
- $this->click('_qf_Search_refresh');
- $this->waitForPageToLoad();
-
- //Minus tr having th and parent activity
- $countOfActivities = $this->getXpathCount("//div[@class='crm-search-results']/table/tbody/tr");
- $countOfActivities = $countOfActivities - 2;
-
- if (!empty($isAssigneeNotificationEnabled)) {
- $countOfActivities--;
- }
-
- $this->assertEquals($occurrences, $countOfActivities);
- $this->assertTrue($this->isTextPresent("Repeating"));
-
- //Cascade changes
- $this->click("xpath=//div[@class='crm-search-results']/table/tbody/tr[2]/td/span/a[text()='Edit']");
- $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']/button/span[text()='Cancel']");
- $this->type('subject', "{$subject} modified");
- $this->click("xpath=//div[@class='ui-dialog-buttonset']/button/span[text()='Save']");
- $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']/button/span[text()='Cancel']");
- $this->click("xpath=//input[@id='recur-this-and-all-following-entity']");
- $this->waitForAjaxContent();
- $this->type('activity_subject', "{$subject} modified");
- $this->click('_qf_Search_refresh');
- $this->waitForPageToLoad();
- $countOfActivities = $this->getXpathCount("xpath=//div[@class='crm-search-results']/table/tbody/tr");
- if ($countOfActivities) {
- for ($i = 0; $i <= $countOfActivities; $i++) {
- $this->verifyText("xpath=//div[@class='crm-search-results']/table/tbody/tr/td[3]", 'Test activity recursion modified');
- }
- }
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Activity_ContactContextAddTest
- */
-class WebTest_Activity_ContactContextAddTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testContactContextActivityAdd() {
- $this->markTestSkipped('Skipping for now as it works fine locally.');
- $this->webtestLogin();
-
- // Adding Adding contact with randomized first name for test testContactContextActivityAdd
- // We're using Quick Add block on the main page for this.
- $firstName1 = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName1, "Summerson", $firstName1 . "@summerson.name");
- $firstName2 = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName2, "Anderson", $firstName2 . "@anderson.name");
- $this->click("css=li#tab_activity a");
-
- // waiting for the activity dropdown to show up
- $this->waitForElementPresent("other_activity");
-
- // Select the activity type from the activity dropdown
- $this->select("other_activity", "label=Meeting");
-
- // button at the end of this page to show up, to make sure it's fully loaded.
- $this->waitForElementPresent("_qf_Activity_upload");
-
- // ...and verifying if the page contains properly formatted display name for chosen contact.
- $this->waitForText("xpath=//div[@id='s2id_target_contact_id']", 'Anderson, ' . $firstName2);
-
- // Now we're filling the "Assigned To" field.
- // Typing contact's name into the field (using typeKeys(), not type()!)...
- $this->click("xpath=//div[@id='s2id_assignee_contact_id']/ul/li/input");
- $this->keyDown("xpath=//div[@id='s2id_assignee_contact_id']/ul/li/input", " ");
- $this->type("xpath=//div[@id='s2id_assignee_contact_id']/ul/li/input", $firstName1);
- $this->typeKeys("xpath=//div[@id='s2id_assignee_contact_id']/ul/li/input", $firstName1);
-
- // ...waiting for drop down with results to show up...
- $this->waitForElementPresent("xpath=//div[@class='select2-result-label']");
-
- // ...need to use mouseDownAt on first result (which is a li element), click does not work
- $this->clickAt("xpath=//div[@class='select2-result-label']");
-
- // ...again, waiting for the box with contact name to show up...
- $this->waitForText("xpath=//div[@id='s2id_assignee_contact_id']", "$firstName1");
-
- // ...and verifying if the page contains properly formatted display name for chosen contact.
- $this->assertElementContainsText("xpath=//div[@id='s2id_assignee_contact_id']", "Summerson, $firstName1", 'Contact not found in line ' . __LINE__);
-
- // Putting the contents into subject field - assigning the text to variable, it'll come in handy later
- $subject = "This is subject of test activity being added through activity tab of contact summary screen.";
- // For simple input fields we can use field id as selector
- $this->type("subject", $subject);
- $this->type("location", "Some location needs to be put in this field.");
-
- // Choosing the Date.
- // Please note that we don't want to put in fixed date, since
- // we want this test to work in the future and not fail because
- // of date being set in the past. Therefore, using helper webtestFillDateTime function.
- $this->webtestFillDateTime('activity_date_time', '+1 month 11:10PM');
-
- // Setting duration.
- $this->type("duration", "30");
-
- // Putting in details.
- $this->type("details", "Really brief details information.");
-
- // Making sure that status is set to Scheduled (using value, not label).
- $this->select("status_id", "value=1");
-
- // Setting priority.
- $this->select("priority_id", "value=1");
-
- // Adding attachment
- // TODO TBD
-
- // Scheduling follow-up.
- $this->click("css=.crm-activity-form-block-schedule_followup div.crm-accordion-header");
- $this->select("followup_activity_type_id", "value=1");
- $this->webtestFillDateTime('followup_date', '+2 months 10:00AM');
- $this->type("followup_activity_subject", "This is subject of schedule follow-up activity");
-
- // Clicking save.
- $this->click("_qf_Activity_upload");
-
- // Is status message correct?
- $this->waitForText('crm-notification-container', $subject);
- $this->waitForElementPresent("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[2]/td[8]/span[1]/a[1][text()='View']");
-
- // click through to the Activity view screen
- $this->click("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody//tr//td/div[text()='$subject']/../../td[8]/span[1]/a[1][text()='View']");
- $this->waitForElementPresent('_qf_Activity_cancel-bottom');
-
- // verify Activity created
- $this->webtestVerifyTabularData(
- array(
- 'Subject' => $subject,
- 'Location' => 'Some location needs to be put in this field.',
- 'Activity Status' => 'Scheduled',
- 'Duration' => '30',
- // Tough luck filling in WYSIWYG editor, so skipping verification for now.
- //'Details' => 'Really brief details information.',
- 'Priority' => 'Urgent',
- ),
- "/label"
- );
-
- $this->webtestVerifyTabularData(
- array(
- 'With Contact' => "Anderson, {$firstName2}",
- 'Assigned to' => "Summerson, {$firstName1}",
- ),
- "/label"
- );
- }
-
- public function testSeparateActivityForMultiTargetContacts() {
- $this->webtestLogin();
-
- //creating contacts
- $firstName1 = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName1, "Summerson", $firstName1 . "@summerson.name");
- $firstName2 = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName2, "Andersonnn", $firstName2 . "@anderson.name");
- $firstName3 = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName3, "Anderson", $firstName3 . "@andersonnn.name");
-
- $this->click("css=li#tab_activity a");
-
- // waiting for the activity dropdown to show up
- $this->waitForElementPresent("other_activity");
-
- // Select the activity type from the activity dropdown
- $this->select("other_activity", "label=Meeting");
-
- // ...and verifying if the page contains properly formatted display name for chosen contact.
- $this->waitForText("xpath=//div[@id='s2id_target_contact_id']", 'Anderson, ' . $firstName3, 'Contact not found in line ' . __LINE__);
-
- //filling the second target Contact
- $this->waitForAjaxContent();
- $this->click("xpath=//div[@id='s2id_target_contact_id']/ul/li/input");
- $this->keyDown("xpath=//div[@id='s2id_target_contact_id']/ul/li/input", " ");
- $this->type("xpath=//div[@id='s2id_target_contact_id']/ul/li/input", $firstName1);
- $this->typeKeys("xpath=//div[@id='s2id_target_contact_id']/ul/li/input", $firstName1);
-
- // ...waiting for drop down with results to show up...
- $this->waitForElementPresent("xpath=//div[@class='select2-result-label']");
-
- // ...need to use mouseDownAt on first result (which is a li element), click does not work
- $this->clickAt("xpath=//div[@class='select2-result-label']");
-
- // ...and verifying if the page contains properly formatted display name for chosen contact.
- $this->waitForText("xpath=//div[@id='s2id_target_contact_id']", "$firstName1", 'Contact not found in line ' . __LINE__);
-
- //filling the third target contact
- $this->waitForAjaxContent();
- $this->click("xpath=//div[@id='s2id_target_contact_id']/ul/li/input");
- $this->keyDown("xpath=//div[@id='s2id_target_contact_id']/ul/li/input", " ");
- $this->type("xpath=//div[@id='s2id_target_contact_id']/ul/li/input", $firstName2);
- $this->typeKeys("xpath=//div[@id='s2id_target_contact_id']/ul/li/input", $firstName2);
-
- // ...waiting for drop down with results to show up...
- $this->waitForElementPresent("xpath=//div[@class='select2-result-label']");
-
- // ...need to use mouseDownAt on first result (which is a li element), click does not work
- $this->clickAt("xpath=//div[@class='select2-result-label']");
-
- // ...and verifying if the page contains properly formatted display name for chosen contact.
- $this->waitForText("xpath=//div[@id='s2id_target_contact_id']", "$firstName2", 'Contact not found in line ' . __LINE__);
-
- //check the checkbox to create a separate activity for the selected target contacts
- $this->check('is_multi_activity');
-
- $subject = "This is subject of test activity for creating a separate activity for contacts {$firstName1},{$firstName2} and {$firstName3}.";
- $this->type("subject", $subject);
-
- $this->webtestFillDateTime('activity_date_time', '+1 month 11:10PM');
- $this->waitForAjaxContent();
- $this->select("status_id", "value=1");
-
- // Clicking save.
- $this->click('_qf_Activity_upload');
-
- // Is status message correct?
- $this->waitForText('crm-notification-container', $subject);
-
- //activity search page
- $this->openCiviPage('activity/search', 'reset=1');
-
- $this->type('activity_subject', $subject);
-
- $this->clickLink('_qf_Search_refresh');
-
- $targetContacts = array("Summerson, " . $firstName1, "Andersonnn, " . $firstName2, "Anderson, " . $firstName3);
-
- //check whether separate activities are created for the target contacts
- foreach ($targetContacts as $contact) {
- $this->assertTrue($this->isElementPresent("xpath=//div[@class='crm-search-results']/table/tbody//tr/td[5]/a[text()='$contact']"));
- }
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-require_once 'CiviTest/CiviMailUtils.php';
-
-/**
- * Class WebTest_Activity_IcalTest
- */
-class WebTest_Activity_IcalTest extends CiviSeleniumTestCase {
-
- // This variable is a bit awkward, but the ezc callback function needed to walk through the email parts needs to be static, so use this variable to "report back" on whether we found what we're looking for or not.
- private static $foundIt = FALSE;
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testStandaloneActivityAdd() {
- $this->webtestLogin();
-
- $this->openCiviPage("admin/setting/preferences/display", "reset=1", "name=activity_assignee_notification_ics");
-
- // Notify assignees should be checked by default, so we just need to click the ical setting which is off by default.
- $this->check("name=activity_assignee_notification_ics");
- $this->click("_qf_Display_next");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Start spooling emails
- $mailer = new CiviMailUtils($this, TRUE);
- self::$foundIt = FALSE;
-
- $firstName1 = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact("$firstName1", "Anderson", $firstName1 . "@anderson.com");
-
- $this->openCiviPage("activity", "reset=1&action=add&context=standalone", "_qf_Activity_upload");
-
- $this->select("activity_type_id", "value=1");
-
- $this->click("xpath=//div[@id='s2id_assignee_contact_id']/ul/li/input");
- // Because it tends to cause problems, all uses of sleep() must be justified in comments
- // Sleep should never be used for wait for anything to load from the server
- // Justification for this instance: tokeninput has a slight delay
- sleep(1);
- $this->keyDown("xpath=//div[@id='s2id_assignee_contact_id']/ul/li/input", " ");
- $this->type("xpath=//div[@id='s2id_assignee_contact_id']/ul/li/input", $firstName1);
- $this->typeKeys("xpath=//div[@id='s2id_assignee_contact_id']/ul/li/input", $firstName1);
-
- $this->waitForElementPresent("xpath=//div[@class='select2-result-label']");
- $this->clickAt("xpath=//div[@class='select2-result-label']");
- $this->waitForText("xpath=//div[@id='s2id_assignee_contact_id']", "$firstName1");
-
- $subject = "Testing Ical attachment for activity assignee";
- $this->type("subject", $subject);
-
- $location = 'Some location needs to be put in this field.';
- $this->type("location", $location);
-
- $this->webtestFillDateTime('activity_date_time', '+1 month 11:10PM');
- $this->select("status_id", "value=1");
-
- $this->click("_qf_Activity_upload");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->waitForText('crm-notification-container', $subject);
-
- // check the resulting email
- $mail = $mailer->getMostRecentEmail('ezc');
- $this->assertNotNull($mail, ts('Assignee email not generated or problem locating it.'));
- $this->assertEquals($mail->subject, "$subject");
- $context = new ezcMailPartWalkContext(array(get_class($this), 'mailWalkCallback'));
- $mail->walkParts($context, $mail);
-
- $mailer->stop();
-
- $this->assertTrue(self::$foundIt, ts('Generated email does not contain an ical attachment.'));
- }
-
- /**
- * @param $context
- * @param $mailPart
- */
- public static function mailWalkCallback($context, $mailPart) {
-
- $disp = $mailPart->contentDisposition;
- if ($disp) {
- if ($disp->disposition == 'attachment') {
- if ($mailPart instanceof ezcMailText) {
- if ($mailPart->subType == 'calendar') {
- // For now we just check for existence.
- self::$foundIt = TRUE;
- }
- }
- }
- }
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Activity_StandaloneAddTest
- */
-class WebTest_Activity_StandaloneAddTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testStandaloneActivityAdd() {
- $this->webtestLogin();
-
- // Adding Anderson, Anthony and Summerson, Samuel for testStandaloneActivityAdd test
- // We're using Quick Add block on the main page for this.
- $firstName1 = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact("$firstName1", "Anderson", $firstName1 . "@anderson.com");
- $firstName2 = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact("$firstName2", "Summerson", $firstName2 . "@summerson.com");
-
- $this->openCiviPage("activity", "reset=1&action=add&context=standalone", "_qf_Activity_upload");
-
- // Select one of the options in Activity Type selector. Use option value, not label - since labels can be translated and test would fail
- $this->select("activity_type_id", "value=1");
-
- // We're filling in ajaxiefied "With Contact" field:
- // We can not use id as selector for these input widgets. Use css selector, starting with the table row containing this field (which will have a unique class)
- // Typing contact's name into the field (using typeKeys(), not type()!)...
- $this->click("xpath=//div[@id='s2id_target_contact_id']/ul/li/input");
- $this->keyDown("xpath=//div[@id='s2id_target_contact_id']/ul/li/input", " ");
- $this->type("xpath=//div[@id='s2id_target_contact_id']/ul/li/input", $firstName1);
- $this->typeKeys("xpath=//div[@id='s2id_target_contact_id']/ul/li/input", $firstName1);
-
- // ...waiting for drop down with results to show up...
- $this->waitForElementPresent("xpath=//div[@class='select2-result-label']");
-
- // ...need to use mouseDownAt on first result (which is a li element), click does not work
- $this->clickAt("xpath=//div[@class='select2-result-label']");
-
- // ...again, waiting for the box with contact name to show up (span with delete token class indicates that it's present)...
- $this->waitForText("xpath=//div[@id='s2id_target_contact_id']", "$firstName1");
-
- //..and verifying if the page contains properly formatted display name for chosen contact.
- $this->assertElementContainsText("xpath=//div[@id='s2id_target_contact_id']", "Anderson, $firstName1", 'Contact not found in line ' . __LINE__);
-
- // Now we're doing the same for "Assigned To" field.
- // Typing contact's name into the field (using typeKeys(), not type()!)...
- $this->click("xpath=//div[@id='s2id_assignee_contact_id']/ul/li/input");
- $this->keyDown("xpath=//div[@id='s2id_assignee_contact_id']/ul/li/input", " ");
- $this->type("xpath=//div[@id='s2id_assignee_contact_id']/ul/li/input", $firstName2);
- $this->typeKeys("xpath=//div[@id='s2id_assignee_contact_id']/ul/li/input", $firstName2);
-
- // ...waiting for drop down with results to show up...
- $this->waitForElementPresent("xpath=//div[@class='select2-result-label']");
-
- //..need to use mouseDownAt on first result (which is a li element), click does not work
- $this->clickAt("xpath=//div[@class='select2-result-label']");
-
- // ...again, waiting for the box with contact name to show up...
- $this->waitForText("xpath=//div[@id='s2id_assignee_contact_id']", "$firstName2");
-
- // ...and verifying if the page contains properly formatted display name for chosen contact.
- $this->assertElementContainsText("xpath=//div[@id='s2id_assignee_contact_id']", "Summerson, $firstName2", 'Contact not found in line ' . __LINE__);
-
- // Putting the contents into subject field - assigning the text to variable, it'll come in handy later
- $subject = "This is subject of test activity being added through standalone screen.";
- // For simple input fields we can use field id as selector
- $this->type("subject", $subject);
-
- $location = 'Some location needs to be put in this field.';
- $this->type("location", $location);
-
- // Choosing the Date.
- // Please note that we don't want to put in fixed date, since
- // we want this test to work in the future and not fail because
- // of date being set in the past. Therefore, using helper webtestFillDate function.
- $this->webtestFillDateTime('activity_date_time', '+1 month 11:10PM');
-
- // Setting duration.
- $this->type("duration", "30");
-
- // Putting in details.
- $this->type("details", "Really brief details information.");
-
- // Making sure that status is set to Scheduled (using value, not label).
- $this->select("status_id", "value=1");
-
- // Setting priority.
- $this->select("priority_id", "value=1");
-
- // Adding attachment
- //FIX ME: need to fix file uploading
- //$this->waitForElementPresent("attachFile_1");
- //$filePath = $this->webtestAttachFile( "attachFile_1" );
-
- // Scheduling follow-up.
- $this->click("css=.crm-activity-form-block-schedule_followup div.crm-accordion-header");
- $this->select("followup_activity_type_id", "value=1");
- $this->webtestFillDateTime('followup_date', '+2 months 10:00AM');
- $this->type("followup_activity_subject", "This is subject of schedule follow-up activity");
-
- // Clicking save.
- $this->clickLink('_qf_Activity_upload');
-
- // Is status message correct?
- $this->waitForText('crm-notification-container', "Activity '$subject' has been saved.");
-
- $this->openCiviPage("activity/search", "reset=1", "_qf_Search_refresh");
-
- $this->type("sort_name", $firstName1);
- $this->click("_qf_Search_refresh");
-
- $this->waitForElementPresent("xpath=//table[@class='selector row-highlight']/tbody//tr/td[6]/a[text()='Summerson, $firstName2']/../../td[9]/span/a[text()='View']");
- $this->click("xpath=//table[@class='selector row-highlight']/tbody//tr/td[6]/a[text()='Summerson, $firstName2']/../../td[9]/span/a[text()='View']");
- $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']/button[3]/span[2]");
-
- $this->VerifyTabularData(
- array(
- 'Subject' => $subject,
- 'Location' => $location,
- 'Activity Status' => 'Scheduled',
- 'Duration' => '30',
- // Tough luck filling in WYSIWYG editor, so skipping verification for now.
- //'Details' => 'Really brief details information.',
- 'Priority' => 'Urgent',
- //'Current Attachment(s)' => basename($filePath)
- ),
- "/label"
- );
-
- $this->VerifyTabularData(
- array(
- 'With Contact' => "Anderson, {$firstName1}",
- 'Assigned to' => "Summerson, {$firstName2}",
- ),
- "/label"
- );
-
- //CRM-17395 -- Test Activity Report for Target Contact Filter
- $this->openCiviPage('report/instance/3', 'reset=1', '_qf_Activity_submit');
- $this->click("//a[contains(text(),'Filters')]");
- $this->waitForElementPresent('contact_target_value');
- $this->select('activity_date_time_relative', '- any -');
- $this->type('contact_target_value', $firstName1);
- $this->clickLink('_qf_Activity_submit');
- $this->assertElementContainsText("//table[@class='report-layout display']/tbody/tr//td[@class='crm-report-civicrm_contact_contact_target']/a", "Anderson, {$firstName1}");
- }
-
- public function testAjaxCustomGroupLoad() {
- $this->webtestLogin();
- $triggerElement = array('name' => 'activity_type_id', 'type' => 'select');
- $customSets = array(
- array('entity' => 'Activity', 'subEntity' => 'Interview', 'triggerElement' => $triggerElement),
- array('entity' => 'Activity', 'subEntity' => 'Meeting', 'triggerElement' => $triggerElement),
- );
-
- $pageUrl = array('url' => 'activity', 'args' => 'reset=1&action=add&context=standalone');
- $this->customFieldSetLoadOnTheFlyCheck($customSets, $pageUrl);
- }
-
- /**
- * @param $expected
- * @param null $xpathPrefix
- */
- public function VerifyTabularData($expected, $xpathPrefix = NULL) {
- foreach ($expected as $label => $value) {
- $this->waitForElementPresent("xpath=//table/tbody/tr/td{$xpathPrefix}[text()='{$label}']/../following-sibling::td/span");
- $this->verifyText("xpath=//table/tbody/tr/td{$xpathPrefix}[text()='{$label}']/../following-sibling::td/span", preg_quote($value));
- }
- }
-
- /**
- * CRM-17656 - Test Activity using Custom Data
- */
- public function testActivityCustomData() {
- $this->webtestLogin();
-
- // Create new Custom Field Set
- $this->openCiviPage('admin/custom/group', 'reset=1');
- $this->click("css=#newCustomDataGroup > span");
- $this->waitForElementPresent('_qf_Group_next-bottom');
- $customFieldSet = 'ActivityFieldset' . rand();
- $this->type("id=title", $customFieldSet);
- $this->select("id=extends_0", "label=Activities");
- $this->addSelection("extends_1", "- Any -");
- $this->click("id=collapse_display");
- $this->clickLink("id=_qf_Group_next-bottom");
- $this->waitForText('crm-notification-container', "Your custom field set '$customFieldSet' has been added.");
- $this->waitForElementPresent('_qf_Field_done-bottom');
-
- // Add field to fieldset
- $customField = 'TestCustomField' . rand();
- $this->type("id=label", $customField);
- $this->select("id=data_type_0", "value=0");
- $this->click("is_required");
- $this->click("id=_qf_Field_done-bottom");
- $this->waitForText('crm-notification-container', "Custom field '$customField' has been saved.");
- $textFieldId = explode('&id=', $this->getAttribute("xpath=//table[@id='options']/tbody//tr/td[1]/div[text()='$customField']/../../td[8]/span/a[1][text()='Edit Field']/@href"));
- $textFieldId = $textFieldId[1];
-
- $fname = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact("$fname", "Anderson", $fname . "@anderson.com");
-
- $this->openCiviPage("activity", "reset=1&action=add&context=standalone", "_qf_Activity_upload");
- $this->select("activity_type_id", "value=1");
- $this->select2('target_contact_id', $fname, TRUE);
- $subject = "This is subject of test activity being added through standalone screen.";
- $this->type("subject", $subject);
- $textField = 'This is test custom data';
- $this->type("custom_{$textFieldId}_-1", $textField);
- // Clicking save.
- $this->clickLink('_qf_Activity_upload');
- $this->waitForText('crm-notification-container', "Activity '$subject' has been saved.");
-
- $this->openCiviPage("activity/search", "reset=1", "_qf_Search_refresh");
- $this->type("sort_name", $fname);
- $this->click("_qf_Search_refresh");
-
- $this->waitForElementPresent("xpath=//table[@class='selector row-highlight']/tbody//tr/td[5]/a[text()='Anderson, {$fname}']/../../td[9]/span/a[text()='View']");
- $this->click("xpath=//table[@class='selector row-highlight']/tbody//tr/td[5]/a[text()='Anderson, {$fname}']/../../td[9]/span/a[text()='View']");
- $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']/button[3]/span[2]");
-
- $this->VerifyTabularData(
- array(
- 'Subject' => $subject,
- 'Activity Status' => 'Scheduled',
- ),
- "/label"
- );
- $this->verifyText("xpath=//td[text()='{$customField}']/following-sibling::td", preg_quote($textField), 'In line ' . __LINE__);
-
- $this->clickAjaxLink("xpath=//button//span[contains(text(),'Edit')]", "xpath=//div[@class='ui-dialog-buttonset']/button[1]/span[contains(text(),'Save')]");
-
- $editedTextField = 'This is test custom data - Edited';
- $this->type("custom_{$textFieldId}_1", $editedTextField);
- $this->clickAjaxLink("xpath=//div[@class='ui-dialog-buttonset']/button[1]/span[contains(text(),'Save')]", "xpath=//button//span[contains(text(),'Edit')]");
- $this->verifyText("xpath=//td[text()='{$customField}']/following-sibling::td", preg_quote($editedTextField), 'In line ' . __LINE__);
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Admin_CustomAddTest
- */
-class WebTest_Admin_CustomAddTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testCustomAdd() {
- $this->webtestLogin();
-
- $this->openCiviPage("admin/custom/group", "action=add&reset=1");
-
- //fill custom group title
- $customGroupTitle = 'custom_group' . substr(sha1(rand()), 0, 3);
- $this->click("title");
- $this->type("title", $customGroupTitle);
-
- //custom group extends
- $this->click("extends[0]");
- $this->select("extends[0]", "label=Contacts");
- $this->click("//option[@value='Contact']");
- $this->click("//form[@id='Group']/div[2]/div[3]/span[1]/input");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForElementPresent('newCustomField');
-
- //Is custom group created?
- $this->waitForText('crm-notification-container', "Your custom field set '$customGroupTitle' has been added. You can add custom fields now.");
-
- //add custom field - alphanumeric text
- $this->waitForElementPresent('_qf_Field_cancel-bottom');
- $textFieldLabel = 'test_text_field' . substr(sha1(rand()), 0, 3);
- $this->click("header");
- $this->type("label", $textFieldLabel);
- $this->click("_qf_Field_next_new-bottom");
- $this->waitForElementPresent('_qf_Field_cancel-bottom');
- $this->click("data_type[0]");
- $this->select("data_type[0]", "value=0");
- $this->click("//option[@value='0']");
- $this->click("data_type[1]");
- $this->select("data_type[1]", "label=CheckBox");
- $this->click("//option[@value='CheckBox']");
-
- $checkboxFieldLabel = 'test_checkbox' . substr(sha1(rand()), 0, 5);
- $this->type("label", $checkboxFieldLabel);
- $checkboxOptionLabel1 = 'check1' . substr(sha1(rand()), 0, 3);
- $this->type("option_label_1", $checkboxOptionLabel1);
- $this->type("option_value_1", "1");
- $checkboxOptionLabel2 = 'check2' . substr(sha1(rand()), 0, 3);
- $this->type("option_label_2", $checkboxOptionLabel2);
- $this->type("option_value_2", "2");
- $this->click("link=add another choice");
- $checkboxOptionLabel3 = 'check3' . substr(sha1(rand()), 0, 3);
- $this->type("option_label_3", $checkboxOptionLabel3);
- $this->type("option_value_3", "3");
- $this->click("link=add another choice");
- $checkboxOptionLabel4 = 'check4' . substr(sha1(rand()), 0, 3);
- $this->type("option_label_4", $checkboxOptionLabel4);
- $this->type("option_value_4", "4");
-
- //enter options per line
- $this->type("options_per_line", "2");
-
- //enter pre help message
- $this->type("help_pre", "this is field pre help");
-
- //enter post help message
- $this->type("help_post", "this field post help");
-
- //Is searchable?
- $this->click("is_searchable");
-
- //clicking save
- $this->click("_qf_Field_next_new-bottom");
- $this->waitForElementPresent('_qf_Field_cancel-bottom');
-
- //create another custom field - Number Radio
- $this->click("data_type[0]");
- $this->select("data_type[0]", "value=2");
- $this->click("//option[@value='2']");
- $this->click("data_type[1]");
- $this->select("data_type[1]", "value=Radio");
- $this->click("//option[@value='Radio']");
-
- $radioFieldLabel = 'test_radio' . substr(sha1(rand()), 0, 5);
- $this->type("label", $radioFieldLabel);
- $radioOptionLabel1 = 'radio1' . substr(sha1(rand()), 0, 3);
- $this->type("option_label_1", $radioOptionLabel1);
- $this->type("option_value_1", "1");
- $radioOptionLabel2 = 'radio2' . substr(sha1(rand()), 0, 3);
- $this->type("option_label_2", $radioOptionLabel2);
- $this->type("option_value_2", "2");
-
- //select options per line
- $this->type("options_per_line", "3");
-
- //enter pre help msg
- $this->type("help_pre", "this is field pre help");
-
- //enter post help msg
- $this->type("help_post", "this is field post help");
-
- //Is searchable?
- $this->click("is_searchable");
-
- //clicking save
- $this->click("_qf_Field_done-bottom");
- $this->waitForElementPresent('newCustomField');
-
- //On New Individual contact form
- $this->openCiviPage("contact/add", "ct=Individual&reset=1");
- $this->assertElementContainsText('page-title', "New Individual");
-
- //expand all tabs
- $this->click("expand");
- $this->waitForElementPresent("address_1_street_address");
-
- //verify custom group fields are present on new Individual Contact Form
- $this->assertElementContainsText('customData', $textFieldLabel);
- $this->assertElementContainsText('customData', $checkboxFieldLabel);
- $this->assertElementContainsText('customData', $checkboxOptionLabel1);
- $this->assertElementContainsText('customData', $checkboxOptionLabel2);
- $this->assertElementContainsText('customData', $checkboxOptionLabel3);
- $this->assertElementContainsText('customData', $checkboxOptionLabel4);
- $this->assertElementContainsText('customData', $radioFieldLabel);
- $this->assertElementContainsText('customData', $radioOptionLabel1);
- $this->assertElementContainsText('customData', $radioOptionLabel2);
-
- //On New Household contact form
- $this->openCiviPage("contact/add", "ct=Household&reset=1");
- $this->assertElementContainsText('page-title', "New Household");
-
- //expand all tabs
- $this->click("expand");
- $this->waitForElementPresent("address_1_street_address");
-
- //verify custom group fields are present on new household Contact Form
- $this->assertElementContainsText('customData', $textFieldLabel);
- $this->assertElementContainsText('customData', $checkboxFieldLabel);
- $this->assertElementContainsText('customData', $checkboxOptionLabel1);
- $this->assertElementContainsText('customData', $checkboxOptionLabel2);
- $this->assertElementContainsText('customData', $checkboxOptionLabel3);
- $this->assertElementContainsText('customData', $checkboxOptionLabel4);
- $this->assertElementContainsText('customData', $radioFieldLabel);
- $this->assertElementContainsText('customData', $radioOptionLabel1);
- $this->assertElementContainsText('customData', $radioOptionLabel2);
-
- //On New Organization contact form
- $this->openCiviPage("contact/add", "ct=Organization&reset=1");
- $this->assertElementContainsText('page-title', "New Organization");
-
- //expand all tabs
- $this->click("expand");
- $this->waitForElementPresent("address_1_street_address");
-
- //verify custom group fields are present on new Organization Contact Form
- $this->assertElementContainsText('customData', $textFieldLabel);
- $this->assertElementContainsText('customData', $checkboxFieldLabel);
- $this->assertElementContainsText('customData', $checkboxOptionLabel1);
- $this->assertElementContainsText('customData', $checkboxOptionLabel2);
- $this->assertElementContainsText('customData', $checkboxOptionLabel3);
- $this->assertElementContainsText('customData', $checkboxOptionLabel4);
- $this->assertElementContainsText('customData', $radioFieldLabel);
- $this->assertElementContainsText('customData', $radioOptionLabel1);
- $this->assertElementContainsText('customData', $radioOptionLabel2);
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Admin_CustomAddTestSameField
- */
-class WebTest_Admin_CustomAddTestSameField extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testCustomSameFieldAdd() {
- $this->open($this->sboxPath);
- $this->webtestLogin();
-
- $this->_testCustomAdd();
- $this->_testCustomAdd();
- }
-
- public function _testCustomAdd() {
- //CRM-7564 : Different gropus can contain same custom fields
- $this->open($this->sboxPath . "civicrm/admin/custom/group?action=add&reset=1");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- //fill custom group title
- $customGroupTitle = 'custom_group' . substr(sha1(rand()), 0, 3);
- $this->click("title");
- $this->type("title", $customGroupTitle);
-
- //custom group extends
- $this->click("extends[0]");
- $this->select("extends[0]", "label=Contacts");
- $this->click("//option[@value='Contact']");
- $this->clickLink("//form[@id='Group']/div[2]/div[3]/span[1]/input");
-
- //Is custom group created?
- $this->waitForText('crm-notification-container', "Your custom field set '$customGroupTitle' has been added. You can add custom fields now.");
-
- $gid = $this->urlArg('gid');
-
- //add custom field - alphanumeric text
- $this->openCiviPage('admin/custom/group/field/add', "reset=1&action=add&gid=$gid");
- $textFieldLabel = 'test_text_field';
- $this->click("header");
- $this->waitForElementPresent('label');
- $this->type("label", $textFieldLabel);
- $this->click("_qf_Field_next_new-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->click("data_type[0]");
- $this->select("data_type[0]", "value=0");
- $this->click("//option[@value='0']");
- $this->click("data_type[1]");
- $this->select("data_type[1]", "label=CheckBox");
- $this->click("//option[@value='CheckBox']");
-
- $checkboxFieldLabel = 'test_checkbox';
- $this->waitForElementPresent('label');
- $this->type("label", $checkboxFieldLabel);
- $checkboxOptionLabel1 = 'check1';
- $this->type("option_label_1", $checkboxOptionLabel1);
- $this->type("option_value_1", "1");
- $checkboxOptionLabel2 = 'check2';
- $this->type("option_label_2", $checkboxOptionLabel2);
- $this->type("option_value_2", "2");
- $this->click("link=another choice");
- $checkboxOptionLabel3 = 'check3';
- $this->type("option_label_3", $checkboxOptionLabel3);
- $this->type("option_value_3", "3");
- $this->click("link=another choice");
- $checkboxOptionLabel4 = 'check4';
- $this->type("option_label_4", $checkboxOptionLabel4);
- $this->type("option_value_4", "4");
-
- //enter options per line
- $this->type("options_per_line", "2");
-
- //enter pre help message
- $this->type("help_pre", "this is field pre help");
-
- //enter post help message
- $this->type("help_post", "this field post help");
-
- //Is searchable?
- $this->click("is_searchable");
-
- //clicking save
- $this->clickLink("_qf_Field_next_new-bottom");
-
- //Is custom field created?
- $this->waitForText('crm-notification-container', "Custom field '$checkboxFieldLabel' has been saved.");
-
- //add custom field - alphanumeric text
- $textFieldLabel = 'test_text_field';
- $this->click("header");
- $this->waitForElementPresent('label');
- $this->type("label", $textFieldLabel);
- $this->clickLink("_qf_Field_next_new-bottom");
-
- // Same group will not contain same custome fields so will show error for this field :
- $this->click("data_type[0]");
- $this->select("data_type[0]", "value=0");
- $this->click("//option[@value='0']");
- $this->click("data_type[1]");
- $this->select("data_type[1]", "label=CheckBox");
- $this->click("//option[@value='CheckBox']");
- //Is custom field created
- $this->waitForText('crm-notification-container', "Custom field '$textFieldLabel' already exists in Database.");
-
- //create another custom field - Number Radio
- $this->click("data_type[0]");
- $this->select("data_type[0]", "value=2");
- $this->click("//option[@value='2']");
- $this->click("data_type[1]");
- $this->select("data_type[1]", "value=Radio");
- $this->click("//option[@value='Radio']");
-
- $radioFieldLabel = 'test_radio';
- $this->waitForElementPresent('label');
- $this->type("label", $radioFieldLabel);
- $radioOptionLabel1 = 'radio1';
- $this->type("option_label_1", $radioOptionLabel1);
- $this->type("option_value_1", "1");
- $radioOptionLabel2 = 'radio2';
- $this->type("option_label_2", $radioOptionLabel2);
- $this->type("option_value_2", "2");
-
- //select options per line
- $this->type("options_per_line", "3");
-
- //enter pre help msg
- $this->type("help_pre", "this is field pre help");
-
- //enter post help msg
- $this->type("help_post", "this is field post help");
-
- //Is searchable?
- $this->click("is_searchable");
-
- //clicking save
- $this->clickLink("_qf_Field_done-bottom");
-
- //Is custom field created
- $this->waitForText('crm-notification-container', "Custom field '$radioFieldLabel' has been saved.");
-
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Admin_Form_ScheduleReminderTest
- */
-class WebTest_Admin_Form_ScheduleReminderTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testScheduleReminder() {
- $this->webtestLogin();
-
- // Add new Schedule Reminder
- $this->openCiviPage("admin/scheduleReminders", "action=add&reset=1", '_qf_ScheduleReminders_cancel-bottom');
-
- // Fill Title
- $title = 'Title' . substr(sha1(rand()), 0, 4);
- $htmlMessage = "Schedule Reminder Test";
- $this->type('title', $title);
-
- // Fill Entity Details
- $this->click('entity_0');
- $this->select('entity_0', 'label=Activity');
- $this->addSelection('entity_1', 'label=Meeting');
- $this->addSelection('entity_2', 'label=Completed');
- $this->select('start_action_offset', 'label=1');
- $this->select('start_action_condition', 'label=after');
- $this->click('is_repeat');
- $this->select('repetition_frequency_interval', 'label=1');
- $this->click('recipient');
- $this->select('recipient', 'label=Activity Assignees');
-
- // Fill Subject
- $subject = 'subject' . substr(sha1(rand()), 0, 4);
- $this->type('subject', $subject);
- $this->waitForElementPresent("html_message");
- $this->fillRichTextField("html_message", $htmlMessage);
-
- //click on save
- $this->click('_qf_ScheduleReminders_next-bottom');
- $this->waitForElementPresent("xpath=//div[@id='reminder']/div/table/tbody//tr/td[1]/div[text()='{$title}']/../../td[7]/span/a[text()='Edit']");
- $this->click("xpath=//div[@id='reminder']/div/table/tbody//tr/td[1]/div[text()='{$title}']/../../td[7]/span/a[text()='Edit']");
- $this->waitForElementPresent('_qf_ScheduleReminders_cancel-bottom');
-
- $this->assertEquals($title, $this->getValue('id=title'));
- $this->removeSelection('entity_1', 'label=Meeting');
- $this->addSelection('entity_1', 'label=Phone Call');
- $this->addSelection('entity_1', 'label=Interview');
- $this->removeSelection('entity_2', 'label=Completed');
- $this->addSelection('entity_2', 'label=Scheduled');
- $this->addSelection('entity_2', 'label=Completed');
-
- $this->assertEquals('1', $this->getSelectedValue('id=start_action_offset'));
- $this->assertEquals('hour', $this->getSelectedValue('id=start_action_unit'));
- $this->assertEquals('after', $this->getSelectedValue('id=start_action_condition'));
- $this->assertEquals('activity_date_time', $this->getSelectedValue('id=start_action_date'));
-
- $this->assertChecked('is_repeat');
-
- $this->assertEquals('1', $this->getSelectedValue('id=recipient'));
- $this->assertChecked('is_active');
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Admin_Form_Setting_LocalizationTest
- */
-class WebTest_Admin_Form_Setting_DebuggingTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testSetCivicrmEnvironment() {
- $this->webtestLogin();
- $this->openCiviPage('admin/setting/debug', 'reset=1');
- $this->select('environment', 'Staging');
- $this->click('_qf_Debugging_next-top');
-
- $this->waitForPageToLoad($this->getTimeoutMsec());
- try {
- $this->assertFalse($this->isTextPresent('Your changes have been saved.'));
- }
- catch (PHPUnit_Framework_AssertionFailedError$e) {
- array_push($this->verificationErrors, $e->toString());
- }
- $envi = $this->getValue("environment");
- $this->assertEquals('Staging', $envi);
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Admin_Form_Setting_LocalizationTest
- */
-class WebTest_Admin_Form_Setting_LocalizationTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testDefaultCountryIsEnabled() {
- $this->webtestLogin();
- $this->openCiviPage("admin/setting/localization", "reset=1");
- $this->addSelection("countryLimit", "label=UNITED STATES");
- $this->click("//select[@id='countryLimit']/option");
- $this->click("//input[@name='remove']");
- $this->addSelection("countryLimit", "label=AFGHANISTAN");
- $this->removeSelection("countryLimit", "label=AFGHANISTAN");
- $this->addSelection("countryLimit", "label=CAMBODIA");
- $this->removeSelection("countryLimit", "label=CAMBODIA");
- $this->addSelection("countryLimit", "label=CAMEROON");
- $this->removeSelection("countryLimit", "label=CAMEROON");
- $this->addSelection("countryLimit", "label=CANADA");
- $this->click("//input[@name='add']");
- $this->click("_qf_Localization_next-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- try {
- $this->assertFalse($this->isTextPresent("Your changes have been saved."));
- }
- catch (PHPUnit_Framework_AssertionFailedError$e) {
- array_push($this->verificationErrors, $e->toString());
- }
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Admin_MoveCustomDataTest
- */
-class WebTest_Admin_MoveCustomDataTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testCreateCustomFields() {
- $this->webtestLogin();
-
- $cid_all = $this->_createContact("all_data", "move_custom_data");
- $cid_from_missing = $this->_createContact("source_missing", "move_custom_data");
- $cid_to_missing = $this->_createContact("destination_missing", "move_custom_data");
-
- $from_group_id = $this->_buildCustomFieldSet("source");
- CRM_Utils_System::flushCache();
- $to_group_id = $this->_buildCustomFieldSet("destination");
-
- $this->_fillCustomDataForContact($cid_all, $from_group_id);
- $this->_fillCustomDataForContact($cid_to_missing, $from_group_id);
-
- $this->_fillCustomDataForContact($cid_all, $to_group_id);
- $this->_fillCustomDataForContact($cid_from_missing, $to_group_id);
-
- //to verify data hasn't been lost, we load the values for each contact
- $pre_move_values = array();
- $pre_move_values[$cid_all]['source'] = $this->_loadDataFromApi($cid_all, $from_group_id);
- $pre_move_values[$cid_all]['destination'] = $this->_loadDataFromApi($cid_all, $to_group_id);
- $pre_move_values[$cid_from_missing]['source'] = $this->_loadDataFromApi($cid_from_missing, $from_group_id);
- $pre_move_values[$cid_from_missing]['destination'] = $this->_loadDataFromApi($cid_from_missing, $to_group_id);
- $pre_move_values[$cid_to_missing]['source'] = $this->_loadDataFromApi($cid_to_missing, $from_group_id);
- $pre_move_values[$cid_to_missing]['destination'] = $this->_loadDataFromApi($cid_to_missing, $to_group_id);
-
- //ok, so after all that setup, we are now good to actually move a field
-
- //first, pick a random field from the source group to move
- $fields = $this->webtest_civicrm_api("CustomField", "get", array('custom_group_id' => $from_group_id));
- $field_to_move = array_rand($fields['values']);
-
- //move the field
- $this->_moveCustomField($field_to_move, $from_group_id, $to_group_id);
-
- //now lets verify the data, load up the new values from the api...
- $post_move_values = array();
- $post_move_values[$cid_all]['source'] = $this->_loadDataFromApi($cid_all, $from_group_id, TRUE);
- $post_move_values[$cid_all]['destination'] = $this->_loadDataFromApi($cid_all, $to_group_id);
- $post_move_values[$cid_from_missing]['source'] = $this->_loadDataFromApi($cid_from_missing, $from_group_id);
- $post_move_values[$cid_from_missing]['destination'] = $this->_loadDataFromApi($cid_from_missing, $to_group_id);
- $post_move_values[$cid_to_missing]['source'] = $this->_loadDataFromApi($cid_to_missing, $from_group_id);
- $post_move_values[$cid_to_missing]['destination'] = $this->_loadDataFromApi($cid_to_missing, $to_group_id);
-
- // Make sure that only the appropriate values have changed.
- foreach (array(
- $cid_all,
- $cid_from_missing,
- $cid_to_missing,
- ) as $cid) {
- foreach (array(
- 'source',
- 'destination',
- ) as $fieldset) {
- foreach ($pre_move_values[$cid][$fieldset] as $id => $value) {
- if ($id != $field_to_move) {
- //All fields that were there should still be there
- $this->assertTrue(isset($post_move_values[$cid][$fieldset][$id]), "A custom field that was not moved is missing!");
- //All fields should have the same value as when we started
- $this->assertTrue($post_move_values[$cid][$fieldset][$id] == $value, "A custom field value has changed in the source custom field set");
- }
- }
- }
- //check that the field is actually moved
- $this->assertTrue(!isset($post_move_values[$cid]['source'][$field_to_move]), "Moved field is still present in the source fieldset");
- $this->assertTrue(isset($post_move_values[$cid]['destination'][$field_to_move]), "Moved field is not present in the destination fieldset");
- $this->assertTrue($pre_move_values[$cid]['source'][$field_to_move] == $post_move_values[$cid]['destination'][$field_to_move], "The moved field has changed values!");
- }
-
- //Go to the contacts page and check that the custom field is in the right group
- $this->openCiviPage('contact/view', "reset=1&cid={$cid_all}");
-
- //load the names of the custom fieldsets
- $source = $this->webtest_civicrm_api("CustomGroup", "get", array('id' => $from_group_id));
- $source = $source['values'][$from_group_id];
- $destination = $this->webtest_civicrm_api("CustomGroup", "get", array('id' => $to_group_id));
- $destination = $destination['values'][$to_group_id];
-
- //assert that the moved custom field is missing from the source fieldset
- $this->assertElementNotContainsText("css=div." . $source['name'], $fields['values'][$field_to_move]['label'], "Moved value still displays in the old fieldset on the contact record");
- $this->assertElementContainsText("css=div." . $destination['name'], $fields['values'][$field_to_move]['label'], "Moved value does not display in the new fieldset on the contact record");
- }
-
- /**
- * moves a field from one field to another.
- * @param $field_to_move
- * @param int $from_group_id
- * @param int $to_group_id
- */
- public function _moveCustomField($field_to_move, $from_group_id, $to_group_id) {
- //go to the move field page
- $this->openCiviPage('admin/custom/group/field/move', "reset=1&fid={$field_to_move}");
-
- //select the destination field set from select box
- $this->click("dst_group_id");
- $this->select("dst_group_id", "value=" . $to_group_id);
- $this->click("//option[@value='" . $to_group_id . "']");
-
- //click the save button
- $this->click("_qf_MoveField_next");
-
- //assert that the success text is present
- $this->waitForText('crm-notification-container', "has been moved");
-
- //assert that the custom field not on old data set page
-
- $this->assertTrue(!$this->isElementPresent("CustomField-" . $field_to_move), "The moved custom field still displays on the old fieldset page");
-
- //go to the destination fieldset and make sure the field is present
- $this->openCiviPage('admin/custom/group/field', "reset=1&action=browse&gid={$to_group_id}");
- $this->assertTrue($this->isElementPresent("CustomField-" . $field_to_move), "The moved custom field does not display on the new fieldset page");
- }
-
- /**
- * create a contact and return the contact id.
- * @param string $firstName
- * @param string $lastName
- *
- * @return mixed
- */
- public function _createContact($firstName = "John", $lastName = "Doe") {
- $firstName .= "_" . substr(sha1(rand()), 0, 5);
- $lastName .= "_" . substr(sha1(rand()), 0, 5);
- $this->webtestAddContact($firstName, $lastName);
- $url = $this->parseURL();
- $cid = $url['queryString']['cid'];
- $this->assertType('numeric', $cid);
- return $cid;
- }
-
- /**
- * Get all custom field values for a given contact and custom group id using the api.
- * @param int $contact_id
- * @param int $group_id
- * @param bool $reset_cache
- *
- * @return array
- */
- public function _loadDataFromApi($contact_id, $group_id, $reset_cache = FALSE) {
- // cache the fields, just to speed things up a little
- static $field_ids = array();
-
- if ($reset_cache) {
- $field_ids = array();
- }
-
- //if the field ids havent been cached yet, grab them
- if (!isset($field_ids[$group_id])) {
- $fields = $this->webtest_civicrm_api("CustomField", "get", array('custom_group_id' => $group_id));
- $field_ids[$group_id] = array();
- foreach ($fields['values'] as $id => $field) {
- $field_ids[$group_id][] = $id;
- }
- }
-
- $params = array('contact_id' => $contact_id);
- foreach ($field_ids[$group_id] as $id) {
- $params['return.custom_' . $id] = 1;
- }
-
- $contact = $this->webtest_civicrm_api("Contact", "get", $params);
-
- //clean up the api results a bit....
- $results = array();
- foreach ($field_ids[$group_id] as $id) {
- if (isset($contact['values'][$contact_id]['custom_' . $id])) {
- $results[$id] = $contact['values'][$contact_id]['custom_' . $id];
- }
- }
-
- return $results;
- }
-
- /**
- * creates a new custom group and fields in that group, and returns the group Id
- * @param $prefix
- *
- * @return null
- */
- public function _buildCustomFieldset($prefix) {
- $group_id = $this->_createCustomGroup($prefix);
- $field_ids[] = $this->_addCustomFieldToGroup($group_id, 'Alphanumeric', "CheckBox", $prefix);
- $field_ids[] = $this->_addCustomFieldToGroup($group_id, 'Alphanumeric', "Radio", $prefix);
- $field_ids[] = $this->_addCustomFieldToGroup($group_id, 'Alphanumeric', "Text", $prefix);
- $field_ids[] = $this->_addCustomFieldToGroup($group_id, 'Note', "Text", $prefix);
- $field_ids[] = $this->_addCustomFieldToGroup($group_id, 'Date', "Date", $prefix);
- return $group_id;
- }
-
- /**
- * Creates a custom field group for a specific entity type and returns the custom group Id.
- * @param string $prefix
- * @param string $entity
- *
- * @return null
- */
- public function _createCustomGroup($prefix = "custom", $entity = "Contact") {
-
- $this->openCiviPage('admin/custom/group', 'action=add&reset=1');
-
- //fill custom group title
- $customGroupTitle = $prefix . '_' . substr(sha1(rand()), 0, 7);
- $this->click("title");
- $this->type("title", $customGroupTitle);
-
- //custom group extends
- $this->click("extends[0]");
- $this->select("extends[0]", "value=" . $entity);
- $this->click("//option[@value='" . $entity . "']");
- $this->click("_qf_Group_next-bottom");
- $this->waitForElementPresent("_qf_Field_cancel-bottom");
-
- //Is custom group created?
- $this->waitForText('crm-notification-container', "Your custom field set '{$customGroupTitle}' has been added. You can add custom fields now.");
-
- return $this->urlArg('gid');
- }
-
- /**
- * Adds a new custom field to a specfied custom field group, using the given
- * datatype and widget.
- * @param int $group_id
- * @param string $type
- * @param string $widget
- * @param string $prefix
- *
- * @return mixed
- * @throws PHPUnit_Framework_AssertionFailedError
- */
- public function _addCustomFieldToGroup($group_id, $type = 'Alphanumeric', $widget = 'CheckBox', $prefix = '') {
- //A mapping of data type names to integer keys
- $type_map = array(
- 'alphanumeric' => array(
- 'id' => 0,
- 'widgets' => array('Text', 'Select', 'Radio', 'CheckBox', 'Multi-Select'),
- 'options' => array(
- 'option_01',
- 'option_02',
- 'option_03',
- 'option_04',
- 'option_05',
- 'option_06',
- 'option_07',
- 'option_08',
- 'option_09',
- 'option_10',
- ),
- ),
- 'integer' => array(
- 'id' => 1,
- 'widgets' => array('Text', 'Select', 'Radio'),
- 'options' => array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10),
- ),
- 'number' => array(
- 'id' => 2,
- 'widgets' => array('Text', 'Select', 'Radio'),
- 'options' => array(1.01, 2.02, 3.03, 4.04, 5.05, 6.06, 7.07, 8.08 . 9.09, 10.1),
- ),
- 'money' => array(
- 'id' => 3,
- 'widgets' => array('Text', 'Select', 'Radio'),
- 'options' => array(1.01, 2.02, 3.03, 4.04, 5.05, 6.06, 7.07, 8.08 . 9.09, 10.1),
- ),
- 'note' => array(
- 'id' => 4,
- 'widgets' => array('TextArea'),
- ),
- 'date' => array(
- 'id' => 5,
- 'widgets' => array('Date'),
- ),
- 'yes or no' => array(
- 'id' => 6,
- 'widgets' => array('Radio'),
- ),
- //'state/province' => array(
- // 'id' => 7,
- //),
- //'country' => array(
- // 'id' => 8,
- //),
- //'link' => array(
- // 'id' => 10,
- //),
- //'contact reference' => array(
- // 'id' => 11,
- //),
- //'file' => 9, hahaha im not doing files.
- );
-
- //downcase the type
- $type = strtolower($type);
-
- //make sure that a supported html type was entered
- if (!isset($type_map[$type])) {
- $this->fail("The custom field html type $type is not supported. Supported types are: " . implode(", ", array_keys($type_map)));
- }
- $html_type_id = $type_map[$type]['id'];
-
- //make sure the widget type can be used for this data type
- //if an invalid widget is selected and only 1 widget is available, use that
- if (!in_array($widget, $type_map[$type]['widgets'])) {
- if (count($type_map[$type]['widgets']) == 1) {
- $widget = $type_map[$type]['widgets'][0];
- }
- else {
- $this->fail("Cannot use $widget for $type fields. Available widgets are: " . implode(", ", $type_map[$type]['widgets']));
- }
- }
-
- //Go to the add custom field page for the given group id
- $this->openCiviPage('admin/custom/group/field/add', "action=add&reset=1&gid={$group_id}");
-
- //Do common setup for all field types
-
- //set the field label
- $fieldLabel = (isset($prefix) ? $prefix . "_" : "") . $widget . "_" . substr(sha1(rand()), 0, 6);
- $this->click("label");
- $this->type("label", $fieldLabel);
-
- //enter pre help message
- $this->type("help_pre", "this is field pre help for " . $fieldLabel);
-
- //enter post help message
- $this->type("help_post", "this field post help for " . $fieldLabel);
-
- //Is searchable?
- $this->click("is_searchable");
-
- //Fill in the html type and widget type
- $this->click("data_type[0]");
- $this->select("data_type[0]", "value=" . $html_type_id);
- $this->click("//option[@value='" . $html_type_id . "']");
- $this->click("data_type[1]");
- $this->select("data_type[1]", "value=" . $widget);
- $this->click("//option[@value='" . $widget . "']");
-
- //fill in specific elements for different widgets
- switch ($widget) {
- case 'CheckBox':
- $this->_createFieldOptions(rand(3, 7), 'option', $type_map[$type]['options']);
- $this->type("options_per_line", "2");
- break;
-
- case 'Radio':
- $this->_createFieldOptions(rand(3, 7), 'option', $type_map[$type]['options']);
- $this->type("options_per_line", "1");
- break;
-
- case 'Date':
- $this->click("date_format");
- $this->select("date_format", "value=yy-mm-dd");
- $this->click("//option[@value='yy-mm-dd']");
- break;
-
- //TODO allow for more things....
- }
-
- //clicking save
- $this->click("_qf_Field_done-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- //Is custom field created?
- $this->waitForText('crm-notification-container', "Custom field '$fieldLabel' has been saved.");
-
- //get the custom id of the custom field that was just created
- $results = $this->webtest_civicrm_api("CustomField", "get", array(
- 'label' => $fieldLabel,
- 'custom_group_id' => $group_id,
- ));
- //While there _technically_ could be two fields with the same name, its highly unlikely
- //so assert that exactly one result is return
- $this->assertTrue($results['count'] == 1, "Could not uniquely get custom field id");
- return $results['id'];
- }
-
- /**
- * Populates $count options for a custom field on the add custom field page
- * @param int $count
- * @param string $prefix
- * @param array $values
- */
- public function _createFieldOptions($count = 3, $prefix = "option", $values = array()) {
- // Only support up to 10 options on the creation form
- $count = $count > 10 ? 10 : $count;
-
- for ($i = 1; $i <= $count; $i++) {
- $label = $prefix . '_' . substr(sha1(rand()), 0, 6);
- $this->type("option_label_" . $i, $label);
- $this->type("option_value_" . $i, (isset($values[$i]) ? $values[$i] : $i));
- }
- }
-
- /**
- * randomly generates data for a specific custom field.
- * @param int $contact_id
- * @param int $group_id
- */
- public function _fillCustomDataForContact($contact_id, $group_id) {
- //edit the given contact
- $this->openCiviPage('contact/add', "reset=1&action=update&cid={$contact_id}");
-
- $this->click("expand");
- $this->waitForElementPresent("address_1_street_address");
-
- //get the custom fields for the group
- $fields = $this->webtest_civicrm_api("CustomField", "get", array('custom_group_id' => $group_id));
- $fields = $fields['values'];
-
- //we need the id the contact's record in the table for this custom group.
- //Recent (4.0.6+, i think?) versions of the api return this when getting
- //custom data for a contact. So we do that.
- $field_ids = array_keys($fields);
- $contact = $this->webtest_civicrm_api("Contact", "get", array(
- 'contact_id' => $contact_id,
- 'return.custom_' . $field_ids[0] => 1,
- ));
- $group = $this->webtest_civicrm_api("CustomGroup", "get", array('id' => $group_id, 'return.table_name' => 1));
-
- //if the contact has not been saved since this fieldset has been creative,
- //the form uses id = -1. In this case the table pk wont be in the api results
- $customValueId = $contact['values'][$contact_id][$group['values'][$group_id]['table_name'] . "_id"];
- if (isset($customValueId) && !empty($customValueId)) {
- $table_pk = $customValueId;
- }
- else {
- $table_pk = -1;
- }
-
- //fill a value in for each field
- foreach ($fields as $field_id => $field) {
- //if there is an option group id, we grab the labels and select on randomly
- if ($field['data_type'] == 'Date') {
- $this->webtestFillDate("custom_" . $field['id'] . "_" . $table_pk, "+1 week");
- }
- elseif (isset($field['option_group_id'])) {
- $options = $this->webtest_civicrm_api("OptionValue", "get", array('option_group_id' => $field['option_group_id']));
- $options = $options['values'];
- $pick_me = $options[array_rand($options)]['label'];
- $this->click("xpath=//table//tr/td/label[text()=\"$pick_me\"]");
- }
- else {
- //gonna go ahead and assume its an alphanumeric text question. This
- //will really only work if the custom data group has not yet been
- //filled out for this contact
- $this->type("custom_" . $field['id'] . '_' . $table_pk, sha1(rand()));
- }
- }
-
- //save the form
- $this->click("_qf_Contact_upload_view");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- //assert success
- $this->waitForText('crm-notification-container', "has been updated");
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Admin_RelationshipTypeAddTest
- */
-class WebTest_Admin_RelationshipTypeAddTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testRelationshipTypeAdd() {
-
- $this->webtestLogin();
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->click('link=CiviCRM');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- //jump directly to relationship type selector.
- $this->openCiviPage('admin/reltype', 'reset=1&action=browse');
-
- //load the form to add new relationship type.
- $this->click('link=Add Relationship Type');
- $this->waitForElementPresent('_qf_RelationshipType_next-bottom');
-
- //enter the relationship type values.
- $labelAB = 'Test Relationship Type A - B -' . rand();
- $labelBA = 'Test Relationship Type B - A -' . rand();
- $this->type('label_a_b', $labelAB);
- $this->type('label_b_a', $labelBA);
- $this->select('contact_types_a', "value=Individual");
- $this->select('contact_types_b', "value=Individual");
- $this->type('description', 'Test Relationship Type Description');
-
- //save the data.
- $this->click('_qf_RelationshipType_next-bottom');
-
- //does data saved.
- $this->waitForText('crm-notification-container', 'The Relationship Type has been saved.');
-
- $this->waitForElementPresent('link=Add Relationship Type');
- //validate data.
- $data = array(
- 'Relationship A to B' => $labelAB,
- 'Relationship B to A' => $labelBA,
- 'Contact Type A' => 'Individual',
- 'Contact Type B' => 'Individual',
- );
- foreach ($data as $param => $val) {
- $this->assertElementContainsText("xpath=//table[@class='display dataTable no-footer']", $val, "Could not able to save $param");
- }
- }
-
- public function testRelationshipTypeAddValidateFormRules() {
-
- $this->webtestLogin();
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->click('link=CiviCRM');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- //jump directly to relationship type selector.
- $this->openCiviPage('admin/reltype', 'reset=1&action=browse');
-
- //validate form rules.
- $this->click('link=Add Relationship Type');
- $this->waitForElementPresent('_qf_RelationshipType_next-bottom');
-
- $this->select('contact_types_a', 'value=Individual');
- $this->select('contact_types_b', 'value=Individual');
- $description = 'Test Relationship Type Description';
- $this->type('description', $description);
-
- $this->click('_qf_RelationshipType_next-bottom');
- $this->waitForText("xpath=//*[@id='RelationshipType']/div[2]/table/tbody/tr[1]/td[2]/label[@class='crm-inline-error']", 'This field is required.');
-
- //enter the relationship type values.
- $labelAB = 'Test Relationship Type A - B - DUPLICATE TO BE' . rand();
- $labelBA = 'Test Relationship Type B - A - DUPLICATE TO BE' . rand();
- $this->type('label_a_b', $labelAB);
- $this->type('label_b_a', $labelBA);
- $this->select('contact_types_a', "value=Individual");
- $this->select('contact_types_b', "value=Individual");
- $this->type('description', 'Test Relationship Type Description');
- $this->click('_qf_RelationshipType_next-bottom');
- $this->waitForElementPresent('link=Add Relationship Type');
-
- $this->openCiviPage('admin/reltype', 'reset=1&action=browse');
- $this->click('link=Add Relationship Type');
- $this->waitForElementPresent('_qf_RelationshipType_next-bottom');
-
- $this->type('label_a_b', $labelAB);
- $this->type('label_b_a', $labelBA);
- $this->click('_qf_RelationshipType_next-bottom');
-
- $this->waitForText('crm-notification-container', 'Label already exists in Database.');
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License and the CiviCRM Licensing Exception along |
- | with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-/**
- * Include parent class definition
- */
-require_once 'CiviTest/CiviTestSuite.php';
-
-/**
- * Class containing all CRM test suites
- *
- * @package CiviCRM
- */
-class WebTest_AllTests extends CiviTestSuite {
- private static $instance = NULL;
-
- /**
- */
- private static function getInstance() {
- if (is_null(self::$instance)) {
- self::$instance = new self();
- }
- return self::$instance;
- }
-
- /**
- * Build test suite dynamically.
- */
- public static function suite() {
- $inst = self::getInstance();
- return $inst->implSuite(__FILE__);
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Campaign_ActivityTest
- */
-class WebTest_Campaign_ActivityTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testCreateCampaign() {
- $this->markTestSkipped('Skipping for now as it works fine locally.');
- $this->webtestLogin('admin');
-
- // Enable CiviCampaign module if necessary
- $this->enableComponents(array('CiviCampaign'));
-
- // add the required Drupal permission
- $permissions = array('edit-2-administer-civicampaign');
- $this->changePermissions($permissions);
-
- // Log in as normal user
- $this->webtestLogin();
-
- // Create new group
- $title = substr(sha1(rand()), 0, 7);
- $groupName = $this->WebtestAddGroup();
-
- // Adding contact
- // We're using Quick Add block on the main page for this.
- $firstName1 = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName1, "Smith", "$firstName1.smith@example.org");
-
- // add contact to group
- // visit group tab
- $this->click("css=li#tab_group a");
- $this->waitForElementPresent("group_id");
-
- // add to group
- $this->select("group_id", "label=$groupName");
- $this->click("_qf_GroupContact_next");
- $this->waitForElementPresent('link=Remove');
-
- $firstName2 = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName2, "John", "$firstName2.john@example.org");
-
- // add contact to group
- // visit group tab
- $this->click("css=li#tab_group a");
- $this->waitForElementPresent("group_id");
-
- // add to group
- $this->select("group_id", "label=$groupName");
- $this->click("_qf_GroupContact_next");
- $this->waitForElementPresent('link=Remove');
-
- $this->openCiviPage('campaign/add', 'reset=1', '_qf_Campaign_upload-bottom');
-
- $campaignTitle = "Campaign " . $title;
- $this->type("title", $campaignTitle);
-
- // select the campaign type
- $this->select("campaign_type_id", "value=2");
-
- // fill in the description
- $this->type("description", "This is a test campaign");
-
- // include groups for the campaign
- $this->multiselect2("includeGroups", array("$groupName", "Advisory Board"));
-
- // fill the end date for campaign
- $this->webtestFillDate("end_date", "+1 year");
-
- // select campaign status
- $this->select("status_id", "value=2");
-
- // click save
- $this->click("_qf_Campaign_upload-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->waitForText('crm-notification-container', "Campaign $title");
-
- $this->waitForElementPresent("xpath=//div[@id='campaignList']/div/table/tbody//tr/td[3]/div[text()='{$campaignTitle}']/../../td[1]");
- $id = (int) $this->getText("xpath=//div[@id='campaignList']/div/table/tbody//tr/td[3]/div[text()='{$campaignTitle}']/../../td[1]");
- $this->activityAddTest($campaignTitle, $id);
- }
-
- /**
- * @param $campaignTitle
- * @param int $id
- */
- public function activityAddTest($campaignTitle, $id) {
- // Adding Adding contact with randomized first name for test testContactContextActivityAdd
- // We're using Quick Add block on the main page for this.
- $firstName1 = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName1, "Summerson", $firstName1 . "@summerson.name");
- $firstName2 = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName2, "Anderson", $firstName2 . "@anderson.name");
-
- $this->click("css=li#tab_activity a");
-
- // waiting for the activity dropdown to show up
- $this->waitForElementPresent("other_activity");
-
- // Select the activity type from the activity dropdown
- $this->select("other_activity", "label=Meeting");
-
- // waitForPageToLoad is not always reliable. Below, we're waiting for the submit
- // button at the end of this page to show up, to make sure it's fully loaded.
- $this->waitForElementPresent("_qf_Activity_upload");
-
- // ...and verifying if the page contains properly formatted display name for chosen contact.
- $this->waitForElementPresent("//*[@id='s2id_target_contact_id']");
- $this->assertElementContainsText('//*[@id="s2id_target_contact_id"]/ul/li[1]/div', 'Anderson, ' . $firstName2, 'Contact not found in line ' . __LINE__);
-
- // Now we're filling the "Assigned To" field.
- // Typing contact's name into the field (using typeKeys(), not type()!)...
- $this->select2("assignee_contact_id", $firstName1, TRUE);
-
- // ...and verifying if the page contains properly formatted display name for chosen contact.
- $this->waitForElementPresent("//*[@id='s2id_assignee_contact_id']");
- $this->assertElementContainsText('//*[@id="s2id_assignee_contact_id"]/ul/li[1]/div', 'Summerson, ' . $firstName1, 'Contact not found in line ' . __LINE__);
-
- // Since we're here, let's check if screen help is being displayed properly
- //$this->assertTrue($this->isTextPresent("A copy of this activity will be emailed to each Assignee"));
-
- // Putting the contents into subject field - assigning the text to variable, it'll come in handy later
- $subject = "This is subject of test activity being added through activity tab of contact summary screen.";
- // For simple input fields we can use field id as selector
- $this->type("subject", $subject);
-
- // select campaign
- $this->waitForElementPresent("campaign_id");
- $this->click("campaign_id");
- $this->select("campaign_id", "value=$id");
-
- $this->type("location", "Some location needs to be put in this field.");
-
- // Choosing the Date.
- // Please note that we don't want to put in fixed date, since
- // we want this test to work in the future and not fail because
- // of date being set in the past. Therefore, using helper webtestFillDateTime function.
- $this->webtestFillDateTime('activity_date_time', '+1 month 11:10PM');
-
- // Setting duration.
- $this->type("duration", "30");
-
- // Putting in details.
- $this->type("details", "Really brief details information.");
-
- // Making sure that status is set to Scheduled (using value, not label).
- $this->select("status_id", "value=1");
-
- // Setting priority.
- $this->select("priority_id", "value=1");
-
- // Adding attachment
- // TODO TBD
-
- // Scheduling follow-up.
- $this->click("css=.crm-activity-form-block-schedule_followup div.crm-accordion-header");
- $this->select("followup_activity_type_id", "value=1");
- $this->webtestFillDateTime('followup_date', '+1 month 11:10PM');
- $this->type("followup_activity_subject", "This is subject of schedule follow-up activity");
-
- // Clicking save.
- $this->clickLink("_qf_Activity_upload", 'link=View', FALSE);
-
- // Is status message correct?
- $this->waitForText('crm-notification-container', $subject);
-
- $this->waitForElementPresent("xpath=//div[@class='crm-activity-selector-activity']/div[2]/table/tbody/tr[2]/td[8]/span[1]/a[1][text()='View']");
-
- // click through to the Activity view screen
- $this->click("xpath=//div[@class='crm-activity-selector-activity']/div[2]/table/tbody/tr[2]/td[8]/span[1]/a[1][text()='View']");
- $this->waitForElementPresent("xpath=//button//span[contains(text(),'Done')]");
-
- // verify Activity created
- $this->waitForAjaxContent();
- $this->verifyText("xpath=//form[@id='Activity']/div[2]/table/tbody/tr[5]/td[2]/span", $campaignTitle);
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Campaign_CampaignDescriptionTest
- */
-class WebTest_Campaign_CampaignDescriptionTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testCreateCampaign() {
- // Fixme: testing a theory that this test was failing due to permissions
- $this->webtestLogin('admin');
-
- // Create new group
- $title = substr(sha1(rand()), 0, 7);
- $groupName = $this->WebtestAddGroup();
-
- // Enable CiviCampaign module if necessary
- $this->enableComponents(array('CiviCampaign'));
-
- //Creating a new Campaign
- $this->openCiviPage('campaign/add', 'reset=1', '_qf_Campaign_upload-bottom');
-
- $campaignTitle = "Campaign $title";
- $this->type("title", $campaignTitle);
-
- // select the campaign type
- $this->select("campaign_type_id", "value=2");
-
- // fill in the description
- $campaignDescription = "This is a test campaign line 1 \n This is a test campaign line 2 \n This is a test campaign line 3";
- $this->type("description", $campaignDescription);
-
- // include groups for the campaign
- $this->multiselect2("includeGroups", array("$groupName", "Advisory Board"));
-
- // fill the end date for campaign
- $this->webtestFillDate("end_date", "+1 year");
-
- // select campaign status
- $this->select("status_id", "value=2");
-
- // click save
- $this->click("_qf_Campaign_upload-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->waitForText('crm-notification-container', "Campaign $title");
-
- //Opening Edit Page of the created Campaign
- $this->waitForElementPresent("//div[@id='campaignList']/div/table/tbody//tr/td[3]/div[text()='{$campaignTitle}']/../../td[13]/span/a[1][text()='Edit']");
- $this->clickLink("//div[@id='campaignList']/div/table/tbody//tr/td[3]/div[text()='{$campaignTitle}']/../../td[13]/span/a[1][text()='Edit']", "//textarea[@id='description']", FALSE);
- $this->assertTrue($this->isTextPresent($campaignDescription), 'Missing text: ' . $campaignDescription);
- }
-
- public function testAjaxCustomGroupLoad() {
- $this->webtestLogin();
-
- $this->enableComponents(array('CiviCampaign'));
- $triggerElement = array('name' => 'campaign_type_id', 'type' => 'select');
- $customSets = array(
- array('entity' => 'Campaign', 'subEntity' => 'Referral Program', 'triggerElement' => $triggerElement),
- array('entity' => 'Campaign', 'subEntity' => 'Constituent Engagement', 'triggerElement' => $triggerElement),
- );
-
- $pageUrl = array('url' => 'campaign/add', 'args' => 'reset=1');
- $this->customFieldSetLoadOnTheFlyCheck($customSets, $pageUrl);
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Campaign_MailingTest
- */
-class WebTest_Campaign_MailingTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testCreateCampaign() {
- // Log in as admin first to verify permissions for CiviCampaign
- $this->webtestLogin('admin');
-
- // Enable CiviCampaign module if necessary
- $this->enableComponents(array('CiviMail', 'CiviCampaign'));
-
- $this->setupDefaultMailbox();
-
- // add the required permission
- $this->changePermissions('edit-2-administer-civicampaign');
-
- // Log in as normal user
- $this->webtestLogin();
-
- // Create new group
- $title = substr(sha1(rand()), 0, 7);
- $groupName = $this->WebtestAddGroup();
-
- // Adding contact
- // We're using Quick Add block on the main page for this.
- $firstName = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName, "Smith", "$firstName.smith@example.org");
- $this->_contactNames = array("$firstName.smith@example.org" => "Smith, $firstName");
-
- // add contact to group
- // visit group tab
- $this->click("css=li#tab_group a");
- $this->waitForElementPresent("group_id");
-
- // add to group
- $this->select("group_id", "label=$groupName");
- $this->click("_qf_GroupContact_next");
- $this->waitForElementPresent('link=Remove');
-
- $this->openCiviPage('campaign/add', 'reset=1', '_qf_Campaign_upload-bottom');
-
- $campaignTitle = "Campaign $title";
- $this->type("title", $campaignTitle);
-
- // select the campaign type
- $this->select("campaign_type_id", "value=2");
-
- // fill in the description
- $this->type("description", "This is a test campaign");
-
- // include groups for the campaign
- $this->multiselect2("includeGroups", array("$groupName", "Advisory Board"));
-
- // fill the end date for campaign
- $this->webtestFillDate("end_date", "+1 year");
-
- // select campaign status
- $this->select("status_id", "value=2");
-
- // click save
- $this->click("_qf_Campaign_upload-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->waitForText('crm-notification-container', "Campaign $title");
-
- $this->mailingAddTest($groupName, $campaignTitle, $title, $firstName);
- }
-
- /**
- * Test mailing add.
- *
- * @param string $groupName
- * @param string $campaignTitle
- * @param string $title
- * @param string $firstUserName
- */
- public function mailingAddTest($groupName, $campaignTitle, $title, $firstUserName) {
- //---- create mailing contact and add to mailing Group
- $firstName = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName, "Mailson", "mailino$firstName@mailson.co.in");
- $this->_contactNames["mailino$firstName@mailson.co.in"] = "Mailson, $firstName";
-
- // go to group tab and add to mailing group
- $this->click("css=li#tab_group a");
- $this->waitForElementPresent("_qf_GroupContact_next");
- $this->select("group_id", "$groupName");
- $this->click("_qf_GroupContact_next");
-
- $this->openCiviPage('a/#/mailing/new');
- $this->waitForElementPresent("xpath=//input[@name='mailingName']");
- //-------select recipients----------
-
- // fill mailing name
- $mailingName = substr(sha1(rand()), 0, 7);
- $this->type("xpath=//input[@name='mailingName']", "Mailing $mailingName Webtest");
-
- // select campaign
- $this->select2("s2id_crmUiId_4", "Campaign_" . $title);
-
- // Add the test mailing group
- $this->select2("s2id_crmUiId_8", $groupName, TRUE);
-
- $this->waitForTextPresent("~2 recipients");
-
- //--------Mailing content------------
- $tokens = ' {domain.address}{action.optOutUrl}';
- // fill subject for mailing
- $this->type("xpath=//input[@name='subject']", "Test subject {$mailingName} for Webtest");
- // HTML format message
- $HTMLMessage = "This is HTML formatted content for Mailing {$mailingName} Webtest.";
- $this->fillRichTextField("crmUiId_1", $HTMLMessage . $tokens);
-
- // FIXME: Selenium can't access content in an iframe
- //$this->click("xpath=//div[@class='preview-popup']//a[text()='Preview as HTML']");
- //$this->waitForTextPresent($HTMLMessage);
- //$this->waitForAjaxContent();
- //$this->click("xpath=//button[@title='Close']");
-
- // Open Plain-text Format pane and type text format msg
- $this->click("//div[starts-with(text(),'Plain Text')]");
- $this->type("xpath=//*[@name='body_text']", "This is text formatted content for Mailing {$mailingName} Webtest.$tokens");
-
- $this->click("xpath=//div[@class='preview-popup']//a[text()='Preview as Plain Text']");
- $this->waitForTextPresent("This is text formatted content for Mailing {$mailingName} Webtest.");
- $this->click("xpath=//button[@title='Close']");
-
- //--------track and respond----------
- $this->waitForAjaxContent();
- $this->click('link=Tracking');
- $this->assertChecked("url_tracking");
- $this->assertChecked("open_tracking");
- // no need tracking for this test
-
- // default header and footer ( with label )
- $this->waitForAjaxContent();
- $this->click('link=Header and Footer');
- $this->select("header_id", "label=Mailing Header");
- $this->select("footer_id", "label=Mailing Footer");
-
- //---------------Test------------------
-
- ////////--Commenting test mailing and mailing preview (test mailing and preview not presently working).
-
- // send test mailing
- //$this->type("test_email", "mailino@mailson.co.in");
- //$this->click("sendtest");
-
- // verify status message
- //$this->assertTrue($this->isTextPresent("Your test message has been sent. Click 'Next' when you are ready to Schedule or Send your live mailing (you will still have a chance to confirm or cancel sending this mailing on the next page)."));
-
- // check mailing preview
- //$this->click("//form[@id='Test']/div[2]/div[4]/div[1]");
- //$this->assertTrue($this->isTextPresent("this is test content for Mailing $mailingName Webtest"));
-
- ////////
-
- // click next
- $this->click("xpath=//div[@class='crm-wizard-buttons']/button[text()='Next']");
-
- //----------Schedule or Send------------
-
- // do check for other option
- $this->waitForTextPresent("Mailing $mailingName Webtest");
- $this->click("xpath=//div[@class='content']//a[text()='~2 recipients']");
- $verifyData = array(
- "$firstUserName Smith" => "$firstUserName.smith@example.org",
- "$firstName Mailson" => "mailino$firstName@mailson.co.in",
- );
- $this->webtestVerifyTabularData($verifyData);
- $this->waitForTextPresent("(Include: $groupName)");
- $this->assertChecked("xpath=//input[@id='schedule-send-now']");
-
- // finally schedule the mail by clicking submit
- $this->click("xpath=//center/a/div[text()='Submit Mailing']");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- //----------end New Mailing-------------
-
- //check redirected page to Scheduled and Sent Mailings and verify for mailing name
- $this->waitForTextPresent("Find Mailings");
- $this->assertElementContainsText('Search', "Mailing $mailingName Webtest");
-
- //--------- mail delivery verification---------
-
- // test undelivered report
-
- // click report link of created mailing
- $this->click("xpath=//table//tbody/tr[td[1]/text()='Mailing $mailingName Webtest']/descendant::a[text()='Report']");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // verify undelivered status message
- $this->assertElementContainsText('crm-container', "Delivery has not yet begun for this mailing. If the scheduled delivery date and time is past, ask the system administrator or technical support contact for your site to verify that the automated mailer task ('cron job') is running - and how frequently.");
-
- // do check for recipient group
- $this->assertElementContainsText('crm-container', "Members of $groupName");
-
- // directly send schedule mailing -- not working right now
- $this->openCiviPage('mailing/queue', 'reset=1');
-
- //click report link of created mailing
- $this->click("xpath=//table//tbody/tr[td[1]/text()='Mailing $mailingName Webtest']/descendant::a[text()='Report']");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // do check again for recipient group
- $this->assertElementContainsText('crm-container', "Members of $groupName");
-
- // check for 100% delivery
- $this->assertElementContainsText('crm-container', "2 (100.00%)");
-
- // verify intended recipients
- $this->verifyText("xpath=//table//tr[td/a[text()='Intended Recipients']]/descendant::td[2]", preg_quote("2"));
-
- // verify successful deliveries
- $this->verifyText("xpath=//table//tr[td/a[text()='Successful Deliveries']]/descendant::td[2]", preg_quote("2 (100.00%)"));
-
- // verify status
- $this->verifyText("xpath=//table//tr[td[1]/text()='Status']/descendant::td[2]", preg_quote("Complete"));
-
- // verify mailing name
- $this->verifyText("xpath=//table//tr[td[1]/text()='Mailing Name']/descendant::td[2]", preg_quote("Mailing $mailingName Webtest"));
-
- // verify mailing subject
- $this->verifyText("xpath=//table//tr[td[1]/text()='Subject']/descendant::td[2]", preg_quote("Test subject $mailingName for Webtest"));
-
- $this->verifyText("xpath=//table//tr[td[1]/text()='Campaign']/descendant::td[2]", preg_quote("$campaignTitle"));
-
- //---- check for delivery detail--
- $this->click("link=Successful Deliveries");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // check for open page
- $this->waitForTextPresent("Successful Deliveries");
- // verify email
- $this->assertElementContainsText('mailing_event', "mailino$firstName@mailson.co.in");
- //------end delivery verification---------
-
- // Search Advanced Search for contacts associated with Campaign in the Mailings Tab.
- $this->mailingCampaignAdvancedSearchTest($campaignTitle, $this->_contactNames);
- }
-
- public function mailingCampaignAdvancedSearchTest($campaignTitle, $contactNames) {
- // Go directly to Advanced Search
- $this->openCiviPage('contact/search/advanced', 'reset=1');
-
- // Select the Mailing Tab
- $this->clickAjaxLink("CiviMail", 'campaigns');
- $this->multiselect2("campaigns", array("$campaignTitle"));
- $this->click("_qf_Advanced_refresh");
-
- // Check for contacts inserted while adding Campaing and Mailing
- $this->waitForElementPresent('search-status');
- $this->assertElementContainsText('search-status', '2 Contacts');
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Campaign_MembershipTest
- */
-class WebTest_Campaign_MembershipTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testCreateCampaign() {
- $this->webtestLogin('admin');
-
- // Create new group
- $title = substr(sha1(rand()), 0, 7);
- $groupName = $this->WebtestAddGroup();
-
- // Adding contact
- // We're using Quick Add block on the main page for this.
- $firstName1 = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName1, "Smith", "$firstName1.smith@example.org");
-
- // add contact to group
- // visit group tab
- $this->click("css=li#tab_group a");
- $this->waitForElementPresent("group_id");
-
- // add to group
- $this->waitForElementPresent("group_id");
- $this->select("group_id", "label=$groupName");
- $this->click("_qf_GroupContact_next");
- $this->waitForElementPresent('link=Remove');
-
- $firstName2 = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName2, "John", "$firstName2.john@example.org");
-
- // add contact to group
- // visit group tab
- $this->click("css=li#tab_group a");
- $this->waitForElementPresent("group_id");
-
- // add to group
- $this->select("group_id", "label=$groupName");
- $this->click("_qf_GroupContact_next");
- $this->waitForElementPresent('link=Remove');
-
- // Enable CiviCampaign module if necessary
- $this->enableComponents(array('CiviCampaign'));
-
- // add the required Drupal permission
- $this->changePermissions('edit-2-administer-civicampaign');
-
- // Log in as normal user
- $this->webtestLogin();
- $this->openCiviPage('campaign/add', 'reset=1', '_qf_Campaign_upload-bottom');
-
- $campaignTitle = "Campaign $title";
- $this->type("title", $campaignTitle);
-
- // select the campaign type
- $this->select("campaign_type_id", "value=2");
-
- // fill in the description
- $this->type("description", "This is a test campaign");
-
- // include groups for the campaign
- $this->multiselect2("includeGroups", array("$groupName", "Advisory Board"));
-
- // fill the end date for campaign
- $this->webtestFillDate("end_date", "+1 year");
-
- // select campaign status
- $this->select("status_id", "value=2");
-
- // click save
- $this->click("_qf_Campaign_upload-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->waitForText('crm-notification-container', "Campaign $title");
- $this->waitForElementPresent("//table[@class='campaigns dataTable no-footer']/tbody//tr//td/div[contains(text(),'{$campaignTitle}')]/../../td[1]");
- $id = (int) $this->getText("//table[@class='campaigns dataTable no-footer']/tbody//tr//td/div[contains(text(),'{$campaignTitle}')]/../../td[1]");
- $this->memberAddTest($campaignTitle, $id);
- }
-
- /**
- * @param $campaignTitle
- * @param int $id
- */
- public function memberAddTest($campaignTitle, $id) {
- //Add new membershipType
- $memTypeParams = $this->webtestAddMembershipType();
-
- // Adding Adding contact with randomized first name for test testContactContextActivityAdd
- // We're using Quick Add block on the main page for this.
- $firstName = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName, "John", $firstName . "john@gmail.com");
- $this->assertTrue($this->isTextPresent("{$firstName} John has been created."));
-
- // click through to the membership view screen
- $this->click("css=li#tab_member a");
-
- $this->waitForElementPresent("link=Add Membership");
- $this->click("link=Add Membership");
-
- $this->waitForElementPresent("_qf_Membership_cancel-bottom");
-
- // fill in Membership Organization and Type
- $this->select("membership_type_id_0", "label={$memTypeParams['member_of_contact']}");
-
- // Wait for membership type select to reload
- $this->waitForTextPresent($memTypeParams['membership_type']);
- $this->select("membership_type_id[1]", "label={$memTypeParams['membership_type']}");
-
- $sourceText = "Membership ContactAddTest Webtest";
- // fill in Source
- $this->type("source", $sourceText);
-
- // select campaign
- $this->click("campaign_id");
- $this->select("campaign_id", "value=$id");
-
- // Let Join Date stay default
- // fill in Start Date
- $this->webtestFillDate('start_date');
-
- // Clicking save.
- $this->click("_qf_Membership_upload");
- $this->waitForElementPresent('link=View');
-
- // page was loaded
- $this->waitForTextPresent($sourceText);
-
- // Is status message correct?
- $this->assertTrue($this->isTextPresent("membership for $firstName John has been added."),
- "Status message didn't show up after saving!"
- );
-
- // click through to the membership view screen
- $this->click("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]//span/a[text()='View']");
- $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
-
- $this->webtestVerifyTabularData(array('Campaign' => $campaignTitle));
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Campaign_OfflineContributionTest
- */
-class WebTest_Campaign_OfflineContributionTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testCreateCampaign() {
- $this->webtestLogin('admin');
-
- // Create new group
- $title = substr(sha1(rand()), 0, 7);
- $groupName = $this->WebtestAddGroup();
-
- // Adding contact
- // We're using Quick Add block on the main page for this.
- $firstName1 = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName1, "Smith", "$firstName1.smith@example.org");
-
- // add contact to group
- // visit group tab
- $this->click("css=li#tab_group a");
- $this->waitForElementPresent("group_id");
-
- // add to group
- $this->select("group_id", "label=$groupName");
- $this->click("_qf_GroupContact_next");
- $this->waitForElementPresent('link=Remove');
-
- $firstName2 = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName2, "John", "$firstName2.john@example.org");
-
- // add contact to group
- // visit group tab
- $this->click("css=li#tab_group a");
- $this->waitForElementPresent("group_id");
-
- // add to group
- $this->select("group_id", "label=$groupName");
- $this->click("_qf_GroupContact_next");
- $this->waitForElementPresent('link=Remove');
-
- // Enable CiviCampaign module if necessary
- $this->enableComponents(array('CiviCampaign'));
-
- // add the required permission
- $this->changePermissions('edit-2-administer-civicampaign');
-
- // Log in as normal user
- $this->webtestLogin();
-
- $this->openCiviPage('campaign', 'reset=1', "link=Add Campaign");
- if ($this->isTextPresent('None found.')) {
- $this->openCiviPage('contribute/add', 'reset=1&action=add&context=standalone', '_qf_Contribution_cancel-bottom');
- $this->assertElementContainsText('crm-container', 'There are currently no active Campaigns.');
- }
- $this->openCiviPage('campaign/add', 'reset=1');
-
- $campaignTitle = "Campaign $title";
- $this->type("title", $campaignTitle);
-
- // select the campaign type
- $this->select("campaign_type_id", "value=2");
-
- // fill in the description
- $this->type("description", "This is a test campaign");
-
- // include groups for the campaign
- $this->multiselect2("includeGroups", array("$groupName", "Advisory Board"));
-
- // fill the end date for campaign
- $this->webtestFillDate("end_date", "+1 year");
-
- // select campaign status
- $this->select("status_id", "value=2");
-
- // click save
- $this->clickLink("_qf_Campaign_upload-bottom");
-
- $this->checkCRMAlert("Campaign $title");
-
- $this->waitForElementPresent("//td[3]/div[text()='$campaignTitle']");
- $campaignId = $this->urlArg('id', $this->getAttribute("//td[3]/div[text()='$campaignTitle']/../../td[13]/span/a[text()='Edit']@href"));
-
- $this->offlineContributionTest($campaignTitle, $campaignId);
-
- $this->pastCampaignsTest($groupName);
- }
-
- /**
- * @param $campaignTitle
- * @param int $id
- * @param bool $past
- */
- public function offlineContributionTest($campaignTitle, $id, $past = FALSE) {
- // Create a contact to be used as soft creditor
- $softCreditFname = substr(sha1(rand()), 0, 7);
- $softCreditLname = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($softCreditFname, $softCreditLname, FALSE);
-
- // Adding contact with randomized first name (so we can then select that contact when creating contribution.)
- // We're using Quick Add block on the main page for this.
- $firstName = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName, "Summerson", $firstName . "@summerson.name");
-
- // go to contribution tab and add contribution.
- $this->click("css=li#tab_contribute a");
-
- // wait for Record Contribution elenment.
- $this->waitForElementPresent("link=Record Contribution (Check, Cash, EFT ...)");
- $this->click("link=Record Contribution (Check, Cash, EFT ...)");
-
- $this->waitForElementPresent("_qf_Contribution_cancel-bottom");
-
- // fill financial type.
- $this->select("financial_type_id", "Donation");
-
- // fill in Received Date
- $this->webtestFillDate('receive_date');
-
- // source
- $this->type("source", "Mailer 1");
-
- if ($past) {
- $this->click("include-past-campaigns");
- $this->waitForElementPresent("css=#campaign_id option[value=$id]");
- }
-
- $this->select("campaign_id", "value=$id");
-
- // total amount
- $this->type("total_amount", "100");
-
- // select payment instrument type = Check and enter chk number
- $this->select("payment_instrument_id", "value=4");
- $this->waitForElementPresent("check_number");
- $this->type("check_number", "check #1041");
-
- $this->type("trxn_id", "P20901X1" . rand(100, 10000));
-
- // soft credit
- $this->click("xpath=id('Contribution')/div[2]/div[@id='softCredit']/div[1]");
- $this->type("soft_credit_amount_1", "50");
- $this->waitForElementPresent("soft_credit_contact_id_1");
- $this->webtestFillAutocomplete("{$softCreditLname}, {$softCreditFname}", 'soft_credit_contact_id_1');
-
- //Additional Detail section
- $this->click("AdditionalDetail");
- $this->waitForElementPresent("thankyou_date");
-
- $this->type("note", "Test note for {$firstName}.");
- $this->type("non_deductible_amount", "10");
- $this->type("fee_amount", "0");
- $this->type("net_amount", "0");
- $this->type("invoice_id", time());
- $this->webtestFillDate('thankyou_date');
-
- //Premium section
- $this->click("Premium");
- $this->waitForElementPresent("fulfilled_date");
- $this->select("product_name[0]", "label=Coffee Mug ( MUG-101 )");
- $this->select("product_name[1]", "label=Black");
- $this->webtestFillDate('fulfilled_date');
-
- // Clicking save.
- $this->click("_qf_Contribution_upload-bottom");
-
- // Is status message correct?
- $this->checkCRMAlert("The contribution record has been saved.");
- $this->waitForElementPresent("xpath=//*[@id='Search']//div[2]//table[2]/tbody/tr/td[8]/span//a[text()='View']");
-
- // click through to the Contribution view screen
- $this->click("xpath=//*[@id='Search']//div[2]//table[2]/tbody/tr/td[8]/span/a[text()='View']");
- $this->waitForElementPresent('_qf_ContributionView_cancel-bottom');
-
- // verify Contribution created
- $this->webtestVerifyTabularData(array('Campaign' => $campaignTitle));
-
- if ($past) {
- // when campaign component is disabled
- $this->openCiviPage('admin/setting/component', 'reset=1', '_qf_Component_next-bottom');
- $this->addSelection("enableComponents-t", "label=CiviCampaign");
- $this->click("//option[@value='CiviCampaign']");
- $this->click("remove");
- $this->clickLink("_qf_Component_next-bottom");
-
- $this->checkCRMAlert("Changes Saved");
-
- $this->openCiviPage('contribute/search', 'reset=1', '_qf_Search_refresh');
-
- $this->type('sort_name', $firstName);
- $this->click("_qf_Search_refresh");
- $this->waitForElementPresent("xpath=//table[@class='selector row-highlight']/tbody/tr/td[10]/span//a[text()='Edit']");
- $this->click("xpath=//table[@class='selector row-highlight']/tbody/tr/td[10]/span//a[text()='Edit']");
- $this->waitForElementPresent("_qf_Contribution_cancel-bottom");
- $this->assertTrue($this->isTextPresent("$campaignTitle"));
- }
- }
-
- /**
- * @param string $groupName
- */
- public function pastCampaignsTest($groupName) {
- $this->openCiviPage('campaign/add', 'reset=1', '_qf_Campaign_upload-bottom');
-
- $pastTitle = substr(sha1(rand()), 0, 7);
- $pastCampaignTitle = "Past Campaign $pastTitle";
- $this->type("title", $pastCampaignTitle);
-
- // select the campaign type
- $this->select("campaign_type_id", "value=2");
-
- // fill in the description
- $this->type("description", "This is a test for past campaign");
-
- // include groups for the campaign
- $this->multiselect2("includeGroups", array("$groupName", "Advisory Board"));
-
- // fill the start date for campaign
- $this->webtestFillDate("start_date", "1 January " . (date('Y') - 1));
-
- // fill the end date for campaign
- $this->webtestFillDate("end_date", "31 January " . (date('Y') - 1));
-
- // select campaign status
- $this->select("status_id", "value=3");
-
- // click save
- $this->clickLink("_qf_Campaign_upload-bottom");
- $this->checkCRMAlert("Campaign $pastCampaignTitle has been saved.");
-
- $this->waitForElementPresent("link=Add Campaign");
- $this->waitForElementPresent("link=Campaigns");
- $this->click("search_form_campaign");
- $this->type("campaign_title", $pastCampaignTitle);
- $this->clickAjaxLink("//a[text()='Search']", "//td[3]/div[text()='$pastCampaignTitle']");
- $campaignId = $this->urlArg('id', $this->getAttribute("//td[3]/div[text()='$pastCampaignTitle']/../../td[13]/span/a[text()='Edit']@href"));
-
- $this->offlineContributionTest($pastCampaignTitle, $campaignId, TRUE);
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Campaign_OfflineEventRegistrationTest
- */
-class WebTest_Campaign_OfflineEventRegistrationTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testCreateCampaign() {
- $this->webtestLogin('admin');
-
- // Create new group
- $title = substr(sha1(rand()), 0, 7);
- $groupName = $this->WebtestAddGroup();
-
- // Adding contact
- // We're using Quick Add block on the main page for this.
- $firstName1 = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName1, "Smith", "$firstName1.smith@example.org");
-
- // add contact to group
- // visit group tab
- $this->click("css=li#tab_group a");
- $this->waitForElementPresent("group_id");
-
- // add to group
- $this->select("group_id", "label=$groupName");
- $this->click("_qf_GroupContact_next");
- $this->waitForElementPresent('link=Remove');
-
- $firstName2 = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName2, "John", "$firstName2.john@example.org");
-
- // add contact to group
- // visit group tab
- $this->click("css=li#tab_group a");
- $this->waitForElementPresent("group_id");
-
- // add to group
- $this->select("group_id", "label=$groupName");
- $this->click("_qf_GroupContact_next");
- $this->waitForElementPresent('link=Remove');
-
- // Enable CiviCampaign module if necessary
- $this->enableComponents("CiviCampaign");
-
- // add the required permission
- $this->changePermissions("edit-2-administer-civicampaign");
-
- // Log in as normal user
- $this->webtestLogin();
-
- $this->openCiviPage("campaign", "reset=1", "link=Add Campaign");
-
- if ($this->isTextPresent('None found.')) {
- $this->openCiviPage("participant/add", "reset=1&action=add&context=standalone", "_qf_Participant_upload-bottom");
- $this->assertTrue($this->isTextPresent('There are currently no active Campaigns.'));
- }
- $this->openCiviPage("campaign/add", "reset=1", "_qf_Campaign_upload-bottom");
-
- $campaignTitle = "Campaign $title";
- $this->type("title", $campaignTitle);
-
- // select the campaign type
- $this->select("campaign_type_id", "value=2");
-
- // fill in the description
- $this->type("description", "This is a test campaign");
-
- // include groups for the campaign
- $this->waitForAjaxContent();
- $this->multiselect2("includeGroups", array("$groupName", "Advisory Board"));
-
- // fill the end date for campaign
- $this->webtestFillDate("end_date", "+1 year");
-
- // select campaign status
- $this->select("status_id", "value=2");
-
- // click save
- $this->click("_qf_Campaign_upload-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->assertTrue($this->isTextPresent("Campaign Campaign $title has been saved."),
- "Status message didn't show up after saving campaign!"
- );
-
- $this->waitForElementPresent("//div[@id='campaignList']/div/table/tbody/tr/td[3]/div[text()='{$campaignTitle}']/../../td[1]");
- $id = (int) $this->getText("//div[@id='campaignList']/div/table/tbody/tr/td[3]/div[text()='{$campaignTitle}']/../../td[1]");
-
- $this->offlineParticipantAddTest($campaignTitle, $id);
- }
-
- /**
- * @param $campaignTitle
- * @param int $id
- */
- public function offlineParticipantAddTest($campaignTitle, $id) {
- // connect campaign with event
- $this->openCiviPage("event/manage", "reset=1");
- $eventId = $this->registerUrl();
-
- $this->openCiviPage('event/manage/settings', "reset=1&action=update&id=$eventId", "_qf_EventInfo_cancel-bottom");
- $this->waitForElementPresent('title');
- $eventName = $this->getAttribute("//*[@id='title']@value");
- // select campaign
- $this->click("campaign_id");
- $this->select("campaign_id", "value=$id");
- $this->waitForElementPresent('_qf_EventInfo_upload_done-bottom');
- $this->clickLink("_qf_EventInfo_upload_done-bottom");
-
- // Adding contact with randomized first name (so we can then select that contact when creating event registration)
- // We're using Quick Add block on the main page for this.
- $firstName = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName, "Anderson", TRUE);
- $contactName = "Anderson, $firstName";
- $displayName = "$firstName Anderson";
-
- $this->openCiviPage("participant/add", "reset=1&action=add&context=standalone", "_qf_Participant_upload-bottom");
-
- // Type contact last name in contact auto-complete, wait for dropdown and click first result
- $this->webtestFillAutocomplete($firstName);
-
- // Select event. Based on label for now.
- $this->select2("event_id", $eventName);
-
- // Select role
- $this->waitForAjaxContent();
- $this->multiselect2("role_id", array('Volunteer'));
-
- // Choose Registration Date.
- // Using helper webtestFillDate function.
- $this->webtestFillDate('register_date', 'now');
- $today = date('F jS, Y', strtotime('now'));
- // May 5th, 2010
-
- // Select participant status
- $this->select("status_id", "value=1");
-
- // Setting registration source
- $this->type("source", "Event StandaloneAddTest Webtest");
-
- // Since we're here, let's check of screen help is being displayed properly
- $this->assertTrue($this->isTextPresent("Source for this registration (if applicable)."));
-
- // Select an event fee
- $this->waitForElementPresent('priceset');
- $this->click("xpath=//*[@id='priceset']//input[1][@class='crm-form-radio']");
-
- // Select 'Record Payment'
- $this->click("record_contribution");
-
- // Enter amount to be paid (note: this should default to selected fee level amount, s/b fixed during 3.2 cycle)
- $this->type("total_amount", "800");
-
- // Select payment method = Check and enter chk number
- $this->select("payment_instrument_id", "value=4");
- $this->waitForElementPresent("check_number");
- $this->type("check_number", "1044");
-
- // go for the chicken combo (obviously)
- // $this->click("CIVICRM_QFID_chicken_Chicken");
-
- // Clicking save.
- $this->click("_qf_Participant_upload-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Is status message correct?
- $this->waitForText("crm-notification-container", "Event registration for $displayName has been added", "Status message didn't show up after saving!");
-
- $this->waitForElementPresent("xpath=//*[@id='Search']//table//tbody/tr[1]/td[8]/span/a[text()='View']");
- //click through to the participant view screen
- $this->click("xpath=//*[@id='Search']//table//tbody/tr[1]/td[8]/span/a[text()='View']");
- $this->waitForElementPresent("_qf_ParticipantView_cancel-bottom");
-
- // verify participant record
- $this->verifyText("xpath=id('ParticipantView')/div[2]/table[1]/tbody/tr[3]/td[2]", preg_quote($campaignTitle));
-
- $this->openCiviPage("admin/setting/component", "reset=1", "_qf_Component_next-bottom");
- $this->addSelection("enableComponents-t", "label=CiviCampaign");
- $this->click("//option[@value='CiviCampaign']");
- $this->click("remove");
- $this->click("_qf_Component_next-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->assertTrue($this->isTextPresent("Changes Saved"));
-
- $this->openCiviPage("event/search", "reset=1", "_qf_Search_refresh");
-
- $this->type('sort_name', $firstName);
- $this->click("_qf_Search_refresh");
- $this->waitForElementPresent("xpath=//table[@class='selector row-highlight']");
- $this->click("xpath=//table[@class='selector row-highlight']/tbody/tr/td[11]/span/a[text()='Edit']");
- $this->waitForElementPresent("_qf_Participant_cancel-bottom");
- $this->assertTrue($this->isTextPresent("$campaignTitle"));
- }
-
- /**
- * @return mixed
- */
- public function registerUrl() {
- $this->openCiviPage("event/manage", "reset=1");
- $eventId = explode('-', $this->getAttribute("//div[@id='event_status_id']//div[2]/table/tbody/tr@id"));
- return $eventId[1];
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Campaign_OnlineContributionTest
- */
-class WebTest_Campaign_OnlineContributionTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testCreateCampaign() {
- $this->webtestLogin('admin');
-
- // Create new group
- $title = substr(sha1(rand()), 0, 7);
- $groupName = $this->WebtestAddGroup();
-
- // Adding contact
- // We're using Quick Add block on the main page for this.
- $firstName1 = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName1, "Smith", "$firstName1.smith@example.org");
-
- // add contact to group
- // visit group tab
- $this->click("css=li#tab_group a");
- $this->waitForElementPresent("group_id");
-
- // add to group
- $this->select("group_id", "label=$groupName");
- $this->click("_qf_GroupContact_next");
- $this->waitForElementPresent('link=Remove');
-
- $firstName2 = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName2, "John", "$firstName2.john@example.org");
-
- // add contact to group
- // visit group tab
- $this->click("css=li#tab_group a");
- $this->waitForElementPresent("group_id");
-
- // add to group
- $this->select("group_id", "label=$groupName");
- $this->click("_qf_GroupContact_next");
- $this->waitForElementPresent('link=Remove');
-
- // Enable CiviCampaign module if necessary
- $this->enableComponents(array('CiviCampaign'));
-
- // add the required permission
- $permissions = array(
- 'edit-2-administer-civicampaign',
- 'edit-1-make-online-contributions',
- 'edit-1-profile-listings-and-forms',
- );
- $this->changePermissions($permissions);
-
- // Log in as normal user
- $this->webtestLogin();
- $this->openCiviPage("campaign/add", "reset=1", "_qf_Campaign_upload-bottom");
-
- $campaignTitle = "Campaign $title";
- $this->type("title", $campaignTitle);
-
- // select the campaign type
- $this->select("campaign_type_id", "value=2");
-
- // fill in the description
- $this->type("description", "This is a test campaign");
-
- // include groups for the campaign
- $this->multiselect2("includeGroups", array("$groupName", "Advisory Board"));
-
- // fill the end date for campaign
- $this->webtestFillDate("end_date", "+1 year");
-
- // select campaign status
- $this->select("status_id", "value=2");
-
- // click save
- $this->click("_qf_Campaign_upload-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->waitForText('crm-notification-container', "Campaign $title");
-
- $this->waitForElementPresent("//div[@id='campaignList']/div/table/tbody//tr/td[3]/div[text()='{$campaignTitle}']/../../td[1]");
- $id = (int) $this->getText("//div[@id='campaignList']/div/table/tbody//tr/td[3]/div[text()='{$campaignTitle}']/../../td[1]");
-
- $this->onlineContributionAddTest($campaignTitle, $id);
- }
-
- /**
- * @param $campaignTitle
- * @param int $id
- */
- public function onlineContributionAddTest($campaignTitle, $id) {
- // Use default payment processor
- $processorName = 'Test Processor';
- $paymentProcessorId = $this->webtestAddPaymentProcessor($processorName);
-
- $this->openCiviPage("admin/contribute/add", "reset=1&action=add");
-
- $contributionTitle = substr(sha1(rand()), 0, 7);
- $rand = 2 * rand(2, 50);
-
- // fill in step 1 (Title and Settings)
- $contributionPageTitle = "Title $contributionTitle";
- $this->type('title', $contributionPageTitle);
- $this->select('financial_type_id', 'value=1');
-
- // select campaign
- $this->click("campaign_id");
- $this->select("campaign_id", "value=$id");
-
- $this->fillRichTextField('intro_text', 'This is Test Introductory Message', 'CKEditor');
- $this->fillRichTextField('footer_text', 'This is Test Footer Message', 'CKEditor');
-
- // Submit form
- $this->clickLink('_qf_Settings_next', "_qf_Amount_next-bottom");
-
- // Get contribution page id
- $pageId = $this->urlArg('id');
-
- //this contribution page for online contribution
- $this->check("payment_processor[{$paymentProcessorId}]");
- $this->assertElementContainsText('crm-container', "Contribution Amounts section enabled");
- $this->type("label_1", "amount 1");
- $this->type("value_1", "100");
- $this->type("label_2", "amount 2");
- $this->type("value_2", "200");
- $this->click("xpath=//*[@id='map-field-table']//tr[2]//input[1][@name='default']");
-
- $this->click("_qf_Amount_next-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // go to step 4
- $this->click("//div[@id='mainTabContainer']/ul//li/a[text()='Receipt']");
- $this->waitForElementPresent('_qf_ThankYou_next-bottom');
-
- // fill in step 4 (Thanks and Receipt)
- $this->type('thankyou_title', "Thank-you Page Title $contributionTitle");
- $this->type('receipt_from_name', "Receipt From Name $contributionTitle");
- $this->type('receipt_from_email', "$contributionTitle@example.org");
- $this->type('receipt_text', "Receipt Message $contributionTitle");
- $this->type('cc_receipt', "$contributionTitle@example.net");
- $this->type('bcc_receipt', "$contributionTitle@example.com");
-
- $this->click('_qf_ThankYou_next-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // go to step 5
- $this->click("//div[@id='mainTabContainer']/ul//li/a[text()='Tell a Friend']");
- $this->waitForElementPresent("_qf_Contribute_next-bottom");
-
- // fill in step 5 (Tell a Friend)
- $this->click('tf_is_active');
- $this->type('tf_title', "TaF Title $contributionTitle");
- $this->type('intro', "TaF Introduction $contributionTitle");
- $this->type('suggested_message', "TaF Suggested Message $contributionTitle");
- $this->type('general_link', "TaF Info Page Link $contributionTitle");
- $this->type('tf_thankyou_title', "TaF Thank-you Title $contributionTitle");
- $this->type('tf_thankyou_text', "TaF Thank-you Message $contributionTitle");
-
- $this->click('_qf_Contribute_next-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // go to step 6
- $this->click("//div[@id='mainTabContainer']/ul//li/a[text()='Profiles']");
- $this->waitForElementPresent("_qf_Custom_next-bottom");
-
- // fill in step 6 (Include Profiles)
- $this->select('css=tr.crm-contribution-contributionpage-custom-form-block-custom_pre_id span.crm-profile-selector-select select', 'value=1');
-
- $this->click('_qf_Custom_next-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // go to step 7
- $this->click("//div[@id='mainTabContainer']/ul//li/a[text()='Premiums']");
- $this->waitForElementPresent("_qf_Premium_next-bottom");
-
- // fill in step 7 (Premiums)
- $this->click('premiums_active');
- $this->type('premiums_intro_title', "Prem Title $contributionTitle");
- $this->type('premiums_intro_text', "Prem Introductory Message $contributionTitle");
- $this->type('premiums_contact_email', "$contributionTitle@example.info");
- $this->type('premiums_contact_phone', rand(100000000, 999999999));
- $this->click('premiums_display_min_contribution');
- $this->type('premiums_nothankyou_label', "No Thank you ");
-
- $this->click('_qf_Premium_next-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // go to step 8
- $this->click("//div[@id='mainTabContainer']/ul//li/a[text()='Widgets']");
- $this->waitForElementPresent("_qf_Widget_next-bottom");
-
- // fill in step 8 (Widget Settings)
- $this->click('is_active');
- $this->type('url_logo', "URL to Logo Image $contributionTitle");
- $this->type('button_title', "Button Title $contributionTitle");
- $this->type('about', "About $contributionTitle");
-
- $this->click('_qf_Widget_next-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // go to step 9
- $this->click("//div[@id='mainTabContainer']/ul//li/a[text()='Personal Campaigns']");
- $this->waitForElementPresent("_qf_Contribute_next-bottom");
-
- // fill in step 9 (Enable Personal Campaign Pages)
- $this->click('pcp_active');
- $this->click('is_approval_needed');
- $this->type('notify_email', "$contributionTitle@example.name");
- $this->select('supporter_profile_id', 'value=2');
- $this->type('tellfriend_limit', 7);
- $this->type('link_text', "'Create Personal Campaign Page' link text $contributionTitle");
-
- // submit new contribution page
- $this->click('_qf_Contribute_next-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Make sure our page shows up in search results
- $this->openCiviPage("admin/contribute", "reset=1", "_qf_SearchContribution_refresh");
- $this->type('title', $contributionPageTitle);
- $this->click("_qf_SearchContribution_refresh");
- $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
- $url = $this->assertElementContainsText("//div[@id='configure_contribution_page']//table/tbody", $contributionPageTitle);
-
- //logout
- $this->webtestLogout();
-
- //Open Live Contribution Page
- $this->openCiviPage('contribute/transact', "reset=1&id=$pageId&action=preview", '_qf_Main_upload-bottom');
-
- $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
- $lastName = 'An' . substr(sha1(rand()), 0, 7);
- $this->type("first_name", $firstName);
- $this->type("last_name", $lastName);
-
- $this->type("email-5", $firstName . "@example.com");
-
- $streetAddress = "100 Main Street";
- $this->type("street_address-1", $streetAddress);
- $this->type("city-1", "San Francisco");
- $this->type("postal_code-1", "94117");
- $this->select("country-1", "value=1228");
- $this->select("state_province-1", "value=1001");
-
- //Credit Card Info
- $this->select("credit_card_type", "value=Visa");
- $this->type("credit_card_number", "4111111111111111");
- $this->type("cvv2", "000");
- $this->select("credit_card_exp_date[M]", "value=1");
- $this->select("credit_card_exp_date[Y]", "value=2020");
-
- //Billing Info
- $this->type("billing_first_name", $firstName . "billing");
- $this->type("billing_last_name", $lastName . "billing");
- $this->type("billing_street_address-5", "15 Main St.");
- $this->type(" billing_city-5", "San Jose");
- $this->select("billing_country_id-5", "value=1228");
- $this->select("billing_state_province_id-5", "value=1004");
- $this->type("billing_postal_code-5", "94129");
- $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
-
- $this->clickLink("_qf_Confirm_next-bottom", NULL);
-
- //login to check contribution
- $this->webtestLogin();
-
- //Find Contribution
- $this->openCiviPage("contribute/search", "reset=1", "contribution_date_low");
- $this->click("xpath=//tr/td[1]/label[contains(text(), 'Contribution is a Test?')]/../../td[2]/label[contains(text(), 'Yes')]/preceding-sibling::input[1]");
- $this->type("sort_name", "$lastName $firstName");
- $this->clickLink("_qf_Search_refresh", "xpath=//table[@class='selector row-highlight']/tbody/tr[1]/td[10]/span//a[text()='View']", FALSE);
- $this->clickLink("xpath=//table[@class='selector row-highlight']/tbody/tr[1]/td[10]/span//a[text()='View']", "_qf_ContributionView_cancel-bottom", FALSE);
- //View Contribution Record
- $this->assertElementContainsText("xpath=//form[@class='CRM_Contribute_Form_ContributionView']/div[2]//table[1]/tbody/tr[10]/td[2]", $campaignTitle);
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Campaign_OnlineEventRegistrationTest
- */
-class WebTest_Campaign_OnlineEventRegistrationTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testCreateCampaign() {
- $this->webtestLogin('admin');
-
- // Create new group
- $title = substr(sha1(rand()), 0, 7);
- $groupName = $this->WebtestAddGroup();
-
- // Adding contact
- // We're using Quick Add block on the main page for this.
- $firstName1 = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName1, "Smith", "$firstName1.smith@example.org");
-
- // add contact to group
- // visit group tab
- $this->click("css=li#tab_group a");
- $this->waitForElementPresent("group_id");
-
- // add to group
- $this->select("group_id", "label=$groupName");
- $this->click("_qf_GroupContact_next");
- $this->waitForElementPresent('link=Remove');
-
- $firstName2 = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName2, "John", "$firstName2.john@example.org");
-
- // add contact to group
- // visit group tab
- $this->click("css=li#tab_group a");
- $this->waitForElementPresent("group_id");
-
- // add to group
- $this->select("group_id", "label=$groupName");
- $this->click("_qf_GroupContact_next");
- $this->waitForElementPresent('link=Remove');
-
- // Enable CiviCampaign module if necessary
- $this->enableComponents(array('CiviCampaign'));
-
- // add the required permission
- $permissions = array('edit-2-administer-civicampaign', 'edit-1-register-for-events');
- $this->changePermissions($permissions);
-
- // Log in as normal user
- $this->webtestLogin();
-
- $this->openCiviPage("campaign/add", "reset=1", "_qf_Campaign_upload-bottom");
-
- $campaignTitle = "Campaign $title";
- $this->type("title", $campaignTitle);
-
- // select the campaign type
- $this->select("campaign_type_id", "value=2");
-
- // fill in the description
- $this->type("description", "This is a test campaign");
-
- // include groups for the campaign
- $this->multiselect2("includeGroups", array("$groupName", "Advisory Board"));
-
- // fill the end date for campaign
- $this->webtestFillDate("end_date", "+1 year");
-
- // select campaign status
- $this->select("status_id", "value=2");
-
- // click save
- $this->click("_qf_Campaign_upload-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->waitForText('crm-notification-container', "Campaign $title");
-
- $this->waitForElementPresent("//div[@id='campaignList']/div/table/tbody/tr/td[3]/div[text()='{$campaignTitle}']/../../td[1]");
- $id = (int) $this->getText("//div[@id='campaignList']/div/table/tbody/tr/td[3]/div[text()='{$campaignTitle}']/../../td[1]");
-
- $this->onlineParticipantAddTest($campaignTitle, $id);
- }
-
- /**
- * @param $campaignTitle
- * @param int $id
- */
- public function onlineParticipantAddTest($campaignTitle, $id) {
- // Use default payment processor
- $processorName = 'Test Processor';
- $paymentProcessorId = $this->webtestAddPaymentProcessor($processorName);
-
- $this->openCiviPage("event/add", "reset=1&action=add");
-
- $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7);
- $eventDescription = "Here is a description for this conference.";
- $this->_testAddEventInfo($id, $eventTitle, $eventDescription);
-
- $streetAddress = "100 Main Street";
- $this->_testAddLocation($streetAddress);
-
- $this->_testAddFees(FALSE, FALSE, $processorName);
-
- // intro text for registration page
- $registerIntro = "Fill in all the fields below and click Continue.";
- $multipleRegistrations = TRUE;
- $this->_testAddOnlineRegistration($registerIntro, $multipleRegistrations);
-
- $eventInfoStrings = array($eventTitle, $eventDescription, $streetAddress);
- $this->_testVerifyEventInfo($eventTitle, $eventInfoStrings);
-
- $registerStrings = array("Member - $ 250.00", "Non-member - $ 325.00", $registerIntro);
- $registerUrl = $this->_testVerifyRegisterPage($registerStrings);
-
- $numberRegistrations = 3;
- $anonymous = TRUE;
-
- $this->_testOnlineRegistration($campaignTitle, $registerUrl, $numberRegistrations, $anonymous);
- }
-
- /**
- * @param int $id
- * @param $eventTitle
- * @param $eventDescription
- */
- public function _testAddEventInfo($id, $eventTitle, $eventDescription) {
- $this->waitForElementPresent("_qf_EventInfo_upload-bottom");
-
- $this->select("event_type_id", "value=1");
-
- // select campaign
- $this->click("campaign_id");
- $this->select("campaign_id", "value=$id");
-
- // Attendee role s/b selected now.
- $this->select("default_role_id", "value=1");
-
- // Enter Event Title, Summary and Description
- $this->type("title", $eventTitle);
- $this->type("summary", "This is a great conference. Sign up now!");
-
- // Type description in ckEditor (fieldname, text to type, editor)
- $this->fillRichTextField("description", $eventDescription, 'CKEditor');
-
- // Choose Start and End dates.
- // Using helper webtestFillDate function.
- $this->webtestFillDateTime("start_date", "+1 week");
- $this->webtestFillDateTime("end_date", "+1 week 1 day 8 hours ");
-
- $this->type("max_participants", "50");
- $this->click("is_map");
- $this->click("_qf_EventInfo_upload-bottom");
- }
-
- /**
- * @param $streetAddress
- */
- public function _testAddLocation($streetAddress) {
- // Wait for Location tab form to load
- $this->waitForElementPresent("_qf_Location_upload-bottom");
-
- // Fill in address fields
- $streetAddress = "100 Main Street";
- $this->waitForElementPresent('address_1_street_address');
- $this->type("address_1_street_address", $streetAddress);
- $this->waitForElementPresent('address_1_city');
- $this->type("address_1_city", "San Francisco");
- $this->type("address_1_postal_code", "94117");
- $this->select('address_1_country_id', 'UNITED STATES');
- $this->select("address_1_state_province_id", "value=1004");
- $this->type("email_1_email", "info@civicrm.org");
-
- $this->clickLink("_qf_Location_upload-bottom", '', FALSE);
-
- // Wait for "saved" status msg
- $this->waitForText('crm-notification-container', "saved");
- }
-
- /**
- * @param bool $discount
- * @param bool $priceSet
- * @param int $processorIds
- */
- public function _testAddFees($discount = FALSE, $priceSet = FALSE, $processorIds) {
- // Go to Fees tab
- $this->click("link=Fees");
- $this->waitForElementPresent("_qf_Fee_upload-bottom");
- $this->click("CIVICRM_QFID_1_is_monetary");
- $this->select2('payment_processor', $processorIds, TRUE);
- $this->select("financial_type_id", "value=4");
- if ($priceSet) {
- // get one - TBD
- }
- else {
- $this->type("label_1", "Member");
- $this->type("value_1", "250.00");
- $this->type("label_2", "Non-member");
- $this->type("value_2", "325.00");
- //add a default fee
- $this->check("xpath=//table[@id='map-field-table']/tbody/tr[2]/td[3]/input[@name='default']");
- }
-
- if ($discount) {
- // enter early bird discounts TBD
- }
-
- $this->click("_qf_Fee_upload-bottom");
-
- // Wait for "saved" status msg
- $this->waitForText('crm-notification-container', "saved");
- }
-
- /**
- * @param $registerIntro
- * @param bool $multipleRegistrations
- */
- public function _testAddOnlineRegistration($registerIntro, $multipleRegistrations = FALSE) {
- // Go to Online Registration tab
- $this->click("link=Online Registration");
- $this->waitForElementPresent("_qf_Registration_upload-bottom");
-
- $this->click("is_online_registration");
- $this->assertChecked("is_online_registration");
- if ($multipleRegistrations) {
- $this->check("is_multiple_registrations");
- $this->assertChecked("is_multiple_registrations");
- }
-
- $this->click("xpath=//div[@id='registration_screen']/table/tbody/tr[1]/td[2]/div[@class='replace-plain']");
- $this->fillRichTextField('intro_text', $registerIntro, 'CKEditor', TRUE);
-
- // enable confirmation email
- $this->click("CIVICRM_QFID_1_is_email_confirm");
- $this->type("confirm_from_name", "Jane Doe");
- $this->type("confirm_from_email", "jane.doe@example.org");
-
- $this->click("_qf_Registration_upload-bottom");
- $this->waitForText('crm-notification-container', "saved");
- }
-
- /**
- * @param $eventTitle
- * @param $eventInfoStrings
- */
- public function _testVerifyEventInfo($eventTitle, $eventInfoStrings) {
- // verify event input on info page
- // start at Manage Events listing
- $this->openCiviPage("event/manage", "reset=1");
- $this->clickLink("link=$eventTitle", "link=Register Now");
-
- // Check for correct event info strings
- $this->assertStringsPresent($eventInfoStrings);
- }
-
- /**
- * @param $registerStrings
- *
- * @return string
- */
- public function _testVerifyRegisterPage($registerStrings) {
- // Go to Register page and check for intro text and fee levels
- $this->click("link=Register Now");
- $this->waitForElementPresent("_qf_Register_upload-bottom");
- $this->assertStringsPresent($registerStrings);
- return $this->getLocation();
- }
-
- /**
- * @param $campaignTitle
- * @param $registerUrl
- * @param int $numberRegistrations
- * @param bool $anonymous
- */
- public function _testOnlineRegistration($campaignTitle, $registerUrl, $numberRegistrations = 1, $anonymous = TRUE) {
- if ($anonymous) {
- $this->webtestLogout();
- }
- $this->open($registerUrl);
-
- $this->select("additional_participants", "value=" . $numberRegistrations);
-
- $this->type("first_name", 'Jane');
- $lastName = "Smith" . substr(sha1(rand()), 0, 7);
- $this->type("last_name", $lastName);
- $email = "smith" . substr(sha1(rand()), 0, 7) . "@example.org";
- $this->type("email-Primary", $email);
-
- $this->select("credit_card_type", "value=Visa");
- $this->type("credit_card_number", "4111111111111111");
- $this->type("cvv2", "000");
- $this->select("credit_card_exp_date[M]", "value=1");
- $this->select("credit_card_exp_date[Y]", "value=2020");
- $this->type("billing_first_name", "Jane");
- $this->type("billing_last_name", $lastName);
- $this->type("billing_street_address-5", "15 Main St.");
- $this->type(" billing_city-5", "San Jose");
- $this->select("billing_country_id-5", "value=1228");
- $this->select("billing_state_province_id-5", "value=1004");
- $this->type("billing_postal_code-5", "94129");
-
- $this->click("_qf_Register_upload-bottom");
-
- if ($numberRegistrations > 1) {
- for ($i = 1; $i <= $numberRegistrations; $i++) {
- $this->waitForPageToLoad($this->getTimeoutMsec());
- // Look for Skip button
- $this->waitForElementPresent("_qf_Participant_{$i}_next_skip-Array");
- $this->type("first_name", "Jane Add $i");
- $this->type("last_name", "Smith" . substr(sha1(rand()), 0, 7));
- $this->type("email-Primary", "smith" . substr(sha1(rand()), 0, 7) . "@example.org");
- $this->click("_qf_Participant_{$i}_next");
- }
- }
-
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForElementPresent("_qf_Confirm_next-bottom");
- $confirmStrings = array("Event Fee(s)", "Billing Name and Address", "Credit Card Information");
- $this->assertStringsPresent($confirmStrings);
- $this->click("_qf_Confirm_next-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $thankStrings = array("Thank You for Registering", "Event Total", "Transaction Date");
- $this->assertStringsPresent($thankStrings);
-
- $this->webtestLogin();
- $this->openCiviPage('event/search', 'reset=1', '_qf_Search_refresh');
-
- $this->type('sort_name', $email);
- $this->click("_qf_Search_refresh");
- $this->waitForElementPresent("xpath=//div[@id='participantSearch']");
- $this->click("xpath=//div[@id='participantSearch']/table/tbody/tr/td[11]/span[1]/a[2][text()='Edit']");
- $this->waitForElementPresent("_qf_Participant_cancel-bottom");
- $this->assertElementContainsText("xpath=//div[@id='s2id_campaign_id']", "$campaignTitle");
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Campaign_PetitionUsageScenarioTest
- */
-class WebTest_Campaign_PetitionUsageScenarioTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testPetitionUsageScenario() {
- $this->markTestSkipped('Skipping for now as it works fine locally.');
- $this->webtestLogin('admin');
-
- // Enable CiviCampaign module if necessary
- $this->enableComponents("CiviCampaign");
-
- // handle permissions early
-
- // let's give permission 'sign CiviCRM Petition' to anonymous user.
- $permissions = array(
- // give profile related permision
- "edit-1-sign-civicrm-petition",
- "edit-1-profile-create",
- "edit-1-profile-edit",
- "edit-1-profile-listings",
- "edit-1-profile-view",
- // now give full permissions to CiviPetition to registered user
- "edit-2-administer-civicampaign",
- "edit-2-manage-campaign",
- "edit-2-gotv-campaign-contacts",
- "edit-2-interview-campaign-contacts",
- "edit-2-release-campaign-contacts",
- "edit-2-reserve-campaign-contacts",
- "edit-2-sign-civicrm-petition",
- );
- $this->changePermissions($permissions);
-
- // Log in as normal user
- $this->webtestLogin();
-
- /////////////// Create Campaign ///////////////////////////////
-
- $this->openCiviPage("campaign/add", "reset=1", "_qf_Campaign_upload-bottom");
-
- $title = substr(sha1(rand()), 0, 7);
- $this->type("title", "$title Campaign");
-
- // select the campaign type
- $this->select("campaign_type_id", "value=2");
-
- // fill in the description
- $this->type("description", "This is a test campaign");
-
- // include groups for the campaign
- $this->addSelection("includeGroups", "label=Advisory Board");
- $this->click("//option[@value=4]");
-
- // fill the end date for campaign
- $this->webtestFillDate("end_date", "+1 year");
-
- // select campaign status
- $this->select("status_id", "value=2");
-
- // click save
- $this->clickLink('_qf_Campaign_upload-bottom');
-
- $this->waitForText('crm-notification-container', "Campaign $title Campaign has been saved.");
-
- ////////////// Create petition using New Individual profile //////////////////////
-
- $this->openCiviPage("petition/add", "reset=1", "_qf_Petition_next-bottom");
-
- // fill petition tile.
- $title = substr(sha1(rand()), 0, 7);
- $this->type("title", "$title Petition");
-
- // fill introduction
- //$this->type("cke_instructions", "This is introduction of $title Petition");
-
- // select campaign
- $this->select("campaign_id", "value=1");
-
- // select profile
- $this->select("contact_profile_id", "value=4");
-
- // click save
- $this->clickLink('_qf_Petition_next-bottom');
-
- $this->waitForText('crm-notification-container', "Petition has been saved.");
-
- $this->waitForElementPresent("link=Add Petition");
- $this->waitForElementPresent("search_form_petition");
- $this->click("search_form_petition");
- $this->type("petition_title", $title);
-
- $this->click("xpath=//div[@class='crm-accordion-body']/table/tbody/tr[2]/td/a[text()='Search']");
- $this->waitForElementPresent("xpath=//div[@id='petitionList']/div/table/tbody//tr//td[@class=' crm-petition-action']//span[text()='more']/ul//li/a[text()='Sign']");
- $url = $this->getAttribute("xpath=//div[@id='petitionList']/div/table/tbody//tr//td[@class=' crm-petition-action']//span[text()='more']/ul//li/a[text()='Sign']@href");
-
- ////////////// Retrieve Sign Petition Url /////////////////////////
-
- // logout and sign as anonymous.
- $this->webtestLogout();
-
- // go to the link that you will be sign as anonymous
- $this->open($url);
- $this->waitForElementPresent("_qf_Signature_next-bottom");
-
- // fill first name
- $firstName = substr(sha1(rand()), 0, 7);
- $this->type("first_name", $firstName);
-
- // fill last name
- $lastName = substr(sha1(rand()), 0, 7);
- $this->type("last_name", $lastName);
-
- // fill email
- $email = $firstName . "@" . $lastName . ".com";
- $this->type("email-Primary", $email);
-
- // click Sign the petition.
- $this->clickLink('_qf_Signature_next-bottom', NULL);
- $this->waitForText('page-title', "Thank You");
-
- // login
- $this->webtestLogin();
-
- $this->openCiviPage("campaign", "reset=1&subPage=petition", "link=Add Petition");
-
- // check for unconfirmed petition signature
- $this->waitForElementPresent("search_form_petition");
- $this->click("search_form_petition");
- $this->type("petition_title", $title);
- $this->click("xpath=//div[@class='crm-accordion-body']/table/tbody/tr[2]/td/a[text()='Search']");
-
- $this->waitForElementPresent("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[10]/span[2][text()='more']");
- $this->click("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[10]/span[2][text()='more']/ul/li[3]/a[text()='Signatures']");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // verify tabular data
- $expected = array(
- 2 => 'Petition',
- 3 => "$title Petition",
- 4 => "$lastName, $firstName",
- 5 => "$lastName, $firstName",
- 8 => 'Scheduled',
- );
-
- foreach ($expected as $column => $value) {
- $this->verifyText("xpath=//div[@class='crm-search-results']/table/tbody/tr[2]/td[$column]/", preg_quote($value));
- }
-
- // ONCE MORE, NO EMAIL VERIFICATION AND CUSTOM THANK-YOU
- $this->openCiviPage("petition/add", "reset=1", "_qf_Petition_next-bottom");
-
- // fill petition tile.
- $title = substr(sha1(rand()), 0, 7);
- $this->type("title", "$title Petition");
-
- // fill introduction
- //$this->type("cke_instructions", "This is introduction of $title Petition");
-
- // select campaign
- $this->select("campaign_id", "value=1");
-
- // select profile
- $this->select("contact_profile_id", "value=4");
-
- // bypass email confirmation
- $this->click("bypass_confirm");
-
- // set custom thank-you title and text
- $this->type('thankyou_title', "Awesome $title donation");
- $this->fillRichTextField('thankyou_text', "Thank you for your kind contribution to support $title", 'CKEditor');
-
- // click save
- $this->clickLink('_qf_Petition_next-bottom');
-
- $this->waitForText('crm-notification-container', "Petition has been saved.");
-
- $this->waitForElementPresent("link=Add Petition");
-
- $this->waitForElementPresent("search_form_petition");
- $this->click("search_form_petition");
- $this->type("petition_title", $title);
-
- $this->click("xpath=//div[@class='crm-accordion-body']/table/tbody/tr[2]/td/a[text()='Search']");
-
- $this->waitForElementPresent("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[10]/span[2][text()='more']/ul/li[2]/a[text()='Sign']");
- $url = $this->getAttribute("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[10]/span[2][text()='more']/ul/li[2]/a[text()='Sign']@href");
-
- // logout and sign as anonymous.
- $this->webtestLogout();
-
- // go to the link that you will be sign as anonymous
- $this->open($url);
- $this->waitForElementPresent("_qf_Signature_next-bottom");
-
- // fill first name
- $firstName = substr(sha1(rand()), 0, 7);
- $this->type("first_name", $firstName);
-
- // fill last name
- $lastName = substr(sha1(rand()), 0, 7);
- $this->type("last_name", $lastName);
-
- // fill email
- $email = $firstName . "@" . $lastName . ".com";
- $this->type("email-Primary", $email);
-
- // click Sign the petition.
- $this->clickLink('_qf_Signature_next-bottom', 'thankyou_text');
-
- // check that thank-you page has appropriate title and message
- $this->waitForText('page-title', "Awesome $title donation");
- $this->waitForText('thankyou_text', "Thank you for your kind contribution to support $title");
-
- // login
- $this->webtestLogin();
-
- $this->openCiviPage("campaign", "reset=1&subPage=petition", "link=Add Petition");
-
- // check for confirmed petition signature
- $this->waitForElementPresent("search_form_petition");
- $this->click("search_form_petition");
- $this->type("petition_title", $title);
- $this->click("xpath=//div[@class='crm-accordion-body']/table/tbody/tr[2]/td/a[text()='Search']");
-
- $this->waitForElementPresent("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[10]/span[2][text()='more']");
- $this->click("xpath=//table[@class='petitions dataTable no-footer']/tbody/tr/td[10]/span[2][text()='more']/ul/li[3]/a[text()='Signatures']");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // verify tabular data
- $expected = array(
- 2 => 'Petition',
- 3 => "$title Petition",
- 4 => "$lastName, $firstName",
- 5 => "$lastName, $firstName",
- 8 => 'Completed',
- );
-
- foreach ($expected as $column => $value) {
- $this->verifyText("xpath=//div[@class='crm-search-results']/table/tbody/tr[2]/td[$column]/", preg_quote($value));
- }
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Campaign_PledgeTest
- */
-class WebTest_Campaign_PledgeTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testCreateCampaign() {
- // Log in as admin first to verify permissions for CiviGrant
- $this->webtestLogin('admin');
-
- // Enable CiviCampaign module and CiviPledge module if necessary
- $this->enableComponents(array("CiviCampaign", "CiviPledge"));
-
- // add the required Drupal permission
- $permissions = array(
- 'edit-2-access-civipledge',
- 'edit-2-edit-pledges',
- );
- $this->changePermissions($permissions);
-
- // Fixme: testing a theory that this test was failing due to permissions
- //$this->webtestLogin();
-
- // Create new group
- $title = substr(sha1(rand()), 0, 7);
- $groupName = $this->WebtestAddGroup();
-
- // Adding contact
- // We're using Quick Add block on the main page for this.
- $firstName1 = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName1, "Smith", "$firstName1.smith@example.org");
-
- // add contact to group
- // visit group tab
- $this->click("css=li#tab_group a");
- $this->waitForElementPresent("group_id");
-
- // add to group
- $this->select("group_id", "label=$groupName");
- $this->click("_qf_GroupContact_next");
- $this->waitForElementPresent('link=Remove');
-
- $firstName2 = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName2, "John", "$firstName2.john@example.org");
-
- // add contact to group
- // visit group tab
- $this->click("css=li#tab_group a");
- $this->waitForElementPresent("group_id");
-
- // add to group
- $this->select("group_id", "label=$groupName");
- $this->click("_qf_GroupContact_next");
- $this->waitForElementPresent('link=Remove');
-
- $this->openCiviPage("campaign/add", "reset=1", "_qf_Campaign_upload-bottom");
-
- $campaignTitle = "Campaign $title";
- $this->type("title", $campaignTitle);
-
- // select the campaign type
- $this->select("campaign_type_id", "value=2");
-
- // fill in the description
- $this->type("description", "This is a test campaign");
-
- // include groups for the campaign
- $this->multiselect2("includeGroups", array("$groupName", "Advisory Board"));
-
- // fill the end date for campaign
- $this->webtestFillDate("end_date", "+1 year");
-
- // select campaign status
- $this->select("status_id", "value=2");
-
- // click save
- $this->click("_qf_Campaign_upload-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->assertTrue($this->isTextPresent("Campaign Campaign $title has been saved."),
- "Status message didn't show up after saving campaign!"
- );
-
- $this->waitForElementPresent("//div[@id='campaignList']/div/table/tbody/tr/td[3]/div[text()='{$campaignTitle}']/../../td[1]");
- $id = (int) $this->getText("//div[@id='campaignList']/div/table/tbody/tr/td[3]/div[text()='{$campaignTitle}']/../../td[1]");
- $this->pledgeAddTest($campaignTitle, $id);
- }
-
- /**
- * @param $campaignTitle
- * @param int $id
- */
- public function pledgeAddTest($campaignTitle, $id) {
- // create unique name
- $name = substr(sha1(rand()), 0, 7);
- $firstName = 'Adam' . $name;
- $lastName = 'Jones' . $name;
-
- // create new contact
- $this->webtestAddContact($firstName, $lastName, $firstName . "@example.com");
-
- // wait for action element
- $this->waitForElementPresent('crm-contact-actions-link');
-
- // now add pledge from contact summary
- $this->click("xpath=//div[@class='crm-actions-ribbon']/ul[@id='actions']/li[@class='crm-contact-activity crm-summary-block']/div/a[@id='crm-contact-actions-link']");
- $this->waitForElementPresent('crm-contact-actions-list');
-
- // wait for add plegde link
- $this->waitForElementPresent('link=Add Pledge');
-
- $this->click('link=Add Pledge');
-
- // wait for pledge form to load completely
- $this->waitForElementPresent('_qf_Pledge_upload-bottom');
-
- // check contact name on pledge form
- $this->assertTrue($this->isTextPresent("$firstName $lastName"));
-
- $this->type("amount", "100");
- $this->type("installments", "10");
- $this->select("frequency_unit", "value=week");
- $this->type("frequency_day", "2");
-
- $this->webtestFillDate('acknowledge_date', 'now');
-
- // select campaign
- $this->click("campaign_id");
- $this->select("campaign_id", "value=$id");
-
- $this->select("contribution_page_id", "value=3");
-
- //PaymentReminders
- $this->click("PaymentReminders");
- $this->waitForElementPresent("additional_reminder_day");
- $this->type("initial_reminder_day", "4");
- $this->type("max_reminders", "2");
- $this->type("additional_reminder_day", "4");
-
- $this->click("_qf_Pledge_upload-bottom");
- $this->waitForElementPresent('link=Add Pledge');
-
- $this->waitForText('crm-notification-container', "Pledge has been recorded and the payment schedule has been created.");
-
- $this->waitForElementPresent("xpath=//div[@class='view-content']//table//tbody/tr[1]/td[10]/span[1]/a[text()='View']");
- //click through to the Pledge view screen
- $this->click("xpath=//div[@class='view-content']//table//tbody/tr[1]/td[10]/span[1]/a[text()='View']");
- $this->waitForElementPresent("_qf_PledgeView_next-bottom");
- $pledgeDate = date('F jS, Y', strtotime('now'));
-
- // verify Activity created
- $this->verifyText("xpath=//form[@id='PledgeView']//table/tbody/tr[8]/td[2]", preg_quote($campaignTitle));
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Campaign_SurveyUsageScenarioTest
- */
-class WebTest_Campaign_SurveyUsageScenarioTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testSurveyUsageScenario() {
- $this->webtestLogin('admin');
-
- // Create new group
- $title = substr(sha1(rand()), 0, 7);
- $groupName = $this->WebtestAddGroup();
-
- // Adding contact
- $firstName1 = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName1, "Smith", "$firstName1.smith@example.org");
-
- // add contact to group
- // visit group tab
- $this->click("css=li#tab_group a");
- $this->waitForElementPresent("css=#group_id option");
-
- // add to group
- $this->select("group_id", "label=$groupName");
- $this->click("_qf_GroupContact_next");
- $this->waitForElementPresent('link=Remove');
-
- $firstName2 = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName2, "John", "$firstName2.john@example.org");
-
- // add contact to group
- // visit group tab
- $this->click("css=li#tab_group a");
- $this->waitForElementPresent("css=#group_id option");
-
- // add to group
- $this->select("group_id", "label=$groupName");
- $this->click("_qf_GroupContact_next");
- $this->waitForElementPresent('link=Remove');
-
- // Enable CiviCampaign module if necessary
- $this->enableComponents(array('CiviCampaign'));
-
- // add the required permission
- $this->changePermissions(array('edit-2-administer-civicampaign'));
-
- // Log in as normal user
- $this->webtestLogin();
-
- $this->openCiviPage("campaign/add", "reset=1", "_qf_Campaign_upload-bottom");
- $this->waitForElementPresent('title');
- $this->type("title", "Campaign $title");
-
- // select the campaign type
- $this->waitForElementPresent('campaign_type_id');
- $this->select("campaign_type_id", "value=2");
-
- // fill in the description
- $this->type("description", "This is a test campaign");
-
- // include groups for the campaign
- $this->addSelection("includeGroups", "label=$groupName");
- $this->click("//option[@value=4]");
-
- // fill the end date for campaign
- $this->webtestFillDate("end_date", "+1 year");
-
- // select campaign status
- $this->select("status_id", "value=2");
-
- // click save
- $this->click("_qf_Campaign_upload-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->waitForText('crm-notification-container', "$title");
-
- // create a custom data set for activities -> survey
- $this->openCiviPage('admin/custom/group', "action=add&reset=1", "_qf_Group_next-bottom");
- // fill in a unique title for the custom group
- $this->type("title", "Group $title");
-
- // select the group this custom data set extends
- $this->select("extends[0]", "value=Activity");
- $this->waitForElementPresent("//select[@id='extends_1']");
- $this->select("//select[@id='extends_1']", "label=Survey");
-
- // save the custom group
- $this->click("_qf_Group_next-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // add a custom field to the custom group
- $this->waitForElementPresent('label');
- $this->type("label", "Field $title");
-
- $this->select("data_type[1]", "value=Radio");
-
- $this->waitForElementPresent("option_label_1");
-
- // create a set of options
- $this->type("option_label_1", "Option $title 1");
- $this->type("option_value_1", "1");
-
- $this->type("option_label_2", "Option $title 2");
- $this->type("option_value_2", "2");
-
- // save the custom field
- $this->click("_qf_Field_done-bottom");
-
- $this->waitForElementPresent("newCustomField");
- $this->waitForText('crm-notification-container', "$title");
-
- // create a profile for campaign
- $this->openCiviPage("admin/uf/group/add", "action=add&reset=1", "_qf_Group_next-bottom");
-
- // fill in a unique title for the profile
- $this->type("title", "Profile $title");
-
- // save the profile
- $this->click("_qf_Group_next-bottom");
-
- $this->waitForElementPresent("xpath=//div[@id='crm-main-content-wrapper']/div/div[2]/a/span");
- $this->click("xpath=//div[@id='crm-main-content-wrapper']/div/div[2]/a/span");
-
- // add a profile field for activity
- $this->waitForElementPresent('field_name[0]');
- $this->select("field_name[0]", "value=Activity");
- $this->waitForElementPresent("field_name[1]");
- $this->select("field_name[1]", "label=Field $title :: Group $title");
-
- $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']/button[1]/span[2]");
- $this->click("xpath=//div[@class='ui-dialog-buttonset']/button[1]/span[2]");
- $this->waitForText('crm-notification-container', "$title");
-
- // create a survey
- $this->openCiviPage("survey/add", "reset=1", "_qf_Main_upload-bottom");
-
- // fill in a unique title for the survey
- $this->type("title", "Survey $title");
-
- // select the created campaign
- $this->select("campaign_id", "label=Campaign $title");
-
- // select the activity type
- $this->select("activity_type_id", "label=Survey");
-
- // fill in reserve survey respondents
- $this->type("default_number_of_contacts", 50);
-
- // fill in interview survey respondents
- $this->type("max_number_of_contacts", 100);
-
- // release frequency
- $this->type("release_frequency", 2);
-
- $this->click("_qf_Main_upload-bottom");
- $this->waitForElementPresent("_qf_Questions_upload_next-bottom");
-
- // Select the profile for the survey
- $this->select("//form[@id='Questions']/div[2]/table/tbody/tr[1]/td[2]/div/div/span/select", "label=New Individual");
-
- // select the question created for the survey
-
- $this->select("//form[@id='Questions']/div[2]/table/tbody/tr[2]/td[2]/div/div/span/select", "label=Profile $title");
- $this->click("_qf_Questions_upload_next-bottom");
-
- // create a set of options for Survey Responses _qf_Results_upload_done-bottom
- $this->waitForElementPresent('_qf_Results_upload_done-bottom');
- $this->type("//input[@id='option_label_1']", "Label $title 1");
- $this->type("//input[@id='option_value_1']", "1");
-
- $this->type("//input[@id='option_label_2']", "Label $title 2");
- $this->type("//input[@id='option_value_2']", "2");
- $this->click('_qf_Results_upload_done-bottom');
- $this->waitForElementPresent("//div[@id='search_form_survey']");
- $this->waitForText('crm-notification-container', "Results");
-
- // Reserve Respondents
- $this->openCiviPage("survey/search", "reset=1&op=reserve", "_qf_Search_refresh");
-
- // search for the respondents
- $this->select("campaign_survey_id", "label=Survey $title");
-
- $this->click("_qf_Search_refresh");
- $this->waitForElementPresent('toggleSelect');
- $this->click('toggleSelect');
- $this->select('task', "Reserve Respondents");
-
- $this->waitForElementPresent("_qf_Reserve_done_reserve-bottom");
- $this->click("_qf_Reserve_done_reserve-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForText('crm-notification-container', "2 contacts have been reserved.");
-
- // Interview Respondents
- $this->openCiviPage("survey/search", "reset=1&op=interview", "_qf_Search_refresh");
- // search for the respondents
- $this->waitForElementPresent('campaign_survey_id');
- $this->select("campaign_survey_id", "label=Survey $title");
- $this->click("_qf_Search_refresh");
-
- $this->waitForElementPresent('toggleSelect');
- $this->click("xpath=//table[@class='selector row-highlight']/thead/tr/th[1]/input[@id='toggleSelect']");
- $this->select('task', "Record Survey Responses");
- $this->waitForElementPresent("_qf_Interview_cancel_interview");
- $this->select("xpath=//table[@class='display crm-copy-fields dataTable no-footer']/tbody/tr[1]/td[@class='result']/select", "value=Label $title 1");
- $this->click("xpath=//table[@class='display crm-copy-fields dataTable no-footer']/tbody/tr[1]/td[9]/a[1]");
-
- $this->select("xpath=//table[@class='display crm-copy-fields dataTable no-footer']/tbody/tr[2]/td[@class='result']/select", "value=Label $title 2");
- $this->click("xpath=//table[@class='display crm-copy-fields dataTable no-footer']/tbody/tr[2]/td[9]/a[1]");
- $this->click("_qf_Interview_cancel_interview");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // add a contact to the group to test release respondents
- $firstName3 = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName3, "James", "$firstName3.james@example.org");
- $id = $this->urlArg('cid');
- $sortName3 = "James, $firstName3";
-
- // add contact to group
- // visit group tab
- $this->click("css=li#tab_group a");
- $this->waitForElementPresent("css=#group_id option");
-
- // add to group
- $this->select("group_id", "label=$groupName");
- $this->click("_qf_GroupContact_next");
- $this->waitForElementPresent('link=Remove');
-
- // Reserve Respondents
- $this->openCiviPage("survey/search", "reset=1&op=reserve", "_qf_Search_refresh");
-
- // search for the respondents
- $this->select("campaign_survey_id", "label=Survey $title");
-
- $this->click("_qf_Search_refresh");
- $this->waitForElementPresent('toggleSelect');
- $this->click('toggleSelect');
- $this->waitForElementPresent('task');
- $this->select('task', "Reserve Respondents");
- $this->waitForElementPresent("_qf_Reserve_done_reserve-bottom");
- $this->click("_qf_Reserve_done_reserve-bottom");
- $this->waitForText('crm-notification-container', "1 contact has been reserved.");
-
- // Release Respondents
- $this->openCiviPage("survey/search", "reset=1&op=release", "_qf_Search_refresh");
-
- // search for the respondents
- $this->select("campaign_survey_id", "label=Survey $title");
-
- $this->click("_qf_Search_refresh");
- $this->waitForElementPresent('toggleSelect');
- $this->click('toggleSelect');
- $this->waitForElementPresent('task');
- $this->select("task", "label=Release Respondents");
- $this->waitForElementPresent('_qf_Release_done-bottom');
- $this->click("_qf_Release_done-bottom");
- $this->waitForText('crm-notification-container', "released");
-
- // check whether contact is available for reserving again
- $this->openCiviPage("survey/search", "reset=1&op=reserve", "_qf_Search_refresh");
-
- // search for the respondents
- $this->select("campaign_survey_id", "label=Survey $title");
-
- $this->waitForElementPresent('_qf_Search_refresh');
- $this->clickLink("_qf_Search_refresh");
- $this->waitForText("xpath=//div[@id='search-status']/table/tbody/tr[1]/td[1]", '1 Result');
- }
-
- public function testSurveyReportTest() {
- $this->markTestSkipped('Skipping for now as it works fine locally.');
- $this->webtestLogin('admin');
-
- // Enable CiviCampaign module if necessary
- $this->enableComponents(array('CiviCampaign'));
-
- // add the required permission
- $this->changePermissions('edit-2-administer-civicampaign');
-
- $this->webtestLogin();
-
- // Create new group
- $title = substr(sha1(rand()), 0, 7);
- $groupName = $this->WebtestAddGroup();
-
- // Adding contact
- $firstName1 = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName1, "Smith", "$firstName1.smith@example.org");
- $id1 = $this->urlArg('cid');
-
- // add contact to group
- // visit group tab
- $this->click("css=li#tab_group a");
- $this->waitForElementPresent('css=#group_id option');
-
- // add to group
- $this->select("group_id", "label=$groupName");
- $this->click("_qf_GroupContact_next");
- $this->waitForElementPresent('link=Remove');
-
- $firstName2 = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName2, "John", "$firstName2.john@example.org");
- $id2 = $this->urlArg('cid');
-
- // add contact to group
- // visit group tab
- $this->click("css=li#tab_group a");
- $this->waitForElementPresent('css=#group_id option');
-
- // add to group
- $this->select("group_id", "label=$groupName");
- $this->click("_qf_GroupContact_next");
- $this->waitForElementPresent('link=Remove');
-
- // Create custom group and add custom data fields
- $this->openCiviPage("admin/custom/group", "reset=1");
-
- $this->click("link=Add Set of Custom Fields");
- $this->waitForElementPresent('_qf_Group_cancel-bottom');
-
- $customGroup = "Custom Group $title";
- $this->type('title', "$customGroup");
- $this->select('extends[0]', "value=Contact");
- $this->clickLink('_qf_Group_next-bottom');
- $this->waitForText('crm-notification-container', $customGroup);
-
- // Add custom fields
- $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']/button[3]/span[2]");
- $field1 = "Checkbox $title";
- $this->type('label', $field1);
- $this->select('data_type[1]', "value=CheckBox");
- $this->waitForElementPresent('option_label_2');
-
- // add multiple choice options
- $label1 = "Check $title One";
- $value1 = 1;
- $this->type('option_label_1', $label1);
- $this->type('option_value_1', $value1);
-
- $label2 = "Check $title Two";
- $value2 = 2;
- $this->type('option_label_2', $label2);
- $this->type('option_value_2', $value2);
-
- $this->click("link=another choice");
-
- $label3 = "Check $title Three";
- $value3 = 3;
- $this->type('option_label_3', $label3);
- $this->type('option_value_3', $value3);
-
- $this->click("xpath=//*[@id='_qf_Field_done-bottom']");
- $this->waitForElementPresent('newCustomField');
- $this->isElementPresent("xpath=//table[@id='options']/tbody//tr/td[1]/span[text()='{$field1}']");
-
- // Create a profile for survey
- $this->openCiviPage("admin/uf/group", "reset=1");
-
- $this->click("link=Add Profile");
- $this->waitForElementPresent('_qf_Group_cancel-bottom');
-
- $surveyProfile = "Survey Profile $title";
- $this->type('title', $surveyProfile);
- $this->click('_qf_Group_next-bottom');
- $this->waitForText('crm-notification-container', "Your CiviCRM Profile '$surveyProfile' has been added. You can add fields to this profile now.");
-
- // Add fields to the profile
- // Phone ( Primary )
- $this->waitForElementPresent('field_name[0]');
- $this->select('field_name[0]', "value=Contact");
- $this->waitForElementPresent('field_name[1]');
- $this->select('field_name[1]', "value=phone");
- $this->click('field_name[1]');
- $this->select('visibility', "value=Public Pages and Listings");
- $this->check('is_searchable');
- $this->check('in_selector');
- $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']/button[2]/span[2]");
- $this->click("xpath=//div[@class='ui-dialog-buttonset']/button[2]/span[2]");
-
- // Custom Data Fields
- $this->waitForElementPresent("xpath=//select[@id='field_name_1'][@style='display: none;']");
- $this->waitForElementPresent('field_name[0]');
- $this->select('field_name[0]', "value=Contact");
- $this->waitForElementPresent('field_name[1]');
- $this->select('field_name[1]', "label=$field1 :: $customGroup");
- $this->click('field_name[1]');
- $this->select('visibility', "value=Public Pages and Listings");
- $this->check('is_searchable');
- $this->check('in_selector');
- $this->click("xpath=//div[@class='ui-dialog-buttonset']/button[1]/span[2]");
- $this->waitForElementPresent("xpath=//table[@id='options']");
- $this->isElementPresent("xpath=//table[@id='options']/tbody//tr/td[1]/span", $field1);
-
- // Create a survey
- $this->openCiviPage("survey/add", "reset=1", "_qf_Main_upload-bottom");
-
- // fill in a unique title for the survey
- $surveyTitle = "Survey $title";
- $this->waitForElementPresent('title');
- $this->type('title', $surveyTitle);
-
- // select the created campaign
- //$this->select("campaign_id", "label=Campaign $title");
-
- // select the activity type
- $this->waitForElementPresent('activity_type_id');
- $this->select("activity_type_id", "label=Survey");
-
- // fill in reserve survey respondents
- $this->type("default_number_of_contacts", 50);
-
- // fill in interview survey respondents
- $this->type("max_number_of_contacts", 100);
-
- // release frequency
- $this->waitForElementPresent('release_frequency');
- $this->type("release_frequency", 2);
-
- $this->click("_qf_Main_upload-bottom");
- $this->waitForElementPresent("_qf_Questions_upload_next-bottom");
-
- //Select the profile for the survey
- $this->select("//form[@id='Questions']/div[2]/table/tbody/tr[1]/td[2]/div/div/span/select", "label=New Individual");
-
- // select the question created for the survey
-
- $this->select("//form[@id='Questions']/div[2]/table/tbody/tr[2]/td[2]/div/div/span/select", "label=$surveyProfile");
- $this->click("_qf_Questions_upload_next-bottom");
-
- // create a set of options for Survey Responses _qf_Results_upload_done-bottom
- $this->waitForElementPresent('_qf_Results_upload_done-bottom');
- $optionLabel1 = "Label $title 1";
- $this->type("//input[@id='option_label_1']", "$optionLabel1");
- $this->type("//input[@id='option_value_1']", "1");
-
- $optionLabel2 = "Label $title 2";
- $this->type("//input[@id='option_label_2']", "$optionLabel2");
- $this->type("//input[@id='option_value_2']", "2");
- $this->type("//input[@id='report_title']", "Survey $title");
- $this->click('_qf_Results_upload_done-bottom');
- $this->waitForElementPresent("//div[@id='search_form_survey']");
- $this->assertTrue($this->isTextPresent("'Results' have been saved."),
- "Status message didn't show up after saving survey!"
- );
-
- // Reserve Respondents
- $this->openCiviPage("survey/search", "reset=1&op=reserve", '_qf_Search_refresh');
-
- // search for the respondents
- // select survey
- $this->select('campaign_survey_id', "label=$surveyTitle");
-
- // need to wait for Groups field to reload dynamically
- $this->waitForElementPresent("//select[@id='group']/option[text()='$groupName']");
-
- // select group
- $this->waitForElementPresent('group');
- $this->click('group');
- $this->waitForElementPresent('group');
- $this->select('group', "label=$groupName");
- $this->click('_qf_Search_refresh');
-
- $this->waitForElementPresent('toggleSelect');
- $this->click('toggleSelect');
- $this->select('task', "Reserve Respondents");
-
- $this->waitForElementPresent('_qf_Reserve_done_reserve-bottom');
-
- $this->clickLink('_qf_Reserve_done_reserve-bottom', 'access');
- $this->waitForText('crm-notification-container', "2 contacts have been reserved.");
-
- $this->openCiviPage("report/survey/detail", "reset=1", '_qf_SurveyDetails_submit');
-
- // Select columns to be displayed
- $this->check('fields[survey_id]');
- $this->check('fields[survey_response]');
- $this->select('survey_id_value', "label=$surveyTitle");
- $this->select('status_id_value', "label=Reserved");
- $this->click('_qf_SurveyDetails_submit');
- $this->waitForElementPresent('_qf_SurveyDetails_submit_print');
- $this->assertTrue($this->isTextPresent("Is equal to Reserved"));
-
- // commenting out the print assertion as print dialog which appears breaks the webtest
- // as it is OS-related and cannot be handled through webtest
-
- // $this->click('_qf_SurveyDetails_submit_print');
- // $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // $this->assertTrue($this->isTextPresent("Survey Title = $surveyTitle"));
- // $this->assertTrue($this->isTextPresent("Q1 = $field1"));
- // $this->assertTrue($this->isTextPresent("$value1 | $value2 | $value3"));
-
- // Interview Respondents
- $this->openCiviPage("survey/search", "reset=1&op=interview", '_qf_Search_refresh');
-
- // search for the respondents
- // select survey
- $this->select('campaign_survey_id', "label=$surveyTitle");
-
- // need to wait for Groups field to reload dynamically
- $this->waitForElementPresent("//select[@id='group']/option[text()='$groupName']");
-
- // select group
- $this->click('group');
- $this->select('group', "label=$groupName");
- //$this->waitForElementPresent("xpath=//ul[@id='crmasmList1']/li");
- $this->click('_qf_Search_refresh');
-
- //$this->click("xpath=//*[@class='selector']//tbody//tr[@id='rowid{$id1}']/td[1]");
- $this->waitForElementPresent("xpath=//table[@class='selector row-highlight']/tbody//tr[@id='rowid{$id1}']/td/input");
- $this->click("xpath=//table[@class='selector row-highlight']/tbody//tr[@id='rowid{$id1}']/td/input");
- $this->waitForElementPresent('task');
- $this->select('task', "Record Survey Responses");
- $this->waitForElementPresent('_qf_Interview_cancel_interview');
-
- $this->waitForElementPresent("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[@id='row_{$id1}']/td[6]/input[@type='text']");
-
- $this->type("field_{$id1}_phone-Primary-1", 9876543210);
-
- $this->waitForElementPresent("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[@id='row_{$id1}']/td[7]/input[2]");
- $this->click("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[@id='row_{$id1}']/td[7]/input[2]");
- $this->waitForElementPresent("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[@id='row_{$id1}']/td[7]/input[4]");
- $this->click("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[@id='row_{$id1}']/td[7]/input[4]");
-
- $this->select("field_{$id1}_result", $optionLabel1);
- $this->click("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[@id='row_{$id1}']/td[10]/a");
- $this->click('_qf_Interview_cancel_interview');
- // Because it tends to cause problems, all uses of sleep() must be justified in comments
- // Sleep should never be used for wait for anything to load from the server
- // Justification for this instance: FIXME
- $this->waitForAjaxContent();
- // Survey Report
- $this->openCiviPage("report/survey/detail", "reset=1", '_qf_SurveyDetails_submit');
-
- // Select columns to be displayed
- $this->check('fields[survey_id]');
- $this->check('fields[survey_response]');
- $this->select('survey_id_value', "label=$surveyTitle");
- $this->select('status_id_value', "label=Interviewed");
- $this->click('_qf_SurveyDetails_submit');
- $this->waitForElementPresent('_qf_SurveyDetails_submit_print');
- $this->assertTrue($this->isTextPresent("Is equal to Interviewed"));
-
- // commenting out the print assertion as print dialog which appears breaks the webtest
- // as it is OS-related and cannot be handled through webtest
-
- // $this->click('_qf_SurveyDetails_submit_print');
- // $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // $this->assertTrue($this->isTextPresent("Survey Title = $surveyTitle"));
- // $this->assertTrue($this->isTextPresent("Q1 = $field1"));
- // $this->assertTrue($this->isTextPresent("$value1"));
-
- // use GOTV (campaign/gotv) to mark the respondents as voted
- $this->openCiviPage("campaign/gotv", "reset=1");
-
- // search for the respondents
- // select survey
- $this->select('campaign_survey_id', "label=$surveyTitle");
- // need to wait for Groups field to reload dynamically
- $this->waitForElementPresent("//select[@id='group']/option[text()='$groupName']");
-
- // select group
- $this->click('group');
- $this->select('group', "label=$groupName");
- //$this->waitForElementPresent("xpath=//ul[@id='crmasmList1']/li");
- //$this->click("xpath=//div[@id='search_form_gotv']/div[2]/table/tbody/tr[6]/td/a[text()='Search']");
- $this->click("link=Search");
-
- $this->waitForElementPresent("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[7]/input");
- $this->click("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[7]/input");
-
- // Check title of the activities created
- $this->openCiviPage("activity/search", "reset=1", '_qf_Search_refresh');
- $this->waitForElementPresent('activity_survey_id');
- $this->select('activity_survey_id', "label=$surveyTitle");
- $this->click('_qf_Search_refresh');
- $this->waitForElementPresent("xpath=//table[@class='selector row-highlight']");
- $this->verifyText("xpath=//table[@class='selector row-highlight']/tbody//tr/td[5]/a[text()='Smith, $firstName1']/../../td[3]",
- preg_quote("$surveyTitle - Respondent Interview")
- );
- $this->verifyText("xpath=//table[@class='selector row-highlight']/tbody//tr/td[5]/a[text()='John, $firstName2']/../../td[3]",
- preg_quote("$surveyTitle - Respondent Reservation")
- );
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Case_ActivityToCaseTest
- */
-class WebTest_Case_ActivityToCaseTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testAddActivityToCase() {
- $this->markTestSkipped('Skipping for now as it works fine locally.');
- // Log in as admin first to verify permissions for CiviCase
- $this->webtestLogin('admin');
-
- // Enable CiviCase module if necessary
- $this->enableComponents("CiviCase");
-
- // let's give full CiviCase permissions to demo user (registered user).
- $permission = array(
- 'edit-2-access-all-cases-and-activities',
- 'edit-2-access-my-cases-and-activities',
- 'edit-2-administer-civicase',
- 'edit-2-delete-in-civicase',
- );
- $this->changePermissions($permission);
-
- // Log in as normal user
- $this->webtestLogin();
-
- $this->openCiviPage('case/add', 'reset=1&action=add&atype=13&context=standalone', '_qf_Case_upload-bottom');
-
- // Adding contact with randomized first name (so we can then select that contact when creating case)
- // We're using pop-up New Contact dialog
- $contact = $this->createDialogContact("client_id");
-
- // Fill in other form values. We'll use a case type which is included in CiviCase sample data / xml files.
- $caseTypeLabel = "Adult Day Care Referral";
- $subject = "Safe daytime setting - senior female";
- $this->select('medium_id', 'value=1');
- $this->type('activity_location', 'Main offices');
- $details = "65 year old female needs safe location during the day for herself and her dog. She is in good health but somewhat disoriented.";
- $this->fillRichTextField("activity_details", $details, 'CKEditor');
- $this->type('activity_subject', $subject);
-
- $this->select('case_type_id', "label={$caseTypeLabel}");
-
- // Choose Case Start Date.
- // Using helper webtestFillDate function.
- $this->webtestFillDate('start_date', 'now');
- $today = date('F jS, Y', strtotime('now'));
-
- $this->type('duration', "20");
- $this->clickLink('_qf_Case_upload-bottom', '_qf_CaseView_cancel-bottom', FALSE);
-
- // Is status message correct?
- $this->checkCRMAlert("Case opened successfully.");
- $customGroupTitle = 'Custom_' . substr(sha1(rand()), 0, 7);
-
- $this->_testAddNewActivity($contact['first_name'], $subject, $customGroupTitle, $contact['sort_name']);
- }
-
- public function testLinkCases() {
- // Log in as admin first to verify permissions for CiviCase
- $this->webtestLogin('admin');
-
- // Enable CiviCase module if necessary
- $this->enableComponents("CiviCase");
-
- // let's give full CiviCase permissions to demo user (registered user).
- $permission = array(
- 'edit-2-access-all-cases-and-activities',
- 'edit-2-access-my-cases-and-activities',
- 'edit-2-administer-civicase',
- 'edit-2-delete-in-civicase',
- );
- $this->changePermissions($permission);
-
- // Log in as normal user
- $this->webtestLogin();
-
- //Add Case 1
- $this->openCiviPage('case/add', 'reset=1&action=add&atype=13&context=standalone', '_qf_Case_upload-bottom');
-
- // Adding contact with randomized first name (so we can then select that contact when creating case)
- // We're using pop-up New Contact dialog
- $contact1 = $this->createDialogContact('client_id');
-
- // Fill in other form values. We'll use a case type which is included in CiviCase sample data / xml files.
- $caseTypeLabel = "Adult Day Care Referral";
- $subject = "Safe daytime setting - senior female";
- $this->select('medium_id', 'value=1');
- $this->type('activity_location', 'Main offices');
- $details = "65 year old female needs safe location during the day for herself and her dog. She is in good health but somewhat disoriented.";
- $this->fillRichTextField("activity_details", $details, 'CKEditor');
- $this->type('activity_subject', $subject);
-
- $this->select('case_type_id', "label={$caseTypeLabel}");
-
- // Choose Case Start Date.
- // Using helper webtestFillDate function.
- $this->webtestFillDate('start_date', 'now');
- $today = date('F jS, Y', strtotime('now'));
-
- $this->type('duration', "20");
- $this->clickLink('_qf_Case_upload-bottom', '_qf_CaseView_cancel-bottom');
-
- // Is status message correct?
- $this->checkCRMAlert("Case opened successfully.");
-
- //Add Case 2
- $this->openCiviPage('case/add', 'reset=1&action=add&atype=13&context=standalone', '_qf_Case_upload-bottom');
-
- // Adding contact with randomized first name (so we can then select that contact when creating case)
- // We're using pop-up New Contact dialog
- $contact2 = $this->createDialogContact('client_id');
-
- // Fill in other form values. We'll use a case type which is included in CiviCase sample data / xml files.
- $caseTypeLabel2 = "Adult Day Care Referral";
- $subject2 = "Subject For Case 2";
- $this->select('medium_id', 'value=1');
- $this->type('activity_location', 'Main offices');
- $details2 = "Details For Case 2";
- $this->fillRichTextField("activity_details", $details2, 'CKEditor');
- $this->type('activity_subject', $subject2);
-
- $this->select('case_type_id', "label={$caseTypeLabel2}");
-
- // Choose Case Start Date.
- // Using helper webtestFillDate function.
- $this->webtestFillDate('start_date', 'now');
- $today = date('F jS, Y', strtotime('now'));
-
- $this->type('duration', "20");
- $this->clickLink('_qf_Case_upload-bottom', '_qf_CaseView_cancel-bottom');
-
- // Is status message correct?
- $this->checkCRMAlert("Case opened successfully.");
-
- // We should now be on the "manage case" screen for case 2
- //Add Link Case Activity to case 1
- $this->select('add_activity_type_id', 'Link Cases');
- $this->waitForElementPresent("_qf_Activity_cancel-bottom");
- $this->select2('link_to_case_id', $contact1['sort_name']);
- $activitydetails = 'Details of Link Case Activity';
- $this->fillRichTextField("details", $activitydetails, 'CKEditor');
- $this->click('css=#activity-details .crm-accordion-header');
- $this->waitForVisible('subject');
- $activitySubject = 'Link Case Activity between case 1 and case 2';
- $activitylocation = 'Main Office Building';
- $this->select2('source_contact_id', $contact2['sort_name']);
- $this->type('subject', $activitySubject);
- $this->type('location', $activitylocation);
- $this->clickAjaxLink('_qf_Activity_upload-bottom');
- $id = $this->urlArg('id');
- $this->waitForText("case_id_$id", $activitySubject);
- $this->click("xpath=//table[@id='case_id_{$id}']/tbody//tr/td[2]/div[text()='{$activitySubject}']/../../td[8]/a[text()='View']");
-
- $LinkCaseActivityData = array(
- "Client" => $contact2['first_name'],
- "Activity Type" => "Link Cases",
- "Subject" => $activitySubject,
- "Reported By" => $contact2['display_name'],
- "Medium" => "Phone",
- "Location" => $activitylocation,
- "Date and Time" => $today,
- "Details" => $activitydetails,
- "Status" => "Scheduled",
- "Priority" => "Normal",
- );
- $this->webtestVerifyTabularData($LinkCaseActivityData);
- }
-
- /**
- * @param string $firstName
- * @param $caseSubject
- * @param $customGroupTitle
- * @param $contactName
- */
- public function _testAddNewActivity($firstName, $caseSubject, $customGroupTitle, $contactName) {
- $customDataParams = $this->_addCustomData($customGroupTitle);
- //$customDataParams = array( 'optionLabel_47d58', 'custom_8_-1' );
-
- // Adding Adding contact with randomized first name for test testContactContextActivityAdd
- // We're using Quick Add block on the main page for this.
- $firstName1 = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName1, "Summerson", $firstName1 . "@summerson.name");
- $firstName2 = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName2, "Anderson", $firstName2 . "@anderson.name");
-
- $this->click("css=li#tab_activity a");
-
- // waiting for the activity dropdown to show up
- $this->waitForElementPresent("other_activity");
-
- // Select the activity type from the activity dropdown
- $this->select("other_activity", "label=Meeting");
-
- // waitForPageToLoad is not always reliable. Below, we're waiting for the submit
- // button at the end of this page to show up, to make sure it's fully loaded.
- $this->waitForElementPresent("_qf_Activity_upload-bottom");
-
- // ...and verifying if the page contains properly formatted display name for chosen contact.
- $this->waitForText("xpath=//div[@id='s2id_target_contact_id']", 'Anderson, ' . $firstName2, "Contact not found in line " . __LINE__);
-
- // Now we're filling the "Assigned To" field.
- // Typing contact's name into the field (using typeKeys(), not type()!)...
- $this->click("xpath=//div[@id='s2id_assignee_contact_id']/ul/li/input");
- $this->keyDown("xpath=//div[@id='s2id_assignee_contact_id']/ul/li/input", " ");
- $this->type("xpath=//div[@id='s2id_assignee_contact_id']/ul/li/input", $firstName1);
- $this->typeKeys("xpath=//div[@id='s2id_assignee_contact_id']/ul/li/input", $firstName1);
-
- // ...waiting for drop down with results to show up...
- $this->waitForElementPresent("xpath=//div[@class='select2-result-label']");
-
- //..need to use mouseDownAt on first result (which is a li element), click does not work
- $this->clickAt("xpath=//div[@class='select2-result-label']");
-
- // ...again, waiting for the box with contact name to show up...
- $this->waitForText("xpath=//div[@id='s2id_assignee_contact_id']", "$firstName1");
-
- // ...and verifying if the page contains properly formatted display name for chosen contact.
- $this->assertElementContainsText("xpath=//div[@id='s2id_assignee_contact_id']", "Summerson, $firstName1", 'Contact not found in line ' . __LINE__);
-
- // Putting the contents into subject field - assigning the text to variable, it'll come in handy later
- $subject = "This is subject of test activity being added through activity tab of contact summary screen.";
- // For simple input fields we can use field id as selector
- $this->type("subject", $subject);
- $this->type("location", "Some location needs to be put in this field.");
-
- // Choosing the Date.
- // Please note that we don't want to put in fixed date, since
- // we want this test to work in the future and not fail because
- // of date being set in the past. Therefore, using helper webtestFillDateTime function.
- $this->webtestFillDateTime('activity_date_time', '+1 month 11:10PM');
-
- // Setting duration.
- $this->type("duration", "30");
-
- // Putting in details.
- $this->type("details", "Really brief details information.");
-
- // Making sure that status is set to Scheduled (using value, not label).
- $this->select("status_id", "value=1");
-
- // Setting priority.
- $this->select("priority_id", "value=1");
-
- $textField = 'This is test custom data';
- $this->click("xpath=//div[@id='customData']//div[@class='custom-group custom-group-$customGroupTitle crm-accordion-wrapper collapsed']");
- $this->waitForElementPresent("xpath=//div[@class='crm-accordion-body']//table/tbody/tr[2]/td[2]/table/tbody/tr/td[1]/input");
- $this->click("xpath=//div[@class='crm-accordion-body']//table/tbody/tr[2]/td[2]/table/tbody/tr/td[1]/input");
- $this->type($customDataParams[1], $textField);
-
- // Scheduling follow-up.
- $this->click("css=.crm-activity-form-block-schedule_followup div.crm-accordion-header");
- $this->select("followup_activity_type_id", "value=1");
- $this->webtestFillDateTime('followup_date', '+2 months 10:00AM');
- $this->type("followup_activity_subject", "This is subject of schedule follow-up activity");
-
- // Clicking save.
- $this->click("_qf_Activity_upload-bottom");
-
- // Is status message correct?
- $this->waitForText('crm-notification-container', $subject);
-
- // click through to the Activity view screen
- $this->waitForElementPresent("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody//tr/td[5]/a[text()='Summerson, $firstName1']/../../td[8]/span/a[1][text()='View']");
- $this->click("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody//tr/td[5]/a[text()='Summerson, $firstName1']/../../td[8]/span/a[1][text()='View']");
- $this->waitForElementPresent("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody//tr/td[5]/a[text()='Summerson, $firstName1']/../../td[8]/span[2][text()='more']/ul[1]/li[1]/a");
- $this->click("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody//tr/td[5]/a[text()='Summerson, $firstName1']/../../td[8]/span[2][text()='more']/ul[1]/li[1]/a");
-
- // file activity on case
- $this->waitForElementPresent('file_on_case_unclosed_case_id');
- $this->select2('file_on_case_unclosed_case_id', $firstName);
- $this->assertElementContainsText("xpath=//div[@id='s2id_file_on_case_unclosed_case_id']", "$firstName", 'Contact not found in line ' . __LINE__);
- $this->type('file_on_case_activity_subject', $subject);
- $this->click("xpath=//div[@class='ui-dialog-buttonset']//button//span[text()='Save']");
- $this->waitForElementPresent("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody//tr/td[5]/a[text()='Summerson, $firstName1']/../../td[8]/span/a[1][text()='View']");
-
- // verify if custom data is present
- $this->openCiviPage('case', 'reset=1');
- $this->click("xpath=//table[@class='caseSelector']/tbody//tr/td[2]/a[text()='{$contactName}']/../../td[9]/span/a[text()='Manage']");
-
- $this->waitForElementPresent('_qf_CaseView_cancel-bottom');
- $id = $this->urlArg('id');
- $this->waitForElementPresent("xpath=//div[@id='activities']//table[@id='case_id_" . $id . "']/tbody/tr[1]/td[2]");
- $this->click("xpath=//table[@id='case_id_" . $id . "']/tbody/tr[1]/td[2]/div[text()='{$subject}']/../../td[8]/a[text()='View']");
-
- $this->waitForElementPresent('ActivityView');
- $this->waitForElementPresent("css=table#crm-activity-view-table tr.crm-case-activityview-form-block-groupTitle");
- $this->assertElementContainsText('crm-activity-view-table', "$textField");
- $this->click("xpath=//span[@class='ui-button-icon-primary ui-icon fa-times']");
- $this->waitForElementPresent("xpath=//div[@id='activities']//table[@id='case_id_" . $id . "']/tbody/tr[1]/td[2]");
-
- $this->click("xpath=//div[@id='activities']//table[@id='case_id_" . $id . "']/tbody//tr/td[2]/div[text()='{$subject}']/../../td[7]/div[text()='Scheduled']");
-
- $this->waitForElementPresent("xpath=//div[@id='activities']//table[@id='case_id_" . $id . "']/tbody//tr/td[2]/div[text()='{$subject}']/../../td[7]/div/form/select");
-
- // change activity status
- $this->select("xpath=//div[@id='activities']//table[@id='case_id_" . $id . "']/tbody//tr/td[2]/div[text()='{$subject}']/../../td[7]/div/form/select", 'value=2');
- $this->click("xpath=//div[@id='activities']//table[@id='case_id_" . $id . "']/tbody//tr/td[2]/div[text()='{$subject}']/../../td[7]/div/form/button[@type='submit']");
- $this->openCiviPage('case', 'reset=1');
- $this->click("xpath=//table[@class='caseSelector']/tbody//tr/td[2]/a[text()='{$contactName}']/../../td[9]/span/a[text()='Manage']");
- $this->waitForElementPresent('_qf_CaseView_cancel-bottom');
- $id2 = $this->urlArg('id');
- $this->waitForElementPresent("xpath=//div[@id='activities']//table[@id='case_id_" . $id2 . "']/tbody/tr[1]/td[2]");
- $this->click("xpath=//div[@id='activities']//table[@id='case_id_" . $id2 . "']/tbody//tr/td[2]/div[text()='{$subject}']/../../td[8]/a[1]");
- $this->waitForElementPresent('ActivityView');
- $this->waitForElementPresent("css=table#crm-activity-view-table tr.crm-case-activityview-form-block-groupTitle");
- }
-
- /**
- * @param $customGroupTitle
- *
- * @return array
- */
- public function _addCustomData($customGroupTitle) {
-
- $this->openCiviPage('admin/custom/group', 'reset=1');
-
- //add new custom data
- $this->clickLink("//a[@id='newCustomDataGroup']/span");
-
- //fill custom group title
- $this->click("title");
- $this->type("title", $customGroupTitle);
-
- //custom group extends
- $this->click("extends[0]");
- $this->select("extends[0]", "value=Activity");
- $this->click("//option[@value='Activity']");
- $this->clickLink('_qf_Group_next-bottom');
-
- //Is custom group created?
- $this->waitForText('crm-notification-container', "Your custom field set '{$customGroupTitle}' has been added. You can add custom fields now.");
-
- // create a custom field - Integer Radio
- $this->clickLinkSuppressPopup('newCustomField', "data_type[0]");
- $this->click("data_type[0]");
- $this->select("data_type[0]", "value=1");
- $this->click("//option[@value='1']");
- $this->click("data_type[1]");
- $this->select("data_type[1]", "value=Radio");
- $this->click("//option[@value='Radio']");
-
- $radioFieldLabel = 'Custom Field Radio_' . substr(sha1(rand()), 0, 4);
- $this->type("label", $radioFieldLabel);
- $radioOptionLabel1 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
- $this->type("option_label_1", $radioOptionLabel1);
- $this->type("option_value_1", "1");
- $radioOptionLabel2 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
- $this->type("option_label_2", $radioOptionLabel2);
- $this->type("option_value_2", "2");
-
- //select options per line
- $this->type("options_per_line", "3");
-
- //enter pre help msg
- $this->type("help_pre", "this is field pre help");
-
- //enter post help msg
- $this->type("help_post", "this is field post help");
-
- //Is searchable?
- $this->click("is_searchable");
-
- //clicking save
- $this->clickLink("_qf_Field_next_new-bottom", "_qf_Field_next_new-bottom");
-
- //Is custom field created
- $this->waitForText('crm-notification-container', "Custom field '$radioFieldLabel' has been saved.");
-
- // create another custom field - text field
- $textFieldLabel = 'Custom Field Text_' . substr(sha1(rand()), 0, 4);
- $this->type('label', $textFieldLabel);
-
- //enter pre help msg
- $this->type('help_pre', "this is field pre help");
-
- //enter post help msg
- $this->type('help_post', "this is field post help");
-
- //Is searchable?
- $this->click('is_searchable');
-
- //clicking save
- $this->clickLink("_qf_Field_done-bottom", "//a[@id='newCustomField']/span");
-
- //Is custom field created
- $this->waitForText('crm-notification-container', "Custom field '$textFieldLabel' has been saved.");
- $textFieldId = explode('&id=', $this->getAttribute("xpath=//table[@id='options']/tbody//tr/td[1]/div[text()='$textFieldLabel']/../../td[8]/span/a[1][text()='Edit Field']/@href"));
- $textFieldId = $textFieldId[1];
-
- return array($radioOptionLabel1, "custom_{$textFieldId}_-1");
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Case_AddCaseTest
- */
-class WebTest_Case_AddCaseTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testStandaloneCaseAdd() {
- // Log in as admin first to verify permissions for CiviCase
- $this->webtestLogin('admin');
-
- // Enable CiviCase module if necessary
- $this->enableComponents("CiviCase");
-
- // let's give full CiviCase permissions to demo user (registered user).
- $permission = array(
- 'edit-2-access-all-cases-and-activities',
- 'edit-2-access-my-cases-and-activities',
- 'edit-2-administer-civicase',
- 'edit-2-delete-in-civicase',
- );
- $this->changePermissions($permission);
-
- // Log in as normal user
- $this->webtestLogin();
-
- // Go to reserved New Individual Profile to set value for logged in user's contact name (we'll need that later)
- $this->openCiviPage('profile/edit', 'reset=1&gid=4', NULL);
- $testUserFirstName = "Testuserfirst";
- $testUserLastName = "Testuserlast";
- $this->waitForElementPresent("_qf_Edit_next");
- $this->type("first_name", $testUserFirstName);
- $this->type("last_name", $testUserLastName);
- $this->clickLink("_qf_Edit_next", "profilewrap4");
- // Is status message correct?
- $this->assertElementContainsText('crm-container', "Thank you. Your information has been saved.", "Save successful status message didn't show up after saving profile to update testUserName!");
-
- $this->openCiviPage('case/add', 'reset=1&action=add&atype=13&context=standalone', '_qf_Case_upload-bottom');
-
- // Try submitting the form without creating or selecting a contact (test for CRM-7971)
- $this->clickLink("_qf_Case_upload-bottom", "css=span.crm-error");
- $this->assertElementContainsText('Case', "Client is a required field.", "Expected form rule error for submit without selecting contact did not show up after clicking Save.");
-
- // Adding contact with randomized first name (so we can then select that contact when creating case)
- // We're using pop-up New Contact dialog
- $client = $this->createDialogContact("client_id");
-
- // Fill in other form values. We'll use a case type which is included in CiviCase sample data / xml files.
- $caseTypeLabel = "Adult Day Care Referral";
- // activity types we expect for this case type
- $activityTypes = array("ADC referral", "Follow up", "Medical evaluation", "Mental health evaluation");
- $caseRoles = array("Senior Services Coordinator", "Health Services Coordinator", "Benefits Specialist", "Client");
- $caseStatusLabel = "Ongoing";
- $subject = "Safe daytime setting - senior female";
- $this->select("medium_id", "value=1");
- $location = "Main offices";
- $this->type("activity_location", $location);
- $details = "65 year old female needs safe location during the day for herself and her dog. She is in good health but somewhat disoriented.";
- $this->fireEvent('activity_details', 'focus');
- $this->fillRichTextField("activity_details", $details, 'CKEditor');
- $this->type("activity_subject", $subject);
-
- $this->select("case_type_id", "label={$caseTypeLabel}");
- $this->select("status_id", "label={$caseStatusLabel}");
- // Choose Case Start Date.
- // Using helper webtestFillDate function.
- $this->webtestFillDate('start_date', 'now');
- $today = date('F jS, Y', strtotime('now'));
-
- $this->type("duration", "20");
- $this->clickLink("_qf_Case_upload-bottom", "_qf_CaseView_cancel-bottom");
-
- // Is status message correct?
- $this->waitForText('crm-notification-container', "Case opened successfully.");
-
- $summaryStrings = array(
- "Summary",
- $client['display_name'],
- "Type: {$caseTypeLabel}",
- "Open Date: {$today}",
- "Status: {$caseStatusLabel}",
- );
-
- $this->_testVerifyCaseSummary($summaryStrings, $activityTypes);
- $this->_testVerifyCaseRoles($caseRoles, "{$testUserLastName}, {$testUserFirstName}");
- $this->_testVerifyCaseActivities($activityTypes);
-
- $openCaseData = array(
- "Client" => $client['display_name'],
- "Activity Type" => "Open Case",
- "Subject" => $subject,
- "Created By" => "{$testUserFirstName} {$testUserLastName}",
- "Reported By" => "{$testUserFirstName} {$testUserLastName}",
- "Medium" => "In Person",
- "Location" => $location,
- "Date and Time" => $today,
- "Details" => $details,
- "Status" => "Completed",
- "Priority" => "Normal",
- );
-
- $this->_testVerifyOpenCaseActivity($subject, $openCaseData);
-
- //change the case status to Resolved to get the end date
- $this->click("xpath=//form[@id='CaseView']/div[2]/table/tbody/tr/td[4]/a");
- $this->waitForElementPresent("_qf_Activity_cancel-bottom");
- $this->select("case_status_id", "value=2");
- $this->click("_qf_Activity_upload-top");
-
- $this->_testSearchbyDate($client['first_name'], $client['last_name'], "this.quarter");
- $this->_testSearchbyDate($client['first_name'], $client['last_name'], "0");
- $this->_testSearchbyDate($client['first_name'], $client['last_name'], "this.year");
- $this->_testAssignToClient($client['first_name'], $client['last_name'], $caseTypeLabel);
- }
-
- public function testAjaxCustomGroupLoad() {
- // Log in as admin first to verify permissions for CiviCase
- $this->webtestLogin('admin');
-
- // Enable CiviCase module if necessary
- $this->enableComponents("CiviCase");
-
- // let's give full CiviCase permissions to demo user (registered user).
- $permission = array(
- 'edit-2-access-all-cases-and-activities',
- 'edit-2-access-my-cases-and-activities',
- 'edit-2-administer-civicase',
- 'edit-2-delete-in-civicase',
- );
- $this->changePermissions($permission);
-
- // Log in as normal user
- $this->webtestLogin();
-
- $triggerElement = array('name' => 'case_type_id', 'type' => 'select');
- $customSets = array(
- array('entity' => 'Case', 'subEntity' => 'Housing Support', 'triggerElement' => $triggerElement),
- );
-
- $pageUrl = array('url' => 'case/add', 'args' => "reset=1&action=add&atype=13&context=standalone");
- $this->customFieldSetLoadOnTheFlyCheck($customSets, $pageUrl);
- }
-
- /**
- * @param $validateStrings
- * @param $activityTypes
- */
- public function _testVerifyCaseSummary($validateStrings, $activityTypes) {
- $this->assertStringsPresent($validateStrings);
- foreach ($activityTypes as $aType) {
- $this->assertElementPresent("xpath=//div[@class='case-control-panel']/div/p/select", $aType);
- }
- $this->assertElementPresent("link=Assign to Another Client", "Assign to Another Client link is missing.");
- $this->assertElementPresent("xpath=//a[text()=' Print Report']", "Print Case Summary button is missing.");
- }
-
- /**
- * @param $caseRoles
- * @param string $creatorName
- */
- public function _testVerifyCaseRoles($caseRoles, $creatorName) {
- $id = $this->urlArg('id');
- $this->click('css=div.crm-case-roles-block div.crm-accordion-header');
-
- $this->waitForElementPresent("xpath=//table[@id='caseRoles-selector-$id']/tbody/tr[4]/td[2]/a");
- // check that expected roles are listed in the Case Roles pane
- foreach ($caseRoles as $role) {
- $this->assertElementContainsText("css=div.crm-case-roles-block", $role);
- }
- // check that case creator role has been assigned to logged in user
- $this->assertElementContainsText("xpath=//table[@id='caseRoles-selector-$id']/tbody/tr[1]/td[2]", $creatorName);
- }
-
- /**
- * @param $activityTypes
- */
- public function _testVerifyCaseActivities($activityTypes) {
- $id = $this->urlArg('id');
- // check that expected auto-created activities are listed in the Case Activities table
- foreach ($activityTypes as $aType) {
- $this->assertElementContainsText("case_id_$id", $aType);
- }
- }
-
- /**
- * @param $subject
- * @param $openCaseData
- */
- public function _testVerifyOpenCaseActivity($subject, $openCaseData) {
- $id = $this->urlArg('id');
- // check that open case subject is present
- $this->assertElementContainsText("case_id_$id", $subject);
- // click open case activity pop-up dialog
- $this->click("xpath=//table[@id='case_id_{$id}']/tbody//tr/td[2]/div[text()='{$subject}']/../../td[8]/a[text()='View']");
- $this->waitForElementPresent("ActivityView");
- $this->waitForElementPresent("css=tr.crm-case-activity-view-Activity");
- // set page location of table containing activity view data
- $activityViewPrefix = "//*[@id='ActivityView']";
- $activityViewTableId = "crm-activity-view-table";
- // Probably don't need both tableId and prefix - but good examples for other situations where only one can be used
-
- $this->webtestVerifyTabularData($openCaseData, '', $activityViewTableId);
- $this->click("xpath=//span[@class='ui-button-icon-primary ui-icon fa-times']");
- }
-
- /**
- * @param string $firstName
- * @param string $lastName
- * @param $action
- */
- public function _testSearchbyDate($firstName, $lastName, $action) {
- // Find Cases
- if ($action != "0") {
- $this->openCiviPage('case/search', 'reset=1');
- $this->select("case_from_relative", "value=$action");
- $this->select("case_to_relative", "value=$action");
- $this->click("_qf_Search_refresh");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->assertElementContainsText('Search', "$lastName, $firstName");
- }
- else {
- //select date range
- $this->openCiviPage('case/search', 'reset=1', '_qf_Search_refresh-bottom');
- $this->select("case_from_relative", "value=$action");
- $this->webtestFillDate("case_from_start_date_low", "-1 month");
- $this->webtestFillDate("case_from_start_date_high", "+1 month");
- $this->select("case_to_relative", "value=$action");
- $this->webtestFillDate("case_to_end_date_low", "-1 month");
- $this->webtestFillDate("case_to_end_date_high", "+1 month");
- $this->click("_qf_Search_refresh-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->assertElementContainsText('Search', "$lastName, $firstName");
- }
-
- //Advanced Search
- $this->openCiviPage('contact/search/advanced', 'reset=1', '_qf_Advanced_refresh');
- $this->click("CiviCase");
- $this->waitForElementPresent("xpath=//div[@id='case-search']/table/tbody/tr[3]/td[2]/input[3]");
- if ($action != "0") {
- $this->select("case_from_relative", "value=$action");
- $this->select("case_to_relative", "value=$action");
- }
- else {
- $this->select("case_from_relative", "value=$action");
- $this->webtestFillDate("case_from_start_date_low", "-1 month");
- $this->webtestFillDate("case_from_start_date_high", "+1 month");
- $this->select("case_to_relative", "value=$action");
- $this->webtestFillDate("case_to_end_date_low", "-1 month");
- $this->webtestFillDate("case_to_end_date_high", "+1 month");
- }
- $this->clickLink("_qf_Advanced_refresh");
- $this->assertElementContainsText('Advanced', "$lastName, $firstName");
- }
-
- /**
- * @param string $firstName
- * @param string $lastName
- * @param $caseTypeLabel
- *
- * test for assign case to another client
- */
- public function _testAssignToClient($firstName, $lastName, $caseTypeLabel) {
- $this->openCiviPage('case/search', 'reset=1', '_qf_Search_refresh-bottom');
- $this->type('sort_name', $firstName);
- $this->clickLink('_qf_Search_refresh-bottom');
- $this->waitForElementPresent("xpath=//table[@class='caseSelector']/tbody//tr/td[3]/a[text()='{$lastName}, {$firstName}']");
-
- $this->clickPopupLink("xpath=//table[@class='caseSelector']/tbody//tr/td[3]/a[text()='{$lastName}, {$firstName}']/../../td[11]/span[2]/ul/li/a[contains(text(),'Assign to Another Client')]");
- $client = $this->createDialogContact("reassign_contact_id");
- $this->clickLink('_qf_EditClient_done-bottom');
- $this->assertElementContainsText('page-title', "{$client['display_name']} - $caseTypeLabel");
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Case_AddCaseTest
- */
-class WebTest_Case_AddCaseTypeTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testAddEditCaseType() {
- $caseRoles = array(1 => 'Parent of', 2 => 'Spouse of', 3 => 'Partner of');
- $activityTypes = array(1 => 'Meeting', 2 => 'Contribution', 3 => 'Event Registration');
- $timelineActivityTypes = array(1 => 'Meeting', 2 => 'Phone Call', 3 => 'Email');
- // Log in as admin first to verify permissions for CiviCase
- $this->webtestLogin('admin');
-
- // Enable CiviCase module if necessary
- $this->enableComponents("CiviCase");
-
- // let's give full CiviCase permissions to demo user (registered user).
- $permission = array(
- 'edit-2-access-all-cases-and-activities',
- 'edit-2-access-my-cases-and-activities',
- 'edit-2-administer-civicase',
- 'edit-2-delete-in-civicase',
- );
- $this->changePermissions($permission);
-
- // Log in as normal user
- $this->webtestLogin();
-
- $this->openCiviPage('a/#/caseType/new');
-
- $caseTypeLabel = "Case Type" . substr(sha1(rand()), 0, 7);
- $this->waitForElementPresent('title');
- $this->type('title', $caseTypeLabel);
-
- foreach ($caseRoles as $cRoles) {
- $this->select2("xpath=//tr[@class='addRow']/td/span/div/a", $cRoles, FALSE, TRUE);
- }
-
- foreach ($activityTypes as $aType) {
- $this->select2("xpath=//tr[@class='addRow']/td/span[@placeholder='Add activity type']/div/a", $aType, FALSE, TRUE);
- }
-
- $this->click("xpath=//a[text()='Standard Timeline']");
- foreach ($timelineActivityTypes as $tActivityType) {
- $this->select2("xpath=//tr[@class='addRow']/td/span[@placeholder='Add activity']/div/a", $tActivityType, FALSE, TRUE);
- }
-
- $this->click('css=.crm-submit-buttons button:first-child');
-
- $this->openCiviPage('case/add', 'reset=1&action=add&atype=13&context=standalone', '_qf_Case_upload-bottom');
- $client = $this->createDialogContact("client_id");
-
- $caseStatusLabel = "Ongoing";
- $subject = "Safe daytime setting - senior female";
- $this->select("medium_id", "value=1");
- $location = "Main offices";
- $this->type("activity_location", $location);
- $details = "65 year old female needs safe location during the day for herself and her dog. She is in good health but somewhat disoriented.";
- $this->fireEvent('activity_details', 'focus');
- $this->fillRichTextField("activity_details", $details, 'CKEditor');
- $this->type("activity_subject", $subject);
- $this->waitForElementPresent('case_type_id');
- $this->waitForElementPresent('status_id');
- $this->select("case_type_id", "label=$caseTypeLabel");
- $this->select("status_id", "label={$caseStatusLabel}");
- $this->webtestFillDate('start_date', 'now');
- $today = date('F jS, Y', strtotime('now'));
-
- $this->type("duration", "20");
- $this->clickLink("_qf_Case_upload-bottom", "_qf_CaseView_cancel-bottom");
-
- // Is status message correct?
- $this->waitForText('crm-notification-container', "Case opened successfully.");
-
- foreach ($activityTypes as $aType) {
- $this->assertElementPresent("xpath=//div[@class='case-control-panel']/div/p/select", $aType);
- }
-
- $this->click("xpath=//div[contains(text(), 'Roles')]");
- $this->waitForAjaxContent();
-
- // check that expected roles are listed in the Case Roles pane
- foreach ($caseRoles as $key => $role) {
- $this->assertElementContainsText("css=div.crm-case-roles-block", $role);
- }
-
- $id = $this->urlArg('id');
- // check that expected activities are listed in the Case Activities table
- foreach ($timelineActivityTypes as $tActivityType) {
- $this->assertElementContainsText("case_id_$id", $tActivityType);
- }
-
- // for edit case type
- $this->openCiviPage('a/#/caseType');
- $this->waitForElementPresent("xpath=//*[@id='crm-main-content-wrapper']/div/div/div[2]/a/span[contains(text(),'New Case Type')]");
-
- $this->click("xpath=//table/tbody//tr/td[1][text()='{$caseTypeLabel}']/../td[5]/span/a[text()='Edit']");
- $this->waitForElementPresent("css=.crm-submit-buttons button:first-child");
-
- $editCaseTypeLabel = "Case Type Edit" . substr(sha1(rand()), 0, 7);
- $this->waitForElementPresent('title');
- $this->type('title', $editCaseTypeLabel);
-
- $this->select2("xpath=//div[@id='crm-main-content-wrapper']/div/div/form/div/div[4]/table/tfoot/tr/td/span/div/a", 'Sibling of', FALSE, TRUE);
- $this->click("xpath=//form[@name='editCaseTypeForm']/div/div[4]/table/tbody/tr[4]/td[2]/input[@type='checkbox']");
-
- $this->click("xpath=//a[text()='Standard Timeline']");
- $this->select2("xpath=//tr[@class='addRow']/td/span[@placeholder='Add activity']/div/a", 'SMS', FALSE, TRUE);
-
- $this->click('css=.crm-submit-buttons button:first-child');
- $this->waitForElementPresent("xpath=//*[@id='crm-main-content-wrapper']/div/div/div[2]/a/span[contains(text(),'New Case Type')]");
-
- $this->verifyText("xpath=//table/tbody//tr/td[contains(text(),'$editCaseTypeLabel')]", $editCaseTypeLabel);
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Case_CaseCustomFieldsTest
- */
-class WebTest_Case_CaseCustomFieldsTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testAddCase() {
- $this->webtestLogin('admin');
-
- // Enable CiviCase module if necessary
- $this->enableComponents("CiviCase");
-
- $customGrp1 = "CaseCustom_Data1_" . substr(sha1(rand()), 0, 7);
-
- // create custom group1
- $this->openCiviPage('admin/custom/group', 'reset=1');
- $this->clickLink("newCustomDataGroup");
- $this->type("title", $customGrp1);
- $this->select("extends[0]", "value=Case");
- $this->waitForAjaxContent();
- $this->select("extends_1", "value=2");
- $this->clickLink("_qf_Group_next-bottom");
-
- // get custom group id
- $customGrpId1 = $this->urlArg('gid');
-
- $customId = $this->_testGetCustomFieldId($customGrpId1);
- $cusId_1 = 'custom_' . $customId[0] . '_-1';
- $cusId_2 = 'custom_' . $customId[1] . '_-1';
- $cusId_3 = 'custom_' . $customId[2] . '_-1';
-
- // let's give full CiviCase permissions.
- $permission = array(
- 'edit-2-access-all-cases-and-activities',
- 'edit-2-access-my-cases-and-activities',
- 'edit-2-administer-civicase',
- 'edit-2-delete-in-civicase',
- );
- $this->changePermissions($permission);
-
- // Log in as normal user
- $this->webtestLogin();
-
- // Go to reserved New Individual Profile to set value for logged in user's contact name (we'll need that later)
- $this->openCiviPage('profile/edit', 'reset=1&gid=4', '_qf_Edit_next');
- $testUserFirstName = "Testuserfirst";
- $testUserLastName = "Testuserlast";
- $this->type("first_name", $testUserFirstName);
- $this->type("last_name", $testUserLastName);
- $this->clickLink("_qf_Edit_next", "profilewrap4", FALSE);
-
- $this->openCiviPage('case/add', 'reset=1&action=add&atype=13&context=standalone', '_qf_Case_upload-bottom');
-
- // Adding contact with randomized first name (so we can then select that contact when creating case)
- $custFname = "Mike" . substr(sha1(rand()), 0, 7);
- $custMname = "Dav" . substr(sha1(rand()), 0, 7);
- $custLname = "Krist" . substr(sha1(rand()), 0, 7);
- // We're using pop-up New Contact dialog
- $client = $this->createDialogContact("client_id");
-
- // Fill in other form values. We'll use a case type which is included in CiviCase sample data / xml files.
- $caseTypeLabel = "Adult Day Care Referral";
-
- $caseStatusLabel = "Ongoing";
- $subject = "Safe daytime setting - senior female";
- $this->select("medium_id", "value=1");
- $location = "Main offices";
- $this->type("activity_location", $location);
- $details = "65 year old female needs safe location during the day for herself and her dog. She is in good health but somewhat disoriented.";
- $this->fillRichTextField("activity_details", $details, 'CKEditor');
- $this->type("activity_subject", $subject);
-
- $this->select("case_type_id", "label={$caseTypeLabel}");
- $this->waitForAjaxContent();
- $this->select("status_id", "label={$caseStatusLabel}");
-
- // Choose Case Start Date.
- // Using helper webtestFillDate function.
- $this->webtestFillDate('start_date', 'now');
- $today = date('F jS, Y', strtotime('now'));
-
- $this->type("duration", "20");
- $this->type("{$cusId_1}", $custFname);
- $this->type("{$cusId_2}", $custMname);
- $this->type("{$cusId_3}", $custLname);
- $this->clickLink("_qf_Case_upload-bottom", "_qf_CaseView_cancel-bottom", FALSE);
-
- // Is status message correct?
- $this->checkCRMAlert("Case opened successfully.");
- $this->click("_qf_CaseView_cancel-bottom");
- $this->openCiviPage('case', 'reset=1', "xpath=//table[@class='caseSelector']/tbody//tr/td[2]/a[text()='{$client['sort_name']}']/../../td[8]/a[text()='Open Case']");
- $this->clickPopupLink("xpath=//table[@class='caseSelector']/tbody//tr/td[2]/a[text()='{$client['sort_name']}']/../../td[8]/a[text()='Open Case']");
-
- $openCaseData = array(
- "Client" => $client['display_name'],
- "Activity Type" => "Open Case",
- "Subject" => $subject,
- "Created By" => "{$testUserFirstName} {$testUserLastName}",
- "Reported By" => "{$testUserFirstName} {$testUserLastName}",
- "Medium" => "In Person",
- "Location" => $location,
- "Date and Time" => $today,
- "Status" => "Completed",
- "Priority" => "Normal",
- );
- $this->webtestVerifyTabularData($openCaseData);
- $this->waitForElementPresent("xpath=//span[@class='ui-button-icon-primary ui-icon fa-times']");
- $this->click("xpath=//span[@class='ui-button-icon-primary ui-icon fa-times']");
-
- // verify if custom data is present
- $this->openCiviPage('case', 'reset=1');
- $this->waitForElementPresent("xpath=//table[@class='caseSelector']/tbody//tr/td[2]/a[text()='{$client['sort_name']}']/../../td[9]/span/a[1][text()='Manage']");
- $this->clickLink("xpath=//table[@class='caseSelector']/tbody//tr/td[2]/a[text()='{$client['sort_name']}']/../../td[9]/span/a[1][text()='Manage']");
-
- $this->clickAjaxLink("css=#{$customGrp1} .crm-accordion-header", "css=#{$customGrp1} a.button");
- $cusId_1 = 'custom_' . $customId[0] . '_1';
- $cusId_2 = 'custom_' . $customId[1] . '_1';
- $cusId_3 = 'custom_' . $customId[2] . '_1';
- $this->clickAjaxLink("css=#{$customGrp1} a.button", $cusId_1);
-
- $custFname = "Miky" . substr(sha1(rand()), 0, 7);
- $custMname = "Davy" . substr(sha1(rand()), 0, 7);
- $custLname = "Kristy" . substr(sha1(rand()), 0, 7);
- $this->type("{$cusId_1}", $custFname);
- $this->type("{$cusId_2}", $custMname);
- $this->type("{$cusId_3}", $custLname);
- $this->clickAjaxLink("_qf_CustomData_upload");
-
- $this->openCiviPage('case', 'reset=1');
- $this->clickAjaxLink("xpath=//table[@class='caseSelector']/tbody//tr/td[2]/a[text()='{$client['sort_name']}']/../../td[8]/a[text()='Change Custom Data']");
-
- $openCaseChangeData = array(
- "Client" => $client['display_name'],
- "Activity Type" => "Change Custom Data",
- "Subject" => $customGrp1 . " : change data",
- "Created By" => "{$testUserFirstName} {$testUserLastName}",
- "Reported By" => "{$testUserFirstName} {$testUserLastName}",
- "Date and Time" => $today,
- "Status" => "Completed",
- "Priority" => "Normal",
- );
- $this->webtestVerifyTabularData($openCaseChangeData);
- $this->_testAdvansearchCaseData($customId, $custFname, $custMname, $custLname);
- $this->_testDeleteCustomData($customGrpId1, $customId);
- }
-
- /**
- * @param $customGrpId1
- * @param bool $noteRichEditor
- *
- * @return array
- */
- public function _testGetCustomFieldId($customGrpId1, $noteRichEditor = FALSE) {
- $customId = array();
- $this->openCiviPage('admin/custom/group/field/add', array('reset' => 1, 'action' => 'add', 'gid' => $customGrpId1));
-
- if ($noteRichEditor) {
- // Create a custom data to add in profile
- $field1 = "Note_Textarea" . substr(sha1(rand()), 0, 7);
- $field2 = "Note_Richtexteditor" . substr(sha1(rand()), 0, 7);
-
- // add custom fields for group 1
- $this->type("label", $field1);
- $this->select("data_type_0", "value=4");
- $this->select("data_type_1", "value=TextArea");
- $this->check("is_searchable");
- $this->clickLink("_qf_Field_next_new-bottom");
-
- $this->type("label", $field2);
- $this->select("data_type_0", "value=4");
- //$this->select("data_type_1", "value=TextArea");
- $this->select("data_type_1", "value=RichTextEditor");
- $this->check("is_searchable");
- $this->clickLink("_qf_Field_next_new-bottom");
-
- // get id of custom fields
- $this->openCiviPage("admin/custom/group/field", array(
- 'reset' => 1,
- 'action' => 'browse',
- 'gid' => $customGrpId1,
- ));
- $custom1 = explode('&id=', $this->getAttribute("xpath=//div[@id='field_page']//table/tbody//tr[1]/td[8]/span/a[text()='Edit Field']/@href"));
- $custom1 = $custom1[1];
- array_push($customId, $custom1);
- $custom2 = explode('&id=', $this->getAttribute("xpath=//div[@id='field_page']//table/tbody//tr[2]/td[8]/span/a[text()='Edit Field']/@href"));
- $custom2 = $custom2[1];
- array_push($customId, $custom2);
- }
- else {
- // Create a custom data to add in profile
- $field1 = "Fname" . substr(sha1(rand()), 0, 7);
- $field2 = "Mname" . substr(sha1(rand()), 0, 7);
- $field3 = "Lname" . substr(sha1(rand()), 0, 7);
-
- // add custom fields for group 1
- $this->type("label", $field1);
- $this->check("is_searchable");
- $this->clickLink("_qf_Field_next_new-bottom");
-
- $this->type("label", $field2);
- $this->check("is_searchable");
- $this->clickLink("_qf_Field_next_new-bottom");
-
- $this->type("label", $field3);
- $this->check("is_searchable");
- $this->clickLink("_qf_Field_done-bottom");
-
- // get id of custom fields
- $this->openCiviPage("admin/custom/group/field", array(
- 'reset' => 1,
- 'action' => 'browse',
- 'gid' => $customGrpId1,
- ));
- $custom1 = explode('&id=', $this->getAttribute("xpath=//div[@id='field_page']//table/tbody//tr[1]/td[8]/span/a[text()='Edit Field']/@href"));
- $custom1 = $custom1[1];
- array_push($customId, $custom1);
- $custom2 = explode('&id=', $this->getAttribute("xpath=//div[@id='field_page']//table/tbody//tr[2]/td[8]/span/a[text()='Edit Field']/@href"));
- $custom2 = $custom2[1];
- array_push($customId, $custom2);
- $custom3 = explode('&id=', $this->getAttribute("xpath=//div[@id='field_page']//table/tbody//tr[3]/td[8]/span/a[text()='Edit Field']/@href"));
- $custom3 = $custom3[1];
- array_push($customId, $custom3);
- }
-
- return $customId;
- }
-
- /**
- * @param $customGrpId1
- * @param array $customId
- */
- public function _testDeleteCustomData($customGrpId1, $customId) {
- // delete all custom data
- foreach ($customId as $cKey => $cValue) {
- $this->openCiviPage("admin/custom/group/field", array(
- 'action' => 'delete',
- 'reset' => '1',
- 'gid' => $customGrpId1,
- 'id' => $cValue,
- ));
- $this->clickLink("_qf_DeleteField_next-bottom");
- }
-
- // delete custom group
- $this->openCiviPage("admin/custom/group", "action=delete&reset=1&id=" . $customGrpId1);
- $this->clickLink("_qf_DeleteGroup_next-bottom");
- }
-
- /**
- * CRM-12812
- */
- public function testCaseCustomNoteRichEditor() {
- $this->webtestLogin('admin');
-
- //setting ckeditor as WYSIWYG
- $this->openCiviPage('admin/setting/preferences/display', 'reset=1', '_qf_Display_next-bottom');
- $this->select('editor_id', 'CKEditor');
- $this->clickLink('_qf_Display_next-bottom');
-
- // Enable CiviCase module if necessary
- $this->enableComponents("CiviCase");
-
- $customGrp1 = "CaseCustom_Data1_" . substr(sha1(rand()), 0, 7);
-
- // create custom group1
- $this->openCiviPage('admin/custom/group', 'reset=1');
- $this->clickLink("newCustomDataGroup");
- $this->type("title", $customGrp1);
- $this->select("extends[0]", "value=Case");
- $this->select("extends_1", "value=2");
- $this->clickLink("_qf_Group_next-bottom");
-
- // get custom group id
- $customGrpId1 = $this->urlArg('gid');
-
- $customId = $this->_testGetCustomFieldId($customGrpId1, TRUE);
- $cusId_1 = 'custom_' . $customId[0] . '_-1';
- $cusId_2 = 'custom_' . $customId[1] . '_-1';
-
- // let's give full CiviCase permissions.
- $permission = array(
- 'edit-2-access-all-cases-and-activities',
- 'edit-2-access-my-cases-and-activities',
- 'edit-2-administer-civicase',
- 'edit-2-delete-in-civicase',
- );
- $this->changePermissions($permission);
-
- // Log in as normal user
- $this->webtestLogin();
-
- // Go to reserved New Individual Profile to set value for logged in user's contact name (we'll need that later)
- $this->openCiviPage('profile/edit', 'reset=1&gid=4', '_qf_Edit_next');
- $testUserFirstName = "Testuserfirst";
- $testUserLastName = "Testuserlast";
- $this->type("first_name", $testUserFirstName);
- $this->type("last_name", $testUserLastName);
- $this->clickLink("_qf_Edit_next", "profilewrap4", FALSE);
-
- $this->openCiviPage('case/add', 'reset=1&action=add&atype=13&context=standalone', '_qf_Case_upload-bottom');
-
- // Adding contact with randomized first name (so we can then select that contact when creating case)
- $custFname = "Mike" . substr(sha1(rand()), 0, 7);
- $custLname = "Krist" . substr(sha1(rand()), 0, 7);
- // We're using pop-up New Contact dialog
- $client = $this->createDialogContact("client_id");
-
- // Fill in other form values. We'll use a case type which is included in CiviCase sample data / xml files.
- $caseTypeLabel = "Adult Day Care Referral";
-
- $caseStatusLabel = "Ongoing";
- $subject = "Safe daytime setting - senior female";
- $this->select("medium_id", "value=1");
- $location = "Main offices";
- $this->type("activity_location", $location);
- $details = "65 year old female needs safe location during the day for herself and her dog. She is in good health but somewhat disoriented.";
- $this->fillRichTextField("activity_details", $details, 'CKEditor');
- $this->type("activity_subject", $subject);
-
- $this->select("case_type_id", "label={$caseTypeLabel}");
- $this->select("status_id", "label={$caseStatusLabel}");
-
- // Choose Case Start Date.
- // Using helper webtestFillDate function.
- $this->webtestFillDate('start_date', 'now');
- $today = date('F jS, Y', strtotime('now'));
-
- $this->type("duration", "20");
- $this->type("{$cusId_1}", $custFname);
- $this->type("{$cusId_2}", $custLname);
- $this->clickLink("_qf_Case_upload-bottom", "_qf_CaseView_cancel-bottom", FALSE);
-
- // Is status message correct?
- $this->checkCRMAlert("Case opened successfully.");
- $this->click("_qf_CaseView_cancel-bottom");
-
- $this->openCiviPage('case', 'reset=1');
- $this->waitForElementPresent("xpath=//table[@class='caseSelector']/tbody//tr/td[2]/a[text()='{$client['sort_name']}']/../../td[8]/a[text()='Open Case']");
-
- $this->click("xpath=//table[@class='caseSelector']/tbody//tr/td[2]/a[text()='{$client['sort_name']}']/../../td[8]/a[text()='Open Case']");
-
- $openCaseData = array(
- "Client" => $client['display_name'],
- "Activity Type" => "Open Case",
- "Subject" => $subject,
- "Created By" => "{$testUserFirstName} {$testUserLastName}",
- "Reported By" => "{$testUserFirstName} {$testUserLastName}",
- "Medium" => "In Person",
- "Location" => $location,
- "Date and Time" => $today,
- "Status" => "Completed",
- "Priority" => "Normal",
- );
- // wait for elements to load
- foreach ($openCaseData as $label => $value) {
- $this->waitForElementPresent("xpath=//table/tbody/tr/td[text()='{$label}']/following-sibling::td");
- }
- $this->webtestVerifyTabularData($openCaseData);
-
- // verify if custom data is present
- $this->openCiviPage('case', 'reset=1');
- $this->clickLink("xpath=//table[@class='caseSelector']/tbody//tr/td[2]/a[text()='{$client['sort_name']}']/../../td[9]/span/a[text()='Manage']", "css=#{$customGrp1} .crm-accordion-header", FALSE);
-
- $this->click("css=#{$customGrp1} .crm-accordion-header");
-
- $cusId_1 = 'custom_' . $customId[0] . '_1';
- $cusId_2 = 'custom_' . $customId[1] . '_1';
- $this->clickLink("css=#{$customGrp1} a.button", '_qf_CustomData_cancel-bottom', FALSE);
- $this->waitForElementPresent("xpath=//span[@class='ui-dialog-title']");
- $this->assertElementContainsText("xpath=//span[@class='ui-dialog-title']", "Edit $customGrp1");
-
- $custFname = "Miky" . substr(sha1(rand()), 0, 7);
- $custLname = "Kristy" . substr(sha1(rand()), 0, 7);
- $this->type("{$cusId_1}", $custFname);
-
- // Wait for rich text editor element
- $this->waitForElementPresent("css=div#cke_{$cusId_2}");
-
- $this->fillRichTextField("{$cusId_2}", $custLname, 'CKEditor');
- $this->click("_qf_CustomData_upload");
- // delete custom data
- $this->_testDeleteCustomData($customGrpId1, $customId);
- }
-
- /**
- * @param int $customId
- * @param string $custFname
- * @param string $custMname
- * @param $custLname
- */
- public function _testAdvansearchCaseData($customId, $custFname, $custMname, $custLname) {
- // search casecontact
- $this->openCiviPage('contact/search/advanced', 'reset=1', '_qf_Advanced_refresh');
- $this->click("CiviCase");
- $this->waitForElementPresent('case_from_relative');
- $cusId_1 = 'custom_' . $customId[0];
- $cusId_2 = 'custom_' . $customId[1];
- $cusId_3 = 'custom_' . $customId[2];
- $this->type("{$cusId_1}", $custFname);
- $this->type("{$cusId_2}", $custMname);
- $this->type("{$cusId_3}", $custLname);
- $this->click("_qf_Advanced_refresh");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->assertElementContainsText('crm-container', '1 Contact');
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Case_CaseDashboardTest
- */
-class WebTest_Case_CaseDashboardTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testAllOrMyCases() {
- // Log in as admin first to verify permissions for CiviCase
- $this->webtestLogin('admin');
-
- // Enable CiviCase module if necessary
- $this->enableComponents("CiviCase");
-
- // let's give full CiviCase permissions to demo user (registered user).
- $permission = array(
- 'edit-2-access-all-cases-and-activities',
- 'edit-2-access-my-cases-and-activities',
- 'edit-2-administer-civicase',
- 'edit-2-delete-in-civicase',
- );
- $this->changePermissions($permission);
-
- // Log in as normal user
- $this->webtestLogin();
-
- $this->openCiviPage('case', 'reset=1');
-
- // Should default to My Cases
- $this->assertTrue($this->isChecked("name=allupcoming value=0"), 'Case dashboard should default to My Cases.');
- // The header text of the table changes too
- $this->assertElementContainsText('crm-container', "Summary of Involvement");
-
- $this->clickLink("name=allupcoming value=1", "css=a.button");
-
- $this->assertTrue($this->isChecked("name=allupcoming value=1"), 'Selection of All Cases failed.');
- $this->assertElementContainsText('crm-container', "Summary of All Cases");
-
- // Go back to dashboard
- $this->openCiviPage('case', 'reset=1', 'css=a.button');
-
- // Click on find my cases and check if right radio is checked
- $this->clickLink("name=find_my_cases", "css=input.crm-form-submit");
- $this->assertTrue($this->isChecked("name=case_owner value=2"), 'Find my cases button not properly setting search form value to my cases.');
-
- //Add case to get drilldown cell on Case dashboard
- $this->openCiviPage('case/add', 'reset=1&action=add&atype=13&context=standalone', '_qf_Case_upload-bottom');
-
- // We're using pop-up New Contact dialog
- $params = $this->createDialogContact('client_id');
-
- // Fill in other form values. We'll use a case type which is included in CiviCase sample data / xml files.
- $caseTypeLabel = "Adult Day Care Referral";
- // activity types we expect for this case type
- $activityTypes = array("ADC referral", "Follow up", "Medical evaluation", "Mental health evaluation");
- $caseRoles = array("Senior Services Coordinator", "Health Services Coordinator", "Benefits Specialist", "Client");
- $caseStatusLabel = "Ongoing";
- $subject = "Safe daytime setting - senior female";
- $this->select("medium_id", "value=1");
- $location = "Main offices";
- $this->type("activity_location", $location);
- $details = "65 year old female needs safe location during the day for herself and her dog. She is in good health but somewhat disoriented.";
- $this->fireEvent('activity_details', 'focus');
- $this->fillRichTextField("activity_details", $details, 'CKEditor');
- $this->type("activity_subject", $subject);
-
- $this->select("case_type_id", "label={$caseTypeLabel}");
- $this->select("status_id", "label={$caseStatusLabel}");
-
- // Choose Case Start Date.
- // Using helper webtestFillDate function.
- $this->webtestFillDate('start_date', 'now');
- $today = date('F jS, Y', strtotime('now'));
-
- $this->type("duration", "20");
- $this->clickLink("_qf_Case_upload-bottom", "_qf_CaseView_cancel-bottom");
-
- // Is status message correct?
- $this->waitForText('crm-notification-container', "Case opened successfully.");
-
- // Go back to dashboard
- $this->openCiviPage('case', 'reset=1');
- //Check whether case status link opens in search correctly
- $this->clickLink("xpath=//table[@class='report']/tbody/tr[3]/td/a");
- $this->assertElementContainsText('Search', "{$params['last_name']}, {$params['first_name']}");
-
- // Go back to dashboard
- $this->openCiviPage('case', 'reset=1');
-
- // Click on a drilldown cell and check if right radio is checked
- $this->clickLink("css=a.crm-case-summary-drilldown", "css=input.crm-form-submit");
- $this->assertTrue($this->isChecked("name=case_owner value=1"), 'Drilldown on dashboard summary cells not properly setting search form value to all cases.');
-
- // Go back to dashboard and reset to my cases
- $this->openCiviPage('case', 'reset=1', 'css=a.button');
- $this->clickLink("name=allupcoming value=0", "css=a.button");
-
- // Click on a drilldown cell and check if right radio is checked
- $this->clickLink("css=a.crm-case-summary-drilldown", "css=input.crm-form-submit");
- $this->assertTrue($this->isChecked("name=case_owner value=2"), 'Drilldown on dashboard summary cells not properly setting search form value to my cases.');
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Contact_AddCmsUserTest
- */
-class WebTest_Contact_AddCmsUserTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testAuthenticAddUser() {
-
- $this->webtestLogin('admin');
-
- $this->open($this->sboxPath . 'admin/people/create');
-
- $this->waitForElementPresent('edit-submit');
-
- $name = 'TestUserAuthenticated' . substr(sha1(rand()), 0, 4);
- $this->type('edit-name', $name);
-
- $emailId = substr(sha1(rand()), 0, 7) . '@web.com';
- $this->type('edit-mail', $emailId);
- $this->type('edit-pass-pass1', 'Test12345');
- $this->type('edit-pass-pass2', 'Test12345');
-
- //Add profile Details
- $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
- $lastName = 'An' . substr(sha1(rand()), 0, 7);
- $this->waitForElementPresent('first_name');
- $this->type('first_name', $firstName);
- $this->type('last_name', $lastName);
-
- //Address Details
- $this->type('street_address-1', '902C El Camino Way SW');
- $this->type('city-1', 'Dumfries');
- $this->type('postal_code-1', '1234');
- $this->select('state_province-1', 'value=1019');
-
- $this->click('edit-submit');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- }
-
- public function testAnonymousAddUser() {
- // Make sure Drupal account settings allow visitors to register for account w/o admin approval
- // login as admin
- $this->webtestLogin('admin');
- $this->open($this->sboxPath . 'admin/config/people/accounts');
- $this->waitForElementPresent('edit-submit');
-
- $this->click('edit-user-register-1');
- $this->check('edit-user-email-verification');
- $this->click('edit-submit');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- // logout
- $this->webtestLogout();
-
- $this->open($this->sboxPath . 'user/register');
-
- $this->waitForElementPresent('edit-submit');
- $name = 'TestUserAnonymous' . substr(sha1(rand()), 0, 7);
- $this->type('edit-name', $name);
- $emailId = substr(sha1(rand()), 0, 7) . '@web.com';
- $this->type('edit-mail', $emailId);
-
- //Add profile Details
- $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
- $lastName = 'An' . substr(sha1(rand()), 0, 7);
- $this->waitForElementPresent('first_name');
- $this->type('first_name', $firstName);
- $this->type('last_name', $lastName);
-
- //Address Details
- $this->type('street_address-1', '902C El Camino Way SW');
- $this->type('city-1', 'Dumfries');
- $this->type('postal_code-1', '1234');
- $this->assertTrue($this->isTextPresent('UNITED STATES'));
- $this->select('state_province-1', 'value=1019');
-
- $this->click('edit-submit');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // In case the site is set up to login immediately upon registration
- $this->webtestLogout();
-
- $this->webtestLogin();
-
- $this->openCiviPage('contact/search', 'reset=1', '_qf_Basic_refresh');
- $this->type('sort_name', $emailId);
- $this->click('_qf_Basic_refresh');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->assertElementContainsText('css=.crm-search-results', $emailId);
- $this->assertElementContainsText('css=.crm-search-results', $lastName . ', ' . $firstName);
- $this->assertElementContainsText('css=.crm-search-results', '902C El Camino Way SW');
- $this->assertElementContainsText('css=.crm-search-results', 'Dumfries');
- $this->assertElementContainsText('css=.crm-search-results', '1234');
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Contact_AddContactsToEventAdvancedSearchTest
- */
-class WebTest_Contact_AddContactsToEventAdvancedSearchTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testAddContactsToEventAdvanceSearch() {
- $this->webtestLogin();
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Advanced Search
- $this->openCiviPage('contact/search/advanced', 'reset=1', '_qf_Advanced_refresh');
- $this->click('_qf_Advanced_refresh');
-
- $this->waitForElementPresent("xpath=//div[@id='search-status']/table/tbody/tr[2]/td[2]/input[1]");
- $this->click("xpath=//div[@id='search-status']/table/tbody/tr[2]/td[2]/input[1]");
-
- $this->select('task', "label=Register participants for event");
-
- // Select event. Based on label for now.
- $this->waitForElementPresent('event_id');
- $this->select2('event_id', "Rain-forest Cup Youth Soccer Tournament");
-
- // Select role
- $this->multiselect2('role_id', array('Volunteer'));
-
- // Select participant status
- $this->select('status_id', 'value=1');
-
- // Setting registration source
- $this->type('source', 'Event StandaloneAddTest Webtest');
-
- $this->assertElementContainsText('css=tr.crm-participant-form-block-source span.description', 'Source for this registration (if applicable).');
-
- // Clicking save.
- $this->click('_qf_Participant_upload-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Contact_AddTest
- */
-class WebTest_Contact_AddTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testIndividualAdd() {
- $this->webtestLogin();
-
- $groupName = $this->WebtestAddGroup();
-
- // go to display preferences to enable Open ID field
- $this->openCiviPage('admin/setting/preferences/display', "reset=1", "_qf_Display_next-bottom");
- $this->waitForAjaxContent();
- if (!$this->isChecked("xpath=//ul[@id='contactEditBlocks']//li[@id='preference-10-contactedit']/span/input")) {
- $this->click("xpath=//ul[@id='contactEditBlocks']//li/span/label[text()='Open ID']");
- }
- $this->click("_qf_Display_next-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->openCiviPage('contact/add', 'reset=1&ct=Individual');
-
- //contact details section
- //select prefix
- $this->click("prefix_id");
- $this->select("prefix_id", "value=" . $this->webtestGetFirstValueForOptionGroup('individual_prefix'));
-
- //fill in first name
- $this->type("first_name", substr(sha1(rand()), 0, 7) . "John");
-
- //fill in middle name
- $this->type("middle_name", "Bruce");
-
- //fill in last name
- $this->type("last_name", substr(sha1(rand()), 0, 7) . "Smith");
-
- //select suffix
- $this->select("suffix_id", "value=3");
-
- //fill in nick name
- $this->type("nick_name", "jsmith");
-
- //fill in email
- $this->type("email_1_email", substr(sha1(rand()), 0, 7) . "john@gmail.com");
-
- //fill in phone
- $this->type("phone_1_phone", "2222-4444");
-
- //fill in IM
- $this->type("im_1_name", "testYahoo");
-
- //fill in openID
- $this->type("openid_1_openid", "http://" . substr(sha1(rand()), 0, 7) . "openid.com");
-
- //fill in website
- $this->type("website_1_url", "http://www.john.com");
-
- //fill in source
- $this->type("contact_source", "johnSource");
-
- //fill in external identifier
- $indExternalId = substr(sha1(rand()), 0, 4);
- $this->type("external_identifier", $indExternalId);
-
- //check for matching contact
- $this->click("_qf_Contact_refresh_dedupe");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- //address section
- $this->click("addressBlock");
- $this->waitForElementPresent("address_1_street_address");
- //fill in address 1
- $this->type("address_1_street_address", "902C El Camino Way SW");
- $this->type("address_1_city", "Dumfries");
- $this->type("address_1_postal_code", "1234");
-
- $this->click("address_1_country_id");
- $this->select("address_1_country_id", "value=" . $this->webtestGetValidCountryID());
-
- if ($this->assertElementContainsText('address_table_1', "Latitude")) {
- $this->type("address_1_geo_code_1", "1234");
- $this->type("address_1_geo_code_2", "5678");
- }
-
- //fill in address 2
- $this->click("//div[@id='addMoreAddress1']/a/span");
- $this->waitForElementPresent("address_2_street_address");
- $this->type("address_2_street_address", "2782Y Dowlen Path W");
- $this->type("address_2_city", "Birmingham");
- $this->type("address_2_postal_code", "3456");
-
- $this->click("address_2_country_id");
- $this->select("address_2_country_id", "value=" . $this->webtestGetValidCountryID());
-
- if ($this->assertElementContainsText('address_table_2', "Latitude")) {
- $this->type("address_2_geo_code_1", "1234");
- $this->type("address_2_geo_code_2", "5678");
- }
-
- //Communication Preferences section
- $this->click("commPrefs");
-
- //select greeting/addressee options
- $this->waitForElementPresent("email_greeting_id");
- $this->select("email_greeting_id", "value=2");
- $this->select("postal_greeting_id", "value=3");
-
- //Select preferred method for Privacy
- $this->click("privacy[do_not_trade]");
- $this->click("privacy[do_not_sms]");
-
- //Select preferred method(s) of communication
- $this->click("preferred_communication_method[1]");
- $this->click("preferred_communication_method[2]");
-
- //select preferred language
- $this->waitForElementPresent("preferred_language");
- $this->select("preferred_language", "value=en_US");
-
- //Notes section
- $this->click("notesBlock");
- $this->waitForElementPresent("subject");
- $this->type("subject", "test note");
- $this->type("note", "this is a test note contact webtest");
- $this->assertElementContainsText('notesBlock', "Subject\n Note");
-
- //Demographics section
- $this->click("//div[@class='crm-accordion-header' and contains(.,'Demographics')]");
- $this->waitForElementPresent("birth_date");
-
- $this->webtestFillDate('birth_date', "-1 year");
-
- //Tags and Groups section
- $this->click("tagGroup");
-
- // select group
- $this->select("group", "label=$groupName");
- $this->click("tag[{$this->webtestGetValidEntityID('Tag')}]");
-
- // Clicking save.
- $this->click("_qf_Contact_upload_view");
-
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForText('crm-notification-container', "Contact Saved");
- }
-
- public function testHouseholdAdd() {
- $this->webtestLogin();
-
- $groupName = $this->WebtestAddGroup();
-
- // go to display preferences to enable Open ID field
- $this->openCiviPage('admin/setting/preferences/display', "reset=1", "_qf_Display_next-bottom");
- $this->waitForAjaxContent();
- if (!$this->isChecked("xpath=//ul[@id='contactEditBlocks']//li[@id='preference-10-contactedit']/span/input")) {
- $this->click("xpath=//ul[@id='contactEditBlocks']//li/span/label[text()='Open ID']");
- }
- $this->click("_qf_Display_next-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->openCiviPage('contact/add', "reset=1&ct=Household");
-
- //contact details section
- //fill in Household name
- $this->click("household_name");
- $name = substr(sha1(rand()), 0, 7) . "Fraddie Grant's home ";
- $this->type("household_name", $name);
-
- //fill in nick name
- $this->type("nick_name", substr(sha1(rand()), 0, 7) . "Grant's home");
-
- //fill in email
- $email = substr(sha1(rand()), 0, 7) . "fraddiegrantshome@web.com ";
- $this->type("email_1_email", $email);
- $this->click("Email_1_IsBulkmail");
-
- //fill in phone
- $this->type("phone_1_phone", "444-4444");
- $this->select("phone_1_phone_type_id", "value=" . $this->webtestGetFirstValueForOptionGroup('phone_type'));
-
- //fill in IM
- foreach (array('Yahoo', 'MSN', 'AIM', 'GTalk', 'Jabber', 'Skype') as $option) {
- $this->assertSelectHasOption('im_1_provider_id', $option);
- }
- $this->type("im_1_name", "testSkype");
- $this->select("im_1_location_type_id", "value=3");
- $this->select("im_1_provider_id", "value=6");
-
- //fill in openID
- $this->type("openid_1_openid", "http://" . substr(sha1(rand()), 0, 7) . "shomeopenid.com");
-
- //fill in website url
- $this->type("website_1_url", "http://www.fraddiegrantshome.com");
-
- //fill in contact source
- $this->type("contact_source", "Grant's home source");
-
- //fill in external identifier
- $houExternalId = substr(sha1(rand()), 0, 4);
- $this->type("external_identifier", $houExternalId);
-
- //check for duplicate contact
- $this->click("_qf_Contact_refresh_dedupe");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- //address section
- $this->click("addressBlock");
- $this->waitForElementPresent("address_1_street_address");
- $this->type("address_1_street_address", "938U Bay Rd E");
- $this->type("address_1_city", "Birmingham");
- $this->type("address_1_postal_code", "35278");
-
- $this->click("address_1_country_id");
- $this->select("address_1_country_id", "value=" . $this->webtestGetValidCountryID());
-
- if ($this->assertElementContainsText('address_table_1', "Latitude")) {
- $this->type("address_1_geo_code_1", "1234");
- $this->type("address_1_geo_code_2", "5678");
- }
-
- //Communication Preferences section
- $this->click("commPrefs");
-
- //select greeting/addressee options
- $this->waitForElementPresent("addressee_id");
- $this->select("addressee_id", "value=4");
- $this->type("addressee_custom", "Grant's home");
-
- //Select preferred method(s) of communication
- $this->click("preferred_communication_method[1]");
- $this->click("preferred_communication_method[2]");
- $this->click("preferred_communication_method[5]");
-
- //Select preferred method for Privacy
- $this->click("privacy[do_not_sms]");
-
- //select preferred language
- $this->waitForElementPresent("preferred_language");
- $this->select("preferred_language", "value=fr_FR");
-
- //Notes section
- $this->clickAt("//*[@id='Contact']/div[2]/div[6]/div[1]");
- $this->waitForElementPresent("subject");
- $this->type("subject", "Grant's note");
- $this->type("note", "This is a household contact webtest note.");
-
- // select group
- $this->clickAt("xpath=//div[text()='Tags and Groups']");
- $this->select("group", "label=$groupName");
-
- //tags section
- $this->click("tag[{$this->webtestGetValidEntityID('Tag')}]");
-
- // Clicking save.
- $this->click("_qf_Contact_upload_view");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->waitForText('crm-notification-container', "Contact Saved");
- }
-
- public function testOrganizationAdd() {
- $this->webtestLogin();
-
- $groupName = $this->WebtestAddGroup();
-
- // go to display preferences to enable Open ID field
- $this->openCiviPage('admin/setting/preferences/display', "reset=1", "_qf_Display_next-bottom");
- $this->waitForAjaxContent();
- if (!$this->isChecked("xpath=//ul[@id='contactEditBlocks']//li[@id='preference-10-contactedit']/span/input")) {
- $this->click("xpath=//ul[@id='contactEditBlocks']//li/span/label[text()='Open ID']");
- }
- $this->click("_qf_Display_next-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->openCiviPage('contact/add', 'reset=1&ct=Organization');
-
- //contact details section
- //fill in Organization name
- $this->click("organization_name");
- $this->type("organization_name", substr(sha1(rand()), 0, 7) . "syntel tech");
-
- //fill in legal name
- $this->type("legal_name", "syntel tech Ltd");
-
- //fill in nick name
- $this->type("nick_name", "syntel");
-
- //fill in email
- $this->type("email_1_email", substr(sha1(rand()), 0, 7) . "info@syntel.com");
-
- //fill in phone
- $this->type("phone_1_phone", "222-7777");
- $this->select("phone_1_phone_type_id", "value=2");
-
- //fill in IM
- $this->type("im_1_name", "testGtalk");
- $this->select("im_1_location_type_id", "value=4");
- $this->select("im_1_provider_id", "value=4");
-
- //fill in openID
- $this->select("openid_1_location_type_id", "value=5");
- $this->type("openid_1_openid", "http://" . substr(sha1(rand()), 0, 7) . "Openid.com");
-
- //fill in website url
- $this->type("website_1_url", "http://syntelglobal.com");
-
- //fill in contact source
- $this->type("contact_source", "syntel's source");
-
- //fill in external identifier
- $orgExternalId = substr(sha1(rand()), 0, 4);
- $this->type("external_identifier", $orgExternalId);
-
- //check for duplicate contact
- $this->click("_qf_Contact_refresh_dedupe");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- //address section
- $this->click("addressBlock");
- $this->waitForElementPresent("address_1_street_address");
- $this->type("address_1_street_address", "928A Lincoln Way W");
- $this->type("address_1_city", "Madison");
- $this->type("address_1_postal_code", "68748");
-
- $this->click("address_1_country_id");
- $this->select("address_1_country_id", "value=" . $this->webtestGetValidCountryID());
-
- if ($this->assertElementContainsText('address_table_1', "Latitude")) {
- $this->type("address_1_geo_code_1", "1234");
- $this->type("address_1_geo_code_2", "5678");
- }
-
- //Communication Preferences section
- $this->click("commPrefs");
-
- //Select preferred method(s) of communication
- $this->click("preferred_communication_method[2]");
- $this->click("preferred_communication_method[5]");
-
- //Select preferred method for Privacy
- $this->click("privacy[do_not_sms]");
- $this->click("privacy[do_not_mail]");
- //select preferred language
- $this->waitForElementPresent("preferred_language");
- $this->select("preferred_language", "value=de_DE");
-
- //Notes section
- $this->click("notesBlock");
- $this->waitForElementPresent("subject");
- $this->type("subject", "syntel global note");
- $this->type("note", "This is a note for syntel global's contact webtest.");
-
- //Tags and Groups section
- $this->click("tagGroup");
-
- // select group
- $this->select("group", "label=$groupName");
-
- $this->click("tag[{$this->webtestGetValidEntityID('Tag')}]");
-
- // Clicking save.
- $this->click("_qf_Contact_upload_view");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->waitForText('crm-notification-container', "Contact Saved");
- }
-
- public function testIndividualAddWithSharedAddress() {
- $this->webtestLogin();
-
- $this->openCiviPage('contact/add', "reset=1&ct=Individual");
-
- //contact details section
- //select prefix
- $this->click("prefix_id");
- $this->select("prefix_id", "value=" . $this->webtestGetFirstValueForOptionGroup('individual_prefix'));
-
- //fill in first name
- $this->type("first_name", substr(sha1(rand()), 0, 7) . "John");
-
- //fill in middle name
- $this->type("middle_name", "Bruce");
-
- $lastName = substr(sha1(rand()), 0, 7) . "Smith";
- //fill in last name
- $this->type("last_name", $lastName);
-
- //create new current employer
- $currentEmployer = substr(sha1(rand()), 0, 7) . "Web Access";
-
- //fill in email
- $this->type("email_1_email", substr(sha1(rand()), 0, 7) . "john@gmail.com");
-
- //fill in phone
- $this->type("phone_1_phone", "2222-4444");
-
- //fill in source
- $this->type("contact_source", "johnSource");
-
- //address section
- $this->click("addressBlock");
- $this->waitForElementPresent("address_1_street_address");
-
- $this->select('address_1_location_type_id', 'value=2');
-
- $this->click('address[1][use_shared_address]');
-
- // create new organization with dialog
- $this->clickAt("xpath=//div[@id='s2id_address_1_master_contact_id']/a");
- $this->click("xpath=//li[@class='select2-no-results']//a[contains(text(),' New Organization')]");
-
- // create new contact using dialog
- $this->waitForElementPresent("css=div#crm-profile-block");
- $this->waitForElementPresent("_qf_Edit_next");
-
- $this->type('organization_name', $currentEmployer);
- $this->type('street_address-1', '902C El Camino Way SW');
- $this->type("email-Primary", "john@gmail.com" . substr(sha1(rand()), 0, 7));
- $this->type('city-1', 'Dumfries');
- $this->type('postal_code-1', '1234');
- $this->select('state_province-1', 'value=1001');
-
- $this->click("_qf_Edit_next");
-
- $this->select2('employer_id', $currentEmployer);
-
- //make sure shared address is selected
- $this->waitForElementPresent('selected_shared_address-1');
-
- //fill in address 2
- $this->click("//div[@id='addMoreAddress1']/a/span");
- $this->waitForElementPresent("address_2_street_address");
-
- $this->select('address_2_location_type_id', 'value=1');
-
- $this->click('address[2][use_shared_address]');
-
- // create new household with dialog
- $this->clickAt("xpath=//div[@id='s2id_address_2_master_contact_id']/a");
- $this->click("xpath=//li[@class='select2-no-results']//a[contains(text(),' New Household')]");
-
- // create new contact using dialog
- $this->waitForElementPresent("css=div#crm-profile-block");
- $this->waitForElementPresent("_qf_Edit_next");
-
- $sharedHousehold = substr(sha1(rand()), 0, 7) . 'Smith Household';
- $this->type('household_name', $sharedHousehold);
- $this->type('street_address-1', '2782Y Dowlen Path W');
- $this->type("email-Primary", substr(sha1(rand()), 0, 7) . "john@gmail.com");
- $this->type('city-1', 'Birmingham');
- $this->type('postal_code-1', '3456');
- $this->select('state_province-1', 'value=1001');
-
- $this->click("_qf_Edit_next");
-
- //make sure shared address is selected
- $this->waitForElementPresent('selected_shared_address-2');
-
- // Clicking save.
- $this->click("_qf_Contact_upload_view");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $name = $this->getText("xpath=//div[@class='crm-summary-display_name']");
- $this->waitForText('crm-notification-container', "$name has been created.");
-
- //make sure current employer is set
- $this->verifyText("xpath=id('contactinfo-block')/div/div/div[2]/div", 'Employer');
- $this->verifyText("xpath=id('contactinfo-block')/div/div/div[2]/div[2]/a[text()]", $currentEmployer);
-
- //make sure both shared address are set.
- $this->assertElementContainsText('address-block-1', "Address belongs to $currentEmployer");
- $this->assertElementContainsText('address-block-2', "Address belongs to $sharedHousehold");
-
- // make sure relationships are created
- $this->click("xpath=id('tab_rel')/a");
- $this->waitForElementPresent('permission-legend');
- $this->assertElementContainsText('DataTables_Table_0', 'Employee of');
- $this->assertElementContainsText('DataTables_Table_0', 'Household Member of');
- }
-
- public function testContactDeceased() {
- $this->webtestLogin();
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->openCiviPage('contact/add', 'reset=1&ct=Individual');
- //contact details section
- //fill in first name
- $fname = substr(sha1(rand()), 0, 7) . "John";
- $lname = substr(sha1(rand()), 0, 7) . "Smith";
- $this->type("first_name", $fname);
- //fill in last name
- $this->type("last_name", $lname);
- //fill in email
- $this->type("email_1_email", substr(sha1(rand()), 0, 7) . "john@gmail.com");
- // Clicking save.
- $this->click("_qf_Contact_upload_view");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForText('crm-notification-container', "Contact Saved");
- //Edit Contact
- $cid = $this->urlArg('cid');
- $dname = $fname . ' ' . $lname . ' (deceased)';
- foreach (array('', 'deceased') as $val) {
- $this->openCiviPage("contact/add", "reset=1&action=update&cid={$cid}");
- if ($val) {
- $this->assertElementContainsText('page-title', 'Edit ' . $dname);
- }
- // Click on the Demographics tab
- $this->click('demographics');
- $this->waitForElementPresent('is_deceased');
- $this->click('is_deceased');
- // Click on Save
- $this->click('_qf_Contact_upload_view-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- if (!$val) {
- $this->assertElementContainsText('css=div.crm-summary-display_name', $dname);
- }
- else {
- $this->assertTrue(($this->getText('css=div.crm-summary-display_name') != $dname));
- }
- }
- foreach (array('', 'deceased') as $val) {
- $this->mouseDown('crm-demographic-content');
- $this->mouseUp('crm-demographic-content');
- $this->waitForElementPresent("css=#crm-demographic-content .crm-container-snippet form");
- $this->click('is_deceased');
- $this->click("css=#crm-demographic-content input.crm-form-submit");
- $this->waitForElementPresent("css=#crm-demographic-content > .crm-inline-block-content");
- if (!$val) {
- $this->assertElementContainsText('css=div.crm-summary-display_name', $dname);
- }
- else {
- $this->assertTrue(($this->getText('css=div.crm-summary-display_name') != $dname));
- }
- }
- $this->openCiviPage("contact/add", "reset=1&action=update&cid={$cid}");
- $this->assertTrue(($this->getText('page-title') != $dname));
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Contact_AddViaProfileTest
- */
-class WebTest_Contact_AddViaProfileTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- /**
- * Add a contact via profile
- */
- public function testAddViaCreateProfile() {
- $this->webtestAddViaCreateProfile();
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Contact_AddressParsingTest
- */
-class WebTest_Contact_AddressParsingTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function teststreetAddressParsing() {
- // Logging in.
- $this->webtestLogin();
-
- //Go to the URL of Address Setting to enable street address parsing option
- $this->openCiviPage('admin/setting/preferences/address', 'reset=1');
-
- //check the street address parsing is already enabled
- if (!$this->isChecked("address_options[13]")) {
- $this->click("address_options[13]");
- $this->clickLink("_qf_Address_next");
- }
-
- // Go to the URL to create an Individual contact.
- $this->openCiviPage('contact/add', array('reset' => 1, 'ct' => "Individual"));
-
- //contact details section
- $firstName = "John" . substr(sha1(rand()), 0, 7);
- $lastName = "Smith" . substr(sha1(rand()), 0, 7);
-
- //fill in name
- $this->type("first_name", $firstName);
- $this->type("last_name", $lastName);
-
- //address section
- $this->click("addressBlock");
- $this->waitForElementPresent("address_1_street_address");
-
- //fill in address 1
- $this->click("//div[@id='addressBlockId']/div[1]");
- $this->type("address_1_street_address", "121A Sherman St. Apt. 12");
- $this->type("address_1_city", "Dumfries");
- $this->type("address_1_postal_code", "1234");
- $this->select("address_1_state_province_id", "value=1019");
- $this->type("address_1_geo_code_1", "1234");
- $this->type("address_1_geo_code_2", "5678");
-
- //fill in address 2
- $this->click("//div[@id='addMoreAddress1']/a/span");
- $this->waitForElementPresent("address_2_street_address");
- $this->type("address_2_street_address", "121 Sherman Street #15");
- $this->waitForElementPresent("address_2_city");
- $this->type("address_2_city", "Birmingham");
- $this->type("address_2_postal_code", "3456");
- $this->select("address_2_state_province_id", "value=1002");
- $this->type("address_2_geo_code_1", "2678");
- $this->type("address_2_geo_code_2", "1456");
-
- //fill in address 3
- $this->click("//div[@id='addMoreAddress2']/a/span");
- $this->waitForElementPresent("address_3_street_address");
- $this->type("address_3_street_address", "121 Sherman Rd Unit 155");
- $this->type("address_3_city", "Birmingham");
- $this->type("address_3_postal_code", "3456");
- $this->select("address_3_state_province_id", "value=1002");
-
- //fill in address 4
- $this->click("//div[@id='addMoreAddress3']/a/span");
- $this->waitForElementPresent("address_4_street_address");
- $this->type("address_4_street_address", "121 SW Sherman Way Suite 15");
- $this->waitForElementPresent("address_4_city");
- $this->type("address_4_city", "Birmingham");
- $this->type("address_4_postal_code", "5491");
- $this->assertSelected('address_4_country_id', "UNITED STATES");
- $this->select("address_4_state_province_id", "value=1002");
-
- // Store location type of each address
- for ($i = 1; $i <= 4; ++$i) {
- $location[$this->getSelectedLabel("address_{$i}_location_type_id")] = $i;
- }
-
- // Submit form
- $this->clickLink("_qf_Contact_upload_view");
- $this->waitForText('crm-notification-container', "{$firstName} {$lastName}");
-
- //Get the ids of newly created contact
- $contactId = $this->urlArg('cid');
-
- //Go to the url of edit contact
- $this->openCiviPage('contact/add', array('reset' => 1, 'action' => 'update', 'cid' => $contactId), 'addressBlock');
- $this->click("addressBlock");
- $this->click("//div[@id='addressBlockId']/div[1]");
-
- // Match addresses by location type since the order may have changed
- for ($i = 1; $i <= 4; ++$i) {
- $this->waitForElementPresent("address_{$i}_street_address");
- $address[$i] = $location[$this->getSelectedLabel("address_{$i}_location_type_id")];
- // Open "Edit Address Elements"
- $this->waitForElementPresent('addressBlockId');
- $this->click('addressBlockId');
- $this->click("//table[@id='address_table_{$i}']//a[text()='Edit Address Elements']");
- }
-
- //verify all the address fields were parsed correctly
- $verifyData = array(
- 1 => array(
- 'street_number' => '121A',
- 'street_name' => 'Sherman St.',
- 'street_unit' => 'Apt. 12',
- ),
- 2 => array(
- 'street_number' => '121',
- 'street_name' => 'Sherman Street',
- 'street_unit' => '#15',
- ),
- 3 => array(
- 'street_number' => '121',
- 'street_name' => 'Sherman Rd',
- 'street_unit' => 'Unit 155',
- ),
- 4 => array(
- 'street_number' => '121',
- 'street_name' => 'SW Sherman Way',
- 'street_unit' => 'Suite 15',
- ),
- );
- foreach ($verifyData as $loc => $values) {
- $num = $address[$loc];
- foreach ($values as $key => $expectedvalue) {
- $this->waitForValue("address_{$num}_$key", $expectedvalue);
- }
- }
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Contact_AdvanceSearchPaneTest
- */
-class WebTest_Contact_AdvanceSearchPaneTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- /**
- * Test individual pane seperatly.
- */
- public function testIndividualPanes() {
- $this->webtestLogin();
-
- // Get all default advance search panes.
- $allpanes = $this->_advanceSearchPanes();
-
- // Test Individual panes.
- foreach (array_keys($allpanes) as $pane) {
- // Go to the Advance Search
- $this->openCiviPage('contact/search/advanced', 'reset=1');
-
- // Select some fields from pane.
- $this->_selectPaneFields($pane);
-
- $this->click('_qf_Advanced_refresh');
-
- $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
-
- // check the opened panes.
- $this->_checkOpenedPanes(array($pane));
- }
- }
-
- /**
- * Test by selecting all panes at a time.
- */
- public function testAllPanes() {
- $this->webtestLogin();
-
- // Get all default advance search panes.
- $allpanes = $this->_advanceSearchPanes();
-
- // Go to the Advance Search
- $this->openCiviPage('contact/search/advanced', 'reset=1');
-
- // Select some fields from all default panes.
- foreach (array_keys($allpanes) as $pane) {
- $this->_selectPaneFields($pane);
- }
-
- $this->click('_qf_Advanced_refresh');
-
- $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
-
- // check all opened panes.
- $this->_checkOpenedPanes(array_keys($allpanes));
- }
-
- /**
- * @param array $openedPanes
- */
- public function _checkOpenedPanes($openedPanes = array()) {
- if (!$this->isTextPresent('None found.')) {
- $this->click('css=div.crm-advanced_search_form-accordion div.crm-accordion-header');
- }
-
- $allPanes = $this->_advanceSearchPanes();
-
- foreach ($allPanes as $paneRef => $pane) {
- if (in_array($paneRef, $openedPanes)) {
- // assert for element present.
- $this->waitForElementPresent("css=div.crm-accordion-wrapper div.crm-accordion-body {$pane['bodyLocator']}");
- }
- else {
- $this->assertTrue(!$this->isElementPresent("css=div.crm-accordion-wrapper div.crm-accordion-body {$pane['bodyLocator']}"));
- }
- }
- }
-
- /**
- * @param $paneRef
- * @param array $selectFields
- */
- public function _selectPaneFields($paneRef, $selectFields = array()) {
- $pane = $this->_advanceSearchPanes($paneRef);
-
- $this->click("css=div.crm-accordion-wrapper {$pane['headerLocator']}");
- $this->waitForElementPresent("css=div.crm-accordion-wrapper div.crm-accordion-body {$pane['bodyLocator']}");
-
- foreach ($pane['fields'] as $fld => $field) {
- if (!empty($selectFields) && !in_array($fld, $selectFields)) {
- continue;
- }
-
- $fldLocator = isset($field['locator']) ? $field['locator'] : '';
-
- switch ($field['type']) {
- case 'text':
- $this->type($fldLocator, current($field['values']));
- break;
-
- case 'select':
- foreach ($field['values'] as $op) {
- $this->select($fldLocator, 'label=' . $op);
- }
- break;
-
- case 'checkbox':
- foreach ($field['values'] as $op) {
- if (!$this->isChecked($op)) {
- $this->click($op);
- }
- }
- break;
-
- case 'radio':
- foreach ($field['values'] as $op) {
- $this->click($op);
- }
- break;
-
- case 'multiselect2':
- foreach ($field['values'] as $op) {
- $this->waitForElementPresent($fldLocator);
- $this->multiselect2($fldLocator, $op);
- }
- break;
-
- case 'date':
- $this->webtestFillDate($fldLocator, current($field['values']));
- break;
- }
- }
- }
-
- /**
- * @param null $paneRef
- *
- * @return array
- */
- public function _advanceSearchPanes($paneRef = NULL) {
- static $_advance_search_panes;
-
- if (!isset($_advance_search_panes) || empty($_advance_search_panes)) {
- $_advance_search_panes = array(
- 'location' => array(
- 'headerLocator' => 'div#location',
- 'bodyLocator' => 'select#country',
- 'title' => 'Address Fields',
- 'fields' => array(
- 'Location Type' => array(
- 'type' => 'multiselect2',
- 'locator' => 'location_type',
- 'values' => array(array('Home', 'Work')),
- ),
- 'Country' => array(
- 'type' => 'select',
- 'locator' => 'country',
- 'values' => array('UNITED STATES'),
- ),
- 'State' => array(
- 'type' => 'multiselect2',
- 'locator' => 'state_province',
- 'values' => array(
- array('Alabama', 'California', 'New Jersey', 'New York'),
- ),
- ),
- ),
- ),
- 'custom' => array(
- 'headerLocator' => 'div#custom',
- 'bodyLocator' => 'div#constituent_information',
- 'title' => 'Custom Data',
- 'fields' => array(
- 'Marital Status' => array(
- 'type' => 'select',
- 'locator' => 'custom_2',
- 'values' => array('Single'),
- ),
- ),
- ),
- 'activity' => array(
- 'headerLocator' => 'div#activity',
- 'bodyLocator' => 'input#activity_subject',
- 'title' => 'Activities',
- 'fields' => array(
- 'Activity Type' => array(
- 'type' => 'multiselect2',
- 'locator' => 'activity_type_id',
- 'values' => array(array('Contribution', 'Email', 'Event Registration', 'Membership Signup')),
- ),
- 'Activity Subject' => array(
- 'type' => 'text',
- 'locator' => 'activity_subject',
- 'values' => array('Test Subject'),
- ),
- 'Activity Status' => array(
- 'type' => 'multiselect2',
- 'locator' => 'status_id',
- 'values' => array(array('Scheduled', 'Completed')),
- ),
- ),
- ),
- 'relationship' => array(
- 'headerLocator' => 'div#relationship',
- 'bodyLocator' => 'select#relation_type_id',
- 'title' => 'Relationships',
- 'fields' => array(
- 'Relation Type' => array(
- 'type' => 'select',
- 'locator' => 'relation_type_id',
- 'values' => array('Employee of'),
- ),
- 'Relation Target' => array(
- 'type' => 'text',
- 'locator' => 'relation_target_name',
- 'values' => array('Test Contact'),
- ),
- ),
- ),
- 'demographics' => array(
- 'headerLocator' => 'div#demographics',
- 'bodyLocator' => 'input#birth_date_low',
- 'title' => 'Demographics',
- 'fields' => array(
- 'Birth Date Range' => array(
- 'type' => 'select',
- 'locator' => 'birth_date_relative',
- 'values' => array('Choose Date Range'),
- ),
- 'Birth Date from' => array(
- 'type' => 'date',
- 'locator' => 'birth_date_low',
- 'values' => array('10 September 1980'),
- ),
- 'Birth Date to' => array(
- 'type' => 'date',
- 'locator' => 'birth_date_high',
- 'values' => array('10 September 2000'),
- ),
- ),
- ),
- 'note' => array(
- 'headerLocator' => 'div#notes',
- 'bodyLocator' => 'input#note',
- 'title' => 'Notes',
- 'fields' => array(
- 'note' => array(
- 'type' => 'text',
- 'locator' => 'css=div#notes-search input#note',
- 'values' => array('Test Note'),
- ),
- ),
- ),
- 'change_log' => array(
- 'headerLocator' => 'div#changeLog',
- 'bodyLocator' => 'input#changed_by',
- 'title' => 'Change Log',
- 'fields' => array(
- 'Modified By' => array(
- 'type' => 'text',
- 'locator' => 'changed_by',
- 'values' => array('Test User'),
- ),
- ),
- ),
- 'contribution' => array(
- 'headerLocator' => 'div#CiviContribute',
- 'bodyLocator' => 'select#financial_type_id',
- 'title' => 'Contributions',
- 'fields' => array(
- 'Amount from' => array(
- 'type' => 'text',
- 'locator' => 'contribution_amount_low',
- 'values' => array('10'),
- ),
- 'Amount to' => array(
- 'type' => 'text',
- 'locator' => 'contribution_amount_high',
- 'values' => array('1000'),
- ),
- 'Financial Type' => array(
- 'type' => 'select',
- 'locator' => 'financial_type_id',
- 'values' => array('Donation'),
- ),
- 'Contribution Status' => array(
- 'type' => 'multiselect2',
- 'locator' => 'contribution_status_id',
- 'values' => array(array('Completed', 'Pending')),
- ),
- ),
- ),
- 'membership' => array(
- 'headerLocator' => 'div#CiviMember',
- 'bodyLocator' => 'input#member_source',
- 'title' => 'Memberships',
- 'fields' => array(
- 'Membership Type' => array(
- 'type' => 'select2',
- 'locator' => 'membership_type_id',
- 'values' => array(array('General', 'Student')),
- ),
- 'Membership Status' => array(
- 'type' => 'multiselect2',
- 'locator' => 'membership_status_id',
- 'values' => array(array('New', 'Current')),
- ),
- ),
- ),
- 'event' => array(
- 'headerLocator' => 'div#CiviEvent',
- 'bodyLocator' => 'input#event_id',
- 'title' => 'Events',
- 'fields' => array(
- 'Participant Status' => array(
- 'type' => 'multiselect2',
- 'locator' => 'participant_status_id',
- 'values' => array(array('Registered', 'Attended')),
- ),
- 'Participant Role' => array(
- 'type' => 'multiselect2',
- 'locator' => 'participant_role_id',
- 'values' => array(array('Attendee', 'Volunteer')),
- ),
- ),
- ),
- );
- }
-
- if ($paneRef) {
- return $_advance_search_panes[$paneRef];
- }
-
- return $_advance_search_panes;
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Contact_AdvanceSearchPrivacyOptionsTest
- */
-class WebTest_Contact_AdvanceSearchPrivacyOptionsTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testSearchForPrivacyOptions() {
- $this->webtestLogin();
-
- $privacyOptions = array(
- 'dn_phone_mail' => array('do_not_phone', 'do_not_mail'),
- 'dn_phone_email' => array('do_not_phone', 'do_not_email'),
- 'dn_trade_sms' => array('do_not_trade', 'do_not_sms'),
- );
- $randString = substr(sha1(rand()), 0, 7);
-
- $contactsReffOptions = array(
- 'dn_phone_mail' => array('first_name' => $randString . 'John', 'last_name' => $randString . 'Smith'),
- 'dn_phone_email' => array('first_name' => $randString . 'Jeff', 'last_name' => $randString . 'Adams'),
- 'dn_trade_sms' => array('first_name' => $randString . 'Rocky', 'last_name' => $randString . 'Stanley'),
- );
-
- //creating individuals
- $this->_addIndividual($contactsReffOptions['dn_phone_mail']['first_name'], $contactsReffOptions['dn_phone_mail']['last_name'], $privacyOptions['dn_phone_mail']);
- $this->_addIndividual($contactsReffOptions['dn_phone_email']['first_name'], $contactsReffOptions['dn_phone_email']['last_name'], $privacyOptions['dn_phone_email']);
- $this->_addIndividual($contactsReffOptions['dn_trade_sms']['first_name'], $contactsReffOptions['dn_trade_sms']['last_name'], $privacyOptions['dn_trade_sms']);
-
- //advance search for created contacts
- $this->openCiviPage('contact/search/advanced', 'reset=1', '_qf_Advanced_refresh');
- $allPrivacyOptions = array(
- 'do_not_phone',
- 'do_not_mail',
- 'do_not_email',
- 'do_not_sms',
- 'do_not_trade',
- );
-
- $this->_addPrivacyCriteria('include', $privacyOptions['dn_phone_mail'], 'OR', $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_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;
- }
- else {
- $assertCheck = FALSE;
- }
- $this->assertTrue($assertCheck, 'Do not phone / mail assertion failed using criteria(include , OR )');
- $this->_addPrivacyCriteria('exclude', $privacyOptions['dn_phone_mail'], 'OR', $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_trade_sms']['first_name'], $contactsReffOptions['dn_trade_sms']['last_name'])) {
- $assertCheck = TRUE;
- }
- else {
- $assertCheck = FALSE;
- }
- $this->assertTrue($assertCheck, 'Do not phone / mail assertion failed using criteria(exclude , OR )');
-
- $this->_addPrivacyCriteria('include', $privacyOptions['dn_phone_mail'], '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;
- }
- else {
- $assertCheck = FALSE;
- }
- $this->assertTrue($assertCheck, 'Do not phone / mail assertion failed using criteria(include , AND )');
-
- $this->_addPrivacyCriteria('exclude', $privacyOptions['dn_phone_mail'], '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_trade_sms']['first_name'], $contactsReffOptions['dn_trade_sms']['last_name'])) {
- $assertCheck = TRUE;
- }
- else {
- $assertCheck = FALSE;
- }
- $this->assertTrue($assertCheck, 'Do not phone / mail assertion failed using criteria(exclude , AND )');
- $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;
- }
- else {
- $assertCheck = FALSE;
- }
- $this->assertTrue($assertCheck, 'Do not trade / sms assertion failed using criteria(include , AND )');
- }
-
- /**
- * @param $inEx
- * @param $privacyOptions
- * @param $privacyOperator
- * @param $allPrivacyOptions
- */
- public 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=//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=//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 string $firstName
- * @param string $lastName
- *
- * @return bool
- */
- public function _searchSortNameCriteria($firstName, $lastName) {
- //type in the criteria
- $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
- */
- public function getOptionVal($privacyOption) {
- if ($privacyOption == 'do_not_phone') {
- $privacyOptionVal = 'Do not phone';
- }
- elseif ($privacyOption == 'do_not_mail') {
- $privacyOptionVal = 'Do not mail';
- }
- elseif ($privacyOption == 'do_not_email') {
- $privacyOptionVal = 'Do not email';
- }
- elseif ($privacyOption == 'do_not_trade') {
- $privacyOptionVal = 'Do not trade';
- }
- elseif ($privacyOption == 'do_not_sms') {
- $privacyOptionVal = 'Do not sms';
- }
- return $privacyOptionVal;
- }
-
- /**
- * @param string $firstName
- * @param string $lastName
- * @param $options
- */
- public function _addIndividual($firstName, $lastName, $options) {
-
- $this->openCiviPage('contact/add', 'reset=1&ct=Individual');
-
- //fill in first name
- $this->type("first_name", $firstName);
-
- //fill in last name
- $this->type("last_name", $lastName);
-
- //fill in email
- $this->type("email_1_email", "{$firstName}@{$lastName}.com");
-
- //fill in phone
- $this->type("phone_1_phone", "2222-4444");
-
- foreach ($options as $option) {
- //Select preferred method for Privacy
- $this->click("privacy_{$option}");
- }
-
- // Clicking save.
- $this->click("_qf_Contact_upload_view");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForText('crm-notification-container', "{$firstName} {$lastName} has been created.");
-
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Contact_AdvancedSearchTest
- */
-class WebTest_Contact_AdvancedSearchTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testAdvanceSearch() {
- $this->markTestSkipped('Skipping for now as it works fine locally.');
- $this->webtestLogin();
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- //------- first create new group and tag -----
-
- // take group name and create group
- $groupName = 'group_' . substr(sha1(rand()), 0, 7);
- $this->WebtestAddGroup($groupName);
-
- // take a tag name and create tag
- include_once 'WebTest/Contact/SearchTest.php';
- $tagName = 'tag_' . substr(sha1(rand()), 0, 7);
- WebTest_Contact_SearchTest::addTag($tagName, $this);
-
- //---------- create detailed contact ---------
-
- $firstName = substr(sha1(rand()), 0, 7);
- $this->createDetailContact($firstName);
-
- // go to group tab and add to new group
- $this->clickAjaxLink("css=li#tab_group a", "_qf_GroupContact_next");
- $this->select("group_id", "$groupName");
- $this->clickAjaxLink("_qf_GroupContact_next");
- $this->waitForText('crm-notification-container', "Contact has been added to '$groupName'");
-
- // go to tag tab and add to new tag
- $this->clickAjaxLink("css=li#tab_tag a", "css=div#tagtree");
- $this->click("xpath=//ul/li/span/label[text()=\"$tagName\"]");
- $this->checkCRMStatus();
-
- // register for event ( auto add activity and contribution )
- $this->clickPopupLink("link=Register for Event");
- $this->waitForText('s2id_event_id', "- select event -");
- $this->select2("event_id", "Fall Fundraiser Dinner");
- $this->waitForElementPresent("receipt_text");
- $this->multiselect2("role_id", array('Volunteer'));
- // Select $100 fee
- $this->click("xpath=//input[@data-amount='100']");
- $this->check("record_contribution");
- $this->waitForElementPresent("contribution_status_id");
- $this->select("payment_instrument_id", "Check");
- $this->type("check_number", "chqNo$firstName");
- $this->type("trxn_id", "trid$firstName");
- $this->clickAjaxLink("_qf_Participant_upload-bottom", "link=Add Event Registration");
- $this->waitForText('crm-notification-container', "Event registration for $firstName adv$firstName has been added");
-
- // Add pledge
- $this->clickPopupLink("link=Add Pledge");
- $this->waitForElementPresent("contribution_page_id");
- $this->type("amount", "200");
- $this->type("installments", "5");
- $this->type("frequency_interval", "1");
- $this->select("frequency_unit", "month(s)");
- $this->clickAjaxLink("_qf_Pledge_upload-bottom", "link=Add Pledge");
- $this->waitForText('crm-notification-container', "Pledge has been recorded and the payment schedule has been created.");
-
- // Add membership
- $this->clickPopupLink("link=Add Membership", "_qf_Membership_cancel-bottom");
- //let the organisation be default (Default Organization)
- $this->select("membership_type_id[0]", "value=1");
- $this->click("membership_type_id[1]");
- $this->select("membership_type_id[1]", "Student");
- $this->type("source", "membership source$firstName");
- $this->clickAjaxLink("_qf_Membership_upload-bottom");
- $this->waitForText('crm-notification-container', "Student membership for $firstName adv$firstName has been added");
-
- // Add relationship
- $this->clickPopupLink("link=Add Relationship", "_qf_Relationship_cancel");
- $this->select2("relationship_type_id", "Employee of");
- $this->waitForElementPresent("xpath=//input[@id='related_contact_id'][@placeholder='- select organization -']");
- $this->select2("related_contact_id", "Default", TRUE);
- $this->waitForAjaxContent();
- $this->webtestFillDate("start_date", "-1 day");
- $this->webtestFillDate("end_date", "+1 day");
- $this->clickAjaxLink('_qf_Relationship_upload-bottom', NULL);
- $this->waitForText('crm-notification-container', "Relationship created.");
-
- //-------------- advance search --------------
-
- $this->openCiviPage('contact/search/advanced', 'reset=1');
-
- //also create a dummy name to test false
- $dummyName = substr(sha1(rand()), 0, 7);
-
- // search block array for adv search
- $searchBlockValues = array(
- 'basic' => array('', 'addBasicSearchDetail'),
- 'location' => array('state_province', 'addAddressSearchDetail'),
- 'demographics' => array('civicrm_gender_Other_3', 'addDemographicSearchDetail'),
- 'notes' => array('note', ''),
- 'activity' => array('activity_type_id', 'addActivitySearchDetail'),
- 'CiviContribute' => array('contribution_currency_type', 'addContributionSearchDetail'),
- 'CiviEvent' => array('participant_fee_amount_high', 'addParticipantSearchDetail'),
- 'CiviMember' => array('member_end_date_high', 'addMemberSearchDetail'),
- 'CiviPledge' => array('pledge_frequency_interval', 'addPledgeSearchDetail'),
- 'relationship' => array(
- "xpath=//div[@id='relationship']/table/tbody/tr//td/label[text()='Relationship Status']/../label[text()='All']",
- '',
- ),
- );
-
- foreach ($searchBlockValues as $block => $blockValues) {
- switch ($block) {
- case 'basic':
- $this->$blockValues[1]($firstName, $groupName, $tagName);
- break;
-
- case 'notes':
- $this->click("$block");
- $this->waitForElementPresent("$blockValues[0]");
- $this->type("note", "this is notes by $firstName");
- break;
-
- case 'relationship':
- $this->click("$block");
- $this->waitForElementPresent("$blockValues[0]");
- $this->select("relation_type_id", "Employee of");
- $this->type("relation_target_name", "Default");
- break;
-
- default:
- $this->click("$block");
- $this->waitForElementPresent("$blockValues[0]");
- $this->$blockValues[1]($firstName);
- break;
- }
- $this->submitSearch($firstName);
- }
-
- //-- search with non existing value ( sort name )
- $this->type("sort_name", "$dummyName");
- $this->clickLink("_qf_Advanced_refresh");
- $this->waitForText("xpath=//form[@id='Advanced']/div[3]/div/div", "No matches found for");
- }
-
- /**
- * Check for CRM-9873
- */
- public function testActivitySearchByTypeTest() {
- $this->webtestLogin();
- $this->openCiviPage('contact/search/advanced', 'reset=1');
- $this->clickAjaxLink("activity", 'activity_subject');
- $this->multiselect2("activity_type_id", array('Tell a Friend'));
- $this->clickLink("_qf_Advanced_refresh");
- $count = explode(" ", trim($this->getText("xpath=//div[@id='search-status']/table/tbody/tr/td")));
- $count = $count[0];
- $this->assertTrue(is_numeric($count), "The total count of search results not found");
-
- //pagination calculation
- $perPageRow = 50;
- if ($count > $perPageRow) {
- $cal = $count / $perPageRow;
- $mod = $count % $perPageRow;
- $j = 1;
- for ($i = 1; $i <= $cal; $i++) {
- $subTotal = $i * $perPageRow;
- $lastPageSub = $subTotal + 1;
-
- //pagination and row count assertion
- $pagerCount = "Contact {$j} - {$subTotal} of {$count}";
- $this->assertElementContainsText("xpath=//div[@class='crm-search-results']/div[@class='crm-pager']/span[@class='crm-pager-nav']", $pagerCount);
- $this->assertEquals($perPageRow, $this->getXpathCount("//div[@class='crm-search-results']/table/tbody/tr"));
-
- //go to next page
- $this->click("xpath=//div[@class='crm-search-results']/div[@class='crm-pager']/span[@class='crm-pager-nav']/a[@title='next page']");
- $this->waitForElementPresent("xpath=//a[@title='first page']");
- $j = $j + $subTotal;
- }
-
- //pagination and row count assertion for the remaining last page
- if ($mod) {
- $pagerCount = "Contact {$lastPageSub} - {$count} of {$count}";
- $this->assertElementContainsText("xpath=//div[@class='crm-search-results']/div[@class='crm-pager']/span[@class='crm-pager-nav']", $pagerCount);
- $this->assertEquals($mod, $this->getXpathCount("//div[@class='crm-search-results']/table/tbody/tr"));
- }
- }
- }
-
- /**
- * function to check match for sumbit Advance Search.
- * @param string $firstName
- */
- public function submitSearch($firstName) {
- $this->clickLink("_qf_Advanced_refresh");
- // verify unique name
- $this->waitForAjaxContent();
- $this->waitForAjaxContent();
- $this->waitForElementPresent("xpath=//div[@class='crm-search-results']/table/tbody/tr//td/a[text()='adv$firstName, $firstName']");
- // should give 1 result only as we are searching with unique name
- $this->waitForText("xpath=//div[@id='search-status']/table/tbody/tr/td", preg_quote("1 Contact"));
- // click to edit search
- $this->click("xpath=//form[@id='Advanced']//div[2]/div/div[1]");
- }
-
- /**
- * Check for CRM-14952
- */
- public function testStateSorting() {
- $this->webtestLogin();
- $this->openCiviPage('contact/search/advanced', 'reset=1', 'group');
- $this->select2("group", "Newsletter", TRUE);
- $this->select2("group", "Summer", TRUE);
- $this->select2("group", "Advisory", TRUE);
- $this->clickAjaxLink("location", 'country');
- $this->select2("country", "UNITED STATES", FALSE);
- $this->waitForElementPresent('state_province');
- $this->multiselect2("state_province", array(
- "Ohio",
- "New York",
- "New Mexico",
- "Connecticut",
- "Georgia",
- "New Jersey",
- "Texas",
- ));
- $this->clickLink("_qf_Advanced_refresh", "xpath=//div[@class='crm-search-results']//table/tbody/tr[1]/td[6]");
-
- $this->clickAjaxLink("xpath=//div[@class='crm-search-results']//table/thead/tr//th/a[contains(text(),'State')]");
- $this->waitForElementPresent("xpath=//div[@class='crm-search-results']//table/thead/tr//th/a[contains(text(),'State')]");
- $stateBeforeSort = $this->getText("xpath=//div[@class='crm-search-results']//table/tbody/tr[1]/td[6]");
- $this->clickAjaxLink("xpath=//div[@class='crm-search-results']//table/thead/tr//th/a[contains(text(), 'State')]");
- $this->waitForElementPresent("xpath=//div[@class='crm-search-results']//table/thead/tr//th/a[contains(text(), 'State')]");
- $this->assertElementNotContainsText("xpath=//div[@class='crm-search-results']//table/tbody/tr[1]/td[6]", $stateBeforeSort);
- }
-
- /**
- * function to fill basic search detail.
- * @param string $firstName
- * @param string $groupName
- * @param $tagName
- */
- public function addBasicSearchDetail($firstName, $groupName, $tagName) {
- // fill partial sort name
- $this->type("sort_name", "$firstName");
- // select subtype
- $this->select("contact_type", "value=Individual__Student");
- // select group
- $this->select("group", "label=$groupName");
- // select tag
- $this->select("contact_tags", "label=$tagName");
- // select preferred language
- $this->select("preferred_language", "value=en_US");
- // select privacy
- $this->select("privacy_options", "value=do_not_email");
-
- // select preferred communication method
- // phone
- $this->select2("preferred_communication_method", array('Phone', 'Email'), TRUE);
- }
-
- /**
- * function to fill address search block values in advance search.
- * @param $firstName
- */
- public function addAddressSearchDetail($firstName) {
- // select location type (home and main)
- $this->multiselect2('location_type', array('Home', 'Main'));
- // fill street address
- $this->type("street_address", "street 1 $firstName");
- // fill city
- $this->type("city", "city$firstName");
- // fill postal code range
- $this->type("postal_code_low", "100010");
- $this->type("postal_code_high", "101000");
- // select country
- $this->select("country", "UNITED STATES");
- // select state-province
- $this->waitForElementPresent('state_province');
- $this->select2("state_province", "Alaska", TRUE);
- }
-
- /**
- * function to fill activity search block in advance search.
- * @param $firstName
- */
- public function addActivitySearchDetail($firstName) {
- // select activity types
- $activityTypes = array("Contribution", "Event Registration", "Membership Signup");
- $this->multiselect2('activity_type_id', $activityTypes);
- // fill date range
- $this->select("activity_date_relative", "value=0");
- $this->webtestFillDate("activity_date_low", "-1 day");
- $this->webtestFillDate("activity_date_high", "+1 day");
- $this->type("activity_subject", "Student - membership source$firstName - Status: New");
- // fill activity status
- $this->multiselect2('status_id', array('Scheduled', 'Completed'));
- }
-
- /**
- * function to fill demographic search details.
- */
- public function addDemographicSearchDetail() {
- // fill birth date range
- $this->select("birth_date_relative", "value=0");
- $this->webtestFillDate("birth_date_low", "-3 year");
- $this->webtestFillDate("birth_date_high", "now");
- // fill deceased date range
- $this->click("xpath=//div[@id='demographics']/table/tbody//tr/td/label[text()='Deceased']/../label[text()='Yes']");
- $this->select("deceased_date_relative", "value=0");
- $this->webtestFillDate("deceased_date_low", "-1 month");
- $this->webtestFillDate("deceased_date_high", "+1 month");
- // fill gender (male)
- $this->check("civicrm_gender_Male_2");
- }
-
- /**
- * function to fill contribution search details.
- * @param $firstName
- */
- public function addContributionSearchDetail($firstName) {
- // fill contribution date range
- $this->select("contribution_date_relative", "value=0");
- $this->webtestFillDate("contribution_date_low", "-1 day");
- $this->webtestFillDate("contribution_date_high", "+1 day");
- // fill amount range
- $this->type("contribution_amount_low", "1");
- $this->type("contribution_amount_high", "200");
- // check for completed
- $this->multiselect2("contribution_status_id", array('Completed'));
- // enter check number
- $this->select("payment_instrument_id", "Check");
- $this->type("contribution_check_number", "chqNo$firstName");
- // fill transaction id
- $this->type("contribution_trxn_id", "trid$firstName");
- // fill financial type
- $this->select("financial_type_id", "Event Fee");
- // fill currency type
- $this->select2("contribution_currency_type", "USD");
- }
-
- /**
- * function to fill participant search details.
- */
- public function addParticipantSearchDetail() {
- // fill event name
- $this->select2("event_id", "Fall Fundraiser Dinner");
- // fill event type
- $this->select2("event_type_id", "Fundraiser");
- // select participant status (registered)
- $this->multiselect2('participant_status_id', array('Registered'));
- // select participant role (Volunteer)
- $this->multiselect2('participant_role_id', array('Volunteer'));
- // fill participant fee level (couple)
- $this->select2("participant_fee_id", "Couple");
- // fill amount range
- $this->type("participant_fee_amount_low", "1");
- $this->type("participant_fee_amount_high", "150");
- }
-
- /**
- * function to fill member search details.
- * @param $firstName
- */
- public function addMemberSearchDetail($firstName) {
- // check membership type (Student)
- $this->select2('membership_type_id', 'Student', TRUE);
- // check membership status (completed)
- $this->select2('membership_status_id', 'New', TRUE);
- // fill member source
- $this->type("member_source", "membership source$firstName");
- // check to search primary member
- $this->click("xpath=//div[@id='memberForm']/table/tbody/tr[2]/td[2]/p/input");
- // add join date range
- $this->select("member_join_date_relative", "value=0");
- $this->webtestFillDate("member_join_date_low", "-1 day");
- $this->webtestFillDate("member_join_date_high", "+1 day");
- // add start date range
- $this->select("member_start_date_relative", "value=0");
- $this->webtestFillDate("member_start_date_low", "-1 day");
- $this->webtestFillDate("member_start_date_high", "+1 day");
- // add end date range
- $this->select("member_end_date_relative", "value=0");
- $this->webtestFillDate("member_end_date_low", "-1 year");
- $this->webtestFillDate("member_end_date_high", "+2 year");
- }
-
- /**
- * function to fill member search details.
- * @param $firstName
- */
- public function addPledgeSearchDetail($firstName) {
- // fill pledge schedule date range
- $this->select("pledge_payment_date_relative", "value=0");
- $this->webtestFillDate("pledge_payment_date_low", "-1 day");
- $this->webtestFillDate("pledge_payment_date_high", "+1 day");
- // fill Pledge payment status
- $this->select2('pledge_status_id', 'Pending', TRUE);
- $this->select2('pledge_payment_status_id', 'Pending', TRUE);
- // fill pledge amount range
- $this->type("pledge_amount_low", "100");
- $this->type("pledge_amount_high", "300");
- // fill pledge created date range
- $this->webtestFillDate("pledge_create_date_low", "-5 day");
- $this->webtestFillDate("pledge_create_date_high", "+5 day");
- // fill plegde start date
- $this->webtestFillDate("pledge_start_date_low", "-2 day");
- $this->webtestFillDate("pledge_start_date_high", "+2 day");
- // fill financial type
- $this->select("pledge_financial_type_id", "Donation");
- }
-
- /**
- * function to create contact with details (contact details, address, Constituent information ...)
- * @param null $firstName
- */
- public function createDetailContact($firstName = NULL) {
- if (!$firstName) {
- $firstName = substr(sha1(rand()), 0, 7);
- }
-
- // create contact type Individual with subtype
- // with most of values to required to search
- $Subtype = "Student";
- $this->openCiviPage('contact/add', 'reset=1&ct=Individual', '_qf_Contact_cancel');
-
- // --- fill few values in Contact Detail block
- $this->type("first_name", "$firstName");
- $this->type("middle_name", "mid$firstName");
- $this->type("last_name", "adv$firstName");
- $this->select("contact_sub_type", "label=$Subtype");
- $this->type("email_1_email", "$firstName@advsearch.co.in");
- $this->type("phone_1_phone", "123456789");
- $this->type("external_identifier", "extid$firstName");
-
- // --- fill few value in Constituent information
- $this->click("customData");
- $this->waitForElementPresent("custom_3_-1");
-
- $this->click("CIVICRM_QFID_Edu_2");
- $this->select("custom_2_-1", "label=Single");
-
- // --- fill few values in address
-
- $this->click("//form[@id='Contact']/div[2]/div[4]/div[1]");
- $this->waitForElementPresent("address_1_geo_code_2");
- $this->type("address_1_street_address", "street 1 $firstName");
- $this->type("address_1_supplemental_address_1", "street supplement 1 $firstName");
- $this->type("address_1_supplemental_address_2", "street supplement 2 $firstName");
- $this->type("address_1_supplemental_address_3", "street supplement 2 $firstName");
- $this->type("address_1_city", "city$firstName");
- $this->type("address_1_postal_code", "100100");
- $this->select("address_1_country_id", "UNITED STATES");
- $this->select("address_1_state_province_id", "Alaska");
-
- // --- fill few values in communication preferences
- $this->click("//form[@id='Contact']/div[2]/div[5]/div[1]");
- $this->waitForElementPresent("preferred_mail_format");
- $this->check("privacy[do_not_phone]");
- $this->check("privacy[do_not_mail]");
- // phone
- $this->check("preferred_communication_method[1]");
- // email
- $this->check("preferred_communication_method[2]");
- $this->select("preferred_language", "value=en_US");
-
- // --- fill few value in notes
- $this->click("//form[@id='Contact']/div[2]/div[6]/div[1]");
- $this->waitForElementPresent("note");
- $this->type("subject", "this is subject by $firstName");
- $this->type("note", "this is notes by $firstName");
-
- // --- fill few values in demographics
- $this->click("//form[@id='Contact']/div[2]/div[7]/div[1]");
- $this->waitForElementPresent("is_deceased");
- $this->click("CIVICRM_QFID_2_gender_id");
-
- $this->webtestFillDate("birth_date", "-1 year");
- $this->click("is_deceased");
- $this->waitForElementPresent("deceased_date");
- $this->webtestFillDate("deceased_date", "now");
-
- // save contact
- $this->clickLink("_qf_Contact_upload_view", 'css=.crm-summary-display_name');
- $this->assertElementContainsText('css=.crm-summary-display_name', "$firstName adv$firstName");
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Contact_AdvancedSearchedRelatedContactTest
- */
-class WebTest_Contact_AdvancedSearchedRelatedContactTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testSearchRelatedContact() {
- // Log in using webtestLogin() method
- $this->webtestLogin();
-
- // Use default payment processor
- $processorName = 'Test Processor';
- $paymentProcessorId = $this->webtestAddPaymentProcessor($processorName);
-
- $this->openCiviPage('event/add', 'reset=1&action=add');
-
- $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7);
- $eventDescription = "Here is a description for this conference.";
- $this->_testAddEventInfo($eventTitle, $eventDescription);
-
- $streetAddress = "100 Main Street";
- $this->_testAddLocation($streetAddress);
-
- $this->_testAddFees(FALSE, FALSE, $processorName);
- $this->openCiviPage('event/manage', 'reset=1');
- $this->type('title', $eventTitle);
- $this->click('_qf_SearchEvent_refresh');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $Id = explode('-', $this->getAttribute("xpath=//div[@id='event_status_id']/div[2]/table/tbody/tr@id"));
- $eventId = $Id[1];
-
- $params = array(
- 'label_a_b' => 'Owner of ' . rand(),
- 'label_b_a' => 'Belongs to ' . rand(),
- 'contact_type_a' => 'Individual',
- 'contact_type_b' => 'Individual',
- 'description' => 'The company belongs to this individual',
- );
-
- $this->webtestAddRelationshipType($params);
- $relType = $params['label_b_a'];
-
- $firstName = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName, "Anderson", "$firstName@anderson.name");
- $sortName = "Anderson, $firstName";
- $displayName = "$firstName Anderson";
-
- //create a New Individual
- $firstName1 = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName1, "Andy", "$firstName1@andy.name");
- $sortName1 = "Andy, $firstName1";
- $displayName1 = "$firstName1 Andy";
- $this->_testAddRelationship($sortName1, $sortName, $relType);
-
- $firstName2 = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName2, "David", "$firstName2@andy.name");
- $sortName2 = "David, $firstName2";
- $displayName2 = "$firstName2 David";
- $this->_testAddRelationship($sortName2, $sortName, $relType);
-
- $this->openCiviPage('contact/search', 'reset=1', '_qf_Basic_refresh');
- $this->type("sort_name", $sortName);
- $this->select("contact_type", "value=Individual");
- $this->clickLink("_qf_Basic_refresh", "//table[@class='selector row-highlight']/tbody//tr/td[11]/span/a[text()='View']", FALSE);
-
- // click through to the Relationship view screen
- $this->click("xpath=//table[@class='selector row-highlight']/tbody//tr/td[11]/span/a[text()='View']");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->click("css=li#tab_participant a");
-
- // wait for add Event link
- $this->waitForElementPresent("link=Add Event Registration");
- $this->click("link=Add Event Registration");
- $this->waitForText("s2id_event_id", "- select event -");
- $this->select2("event_id", $eventTitle);
- $this->click("_qf_Participant_upload-bottom");
- $this->waitForElementPresent("link=Add Event Registration");
-
- $this->openCiviPage('contact/search/advanced', 'reset=1');
-
- $this->waitForElementPresent("sort_name");
- $this->type("sort_name", $sortName);
- $this->click('_qf_Advanced_refresh');
- $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
-
- $this->waitForElementPresent('search-status');
- $this->assertElementContainsText('search-status', '1 Contact');
-
- $this->click('css=div.crm-advanced_search_form-accordion div.crm-accordion-header');
- $this->waitForElementPresent("component_mode");
- $this->select("component_mode", "label=Related Contacts");
- $this->waitForElementPresent("display_relationship_type");
- $this->select("display_relationship_type", $relType);
- $this->click('_qf_Advanced_refresh');
- $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
-
- $this->waitForElementPresent('search-status');
- $this->assertElementContainsText('search-status', '2 Contact');
-
- $this->select("task", "label=Group - add contacts");
-
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->click('CIVICRM_QFID_1_group_option');
-
- $groupName = "Group " . substr(sha1(rand()), 0, 7);
- $this->type('title', $groupName);
-
- $this->click("_qf_AddToGroup_next-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->waitForText('crm-notification-container', "Added Contacts to " . $groupName);
- $this->waitForText('crm-notification-container', '2 contacts added to group');
- $this->_testSearchResult($relType);
- }
-
- /**
- * @param $eventTitle
- * @param $eventDescription
- */
- public function _testAddEventInfo($eventTitle, $eventDescription) {
- $this->waitForElementPresent("_qf_EventInfo_upload-bottom");
-
- $this->select("event_type_id", "value=1");
- $this->waitForAjaxContent();
-
- // Attendee role s/b selected now.
- $this->select("default_role_id", "value=1");
-
- // Enter Event Title, Summary and Description
- $this->type("title", $eventTitle);
- $this->type("summary", "This is a great conference. Sign up now!");
-
- // Type description in ckEditor (fieldname, text to type, editor)
- $this->fillRichTextField("description", $eventDescription, 'CKEditor');
-
- // Choose Start and End dates.
- // Using helper webtestFillDate function.
- $this->webtestFillDateTime("start_date", "+1 week");
- $this->webtestFillDateTime("end_date", "+1 week 1 day 8 hours ");
-
- $this->type("max_participants", "50");
- $this->click("is_map");
- $this->click("_qf_EventInfo_upload-bottom");
- }
-
- /**
- * @param $streetAddress
- */
- public function _testAddLocation($streetAddress) {
- // Wait for Location tab form to load
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForElementPresent("_qf_Location_upload-bottom");
-
- // Fill in address fields
- $streetAddress = "100 Main Street";
- $this->type("address_1_street_address", $streetAddress);
- $this->type("address_1_city", "San Francisco");
- $this->type("address_1_postal_code", "94117");
- $this->select('address_1_country_id', 'UNITED STATES');
- $this->waitForAjaxContent();
- $this->select("address_1_state_province_id", "value=1004");
- $this->type("email_1_email", "info@civicrm.org");
-
- $this->click("_qf_Location_upload-bottom");
-
- // Wait for "saved" status msg
- $this->waitForElementPresent("_qf_Location_upload-bottom");
- $this->waitForText('crm-notification-container', "'Event Location' information has been saved.");
- }
-
- /**
- * @param bool $discount
- * @param bool $priceSet
- * @param int|array $processorIDs
- */
- public function _testAddFees($discount = FALSE, $priceSet = FALSE, $processorIDs) {
- // Go to Fees tab
- $this->click("link=Fees");
- $this->waitForElementPresent("_qf_Fee_upload-bottom");
- $this->click("CIVICRM_QFID_1_is_monetary");
- $this->select2('payment_processor', $processorIDs, TRUE);
- $this->select("financial_type_id", "value=4");
- if ($priceSet) {
- // get one - TBD
- }
- else {
- $this->type("label_1", "Member");
- $this->type("value_1", "250.00");
- $this->type("label_2", "Non-member");
- $this->type("value_2", "325.00");
- //set default
- $this->click("xpath=//table[@id='map-field-table']/tbody/tr[2]/td[3]/input");
- }
-
- if ($discount) {
- // enter early bird discounts TBD
- }
-
- $this->click("_qf_Fee_upload-bottom");
-
- // Wait for "saved" status msg
- $this->waitForElementPresent("_qf_Fee_upload-bottom");
- $this->waitForTextPresent("'Fees' information has been saved.");
- }
-
- /**
- * @param string $ContactName
- * @param string $relatedName
- * @param $relType
- */
- public function _testAddRelationship($ContactName, $relatedName, $relType) {
-
- $this->openCiviPage('contact/search', 'reset=1', '_qf_Basic_refresh');
- $this->type("sort_name", $ContactName);
- $this->select("contact_type", "value=Individual");
- $this->clickLink("_qf_Basic_refresh", "//div[@class='crm-search-results']/table[@class='selector row-highlight']/tbody/tr/", FALSE);
-
- // click through to the Contribution view screen
- $this->click("xpath=//table[@class='selector row-highlight']/tbody/tr/td[11]//span/a[text()='View']");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->click("css=li#tab_rel a");
-
- // wait for add Relationship link
- $this->waitForElementPresent('link=Add Relationship');
- $this->click('link=Add Relationship');
-
- //choose the created relationship type
- $this->waitForElementPresent("relationship_type_id");
- $this->select('relationship_type_id', "label={$relType}");
-
- //fill in the individual
- $this->waitForElementPresent("related_contact_id");
- $this->select2('related_contact_id', $relatedName, TRUE);
-
- //fill in the relationship start date
- $this->webtestFillDate('start_date', '-2 year');
- $this->webtestFillDate('end_date', '+1 year');
-
- $description = "Well here is some description !!!!";
- $this->type("description", $description);
-
- //save the relationship
- //$this->click("_qf_Relationship_upload");
- $this->click('_qf_Relationship_upload-bottom');
- $this->waitForElementPresent("xpath=//div[@class='dataTables_wrapper no-footer']");
-
- //check the status message
- $this->waitForText('crm-notification-container', "Relationship created.");
- $this->waitForElementPresent("xpath=//div[@class='crm-contact-relationship-current']//div[@class='dataTables_wrapper no-footer']//table/tbody//tr/td[9]/span/a[text()='View']");
- $this->click("xpath=//div[@class='crm-contact-relationship-current']//div[@class='dataTables_wrapper no-footer']//table/tbody//tr/td[9]/span/a[text()='View']");
-
- $this->waitForElementPresent("xpath=//table[@class='crm-info-panel']");
- $this->webtestVerifyTabularData(
- array(
- 'Description' => $description,
- 'Status' => 'Enabled',
- )
- );
- $this->assertElementContainsText("xpath=//table[@class='crm-info-panel']", $relType);
- }
-
- /**
- * @param $relType
- */
- public function _testSearchResult($relType) {
-
- //search related contact using Advanced Search
- $this->openCiviPage('contact/search/advanced', 'reset=1', '_qf_Advanced_refresh');
- $this->select("component_mode", "label=Related Contacts");
- $this->select("display_relationship_type", "label={$relType}");
- $this->click("CiviEvent");
- $this->waitForElementPresent("event_type_id");
- $this->select2("event_type_id", "Conference");
- $this->click("_qf_Advanced_refresh");
- $this->waitForElementPresent("xpath=//div[@class='crm-content-block']//div[@id='search-status']");
- $this->assertElementContainsText("xpath=//div[@id='search-status']/table/tbody/tr[1]/td[1]", "2 Contacts");
- }
-
- public function testAdvanceSearchForLog() {
- $this->webtestLogin();
-
- $Pdate = date('F jS, Y h:i:s A', mktime(0, 0, 0, date('m'), date('d') - 1, date('Y')));
- $Ndate = date('F jS, Y h:i:s A', mktime(0, 0, 0, date('m'), date('d') + 1, date('Y')));
-
- //create a contact and return the contact id
- $firstNameSoft = "John_" . substr(sha1(rand()), 0, 5);
- $lastNameSoft = "Doe_" . substr(sha1(rand()), 0, 5);
- $this->webtestAddContact($firstNameSoft, $lastNameSoft);
- $cid = $this->urlArg('cid');
-
- //advance search for created contacts
- $this->openCiviPage('contact/search/advanced', 'reset=1', '_qf_Advanced_refresh');
- $this->type('sort_name', $lastNameSoft . ', ' . $firstNameSoft);
- $this->click('changeLog');
- $this->waitForElementPresent("log_date_low");
- $this->select("log_date_relative", "value=0");
- $this->webtestFillDate('log_date_low', "-1 day");
- $this->webtestFillDate('log_date_high', "+1 day");
- $this->click('_qf_Advanced_refresh');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->assertTrue(TRUE, 'greater than or equal to "{$Pdate}" AND less than or equal to "{$Ndate}"');
- $value = "$lastNameSoft, $firstNameSoft";
- $this->waitForElementPresent("xpath= id('rowid{$cid}')/td[3]/a");
- $this->verifyText("xpath= id('rowid{$cid}')/td[3]/a", preg_quote($value));
-
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Contact_ContactReferenceFieldTest
- */
-class WebTest_Contact_ContactReferenceFieldTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testContactReferenceField() {
- $this->webtestLogin();
-
- /* add new group */
-
- $this->openCiviPage('group/add', 'reset=1', '_qf_Edit_upload');
-
- $groupName = 'group_' . substr(sha1(rand()), 0, 7);
- $this->type("title", $groupName);
-
- // fill description
- $this->type("description", "Adding new group.");
-
- // check Access Control
- $this->click("group_type[1]");
-
- // Clicking save.
- $this->click("_qf_Edit_upload");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- /* add contacts */
-
- // Individual 1
- $contact1 = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($contact1, "Anderson", "{$contact1}@example.com");
-
- // Add Individual 1 to group
- $this->click('css=li#tab_group a');
- $this->waitForElementPresent('_qf_GroupContact_next');
- $this->select('group_id', "label={$groupName}");
- $this->click('_qf_GroupContact_next');
- $this->waitForText('crm-notification-container', "Added to Group");
-
- // Individual 1
- $contact2 = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($contact2, "Anderson", "{$contact2}@example.com");
-
- // Organization 1
- $org1 = 'org_' . substr(sha1(rand()), 0, 5);
- $this->webtestAddOrganization($org1, "{$org1}@example.com");
-
- /* create custom group and fields */
-
- // Add Custom group //
-
- $this->openCiviPage('admin/custom/group', 'action=add&reset=1');
-
- //fill custom group title
- $customGroupTitle = 'custom_' . substr(sha1(rand()), 0, 7);
- $this->click("title");
- $this->type("title", $customGroupTitle);
-
- //custom group extends
- $this->click("extends[0]");
- $this->select("extends[0]", "value=Contact");
- $this->click("//option[@value='Contact']");
- $this->click("_qf_Group_next-bottom");
- $this->waitForElementPresent("newCustomField");
-
- //Is custom group created?
- $this->waitForText('crm-notification-container', "Your custom field set '{$customGroupTitle}' has been added. You can add custom fields now.");
-
- $customGroupId = $this->urlArg('gid');
-
- // Add contact reference fields
- $contactRefFieldLabel1 = 'contact_ref_' . substr(sha1(rand()), 0, 4);
- $this->waitForElementPresent("label");
- $this->click("label");
- $this->waitForElementPresent("label");
- $this->type("label", $contactRefFieldLabel1);
- $this->waitForElementPresent("data_type[0]");
- $this->select("data_type[0]", "label=Contact Reference");
-
- $this->waitForElementPresent("group_id");
- $this->select("group_id", $groupName);
-
- //clicking save
- $this->click("xpath=//div[@class='ui-dialog-buttonset']/button[2]/span[2]/");
-
- //Is custom field created?
- $this->waitForText('crm-notification-container', "Custom field '$contactRefFieldLabel1' has been saved.");
- $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']/button[3]/span[2]/");
- //add custom field - alphanumeric checkbox
- $contactRefFieldLabel2 = 'contact_ref_' . substr(sha1(rand()), 0, 4);
-
- $this->click("label");
- $this->waitForElementPresent("label");
- $this->type("label", $contactRefFieldLabel2);
- $this->waitForElementPresent("data_type[0]");
- $this->select("data_type[0]", "label=Contact Reference");
-
- $this->waitForElementPresent("group_id");
- $this->click("xpath=//form[@id='Field']//a[text()='Advanced Filter']");
- $this->waitForElementPresent("filter");
-
- $this->type("filter", "action=get&contact_type=Organization");
-
- //clicking save
- $this->click("xpath=//div[@class='ui-dialog-buttonset']/button[1]/span[2]/");
-
- //Is custom field created?
- $this->waitForText('crm-notification-container', "Custom field '$contactRefFieldLabel2' has been saved.");
-
- $this->openCiviPage('admin/custom/group/field', "reset=1&action=browse&gid={$customGroupId}");
-
- $fieldid1 = explode("&id=", $this->getAttribute("xpath=//div[@id='field_page']//table/tbody/tr[1]/td[8]/span[1]/a[text()='Edit Field']@href"));
- $fieldid1 = $fieldid1[1];
-
- $contactRefFieldID1 = $fieldid1;
-
- $this->openCiviPage('admin/custom/group/field', "reset=1&action=browse&gid={$customGroupId}");
-
- $fieldid2 = explode("&id=", $this->getAttribute("xpath=//div[@id='field_page']//table/tbody/tr[2]/td[8]/span[1]/a[text()='Edit Field']@href"));
- $fieldid2 = $fieldid2[1];
-
- $contactRefFieldID2 = $fieldid2;
-
- // Visit custom group preview page
- $this->openCiviPage('admin/custom/group', "action=preview&reset=1&id={$customGroupId}");
-
- $this->clickAt("//*[@id='custom_{$contactRefFieldID1}_-1']/../div/a");
- $this->keyDown("//*[@id='select2-drop']/div/input", " ");
- $this->type("//*[@id='select2-drop']/div/input", "Anderson");
- $this->typeKeys("//*[@id='select2-drop']/div/input", "Anderson");
- $this->waitForElementPresent("css=div.select2-result-label span");
- $this->assertElementContainsText("css=div.select2-result-label", "{$contact1}@example.com");
- $this->assertElementNotContainsText("css=div.select2-result-label", "{$contact2}@example.com");
-
- $this->openCiviPage('admin/custom/group', "action=preview&reset=1&id={$customGroupId}");
-
- $this->clickAt("//*[@id='custom_{$contactRefFieldID2}_-1']/../div/a");
- $this->keyDown("//*[@id='select2-drop']/div/input", " ");
- $this->type("//*[@id='select2-drop']/div/input", $org1);
- $this->typeKeys("//*[@id='select2-drop']/div/input", $org1);
- $this->waitForElementPresent("css=div.select2-result-label");
- $this->assertElementContainsText("css=div.select2-result-label", "{$org1}@example.com");
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Contact_ContactTagTest
- */
-class WebTest_Contact_ContactTagTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testTagAContact() {
- $this->webtestLogin();
-
- $this->openCiviPage("admin/tag", "action=add&reset=1", "_qf_Tag_next");
-
- // take a tag name
- $tagName = 'tag_' . substr(sha1(rand()), 0, 7);
-
- // fill tag name
- $this->type("name", $tagName);
-
- // fill description
- $this->type("description", "Adding new tag.");
-
- // select used for contact
- $this->select("used_for", "value=civicrm_contact");
-
- // check reserved
- $this->click("is_reserved");
-
- // Clicking save.
- $this->click("_qf_Tag_next");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Is status message correct?
- $this->waitForText('crm-notification-container', "The tag '$tagName' has been saved.");
-
- // Adding contact
- // We're using Quick Add block on the main page for this.
- $firstName = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName, "Anderson", "$firstName@anderson.name");
-
- // visit tag tab
- $this->click("css=li#tab_tag a");
- $this->waitForElementPresent("css=div#tagtree");
-
- // check tag we have created
- $this->click("xpath=//ul/li/span/label[text()=\"$tagName\"]");
- $this->checkCRMStatus();
- }
-
- public function testTagSetContact() {
- $this->webtestLogin();
-
- $this->openCiviPage("admin/tag", "action=add&reset=1&tagset=1");
-
- // take a tagset name
- $tagSetName = 'tagset_' . substr(sha1(rand()), 0, 7);
-
- // fill tagset name
- $this->type("name", $tagSetName);
-
- // fill description
- $this->type("description", "Adding new tag set.");
-
- // select used for contact
- $this->select("used_for", "value=civicrm_contact");
-
- // check reserved
- $this->click("is_reserved");
-
- // Clicking save.
- $this->click("_qf_Tag_next");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Is status message correct?
- $this->waitForText('crm-notification-container', "The tag '$tagSetName' has been saved.");
-
- // Adding contact
- // We're using Quick Add block on the main page for this.
- $firstName = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName, "Anderson", "$firstName@anderson.name");
-
- // visit tag tab
- $this->click("css=li#tab_tag a");
- $this->waitForElementPresent("css=div#tagtree");
-
- //add Tagset to contact
- $this->click("xpath=//div[@id='Tag']/div[2]/div/div/ul/li/input");
- $this->keyDown("xpath=//div[@id='Tag']/div[2]/div/div/ul/li/input", " ");
- $this->type("xpath=//div[@id='Tag']/div[2]/div/div/ul/li/input", 'tagset1');
- $this->typeKeys("xpath=//div[@id='Tag']/div[2]/div/div/ul/li/input", 'tagset1');
-
- // ...waiting for drop down with results to show up...
- $this->waitForElementPresent("xpath=//div[@class='select2-result-label']");
-
- // ...need to use mouseDownAt on first result (which is a li element), click does not work
- $this->clickAt("xpath=//div[@class='select2-result-label']");
- $this->waitForElementPresent("//div[@id='Tag']/div[2]/div/div/ul/li[1]/div[text()='tagset1']");
- $this->click("xpath=//div[@id='Tag']/div[2]/div/div/ul/li[2]/input");
- $this->keyDown("xpath=//div[@id='Tag']/div[2]/div/div/ul/li[2]/input", " ");
- $this->type("xpath=//div[@id='Tag']/div[2]/div/div/ul/li[2]/input", 'tagset2');
- $this->typeKeys("xpath=//div[@id='Tag']/div[2]/div/div/ul/li[2]/input", 'tagset2');
-
- // ...waiting for drop down with results to show up...
- $this->waitForElementPresent("xpath=//div[@class='select2-result-label']");
-
- // ...need to use mouseDownAt on first result (which is a li element), click does not work
- $this->clickAt("xpath=//div[@class='select2-result-label']");
-
- // Type search name in autocomplete.
- $this->click("css=input#sort_name_navigation");
- $this->type("css=input#sort_name_navigation", $firstName);
- $this->typeKeys("css=input#sort_name_navigation", $firstName);
-
- // Wait for result list.
- $this->waitForElementPresent("css=ul.ui-autocomplete li");
-
- // Visit contact summary page.
- $this->click("css=ul.ui-autocomplete li");
- $this->waitForAjaxContent();
- $this->waitForText('tags', "tagset1, tagset2");
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Tests for the ability to add a CMS user from a contact's record
- * See http://issues.civicrm.org/jira/browse/CRM-8723
- * Class WebTest_Contact_CreateCmsUserFromContactTest
- */
-class WebTest_Contact_CreateCmsUserFromContactTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- /**
- * Test that option to create a cms user is present on a contact who.
- * does not have a cms account already (in this case, a new
- * contact).
- */
- public function testCreateContactLinkPresent() {
-
- //login
- $this->webtestLogin('admin');
-
- //create a New Contact
- $firstName = substr(sha1(rand()), 0, 7) . "John";
- $lastName = substr(sha1(rand()), 0, 7) . "Smith";
- $email = $this->webtestAddContact($firstName, $lastName, TRUE);
-
- //Assert that the user actually does have a CMS Id displayed
- $this->assertTrue(!$this->isTextPresent("User ID"));
-
- //Assert that the contact user record link says create user record
- $this->assertElementContainsText("css=#actions li.crm-contact-user-record", "Create User Record", "Create User Record link not in action menu of new contact");
- }
-
- /**
- * Test that the action link is missing for users who already have a
- * contact record. The contact record for drupal user 1 is used.
- */
- public function testCreateContactLinkMissing() {
-
- //login
- $this->webtestLogin('admin');
-
- // go to My Account page
- $this->open($this->sboxPath . "user");
-
- // click "View contact record" link
- $this->waitForElementPresent("xpath=//div[@class='profile']/span/a[text()='View contact record']");
- $this->click("xpath=//div[@class='profile']/span/a[text()='View contact record']");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- //Assert that the user actually does have a CMS Id displayed
- $this->assertTrue($this->isTextPresent("User ID"));
-
- //Assert that the text of the user record link does not say Create User Record
- $this->assertElementNotContainsText("css=#actions li.crm-contact-user-record", "Create User Record", "Create User Record link not in action menu of new contact");
- }
-
- /**
- * Test the ajax "check username availibity" link when adding cms user.
- */
- public function testCheckUsernameAvailability() {
- $this->webtestLogin('admin');
-
- $email = $this->_createUserAndGotoForm();
- $password = "abc123";
-
- //use the username of the admin user to test if the username is taken
- $username = $this->settings->adminUsername;
-
- $this->_fillCMSUserForm($username, $password, $password);
- $this->click("checkavailability");
- $this->waitForCondition("selenium.browserbot.getCurrentWindow().jQuery('#msgbox').text() != 'Checking...'");
- $this->assertElementContainsText("msgbox", "This username is taken", "Taken username is indicated as being available");
-
- //fill the form with a good username
- $username = sha1(rand());
- $this->_fillCMSUserForm($username, $password, $password);
- $this->click("checkavailability");
- $this->waitForCondition("selenium.browserbot.getCurrentWindow().jQuery('#msgbox').text() != 'Checking...'");
- $this->assertElementContainsText("msgbox", "This username is currently available", "Available username is indicated as being taken");
- }
-
- /**
- * Test form submission when the username is taken.
- */
- public function testTakenUsernameSubmission() {
-
- //login
- $this->webtestLogin('admin');
-
- //create a New Contact
- list($cid, $firstName, $lastName, $email) = $this->_createUserAndGotoForm();
- $password = 'abc123';
-
- //submit the form with the bad username
- $username = $this->settings->adminUsername;
- $this->_fillCMSUserForm($username, $password, $password);
- $this->click("_qf_Useradd_next-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- //the civicrm messages should indicate the username is taken
-
- $this->assertElementContainsText("xpath=//span[@class = 'crm-error']", "already taken", "CiviCRM Message does not indicate the username is in user");
- //check the uf match table that no contact has been created
- $results = $this->webtest_civicrm_api("UFMatch", "get", array('contact_id' => $cid));
- $this->assertTrue($results['count'] == 0);
- }
-
- /**
- * Test form sumbission when user passwords dont match.
- */
- public function testMismatchPasswordSubmission() {
-
- //login
- $this->webtestLogin('admin');
-
- //create a New Contact
- list($cid, $firstName, $lastName, $email) = $this->_createUserAndGotoForm();
- $password = 'abc123';
-
- //submit with mismatch passwords
- $username = $this->settings->adminUsername;
- $this->_fillCMSUserForm($username, $password, $password . "mismatch");
- $this->click("_qf_Useradd_next-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- //check that that there is a password mismatch text
- $this->assertElementContainsText("xpath=//table[@class='form-layout-compressed']/tbody/tr[3]/td/span[@class='crm-error']", "Password mismatch", "No form error given on password missmatch");
-
- //check that no user was created;
- $results = $this->webtest_civicrm_api("UFMatch", "get", array('contact_id' => $cid));
- $this->assertTrue($results['count'] == 0);
- }
-
- public function testMissingDataSubmission() {
-
- //login
- $this->webtestLogin('admin');
-
- //create a New Contact
- list($cid, $firstName, $lastName, $email) = $this->_createUserAndGotoForm();
- $password = 'abc123';
-
- //submit with mismatch passwords
- $username = $this->settings->adminUsername;
- $this->click("_qf_Useradd_next-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- //the civicrm messages section should not indicate that a user has been created
- $this->assertElementNotContainsText("xpath=//span[@class='crm-error']", "User has been added", "CiviCRM messages say that a user was created when username left blank");
-
- //the civicrm message should say username is required
- $this->assertElementContainsText("xpath=//span[@class='crm-error']", "Username is required", "The CiviCRM messae does not indicate that the username is required");
-
- //the civicrm message should say password is required
- $this->assertElementContainsText("xpath=//table[@class='form-layout-compressed']/tbody/tr[3]/td/span[@class='crm-error']", "Password is required", "The CiviCRM messae does not indicate that the password is required");
-
- //check that no user was created;
- $results = $this->webtest_civicrm_api("UFMatch", "get", array('contact_id' => $cid));
- $this->assertTrue($results['count'] == 0);
- }
-
- /**
- * Test a valid (username unique and passwords match) submission.
- */
- public function testValidSubmission() {
-
- //login
- $this->webtestLogin('admin');
-
- //create a New Contact
- list($cid, $firstName, $lastName, $email) = $this->_createUserAndGotoForm();
- $password = 'abc123';
-
- //submit with matching passwords
- $this->_fillCMSUserForm($firstName, $password, $password);
- $this->waitForAjaxContent();
- $this->click("_qf_Useradd_next-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- //drupal messages should say user created
- $this->assertTrue($this->isTextPresent("Created a new user account"), "Drupal does not report success creating user in the message");
-
- //The new user id should be on the page
- $this->assertTrue($this->isTextPresent("User ID"));
-
- //Assert that a user was actually created AND that they are tied to the record
- $results = $this->webtest_civicrm_api("UFMatch", "get", array('contact_id' => $cid));
- $this->assertTrue($results['count'] == 1);
- }
-
- /**
- * @param string $username
- * @param $password
- * @param $confirm_password
- */
- public function _fillCMSUserForm($username, $password, $confirm_password) {
- $this->type("cms_name", $username);
- $this->type("cms_pass", $password);
- $this->type("cms_confirm_pass", $confirm_password);
- }
-
- /**
- * @return array
- */
- public function _createUserAndGoToForm() {
- $firstName = substr(sha1(rand()), 0, 7) . "John";
- $lastName = substr(sha1(rand()), 0, 7) . "Smith";
- $email = $this->webtestAddContact($firstName, $lastName, TRUE);
-
- // Get the contact id of the new contact
- $cid = $this->urlArg('cid');
-
- //got to the new cms user form
- $this->openCiviPage('contact/view/useradd', "reset=1&action=add&cid={$cid}");
-
- return array($cid, $firstName, $lastName, $email);
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Contact_CustomDataAddTest
- */
-class WebTest_Contact_CustomDataAddTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testCustomDataAdd() {
- $this->webtestLogin();
-
- $this->openCiviPage('admin/custom/group', 'action=add&reset=1');
-
- //fill custom group title
- $customGroupTitle = 'custom_' . substr(sha1(rand()), 0, 7);
- $this->click("title");
- $this->type("title", $customGroupTitle);
-
- //custom group extends
- $this->click("extends[0]");
- $this->select("extends[0]", "value=Contact");
- $this->click("//option[@value='Contact']");
- $this->clickLink("_qf_Group_next-bottom");
-
- //Is custom group created?
- $this->waitForText('crm-notification-container', "Your custom field set '{$customGroupTitle}' has been added. You can add custom fields now.");
- $this->waitForElementPresent("_qf_Field_cancel-bottom");
-
- //add custom field - alphanumeric checkbox
- $checkboxFieldLabel = 'custom_field' . substr(sha1(rand()), 0, 4);
- $this->click("label");
- $this->type("label", $checkboxFieldLabel);
- $this->click("data_type[1]");
- $this->select("data_type[1]", "value=CheckBox");
- $this->click("//option[@value='CheckBox']");
- $checkboxOptionLabel1 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
- $this->type("option_label_1", $checkboxOptionLabel1);
- $this->type("option_value_1", "1");
- $checkboxOptionLabel2 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
- $this->type("option_label_2", $checkboxOptionLabel2);
- $this->type("option_value_2", "2");
- $this->click("link=add another choice");
- $checkboxOptionLabel3 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
- $this->type("option_label_3", $checkboxOptionLabel3);
- $this->type("option_value_3", "3");
-
- //enter options per line
- $this->type("options_per_line", "2");
-
- //enter pre help message
- $this->type("help_pre", "this is field pre help");
-
- //enter post help message
- $this->type("help_post", "this field post help");
-
- //Is searchable?
- $this->click("is_searchable");
-
- //clicking save
- $this->click("_qf_Field_done");
-
- //Is custom field created?
- $this->waitForText('crm-notification-container', "Custom field '$checkboxFieldLabel' has been saved.");
- $this->waitForElementPresent('newCustomField');
-
- //create another custom field - Integer Radio
- $this->clickLink("newCustomField", '_qf_Field_cancel', FALSE);
- $this->click("data_type[0]");
- $this->select("data_type[0]", "value=1");
- $this->click("//option[@value='1']");
- $this->click("data_type[1]");
- $this->select("data_type[1]", "value=Radio");
- $this->click("//option[@value='Radio']");
-
- $radioFieldLabel = 'custom_field' . substr(sha1(rand()), 0, 4);
- $this->type("label", $radioFieldLabel);
- $radioOptionLabel1 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
- $this->type("option_label_1", $radioOptionLabel1);
- $this->type("option_value_1", "1");
- $radioOptionLabel2 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
- $this->type("option_label_2", $radioOptionLabel2);
- $this->type("option_value_2", "2");
- $this->click("link=add another choice");
- $radioOptionLabel3 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
- $this->type("option_label_3", $radioOptionLabel3);
- $this->type("option_value_3", "3");
-
- //select options per line
- $this->type("options_per_line", "3");
-
- //enter pre help msg
- $this->type("help_pre", "this is field pre help");
-
- //enter post help msg
- $this->type("help_post", "this is field post help");
-
- //Is searchable?
- $this->click("is_searchable");
-
- //clicking save
- $this->click("_qf_Field_done");
-
- //Is custom field created
- $this->waitForText('crm-notification-container', "Custom field '$radioFieldLabel' has been saved.");
-
- // Go to the URL to create an Individual contact.
- $this->openCiviPage("contact/add", "reset=1&ct=Individual");
-
- //expand all tabs
- $this->click("expand");
- $this->waitForElementPresent("address_1_street_address");
-
- //fill first name, last name, email id
- $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
- $lastName = 'An' . substr(sha1(rand()), 0, 7);
- $emailId = substr(sha1(rand()), 0, 7) . '@web.com';
- $this->click("first_name");
- $this->type("first_name", $firstName);
- $this->type("last_name", $lastName);
- $this->type("email_1_email", $emailId);
-
- //fill custom values for the contact
- $this->click("xpath=//table//tr/td/label[text()=\"$checkboxOptionLabel2\"]");
- $this->click("xpath=//table//tr/td/label[text()=\"$radioOptionLabel3\"]");
- $this->click("_qf_Contact_upload_view");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- }
-
- public function testCustomDataMoneyAdd() {
- $this->webtestLogin();
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->openCiviPage('admin/custom/group', 'action=add&reset=1');
-
- //fill custom group title
- $customGroupTitle = 'custom_' . substr(sha1(rand()), 0, 7);
- $this->waitForElementPresent("title");
- $this->click("title");
- $this->type("title", $customGroupTitle);
-
- //custom group extends
- $this->click("extends[0]");
- $this->select("extends[0]", "value=Contact");
- $this->click("//option[@value='Contact']");
- $this->clickLink("_qf_Group_next-bottom");
-
- //Is custom group created?
- $this->waitForText('crm-notification-container', "Your custom field set '{$customGroupTitle}' has been added. You can add custom fields now.");
- $this->waitForElementPresent("_qf_Field_cancel-bottom");
-
- //add custom field - money text
- $moneyTextFieldLabel = 'money' . substr(sha1(rand()), 0, 4);
- $this->click("label");
- $this->type("label", $moneyTextFieldLabel);
- $this->waitForElementPresent("data_type[0]");
- $this->click("data_type[0]");
- $this->select("data_type[0]", "label=Money");
-
- $this->click("data_type[1]");
- $this->select("data_type[1]", "value=Text");
-
- //enter pre help message
- $this->type("help_pre", "this is field pre help");
-
- //enter post help message
- $this->type("help_post", "this field post help");
-
- //Is searchable?
- $this->click("is_searchable");
-
- //clicking save
- $this->click("_qf_Field_done");
-
- //Is custom field created?
- $this->waitForText('crm-notification-container', "Custom field '$moneyTextFieldLabel' has been saved.");
-
- //Get the customFieldsetID
- $this->openCiviPage('admin/custom/group', 'reset=1');
- $customFieldsetId = explode('&gid=', $this->getAttribute("xpath=//div[@id='custom_group']/table/tbody//tr/td/div[text()='$customGroupTitle']/../../td[7]/span/a@href"));
- $customFieldsetId = $customFieldsetId[1];
-
- //create Individual contact
- $this->openCiviPage("contact/add", "reset=1&ct=Individual");
-
- //expand all tabs
- $this->click("expand");
- $this->waitForElementPresent("address_1_street_address");
-
- //fill first name, last name, email id
- $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
- $lastName = 'An' . substr(sha1(rand()), 0, 7);
- $emailId = substr(sha1(rand()), 0, 7) . '@web.com';
- $this->click("first_name");
- $this->type("first_name", $firstName);
- $this->type("last_name", $lastName);
- $this->type("email_1_email", $emailId);
-
- //fill custom values for the contact
- $this->click("xpath=//table//tr/td/label[text()=\"$moneyTextFieldLabel\"]");
- $this->type("xpath=//table//tr/td/label[text()=\"$moneyTextFieldLabel\"]/../following-sibling::td/input", "12345678.98");
- $this->click("_qf_Contact_upload_view");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- //verify the money custom field value in the proper format
- $this->assertTrue($this->isElementPresent("xpath=//div[@id='custom-set-content-{$customFieldsetId}']/div/div[2]/div[2]"));
- $this->assertElementContainsText("xpath=//div[@id='custom-set-content-{$customFieldsetId}']/div/div[2]/div[2]", '12,345,678.98');
- }
-
- public function testCustomDataChangeLog() {
- $this->webtestLogin();
-
- //enable logging
- $this->openCiviPage('admin/setting/misc', 'reset=1');
- $this->click("CIVICRM_QFID_1_logging");
- $this->click("_qf_Miscellaneous_next-top");
-
- // Increase timeout by quadruple since enabling logging takes a long time
- $this->waitForPageToLoad($this->getTimeoutMsec() * 4);
- $this->waitForTextPresent("Changes Saved");
-
- // Create new Custom Field Set
- $this->openCiviPage('admin/custom/group', 'reset=1');
- $this->click("css=#newCustomDataGroup > span");
- $this->waitForElementPresent('_qf_Group_next-bottom');
- $customFieldSet = 'Fieldset' . rand();
- $this->type("id=title", $customFieldSet);
- $this->select("id=extends_0", "label=Individual");
- $this->click("id=collapse_display");
- $this->clickLink("id=_qf_Group_next-bottom");
- $this->waitForText('crm-notification-container', "Your custom field set '$customFieldSet' has been added.");
- $this->waitForElementPresent('_qf_Field_done-bottom');
-
- // Add field to fieldset
- $customField = 'CustomField' . rand();
- $this->type("id=label", $customField);
- $this->select("id=data_type_0", "value=0");
- $this->click("id=_qf_Field_done-bottom");
- $this->waitForText('crm-notification-container', "Custom field '$customField' has been saved.");
-
- $this->openCiviPage('contact/add', 'reset=1&ct=Individual');
-
- //contact details section
- //fill in first name
- $firstName = 'Jimmy' . substr(sha1(rand()), 0, 7);
- $this->type('first_name', $firstName);
-
- //fill in last name
- $lastName = 'Page' . substr(sha1(rand()), 0, 7);
- $this->type('last_name', $lastName);
-
- //fill in email id
- $this->type('email_1_email', "{$firstName}.{$lastName}@example.com");
-
- //fill in phone
- $this->type("phone_1_phone", "2222-4444");
-
- $this->click("xpath=//table//tr/td/label[text()=\"$customField\"]");
- $value = "custom" . rand();
- $this->type("xpath=//table//tr/td/label[text()=\"$customField\"]/../following-sibling::td/input", $value);
-
- //check for matching contact
- $this->click("_qf_Contact_refresh_dedupe");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- //address section
- $this->click("addressBlock");
- $this->waitForElementPresent("address_1_street_address");
- //fill in address 1
- $this->type("address_1_street_address", "902C El Camino Way SW");
- $this->type("address_1_city", "Dumfries");
- $this->type("address_1_postal_code", "1234");
-
- $this->click("address_1_country_id");
- $this->select("address_1_country_id", "value=1228");
-
- if ($this->assertElementContainsText("address_table_1", "Latitude")) {
- $this->type("address_1_geo_code_1", "1234");
- $this->type("address_1_geo_code_2", "5678");
- }
-
- // Clicking save.
- $this->click("_qf_Contact_upload_view");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->waitForText('crm-notification-container', "{$firstName} {$lastName} has been created.");
-
- //Update the custom field
- $this->waitForElementPresent("xpath=//ul[@id='actions']/li[2]/a/span");
- $this->clickLink("xpath=//ul[@id='actions']/li[2]/a/span");
- $this->click("xpath=//table//tr/td/label[text()=\"$customField\"]");
- $value1 = "custom_1" . rand();
- $this->type("xpath=//table//tr/td/label[text()=\"$customField\"]/../following-sibling::td/input", $value1);
- $this->click("_qf_Contact_upload_view-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->click("css=#tab_log a");
-
- //check the changed log
- $this->waitForElementPresent("xpath=//div[@id='changeLog']/div[2]/form/div[2]/table/tbody/tr[1]/td[4]/a[contains(text(), '$firstName $lastName')]");
- $this->waitForElementPresent("xpath=//div[@id='changeLog']/div[2]/form/div[2]/table/tbody/tr[1]/td/a[2]");
- $this->click("xpath=//div[@id='changeLog']/div[2]/form/div[2]/table/tbody/tr[1]/td/a[2]");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->assertTrue($this->isElementPresent("xpath=//form[@id='LoggingDetail']/div[2]/table/tbody/tr/td[2][contains(text(), '$value')]"));
- $this->assertTrue($this->isElementPresent("xpath=//form[@id='LoggingDetail']/div[2]/table/tbody/tr/td[3][contains(text(), '$value1')]"));
-
- //disable logging
- $this->openCiviPage('admin/setting/misc', 'reset=1');
- $this->click("CIVICRM_QFID_0_logging");
- $this->click("_qf_Miscellaneous_next-top");
-
- // Increase timeout by triple since disabling logging takes a long time
- $this->waitForPageToLoad($this->getTimeoutMsec() * 3);
- $this->waitForTextPresent("Changes Saved");
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Contact_DeceasedContactsAdvancedSearchTest
- */
-class WebTest_Contact_DeceasedContactsAdvancedSearchTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testDeceasedContactsAdvanceSearch() {
- $this->webtestLogin();
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Create a group
- $groupName = $this->WebtestAddGroup();
-
- // Add contacts from the quick add block
- $lastName = substr(sha1(rand()), 0, 7);
- $names = array(
- 'firstName1' => FALSE,
- 'firstName2' => FALSE,
- 'firstName3' => FALSE,
- 'firstName4' => TRUE,
- 'firstName5' => TRUE,
- );
-
- foreach ($names as $key => $value) {
- $$key = substr(sha1(rand()), 0, 7);
- $this->_testAddContact($$key, $lastName, "{$$key}.{$lastName}@example.com", $groupName, $value);
- }
-
- // Advanced Search
- $this->openCiviPage('contact/search/advanced', 'reset=1', '_qf_Advanced_refresh');
-
- // Select the group and check deceased contacts
- $this->select('group', "label={$groupName}");
- $this->click('demographics');
- $this->waitForElementPresent('CIVICRM_QFID_1_is_deceased');
- $this->click('CIVICRM_QFID_1_is_deceased');
- $this->clickLink('_qf_Advanced_refresh');
- $this->assertElementContainsText('search-status', '2 Contacts');
- $this->click("toggleSelect");
- $this->waitForTextPresent('2 Selected records only');
-
- $this->select('task', 'label=Group - remove contacts');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForElementPresent('_qf_RemoveFromGroup_back-bottom');
- $this->assertElementContainsText('crm-container', 'Number of selected contacts: 2');
- $this->select('group_id', "label={$groupName}");
- $this->click('_qf_RemoveFromGroup_next-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForText('crm-notification-container', "2 contacts removed from '{$groupName}'");
-
- // Search for the contacts who are not deceased
- $this->openCiviPage('contact/search/advanced', 'reset=1', '_qf_Advanced_refresh');
- $this->select('group', "label={$groupName}");
- $this->click('_qf_Advanced_refresh');
-
- // Check if non-deceased contacts are still present
- $this->waitForElementPresent('search-status');
- $this->assertElementContainsText('search-status', '3 Contacts');
- }
-
- /**
- * @param string $firstName
- * @param string $lastName
- * @param $email
- * @param string $groupName
- * @param bool $deceased
- */
- public function _testAddContact($firstName, $lastName, $email, $groupName, $deceased = FALSE) {
- $this->webtestAddContact($firstName, $lastName, $email);
- if ($deceased) {
- $this->click('link=Edit');
- $this->waitForElementPresent('_qf_Contact_cancel-bottom');
-
- // Click on the Demographics tab
- $this->click('demographics');
- $this->waitForElementPresent('is_deceased');
- $this->click('is_deceased');
-
- // Click on Save
- $this->click('_qf_Contact_upload_view-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- }
-
- // Add contact to group
- $this->click('css=#tab_group a');
- $this->waitForElementPresent('_qf_GroupContact_next');
- $this->select('group_id', "{$groupName}");
- $this->click('_qf_GroupContact_next');
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Contact_DupeContactTest
- */
-class WebTest_Contact_DupeContactTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testDuplicateContactAdd() {
- $this->webtestLogin();
-
- $this->openCiviPage('contact/add', 'reset=1&ct=Individual');
-
- $firstName = substr(sha1(rand()), 0, 7);
- $lastName1 = substr(sha1(rand()), 0, 7);
- $email = "{$firstName}@example.com";
- $lastName2 = substr(sha1(rand()), 0, 7);
-
- //contact details section
- //select prefix
- $this->click("prefix_id");
- $this->select("prefix_id", "value=3");
-
- //fill in first name
- $this->type("first_name", "$firstName");
-
- //fill in last name
- $this->type("last_name", "$lastName1");
-
- //fill in email
- $this->type("email_1_email", "$email");
-
- //check for matching contact
- //$this->click("_qf_Contact_refresh_dedupe");
- //$this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Clicking save.
- $this->click("_qf_Contact_upload_view");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForText('crm-notification-container', "Contact Saved");
-
- $this->openCiviPage('contact/add', 'reset=1&ct=Individual');
-
- //contact details section
-
- //fill in first name
- $this->type("first_name", "$firstName");
-
- //fill in last name
- $this->type("last_name", "$lastName1");
-
- //fill in email
- $this->type("email_1_email", "$email");
-
- // Clicking save.
- $this->click("_qf_Contact_upload_view");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->assertElementContainsText("css=.notify-content", "Please correct the following errors in the form fields below: One matching contact was found. You can View or Edit the existing contact.");
- }
-
- /**
- * Edit Dedupe rule for individual
- */
- public function testEditRule() {
- $this->webtestLogin();
- $this->openCiviPage('contact/deduperules', 'action=add&contact_type=Individual&reset=1');
- $ruleName = 'Rule_' . substr(sha1(rand()), 0, 7);
-
- //Add Rule for individual
- $this->type("title", "$ruleName");
- $this->click("xpath=//table[@class='form-layout']/tbody/tr[@class='crm-dedupe-rules-form-block-used']/td[2]/label[text()='General']");
- $lengthValueFname = $lengthValueLname = 7;
- $weighthValueFname = 5;
- $weightValueLname = 8;
- $lengthValueEmail = 20;
- $weightValueEmail = 15;
-
- // Add first name
- $this->select("xpath=//table[@class='form-layout-compressed']/tbody/tr[2]/td[1]/select", 'label=First Name');
- $this->type("xpath=//table[@class='form-layout-compressed']/tbody/tr[2]/td[2]/input", 10);
- $this->type("xpath=//table[@class='form-layout-compressed']/tbody/tr[2]/td[3]/input", 10);
- // Add last name
- $this->select("xpath=//table[@class='form-layout-compressed']/tbody/tr[3]/td[1]/select", 'label=Last Name');
- $this->type("xpath=//table[@class='form-layout-compressed']/tbody/tr[3]/td[2]/input", 10);
- $this->type("xpath=//table[@class='form-layout-compressed']/tbody/tr[3]/td[3]/input", 10);
- // Add email
- $this->select("xpath=//table[@class='form-layout-compressed']/tbody/tr[4]/td[1]/select", 'label=Email');
- $this->type("xpath=//table[@class='form-layout-compressed']/tbody/tr[4]/td[2]/input", 10);
- $this->type("xpath=//table[@class='form-layout-compressed']/tbody/tr[4]/td[3]/input", 10);
- $this->click("_qf_DedupeRules_next-bottom");
- $this->waitForText("crm-notification-container", "The rule '$ruleName' has been saved.");
-
- // Edit the rule for individual.
- $this->click("xpath=//div[@id='browseValues_Individual']/div[1]/div/table/tbody//tr/td[1][text()='$ruleName']/../td[3]/span//a[text()='Edit Rule']");
- $this->waitForElementPresent("_qf_DedupeRules_cancel-bottom");
-
- //edit length and weight for First Name
- $this->type("xpath=//table[@class='form-layout-compressed']/tbody/tr[2]/td[2]/input", $lengthValueFname);
- $this->type("xpath=//table[@class='form-layout-compressed']/tbody/tr[2]/td[3]/input", $weighthValueFname);
-
- //edit length and weight for Last Name
- $this->type("xpath=//table[@class='form-layout-compressed']/tbody/tr[3]/td[2]/input", $lengthValueLname);
- $this->type("xpath=//table[@class='form-layout-compressed']/tbody/tr[3]/td[3]/input", $weightValueLname);
-
- //edit length and weight for Email
- $this->type("xpath=//table[@class='form-layout-compressed']/tbody/tr[4]/td[2]/input", $lengthValueEmail);
- $this->type("xpath=//table[@class='form-layout-compressed']/tbody/tr[4]/td[3]/input", $weightValueEmail);
-
- $this->click("_qf_DedupeRules_next-bottom");
- $this->waitForAjaxContent();
- $this->click("xpath=//div[@id='browseValues_Individual']/div[1]/div/table/tbody//tr/td[1][text()='$ruleName']/../td[3]/span//a[text()='Edit Rule']");
- $this->waitForAjaxContent();
-
- $this->assertTrue($this->isElementPresent("xpath=//table[@class='form-layout-compressed']/tbody/tr[2]/td[2]/input[@value=$lengthValueFname]"));
- $this->assertTrue($this->isElementPresent("xpath=//table[@class='form-layout-compressed']/tbody/tr[2]/td[3]/input[@value=$weighthValueFname]"));
- $this->assertTrue($this->isElementPresent("xpath=//table[@class='form-layout-compressed']/tbody/tr[3]/td[2]/input[@value=$lengthValueLname]"));
- $this->assertTrue($this->isElementPresent("xpath=//table[@class='form-layout-compressed']/tbody/tr[3]/td[3]/input[@value=$weightValueLname]"));
- $this->assertTrue($this->isElementPresent("xpath=//table[@class='form-layout-compressed']/tbody/tr[4]/td[2]/input[@value=$lengthValueEmail]"));
- $this->assertTrue($this->isElementPresent("xpath=//table[@class='form-layout-compressed']/tbody/tr[4]/td[3]/input[@value=$weightValueEmail]"));
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Contact_EditContactTest
- */
-class WebTest_Contact_EditContactTest extends CiviSeleniumTestCase {
- protected function setUp() {
- parent::setUp();
- }
-
- public function testEditContact() {
- // Log in using webtestLogin() method
- $this->webtestLogin();
-
- // create contact
- $firstName = 'WebTest' . substr(sha1(rand()), 0, 7);
- $lastName = 'ContactEdit' . substr(sha1(rand()), 0, 7);
- $this->openCiviPage("contact/add", "reset=1&ct=Individual");
- $this->type("first_name", $firstName);
- $this->type("last_name", $lastName);
-
- //fill in phone 1
- $this->type("phone_1_phone", "111113333");
- $this->type("phone_1_phone_ext", "101");
-
- //fill in phone 2
-
- $this->click("//a[@id='addPhone']");
- $this->type("phone_2_phone", "23213333");
- $this->type("phone_2_phone_ext", "165");
- $this->select('phone_2_location_type_id', 'value=2');
-
- //fill in phone 3
- $this->click("//a[@id='addPhone']");
- $this->type("phone_3_phone", "2321877699");
- $this->type("phone_3_phone_ext", "195");
- $this->select('phone_3_location_type_id', 'value=2');
-
- //fill in phone 4
- $this->click("//a[@id='addPhone']");
- $this->type("phone_4_phone", "2321398766");
- $this->type("phone_4_phone_ext", "198");
- $this->select('phone_4_location_type_id', 'value=2');
-
- // Submit form
- $this->click("_qf_Contact_upload_view-bottom");
- $this->waitForElementPresent('css=.crm-inline-edit-container.crm-edit-ready');
-
- //assert
- $this->assertTextPresent("111113333 ext. 101");
- $this->assertTextPresent("23213333 ext. 165");
- $this->assertTextPresent("2321877699 ext. 195");
- $this->assertTextPresent("2321398766 ext. 198");
-
- //Edit COntact
- $cid = $this->urlArg('cid');
- $this->openCiviPage("contact/add", "reset=1&action=update&cid={$cid}");
-
- //Edit in phone 1
- $this->type("phone_1_phone", "12223333");
- $this->type("phone_1_phone_ext", "100");
-
- //Edit in phone 2
- $this->type("phone_2_phone", "2321800000");
- $this->type("phone_2_phone_ext", "111");
- $this->select('phone_2_location_type_id', 'value=3');
-
- //Edit in phone 3
- $this->type("phone_3_phone", "777777699");
- $this->type("phone_3_phone_ext", "197");
- $this->select('phone_3_location_type_id', 'value=1');
-
- //Edit in phone 4
- $this->type("phone_4_phone", "2342322222");
- $this->type("phone_4_phone_ext", "198");
- $this->select('phone_4_location_type_id', 'value=3');
-
- // Submit form
- $this->click("_qf_Contact_upload_view-bottom");
- $this->waitForElementPresent('css=.crm-inline-edit-container.crm-edit-ready');
-
- //assert
- $this->assertTextPresent("12223333 ext. 100");
- $this->assertTextPresent("2321800000 ext. 111");
- $this->assertTextPresent("777777699 ext. 197");
- $this->assertTextPresent("2342322222 ext. 198");
-
- }
-
- /**
- * CRM-17273
- */
- public function testdisallowEditLocationType() {
- $this->webtestLogin();
-
- // create contact
- $firstName = 'WebTest' . substr(sha1(rand()), 0, 7);
- $lastName = 'ContactEdit' . substr(sha1(rand()), 0, 7);
- $this->openCiviPage("contact/add", "reset=1&ct=Individual");
- $this->waitForElementPresent('_qf_Contact_cancel-bottom');
-
- $this->type("first_name", $firstName);
- $this->type("last_name", $lastName);
-
- //fill email
- $this->type("email_1_email", substr(sha1(rand()), 0, 7) . "email1@gmail.com");
- $this->click("xpath=//div[@id='contactDetails']/table[1]/tbody/tr[1]/td[1]/a[text()='add']");
- $this->waitForElementPresent('email_2_email');
- $this->type("email_2_email", substr(sha1(rand()), 0, 7) . "email2@gmail.com");
-
- //fill in phone 1
- $this->type("phone_1_phone", "111113333");
- $this->type("phone_1_phone_ext", "101");
-
- //fill in IM
- $this->type("im_1_name", "testYahoo");
-
- //address section
- $this->click("addressBlock");
- $this->waitForElementPresent("address_1_street_address");
- //fill in address 1
- $this->type("address_1_street_address", "902C El Camino Way SW");
- $this->type("address_1_city", "Dumfries");
- $this->type("address_1_postal_code", "1234");
-
- // Submit form
- $this->click("_qf_Contact_upload_view-top");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Get Contact id
- $cid = $this->urlArg('cid');
- $this->openCiviPage("contact/add", "reset=1&action=update&cid=$cid");
-
- $this->waitForElementPresent('_qf_Contact_cancel-bottom');
- $this->waitForElementNotPresent("xpath=//div[@id='contactDetails']/table[1]/tbody/tr[@id='Email_Block_1']/td[1]/a/i");
- $this->waitForElementNotPresent("xpath=//div[@id='contactDetails']/table[1]/tbody/tr[@id='Email_Block_2']/td[1]/a/i");
- $this->waitForElementNotPresent("xpath=//div[@id='contactDetails']/table[1]/tbody/tr[@id='Phone_Block_1']/td[2]/a/i");
- $this->waitForElementNotPresent("xpath=//div[@id='contactDetails']/table[1]/tbody/tr[@id='IM_Block_1']/td[2]/a/i");
-
- $this->click("addressBlockId");
- $this->waitForElementNotPresent("xpath=//div[@id='addressBlock']/div/table/tbody/tr[1]/td[1]/span[1]/a/i");
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Contact_GroupAddTest
- */
-class WebTest_Contact_GroupAddTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testGroupAdd() {
- $this->webtestLogin();
-
- $this->openCiviPage('group/add', 'reset=1', '_qf_Edit_upload-bottom');
-
- // Group name
- $params = array('name' => 'group_' . substr(sha1(rand()), 0, 7));
-
- // fill group name
- $this->type("title", $params['name']);
-
- // fill description
- $this->type("description", "Adding new group.");
-
- // check Access Control
- if (isset($params['type1']) && $params['type1'] !== FALSE) {
- $this->click("group_type[1]");
- }
-
- // check Mailing List
- if (isset($params['type2']) && $params['type2'] !== FALSE) {
- $this->click("group_type[2]");
- }
-
- // select Visibility as Public Pages
- $params['visibility'] = 'Public Pages';
-
- $this->select("visibility", "value={$params['visibility']}");
-
- // Clicking save.
- $this->click("_qf_Edit_upload");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Is status message correct?
- $this->waitForText('crm-notification-container', "The Group '{$params['name']}' has been saved.");
-
- $this->openCiviPage('group', 'reset=1');
- $this->type('title', $params['name']);
- $this->click('title');
- $this->waitForAjaxContent();
- $this->waitForElementPresent("xpath=//table/tbody//tr/td/div[contains(text(), '{$params['name']}')]");
- $createdBy = $this->getText("xpath=//table/tbody//tr/td[3]/a");
- $this->click("xpath=//table/tbody//tr/td[7]//span/a[text()='Settings']");
- $this->waitForElementPresent("xpath=//form[@id='Edit']/div[2]/div/table[1]/tbody/tr[2]/td[contains(text(), '{$createdBy}')]");
- $this->openCiviPage('group', 'reset=1');
-
- //search groups using created by
- $this->type('created_by', $createdBy);
- $this->click('created_by');
-
- //show maximum no. of groups on first result set page
- //as many groups can be created by same creator
- //and checking is done on first result set page
- $this->waitForVisible("xpath=//table[@class='crm-group-selector crm-ajax-table dataTable no-footer']");
- $this->select("xpath=//div[@class='dataTables_length']/label/select", '100');
- $this->waitForVisible("xpath=//table[@class='crm-group-selector crm-ajax-table dataTable no-footer']");
-
- $this->waitForElementPresent("xpath=//table/tbody/tr/td/div[contains(text(), '{$params['name']}')]");
- $this->click("xpath=//table/tbody/tr/td/div[contains(text(), '{$params['name']}')]/../following-sibling::td[2]/a[text()='{$createdBy}']");
- $this->waitForElementPresent("xpath=//table/tbody/tr/td/div[contains(text(), '{$params['name']}')]/../following-sibling::td[2]/a[text()='{$createdBy}']");
-
- //check link of the contact who created the group
- $this->clickLink("xpath=//table/tbody//tr/td[1]/div[contains(text(),'{$params['name']}')]/../following-sibling::td[2]/a", "css=div.crm-summary-display_name", FALSE);
- $name = explode(',', $createdBy);
- $name1 = isset($name[1]) ? trim($name[1]) : NULL;
- $name0 = trim($name[0]);
- $displayName = isset($name1) ? "{$name1} {$name0}" : "{$name0}";
- $this->assertElementContainsText("css=div.crm-summary-display_name", $displayName);
- }
-
- public function testGroupReserved() {
- $this->webtestLogin('admin');
-
- $this->openCiviPage('group/add', 'reset=1', '_qf_Edit_upload-bottom');
-
- // take group name
- $params = array('name' => 'group_' . substr(sha1(rand()), 0, 7));
-
- // fill group name
- $this->type("title", $params['name']);
-
- // fill description
- $this->type("description", "Adding new reserved group.");
-
- // check Access Control
- if (isset($params['type1']) && $params['type1'] !== FALSE) {
- $this->click("group_type[1]");
- }
-
- // check Mailing List
- if (isset($params['type2']) && $params['type2'] !== FALSE) {
- $this->click("group_type[2]");
- }
-
- // select Visibility as Public Pages
- if (empty($params['visibility'])) {
- $params['visibility'] = 'Public Pages';
- }
-
- $this->select("visibility", "value={$params['visibility']}");
-
- // Check Reserved box
- $this->click("is_reserved");
-
- // Clicking save.
- $this->clickLink("_qf_Edit_upload");
-
- // Is status message correct?
- $this->waitForText('crm-notification-container', "The Group '{$params['name']}' has been saved.");
-
- // Create a new role w/o reserved group permissions
- $role = 'role' . substr(sha1(rand()), 0, 7);
- $this->open($this->sboxPath . "admin/people/permissions/roles");
-
- $this->waitForElementPresent("edit-add");
- $this->type("edit-name", $role);
- $this->clickLink("edit-add", NULL);
-
- $this->open($this->sboxPath . "admin/people/permissions/roles");
- $this->waitForElementPresent("xpath=//table[@id='user-roles']/tbody//tr/td[1][text()='{$role}']");
- $roleId = explode('/', $this->getAttribute("xpath=//table[@id='user-roles']/tbody//tr/td[1][text()='{$role}']/../td[4]/a[text()='edit permissions']/@href"));
- $roleId = end($roleId);
- $user = $this->_testCreateUser($roleId);
- $permissions = array(
- "edit-{$roleId}-view-all-contacts",
- "edit-{$roleId}-access-civicrm",
- );
- $this->changePermissions($permissions);
-
- // Now logout as admin, login as regular user and verify that Group settings,
- // delete and disable links are not available
- $this->webtestLogin($user, 'Test12345');
-
- $this->openCiviPage('group', 'reset=1');
- $this->type('title', $params['name']);
- $this->click('title');
- $this->waitForTextPresent("Adding new reserved group.");
- // Settings link should NOT be included in selector
- // after search returns with only the reserved group.
- $this->assertElementNotContainsText("css=td.crm-group-group_links", "Settings");
-
- //login as admin and delete the role
- $this->webtestLogin('admin');
- $this->open($this->sboxPath . "admin/people/permissions/roles");
- $this->_roleDelete($role);
- }
-
- /**
- * @param int $roleid
- *
- * @return string
- */
- public function _testCreateUser($roleid) {
- $this->open($this->sboxPath . "admin/people/create");
-
- $this->waitForElementPresent("edit-submit");
-
- $name = "TestUser" . substr(sha1(rand()), 0, 4);
- $this->type("edit-name", $name);
-
- $emailId = substr(sha1(rand()), 0, 7) . '@web.com';
- $this->type("edit-mail", $emailId);
- $this->type("edit-pass-pass1", "Test12345");
- $this->type("edit-pass-pass2", "Test12345");
- $role = "edit-roles-" . $roleid;
- $this->check("name=roles[$roleid] value={$roleid}");
-
- //Add profile Details
- $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
- $lastName = 'An' . substr(sha1(rand()), 0, 7);
-
- $this->type("first_name", $firstName);
- $this->type("last_name", $lastName);
-
- //Address Details
- $this->type("street_address-1", "902C El Camino Way SW");
- $this->type("city-1", "Dumfries");
- $this->type("postal_code-1", "1234");
- $this->select("state_province-1", "value=1019");
-
- $this->click("edit-submit");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- return $name;
- }
-
- /**
- * @param $role
- */
- public function _roleDelete($role) {
- $this->waitForElementPresent("xpath=//table[@id='user-roles']/tbody//tr/td[text()='{$role}']/..//td/a[text()='edit role']");
- $this->click("xpath=//table[@id='user-roles']/tbody//tr/td[text()='{$role}']/..//td/a[text()='edit role']");
- $this->waitForElementPresent('edit-delete');
- $this->click('edit-delete');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->click("edit-submit");
- $this->waitForTextPresent("The role has been deleted.");
- }
-
- /**
- * Webtest for add contact to group (CRM-15108)
- */
- public function testAddContactToGroup() {
- $this->webtestLogin();
- $this->openCiviPage("contact/add", "reset=1&ct=Individual");
- $this->waitForElementPresent('_qf_Contact_upload_view-bottom');
-
- //Create contact.
- $group = "Advisory Board";
- $firstName = "Adams" . substr(sha1(rand()), 0, 4);
- $lastName = substr(sha1(rand()), 0, 4);
- $email = "{$lastName}.{$firstName}@example.org";
- $this->type('first_name', $firstName);
- $this->type('last_name', $lastName);
- $this->type('email_1_email', "{$firstName}.{$lastName}@example.com");
- $this->click('_qf_Contact_upload_view-bottom');
- $this->waitForText('crm-notification-container', "Contact Saved");
-
- $this->openCiviPage('group', 'reset=1');
- $this->waitForElementPresent("xpath=//div[@id='crm-main-content-wrapper']/div[@class='crm-submit-buttons']/a/span[text()=' Add Group']");
- $this->waitForElementPresent("xpath=//table[@id='DataTables_Table_0']/tbody//tr/td[1]/div[contains(text(), '{$group}')]");
- $this->click("xpath=//table[@id='DataTables_Table_0']/tbody//tr/td[1]/div[text()='{$group}']/../../td[7]/span[1]/a[1]");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->clickLink("xpath=//form[@id='Basic']/div[2]/a/span");
- $this->waitForElementPresent("_qf_Basic_refresh");
- $this->type('sort_name', $firstName);
- $this->click('_qf_Basic_refresh');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForElementPresent("_qf_Basic_next_action");
-
- $this->assertTrue($this->isElementPresent("xpath=//table/tbody//tr/td[3]/a[text()='{$lastName}, {$firstName}']"));
- $this->click("xpath=//table/tbody//tr/td[1]/input[@type='checkbox']");
- $this->click('_qf_Basic_next_action');
- $this->waitForElementPresent("_qf_AddToGroup_back-bottom");
- $this->click('_qf_AddToGroup_next-bottom');
- $this->waitForText('crm-notification-container', "1 contact added to group");
-
- $this->openCiviPage('contact/search', 'reset=1');
- $this->waitForElementPresent("_qf_Basic_refresh");
- $this->type('sort_name', $firstName);
- $this->select('group', "Advisory Board");
- $this->click('_qf_Basic_refresh');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->assertTrue($this->isElementPresent("xpath=//table/tbody//tr/td[3]/a[text()='{$lastName}, {$firstName}']"));
- }
-
- /**
- * CRM-18585 - test to check OR operator on Smart Groups
- */
- public function testAddSmartGroup() {
- $this->webtestLogin();
- $this->openCiviPage('contact/search/advanced', 'reset=1');
- $this->click("xpath=//input[@value='OR']");
- $this->select('group', 'Advisory Board');
- $this->select('contact_tags', 'Major Donor');
- $this->clickLink("_qf_Advanced_refresh");
- $this->waitForElementPresent("task");
- $count = trim($this->getText("//div[@id='search-status']/table/tbody/tr/td"));
-
- //create smart group for contacts resulted from OR operator search.
- $this->click('radio_ts', 'ts_all');
- $this->click('task');
- $this->select('task', 'label=Group - create smart group');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $smartGroupTitle = "SmartGroup" . substr(sha1(rand()), 0, 4);
- $this->type("title", $smartGroupTitle);
- $this->clickLink("_qf_SaveSearch_next-bottom");
- $this->waitForText('crm-notification-container', "Your smart group has been saved as '$smartGroupTitle'");
- $this->clickLink("_qf_Result_done");
- $expectedCount = explode('-', $this->getText("//div[@id='search-status']/table/tbody/tr/td"));
- $this->assertEquals($count, trim($expectedCount[1]));
-
- //Assert the count from Contacts link in Manage Group Page.
- $this->openCiviPage('group', 'reset=1');
- $this->waitForElementPresent("xpath=//table/tbody//tr//td/div[contains(text(), \"{$smartGroupTitle} (Smart Group)\")]");
- $this->clickLink("xpath=//table/tbody//tr//td/div[contains(text(), \"{$smartGroupTitle} (Smart Group)\")]/../../td[@class='crm-group-group_links']/span/a[contains(text(), 'Contacts')]");
- $this->waitForElementPresent("xpath=//span[contains(text(), \"Edit Smart Group Search Criteria for {$smartGroupTitle}\")]");
- $this->clickLink("xpath=//a/span[contains(text(), \"Edit Smart Group Search Criteria for {$smartGroupTitle}\")]/");
- $this->waitForElementPresent('search-status');
- $expectedCount = explode('-', $this->getText("//div[@id='search-status']/table/tbody/tr/td"));
- $this->assertEquals($count, trim($expectedCount[1]));
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Contact_InlineFieldsEditTest
- */
-class WebTest_Contact_InlineFieldsEditTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testAddAndEditField() {
- $this->webtestLogin();
-
- // Add a contact
- $firstName = 'WebTest' . substr(sha1(rand()), 0, 7);
- $lastName = 'InlineFieldsEdit' . substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName, $lastName);
- $contactId = $this->urlArg('cid');
- $this->waitForElementPresent('css=.crm-inline-edit-container.crm-edit-ready');
-
- // Set Communication Prefs
- $this->inlineEdit('crm-communication-pref-content', array(
- 'email_greeting_id' => TRUE,
- 'privacy_do_not_email' => 1,
- 'preferred_communication_method_1' => 1,
- 'preferred_communication_method_2' => 1,
- ), 'keep_open');
- $this->waitForElementPresent('css=.icon.privacy-flag.do-not-email');
- $this->inlineEdit('crm-communication-pref-content', array(
- 'privacy_do_not_phone' => 1,
- 'privacy_do_not_email' => 0,
- 'preferred_communication_method_1' => 0,
- 'preferred_communication_method_2' => 0,
- ), 'keep_open');
- $this->waitForElementPresent('css=.icon.privacy-flag.do-not-phone');
- $this->inlineEdit('crm-communication-pref-content', array(
- 'email_greeting_custom' => 'Hey You!',
- ), 'no_open');
- $this->assertElementNotPresent('css=.icon.privacy-flag.do-not-email');
-
- // Custom data
- $this->click('css=div.crm-custom-set-block-1 .collapsible-title');
- $this->waitForAjaxContent();
- $this->openInlineForm('custom-set-content-1');
- $dateFieldId = $this->getAttribute("xpath=//table[@class='form-layout-compressed']/tbody/tr[3]/td[@class='html-adjust']/span/input@id");
- $this->inlineEdit('custom-set-content-1', array(
- 'CIVICRM_QFID_Edu_2' => 1,
- "//table[@class='form-layout-compressed']/tbody/tr[2]/td[@class='html-adjust']/select" => array('Single'),
- $dateFieldId => 'date: now - 10 years',
- ));
-
- // Edit contact info
- $params = array(
- 'job_title' => 'jobtest123',
- 'nick_name' => 'nicktest123',
- 'contact_source' => 'sourcetest123',
- );
- $this->inlineEdit('crm-contactinfo-content', $params, 'keep_open');
- // Clear fields and verify they are deleted
- $this->inlineEdit('crm-contactinfo-content', array(
- 'job_title' => '',
- 'nick_name' => '',
- 'contact_source' => '',
- ), 'no_open');
- foreach ($params as $str) {
- $this->assertElementNotContainsText('crm-contactinfo-content', $str);
- }
-
- // Add a phone
- $this->inlineEdit('crm-phone-content', array(
- 'phone_1_phone' => '123-456-7890',
- 'phone_1_phone_ext' => '101',
- 'phone_1_location_type_id' => array('Work'),
- 'phone_1_phone_type_id' => array('Mobile'),
- ));
-
- // Add im
- $this->inlineEdit('crm-im-content', array(
- 'im_1_name' => 'testmeout',
- 'im_1_location_type_id' => array('Work'),
- 'im_1_provider_id' => array('Jabber'),
- ));
-
- // Add an address - should default to home
- $this->inlineEdit('address-block-1', array(
- 'address_1_street_address' => '123 St',
- 'address_1_city' => 'San Somewhere',
- ), 'keep_open');
- // Try to uncheck is_primary, we should get an error and it should stay checked
- $this->click('address[1][is_primary]');
- $this->waitForElementPresent('css=#crm-notification-container .error.ui-notify-message');
- $this->assertChecked('address[1][is_primary]');
- // Try to open another form while this one is still open - nothing should happen
- $this->waitForElementPresent('address-block-2');
- $this->openInlineForm('address-block-2', FALSE);
- $this->assertElementNotPresent('css#address-block-2.form');
- // Update address
- $this->inlineEdit('address-block-1', array(
- 'address_1_street_address' => '321 Other St',
- 'address_1_city' => 'Sans Nowhere',
- 'address_1_postal_code' => '99999',
- 'address_1_postal_code_suffix' => '99',
- ), 'no_open');
- // Another address with same location type as first - should give an error
- $this->inlineEdit('address-block-2', array(
- 'address_2_street_address' => '123 Foo',
- 'address_2_city' => 'San Anywhere',
- 'address_2_location_type_id' => array('Home'),
- ), 'error');
- $this->waitForTextPresent('required');
- // Share address with a new org
- $this->click('address[2][use_shared_address]');
- $orgName = 'Test Org Inline' . substr(sha1(rand()), 0, 7);
-
- // create new organization with dialog
- $this->clickAt("xpath=//div[@id='s2id_address_2_master_contact_id']/a");
- $this->click("xpath=//li[@class='select2-no-results']//a[contains(text(),' New Organization')]");
- $this->waitForElementPresent("css=div#crm-profile-block");
- $this->waitForElementPresent("_qf_Edit_next");
-
- $this->type('organization_name', $orgName);
- $this->type('street_address-1', 'Test Org Street');
- $this->type('city-1', 'Test Org City');
- $this->clickLink('_qf_Edit_next', 'selected_shared_address-2', FALSE);
- $this->waitForTextPresent('Test Org Street');
- $this->inlineEdit('address-block-2', array(
- 'address_2_location_type_id' => array('Work'),
- ), 'no_open');
- $this->waitForElementPresent('css=.crm-content.crm-contact-current_employer');
- $this->assertElementContainsText('crm-contactinfo-content', $orgName);
- $this->assertElementContainsText('address-block-2', $orgName);
- $this->assertElementContainsText('address-block-2', 'Work Address');
-
- // Edit demographics
- $this->inlineEdit('crm-demographic-content', array(
- "xpath=//div[@class='crm-clear']/div[1]/div[@class='crm-content']/label[text()='Female']" => TRUE,
- 'is_deceased' => 1,
- 'birth_date' => 'date: Jan 1 1970',
- ), 'no_open');
- $this->assertElementContainsText('crm-demographic-content', 'Female');
- $this->assertElementContainsText('crm-demographic-content', 'Contact is Deceased');
- $this->inlineEdit('crm-demographic-content', array(
- 'is_deceased' => 0,
- ), 'no_open');
- $age = date('Y') - 1970;
- $this->assertElementContainsText('crm-demographic-content', "$age years");
-
- // Add emails
- $this->inlineEdit('crm-email-content', array(
- 'css=#crm-email-content a.add-more-inline' => TRUE,
- 'email_1_email' => 'test1@monkey.com',
- 'email_2_email' => 'test2@monkey.com',
- ), 'keep_open');
-
- // Try an invalid email
- $this->inlineEdit('crm-email-content', array(
- 'email_2_email' => 'invalid@monkey,com',
- ), 'errorJs');
-
- // Delete email
- $this->inlineEdit('crm-email-content', array(
- 'css=#Email_Block_2 a.crm-delete-inline' => TRUE,
- ));
- $this->assertElementNotContainsText('crm-email-content', 'test2@monkey.com');
-
- // Add website with invalid url
- $this->inlineEdit('crm-website-content', array(
- 'css=#crm-website-content a.add-more-inline' => TRUE,
- 'website_1_url' => 'http://example.com',
- 'website_2_url' => 'something.wrong',
- ), 'errorJs');
-
- // Correct invalid url and add a third website
- $this->inlineEdit('crm-website-content', array(
- 'css=#crm-website-content a.add-more-inline' => TRUE,
- 'website_2_url' => 'http://example.net',
- 'website_2_website_type_id' => array('Work'),
- 'website_3_url' => 'http://example.biz',
- 'website_3_website_type_id' => array('Main'),
- ), 'keep_open');
-
- // Delete website
- $this->inlineEdit('crm-website-content', array(
- 'css=#Website_Block_2 a.crm-delete-inline' => TRUE,
- ));
- $this->assertElementNotContainsText('crm-website-content', 'http://example.net');
-
- // Change contact name
- $this->inlineEdit('crm-contactname-content', array(
- 'first_name' => 'NewName',
- 'prefix_id' => array('Mr.'),
- ));
- $this->assertElementContainsText('css=div.crm-summary-display_name', "Mr. NewName $lastName");
- // Page title should be updated with new name on reload
- $this->openCiviPage('contact/view', "reset=1&cid=$contactId", "crm-record-log");
- $this->assertElementContainsText('css=title', "Mr. NewName $lastName");
- }
-
- /**
- * Click on an inline-edit block and wait for it to open
- *
- * @param string $block
- * selector.
- * @param bool $wait
- */
- private function openInlineForm($block, $wait = TRUE) {
- $this->mouseDown($block);
- $this->mouseUp($block);
- if ($wait) {
- $this->waitForElementPresent("css=#$block .crm-container-snippet form");
- }
- }
-
- /**
- * Enter values in an inline edit block and save.
- *
- * @param string $block
- * selector.
- * @param array $params
- * @param \str|string $valid str: submit behavior
- * 'error' if we are expecting a form validation error,
- * 're_open' (default) after saving, opens the form and validate inputs
- * 'keep_open' same as 're_open' but doesn't automatically cancel at the end
- * 'no_open' do not re-open to validate
- */
- private function inlineEdit($block, $params, $valid = 're_open') {
- $this->openInlineForm($block);
- foreach ($params as $item => $val) {
- switch (gettype($val)) {
- case 'boolean':
- $this->click($item);
- break;
-
- case 'string':
- if (substr($val, 0, 5) == 'date:') {
- $this->webtestFillDate($item, trim(substr($val, 5)));
- }
- else {
- $this->type($item, $val);
- }
- break;
-
- case 'integer':
- $method = $val ? 'check' : 'uncheck';
- $this->$method($item);
- break;
-
- case 'array':
- foreach ($val as $option) {
- $selector = is_int($option) ? 'value' : 'label';
- $this->select($item, "$selector=$option");
- }
- break;
- }
- }
- $this->click("css=#$block input.crm-form-submit");
- if ($valid !== 'error' && $valid != 'errorJs') {
- // Verify the form saved
- $this->waitForElementPresent("css=#$block > .crm-inline-block-content");
- $validate = FALSE;
- foreach ($params as $val) {
- if (is_string($val) && $val && substr($val, 0, 5) != 'date:') {
- $this->assertElementContainsText($block, $val);
- $validate = TRUE;
- }
- elseif (!is_bool($val)) {
- $validate = TRUE;
- }
- if (is_array($val)) {
- foreach ($val as $option) {
- if (!is_int($option)) {
- $this->assertElementContainsText($block, $option);
- }
- }
- }
- }
- // Open the form back up and check everything
- if ($validate && $valid !== 'no_open') {
- $this->openInlineForm($block);
- foreach ($params as $item => $val) {
- switch (gettype($val)) {
- case 'string':
- if ($val && substr($val, 0, 5) == 'date:') {
- $val = date('m/d/Y', strtotime(trim(substr($val, 5))));
- $item = "xpath=//input[@id='{$item}']/following-sibling::input";
- }
- if ($val) {
- $this->assertElementValueEquals($item, $val);
- }
- break;
-
- case 'integer':
- $method = $val ? 'assertChecked' : 'assertNotChecked';
- $this->$method($item);
- break;
-
- case 'array':
- foreach ($val as $option) {
- $method = is_int($option) ? 'assertIsSelected' : 'assertSelected';
- $this->$method($item, $option);
- }
- break;
- }
- }
- if ($valid !== 'keep_open') {
- $this->click("css=#$block input.cancel");
- }
- }
- }
- // Verify there was a form error
- else {
- switch ($valid) {
- case 'errorJs':
- $this->waitForElementPresent('css=label.error');
- break;
-
- default:
- $this->waitForElementPresent('css=#crm-notification-container .error.ui-notify-message');
- $this->click('css=#crm-notification-container .error .ui-notify-cross');
- }
- }
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Contact_MergeContactsTest
- */
-class WebTest_Contact_MergeContactsTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testIndividualAdd() {
- $this->markTestSkipped('Skipping for now as it works fine locally.');
- $this->webtestLogin();
-
- $this->openCiviPage("contact/add", "reset=1&ct=Individual");
-
- // add contact1
- //select prefix
- $prefix = 'Mr.';
- $this->click("prefix_id");
- $this->select("prefix_id", "label=$prefix");
-
- //fill in first name
- $firstName = substr(sha1(rand()), 0, 7);
- $this->type('first_name', $firstName);
-
- //fill in last name
- $lastName = substr(sha1(rand()), 0, 7);
- $this->type('last_name', $lastName);
-
- //fill in email id
- $this->type('email_1_email', "{$firstName}.{$lastName}@example.com");
-
- //fill in billing email id
- $this->click('addEmail');
- $this->waitForElementPresent('email_2_email');
- $this->type('email_2_email', "$firstName.$lastName@billing.com");
- $this->select('email_2_location_type_id', 'value=5');
-
- // Clicking save.
- $this->click("_qf_Contact_upload_view");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForText('crm-notification-container', "Contact Saved");
-
- // Add Contact to a group
- $group = 'Newsletter Subscribers';
- $this->click('css=li#tab_group a');
- $this->waitForElementPresent('_qf_GroupContact_next');
- $this->select('group_id', "label=$group");
- $this->click('_qf_GroupContact_next');
- $this->waitForElementPresent('link=Delete');
- $this->waitForText('crm-notification-container', "Added to Group");
-
- // Add Tags to the contact
- $tag = 'Government Entity';
- $this->click("css=li#tab_tag a");
- $this->waitForElementPresent('tagtree');
- $this->click("xpath=//div[@id='tagtree']/ul//li/input/../span/label[text()='$tag']");
- $this->click("css=#tab_summary a");
- $this->assertElementContainsText('css=.crm-summary-block #tags', $tag);
-
- // Add an activity
- $subject = "This is subject of test activity being added through activity tab of contact summary screen.";
- $this->addActivity($firstName, $lastName, $subject);
-
- // contact2: duplicate of contact1.
- $this->openCiviPage("contact/add", "reset=1&ct=Individual");
-
- //fill in first name
- $this->type("first_name", $firstName);
-
- //fill in last name
- $this->type("last_name", $lastName);
-
- //fill in email
- $this->type("email_1_email", "{$firstName}.{$lastName}@example.com");
-
- // Clicking save.
- $this->click("_qf_Contact_refresh_dedupe");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->waitForText('crm-notification-container', "One matching contact was found. You can View or Edit the existing contact.");
- $this->click("_qf_Contact_upload_duplicate");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForText('crm-notification-container', "Contact Saved");
-
- // Add second pair of dupes so we can test Merge and Goto Next Pair
- $fname2 = 'Janet';
- $lname2 = 'Rogers' . substr(sha1(rand()), 0, 7);
- $email2 = "{$fname2}.{$lname2}@example.org";
- $this->webtestAddContact($fname2, $lname2, $email2);
-
- // Can not use helper for 2nd contact since it is a dupe
- $this->openCiviPage("contact/add", "reset=1&ct=Individual");
- $this->type("first_name", $fname2);
- $this->type("last_name", $lname2);
- $this->type("email_1_email", $email2);
- $this->click("_qf_Contact_refresh_dedupe");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForText('crm-notification-container', "One matching contact was found. You can View or Edit the existing contact.");
- $this->click("_qf_Contact_upload_duplicate");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForText('crm-notification-container', "Contact Saved");
-
- // Find and Merge Contacts with Supervised Rule
- $this->openCiviPage("contact/dedupefind", "reset=1&rgid=1&action=renew");
-
- // reload the page
- $this->openCiviPage("contact/dedupefind", "reset=1&rgid=1&action=update");
-
- // Select the contacts to be merged
- $this->waitForElementPresent('dupePairs_length');
- $this->select("name=dupePairs_length", "value=100");
- $this->waitForElementPresent("xpath=//table[@id='dupePairs']/tbody//tr/td[5]/a[text()='$firstName $lastName']/../../td[8]/a[text()='merge']");
- $this->click("xpath=//table[@id='dupePairs']/tbody//tr/td[5]/a[text()='$firstName $lastName']/../../td[8]/a[text()='merge']");
- $this->waitForElementPresent('_qf_Merge_cancel-bottom');
-
- $this->clickLink("css=div.crm-contact-merge-form-block div.action-link a", '_qf_Merge_cancel-bottom');
-
- // Move the activities, groups, etc to the main contact and merge using Merge and Goto Next Pair
- $this->check('move_prefix_id');
- $this->check('move_location_email_2');
- $this->check('move_rel_table_activities');
- $this->check('move_rel_table_groups');
- $this->check('move_rel_table_tags');
- $this->clickLink('_qf_Merge_next-bottom', '_qf_Merge_cancel-bottom');
- $this->assertTrue($this->isTextPresent('Contacts Merged'), "Contacts Merged text was not found after merge.");
-
- // Check that we are viewing the next Merge Pair (our 2nd contact, since the merge list is ordered by contact_id)
- $this->assertTrue($this->isTextPresent("{$fname2} {$lname2}"), "Redirect for Goto Next Pair after merge did not work.");
-
- // Ensure that the duplicate contact has been deleted
- $this->openCiviPage("contact/search/advanced", "reset=1", '_qf_Advanced_refresh');
- $this->type('sort_name', $firstName);
- $this->click('deleted_contacts');
- $this->click('_qf_Advanced_refresh');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->assertTrue($this->isTextPresent('1 Contact'), "Deletion of duplicate contact during merge was not successful. Dupe contact not found when searching trash.");
-
- // Search for the main contact
- $this->openCiviPage("contact/search/advanced", "reset=1", '_qf_Advanced_refresh');
- $this->type('sort_name', $firstName);
- $this->click('_qf_Advanced_refresh');
- $this->waitForElementPresent("xpath=//form[@id='Advanced']/div[3]/div/div[2]/table/tbody/tr");
-
- $this->click("//form[@id='Advanced']/div[3]/div/div[2]/table/tbody/tr/td[11]/span[1]/a[text()='View']");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Verify prefix merged
- // $this->verifyText( "xpath=//div[@class='left-corner']/h2", preg_quote( "$prefix $firstName $lastName" ) );
-
- // Verify billing email merged
- $this->isElementPresent("xpath=//div[@class='contact_details']/div[1][@class='contact_panel']/div[1][@class='contactCardLeft']/table/tbody/tr[4]/td[2]/span/a[text()='$firstName.$lastName@billing.com']");
-
- // Verify activity merged
- $this->click("css=li#tab_activity a");
- $this->waitForAjaxContent();
- $this->waitForElementPresent("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr");
- $this->verifyText("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[5]/a", preg_quote("$lastName, $firstName"));
-
- // Verify group merged
- $this->click("css=li#tab_group a");
- $this->waitForElementPresent("GroupContact");
- $this->waitForElementPresent("xpath=//form[@id='GroupContact']//div[@class='view-content view-contact-groups']//div/table/tbody/tr/td/a");
- $this->verifyText("xpath=//form[@id='GroupContact']//div[@class='view-content view-contact-groups']//div/table/tbody/tr/td/a",
- preg_quote("$group")
- );
-
- // Verify tag merged
- $this->click("css=li#tab_tag a");
- $this->waitForElementPresent('check_5');
- $this->assertChecked("check_3");
- }
-
- public function testMergeContactSubType() {
- $this->webtestLogin();
- $this->openCiviPage("contact/add", "reset=1&ct=Individual");
- $this->waitForElementPresent('_qf_Contact_cancel-bottom');
- //fill in first name
- $firstName = "Anderson" . substr(sha1(rand()), 0, 4);
- $this->type('first_name', $firstName);
-
- //fill in last name
- $lastName = substr(sha1(rand()), 0, 4);
- $this->type('last_name', $lastName);
-
- //fill in email id
- $this->waitForElementPresent('email_1_email');
- $this->type('email_1_email', "{$firstName}.{$lastName}@example.com");
- $this->waitForElementPresent('contact_sub_type');
- $this->select('contact_sub_type', "Parent");
-
- // Clicking save.
- $this->click("_qf_Contact_upload_view");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForText('crm-notification-container', "Contact Saved");
-
- // contact2: contact with same email id as contact 1.
- $this->openCiviPage("contact/add", "reset=1&ct=Individual");
- $this->waitForElementPresent('_qf_Contact_cancel-bottom');
-
- $fName = "John" . substr(sha1(rand()), 0, 4);
- $this->type('first_name', $fName);
- $lName = substr(sha1(rand()), 0, 4);
- $this->type('last_name', $lName);
- $this->type('email_1_email', "{$firstName}.{$lastName}@example.com");
- $this->waitForElementPresent('contact_sub_type');
- $this->multiselect2('contact_sub_type', array("Student", "Staff"));
- $this->click("_qf_Contact_upload_view");
- $this->waitForText('crm-notification-container', "Contact Saved");
- $this->openCiviPage("contact/deduperules", "reset=1");
- $this->click("xpath=//*[@id='option12']/tbody/tr[3]/td[3]/span/a[1][contains(text(),'Use Rule')]");
- $this->waitForElementPresent('_qf_DedupeFind_submit-bottom');
- $this->click("_qf_DedupeFind_next-bottom");
-
- $this->waitForElementPresent("xpath=//table[@id='dupePairs']/tbody//tr/td[3]/a[text()='{$firstName} {$lastName}']/../../td[8]/a[2][text()='merge']");
- $this->waitForElementPresent("xpath=//form[@id='DedupeFind']//a/span[contains(text(),'Done')]");
- $this->isElementPresent("xpath=//table[@id='dupePairs']/tbody//tr//td/a[text()='$firstName $lastName']/../../td[5]/a[text()='{$fName} {$lName}']/../../td[8]/a[text()='merge']");
- $this->click("xpath=//table[@id='dupePairs']/tbody//tr/td[3]/a[text()='{$firstName} {$lastName}']/../../td[8]/a[2][text()='merge']");
- $this->waitForElementPresent('_qf_Merge_cancel-bottom');
- $this->click('toggleSelect');
- $this->click('_qf_Merge_next-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->assertTrue($this->isTextPresent("Staff, Student"));
- }
-
- /**
- * @param string $firstName
- * @param string $lastName
- * @param $subject
- */
- public function addActivity($firstName, $lastName, $subject) {
- $withContact = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($withContact, "Anderson", $withContact . "@anderson.name");
-
- $this->click("css=li#tab_activity a");
-
- // waiting for the activity dropdown to show up
- $this->waitForElementPresent("other_activity");
-
- // Select the activity type from the activity dropdown
- $this->select("other_activity", "label=Meeting");
-
- // waitForPageToLoad is not always reliable. Below, we're waiting for the submit
- // button at the end of this page to show up, to make sure it's fully loaded.
- $this->waitForElementPresent("_qf_Activity_upload");
-
- // ...and verifying if the page contains properly formatted display name for chosen contact.
- $this->assertTrue($this->isTextPresent("Anderson, " . $withContact), "Contact not found in line " . __LINE__);
-
- // Now we're filling the "Assigned To" field.
- // Typing contact's name into the field (using typeKeys(), not type()!)...
- $this->select2("assignee_contact_id", $firstName, TRUE, FALSE);
-
- // ...and verifying if the page contains properly formatted display name for chosen contact.
- $this->assertTrue($this->isTextPresent("$lastName, " . $firstName), "Contact not found in line " . __LINE__);
-
- // Since we're here, let's check if screen help is being displayed properly
- $this->assertTrue($this->isTextPresent("A copy of this activity will be emailed to each Assignee."));
-
- // Putting the contents into subject field - assigning the text to variable, it'll come in handy later
- // For simple input fields we can use field id as selector
- $this->type("subject", $subject);
- $this->type("location", "Some location needs to be put in this field.");
-
- // Choosing the Date.
- // Please note that we don't want to put in fixed date, since
- // we want this test to work in the future and not fail because
- // of date being set in the past. Therefore, using helper webtestFillDateTime function.
- $this->webtestFillDateTime('activity_date_time', '+1 month 11:10PM');
-
- // Setting duration.
- $this->type("duration", "30");
-
- // Putting in details.
- $this->type("details", "Really brief details information.");
-
- // Making sure that status is set to Scheduled (using value, not label).
- $this->select("status_id", "value=1");
-
- // Setting priority.
- $this->select("priority_id", "value=1");
-
- // Clicking save.
- $this->click("_qf_Activity_upload");
- $this->waitForElementPresent("crm-notification-container");
-
- // Is status message correct?
- $this->waitForText('crm-notification-container', "Activity '$subject' has been saved.", "Status message didn't show up after saving!");
- }
-
- public function testMergeTest() {
- $this->webtestLogin();
-
- $this->openCiviPage("contact/add", "reset=1&ct=Individual");
-
- // add contact1
- //fill in first name
- $firstName = substr(sha1(rand()), 0, 7);
- $this->type('first_name', $firstName);
-
- //fill in last name
- $lastName = substr(sha1(rand()), 0, 7);
- $this->type('last_name', $lastName);
-
- //fill in email id
- $this->type('email_1_email', "{$firstName}.{$lastName}@example.com");
-
- //fill in billing email id
- $this->click('addEmail');
- $this->waitForElementPresent('email_2_email');
- $this->type('email_2_email', "$firstName.$lastName@billing.com");
- $this->select('email_2_location_type_id', 'value=5');
-
- //fill in home phone no
- $this->type('phone_1_phone', "9876543210");
-
- //fill in billing phone id
- $this->click('addPhone');
- $this->waitForElementPresent('phone_2_phone');
- $this->type('phone_2_phone', "9876543120");
- $this->select('phone_2_location_type_id', 'value=5');
-
- // Clicking save.
- $this->click("_qf_Contact_upload_view");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForText('crm-notification-container', "Contact Saved");
-
- // contact2: duplicate of contact1.
- $this->openCiviPage("contact/add", "reset=1&ct=Individual");
-
- //fill in first name
- $this->type("first_name", $firstName);
-
- //fill in last name
- $this->type("last_name", $lastName);
-
- //fill in email
- $this->type("email_1_email", "{$firstName}.{$lastName}@example.com");
-
- //fill in home phone no
- $this->type('phone_1_phone', "9876543211");
-
- // Clicking save.
- $this->click("_qf_Contact_refresh_dedupe");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->waitForText('crm-notification-container', "One matching contact was found. You can View or Edit the existing contact.");
- $this->click("_qf_Contact_upload_duplicate");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForText('crm-notification-container', "Contact Saved");
-
- // Find and Merge Contacts with Supervised Rule
- $this->openCiviPage("contact/dedupefind", "reset=1&rgid=1&action=renew");
-
- // Select the contacts to be merged
- $this->waitForElementPresent('dupePairs_length');
- $this->waitForElementPresent("xpath=//a[text()='$firstName $lastName']");
- $this->click("xpath=//a[text()='$firstName $lastName']/../../td[8]/a[text()='merge']");
- $this->waitForElementPresent('_qf_Merge_cancel-bottom');
- $this->clickLink("css=div.crm-contact-merge-form-block div.action-link a");
-
- $this->waitForElementPresent("xpath=//form[@id='Merge']/div[2]/table/tbody/tr[3]/td[4]/span[text()='(overwrite)']");
- $this->waitForElementPresent("xpath=//form[@id='Merge']/div[2]/table/tbody/tr[5]/td[4]/span[text()='(add)']");
- $this->waitForElementPresent('_qf_Merge_cancel-bottom');
-
- $this->check("move_location_email_1");
- $this->check("location[email][1][operation]");
- $this->check("move_location_email_2");
- $this->check("move_location_phone_1");
- $this->check("location[phone][1][operation]");
- $this->check("move_location_phone_2");
- $this->click("_qf_Merge_next-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->assertTrue($this->isTextPresent('Contacts Merged'));
- $this->assertTrue($this->isElementPresent("xpath=//div[@id='email-block']/div/div/div[2]/div[1][contains(text(), 'Home')]"));
- $this->assertTrue($this->isElementPresent("xpath=//div[@id='email-block']/div/div/div[2]/div[2]/a[contains(text(), '{$firstName}.{$lastName}@example.com')]"));
- $this->assertTrue($this->isElementPresent("xpath=//div[@id='email-block']/div/div/div[3]/div[1][contains(text(), 'Home')]"));
- $this->assertTrue($this->isElementPresent("xpath=//div[@id='email-block']/div/div/div[3]/div[2]/a[contains(text(), '{$firstName}.{$lastName}@example.com')]"));
- $this->assertTrue($this->isElementPresent("xpath=//div[@id='email-block']/div/div/div[4]/div[1][contains(text(), 'Billing')]"));
- $this->assertTrue($this->isElementPresent("xpath=//div[@id='email-block']/div/div/div[4]/div[2]/a[contains(text(), '$firstName.$lastName@billing.com')]"));
- $this->assertTrue($this->isElementPresent("xpath=//div[@id='phone-block']/div/div/div[2]/div[1][contains(text(), 'Home')]"));
- $this->assertTrue($this->isElementPresent("xpath=//div[@id='phone-block']/div/div/div[2]/div[2][contains(text(), '9876543211')]"));
- $this->assertTrue($this->isElementPresent("xpath=//div[@id='phone-block']/div/div/div[3]/div[1][contains(text(), 'Home')]"));
- $this->assertTrue($this->isElementPresent("xpath=//div[@id='phone-block']/div/div/div[3]/div[2][contains(text(), '9876543210')]"));
- $this->assertTrue($this->isElementPresent("xpath=//div[@id='phone-block']/div/div/div[4]/div[1][contains(text(), 'Billing')]"));
- $this->assertTrue($this->isElementPresent("xpath=//div[@id='phone-block']/div/div/div[4]/div[2][contains(text(), '9876543120')]"));
-
- //Merge with the feature of (add)
- $this->openCiviPage("contact/add", "reset=1&ct=Individual");
-
- // add contact1
- //fill in first name
- $firstName1 = substr(sha1(rand()), 0, 7);
- $this->type('first_name', $firstName1);
-
- //fill in last name
- $lastName1 = substr(sha1(rand()), 0, 7);
- $this->type('last_name', $lastName1);
-
- //fill in billing email id
- $this->waitForElementPresent('email_1_email');
- $this->type('email_1_email', "$firstName1.$lastName1@example.com");
- $this->select('email_1_location_type_id', 'value=5');
-
- $this->click('addEmail');
- $this->waitForElementPresent('email_2_email');
- $this->type('email_2_email', "$firstName.$lastName@home.com");
- $this->select('email_2_location_type_id', 'value=1');
-
- //fill in home phone no
- $this->type('phone_1_phone', "9876543210");
-
- // Clicking save.
- $this->click("_qf_Contact_upload_view");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForText('crm-notification-container', "Contact Saved");
-
- // contact2: duplicate of contact1.
- $this->openCiviPage("contact/add", "reset=1&ct=Individual");
-
- //fill in first name
- $this->type("first_name", $firstName1);
-
- //fill in last name
- $this->type("last_name", $lastName1);
-
- //fill in email
- $this->type("email_1_email", "{$firstName1}.{$lastName1}@example.com");
-
- //fill in billing phone no
- $this->type('phone_1_phone', "9876543120");
- $this->select('phone_1_location_type_id', 'value=5');
-
- // Clicking save.
- $this->click("_qf_Contact_refresh_dedupe");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForText('crm-notification-container', "One matching contact was found. You can View or Edit the existing contact.");
- $this->click("_qf_Contact_upload_duplicate");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForText('crm-notification-container', "Contact Saved");
-
- // Find and Merge Contacts with Supervised Rule
- $this->openCiviPage("contact/dedupefind", "reset=1&rgid=1&action=renew");
-
- // Select the contacts to be merged
- $this->waitForElementPresent('dupePairs_length');
- $this->waitForElementPresent("xpath=//a[text()='$firstName1 $lastName1']");
- $this->click("xpath=//a[text()='$firstName1 $lastName1']/../../td[8]/a[text()='merge']");
- $this->waitForElementPresent('_qf_Merge_cancel-bottom');
- $this->clickLink("css=div.crm-contact-merge-form-block div.action-link a", "xpath=//form[@id='Merge']/div[2]/table/tbody/tr[4]/td[4]/span[text()='(overwrite)']");
- $this->waitForElementPresent("xpath=//form[@id='Merge']/div[2]/table/tbody/tr[3]/td[4]/span[text()='(add)']");
- $this->waitForElementPresent("xpath=//form[@id='Merge']/div[2]/table/tbody/tr[4]/td[4]/span[text()='(overwrite)']");
- $this->select('location_email_1_locTypeId', 'value=3');
- $this->select('location_phone_1_locTypeId', 'value=1');
- $this->assertFalse($this->isElementPresent("xpath=//form[@id='Merge']/div[2]/table/tbody/tr[2]/td[4]/span[text()='(overwrite)']"));
- $this->assertFalse($this->isElementPresent("xpath=//form[@id='Merge']/div[2]/table/tbody/tr[4]/td[4]/span[text()='(overwrite)']"));
- $this->assertTrue($this->isElementPresent("xpath=//form[@id='Merge']/div[2]/table/tbody/tr[3]/td[4]/span[text()='(add)']"));
- $this->waitForElementPresent('_qf_Merge_cancel-bottom');
-
- $this->check("move_location_email_1");
- $this->check("move_location_phone_1");
- $this->click("_qf_Merge_next-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->assertTrue($this->isTextPresent('Contacts Merged'));
- $this->assertTrue($this->isElementPresent("xpath=//div[@id='email-block']/div/div/div[2]/div[1][contains(text(), 'Home')]"));
- $this->assertTrue($this->isElementPresent("xpath=//div[@id='email-block']/div/div/div[2]/div[2]/a[contains(text(), '{$firstName1}.{$lastName1}@example.com')]"));
- $this->assertTrue($this->isElementPresent("xpath=//div[@id='email-block']/div/div/div[3]/div[1][contains(text(), 'Main')]"));
- $this->assertTrue($this->isElementPresent("xpath=//div[@id='email-block']/div/div/div[3]/div[2]/a[contains(text(), '{$firstName1}.{$lastName1}@example.com')]"));
- $this->assertTrue($this->isElementPresent("xpath=//div[@id='phone-block']/div/div/div[2]/div[1][contains(text(), 'Billing')]"));
- $this->assertTrue($this->isElementPresent("xpath=//div[@id='phone-block']/div/div/div[2]/div[2][contains(text(), '9876543120')]"));
- $this->assertTrue($this->isElementPresent("xpath=//div[@id='phone-block']/div/div/div[3]/div[1][contains(text(), 'Home')]"));
- $this->assertTrue($this->isElementPresent("xpath=//div[@id='phone-block']/div/div/div[3]/div[2][contains(text(), '9876543210')]"));
- }
-
- public function testBatchMerge() {
- $this->webtestLogin();
-
- // add contact1 and its duplicate
- //first name
- $firstName = "Kerry" . substr(sha1(rand()), 0, 7);
- //last name
- $lastName = "King" . substr(sha1(rand()), 0, 7);
- $this->_createContacts($firstName, $lastName);
-
- //add contact2 and its duplicate
- //These are the contacts with conflicts in communication preference.these contacts will be skipped during merge.
- $this->openCiviPage("contact/add", "reset=1&ct=Individual");
-
- //fill in first name
- $firstName1 = "Kurt" . substr(sha1(rand()), 0, 7);
- $this->type('first_name', $firstName1);
-
- //fill in last name
- $lastName1 = "Cobain" . substr(sha1(rand()), 0, 7);
- $this->type('last_name', $lastName1);
-
- //fill in email id
- $this->type('email_1_email', "{$firstName1}.{$lastName1}@example.com");
-
- //fill in billing email id
- $this->click('addEmail');
- $this->waitForElementPresent('email_2_email');
- $this->type('email_2_email', "$firstName1.$lastName1@billing.com");
- $this->select('email_2_location_type_id', 'value=5');
-
- //fill in home phone no
- $this->type('phone_1_phone', "9876543210");
-
- //fill in billing phone id
- $this->click('addPhone');
- $this->waitForElementPresent('phone_2_phone');
- $this->type('phone_2_phone', "9876543120");
- $this->select('phone_2_location_type_id', 'value=5');
-
- //select communication preference
- $this->check("privacy[do_not_phone]");
-
- //Clicking save.
- $this->click("_qf_Contact_upload_view");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForText('crm-notification-container', "Contact Saved");
-
- //duplicate of contact2.
- $this->openCiviPage("contact/add", "reset=1&ct=Individual");
-
- //fill in first name
- $this->type("first_name", $firstName1);
-
- //fill in last name
- $this->type("last_name", $lastName1);
-
- //fill in email
- $this->type("email_1_email", "{$firstName1}.{$lastName1}@example.com");
-
- //fill in home phone no
- $this->type('phone_1_phone', "9876543211");
-
- //select communication preference
- $this->check("preferred_communication_method[1]");
-
- // Clicking save.
- $this->click("_qf_Contact_refresh_dedupe");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->waitForText('crm-notification-container', "One matching contact was found. You can View or Edit the existing contact.");
- $this->click("_qf_Contact_upload_duplicate");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForText('crm-notification-container', "Contact Saved");
-
- // add contact3 and its duplicate
- //fill in first name
- $firstName2 = "David" . substr(sha1(rand()), 0, 7);
- //fill in last name
- $lastName2 = "Gilmour" . substr(sha1(rand()), 0, 7);
- $this->_createContacts($firstName2, $lastName2);
-
- // add contact4 and its duplicate
- //fill in first name
- $firstName3 = "Dave" . substr(sha1(rand()), 0, 7);
- //fill in last name
- $lastName3 = "Mustaine" . substr(sha1(rand()), 0, 7);
- $this->_createContacts($firstName3, $lastName3);
-
- // Find and Merge Contacts with Supervised Rule
- $this->openCiviPage("contact/dedupefind", "reset=1&rgid=1&action=renew", "dupePairs");
-
- $this->waitForElementPresent('dupePairs_length');
- $this->select("name=dupePairs_length", "value=100");
- $totalContacts = $this->getXpathCount("//table[@id='dupePairs']/tbody/tr");
- $this->click("//form[@id='DedupeFind']//a/span[contains(text(),' Batch Merge All Duplicates')]");
-
- // Check confirmation alert.
- $this->assertTrue(
- (bool) preg_match("/^This will run the batch merge process on the listed duplicates. The operation will run in safe mode - only records with no direct data conflicts will be merged. Click OK to proceed if you are sure you wish to run this operation./",
- $this->getConfirmation()
- )
- );
- $this->chooseOkOnNextConfirmation();
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForElementPresent('civicrm-footer');
- $this->waitForElementPresent("crm-main-content-wrapper");
-
- // If we are still on the dedupe table page, count unmerged contacts
- if ($this->isElementPresent("//table[@class='pagerDisplay']")) {
- // Wait for datatable to load
- $this->waitForElementPresent("//table[@class='pagerDisplay']/tbody/tr");
- $unMergedContacts = $this->getXpathCount("//table[@class='pagerDisplay']/tbody/tr");
- }
- else {
- $unMergedContacts = 0;
- }
-
- $mergedContacts = $totalContacts - $unMergedContacts;
-
- //check the existence of merged contacts
- $contactEmails = array(
- 1 => "{$firstName}.{$lastName}@example.com",
- 2 => "{$firstName2}.{$lastName2}@example.com",
- 3 => "{$firstName3}.{$lastName3}@example.com",
- );
-
- foreach ($contactEmails as $key => $value) {
- $this->click('sort_name_navigation');
- $this->type('css=input#sort_name_navigation', $value);
- $this->typeKeys('css=input#sort_name_navigation', $value);
- // Wait for result list.
- $this->waitForElementPresent("css=ul.ui-autocomplete li.ui-menu-item");
-
- // Visit contact summary page.
- $this->clickLink("css=ul.ui-autocomplete li.ui-menu-item", 'civicrm-footer');
- }
- }
-
- /**
- * Helper FN.
- * @param null $firstName
- * @param null $lastName
- * @param null $organizationName
- * @param string $contactType
- * @return array
- */
- public function _createContacts($firstName = NULL, $lastName = NULL, $organizationName = NULL, $contactType = 'Individual') {
- if ($contactType == 'Individual') {
- // add contact
- $this->openCiviPage("contact/add", "reset=1&ct=Individual");
- //fill in first name
- $this->type('first_name', $firstName);
-
- //fill in last name
- $this->type('last_name', $lastName);
-
- //fill in email id
- $this->type('email_1_email', "{$firstName}.{$lastName}@example.com");
-
- //fill in billing email id
- $this->click('addEmail');
- $this->waitForElementPresent('email_2_email');
- $this->type('email_2_email', "$firstName.$lastName@billing.com");
- $this->select('email_2_location_type_id', 'value=5');
-
- // Clicking save.
- $this->click("_qf_Contact_upload_view");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForText('crm-notification-container', "Contact Saved");
-
- //duplicate of above contact.
- $this->openCiviPage("contact/add", "reset=1&ct=Individual");
-
- //fill in first name
- $this->type("first_name", $firstName);
-
- //fill in last name
- $this->type("last_name", $lastName);
-
- //fill in email
- $this->type("email_1_email", "{$firstName}.{$lastName}@example.com");
-
- // Clicking save.
- $this->click("_qf_Contact_refresh_dedupe");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->waitForText('crm-notification-container', "One matching contact was found. You can View or Edit the existing contact.");
- $this->click("_qf_Contact_upload_duplicate");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForText('crm-notification-container', "Contact Saved");
- }
- elseif ($contactType == 'Organization') {
- // add contact
- $this->openCiviPage("contact/add", "reset=1&ct=Organization");
- //fill in Organization name
- $this->type('organization_name', $organizationName);
-
- //fill in email id
- $this->type('email_1_email', "{$organizationName}@org.com");
- // Clicking save.
- $this->click("_qf_Contact_upload_view-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForText('crm-notification-container', "Contact Saved");
- $mainId = explode("Contact ID:", trim($this->getText("xpath=//div[@id='crm-record-log']/span[@class='col1']")));
- $mainId = trim($mainId[1]);
-
- //Duplicate of above contact.
- $this->openCiviPage("contact/add", "reset=1&ct=Organization");
-
- //fill in Organization name
- $this->type('organization_name', $organizationName);
-
- //fill in email id
- $this->type('email_1_email', "{$organizationName}@org.com");
-
- // Clicking save.
- $this->click("_qf_Contact_upload_view-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->waitForText('crm-notification-container', "One matching contact was found. You can View or Edit the existing contact.");
- $this->click("_qf_Contact_upload_duplicate");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForText('crm-notification-container', "Contact Saved");
- $duplicateId = explode("Contact ID:", trim($this->getText("xpath=//div[@id='crm-record-log']/span[@class='col1']")));
- $duplicateId = trim($duplicateId[1]);
-
- return array(
- 'mainId' => $mainId,
- 'duplicateId' => $duplicateId,
- );
- }
- }
-
- /**
- * Helper FN.
- * to create new membership type
- * @param $membershipOrganization
- */
- public function addMembershipType($membershipOrganization) {
- $this->openCiviPage("admin/member/membershipType", "reset=1&action=browse");
- $this->click("link=Add Membership Type");
- $this->waitForElementPresent('_qf_MembershipType_cancel-bottom');
-
- $this->type('name', "Membership Type $membershipOrganization");
- $this->select2('member_of_contact_id', $membershipOrganization);
-
- $this->type('minimum_fee', '1');
- $this->select('financial_type_id', 'value=2');
- $this->type('duration_interval', 1);
- $this->select('duration_unit', "label=year");
-
- $this->select('period_type', "label=Fixed");
- $this->waitForElementPresent('fixed_period_rollover_day[d]');
-
- // fixed period start set to April 1
- $this->select('fixed_period_start_day[M]', 'value=4');
- // rollover date set to Jan 31
- $this->select('fixed_period_rollover_day[M]', 'value=1');
-
- // Employer of relationship
- $this->select('relationship_type_id', 'value=5_b_a');
- $this->click('_qf_MembershipType_upload-bottom');
- $this->waitForElementPresent('link=Add Membership Type');
- $this->waitForText("crm-notification-container", "The membership type 'Membership Type $membershipOrganization' has been saved.");
- }
-
- /**
- * Test for CRM-12695 fix
- */
- public function testMergeOrganizations() {
- $this->webtestLogin();
-
- // build organisation name
- $orgnaizationName = 'org_' . substr(sha1(rand()), 0, 7);
-
- $contactIds = array();
- // create organization and its duplicate
- $contactIds = $this->_createContacts(NULL, NULL, $orgnaizationName, 'Organization');
-
- /*** Add Membership Type - start ***/
- $this->addMembershipType($orgnaizationName);
- /*** Add Membership Type - end ***/
-
- //create a New Individual to be related to main organization
- $firstName = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName, "Anderson", "$firstName@anderson.name");
- $sortName = "Anderson, $firstName";
-
- // go to main organization contact to add membership
- $this->openCiviPage("contact/view", "reset=1&cid={$contactIds['mainId']}");
- // click through to the membership view screen
- $this->click("css=li#tab_member a");
-
- $this->waitForElementPresent("link=Add Membership");
- $this->click("link=Add Membership");
-
- $this->waitForElementPresent("_qf_Membership_cancel-bottom");
-
- // fill in Membership Organization and Type
- $this->select("membership_type_id[0]", "label={$orgnaizationName}");
- $this->waitForElementPresent("membership_type_id[1]");
- // Wait for membership type select to reload
- $this->waitForTextPresent("Membership Type $orgnaizationName");
- $this->select("membership_type_id[1]", "label=Membership Type $orgnaizationName");
-
- $sourceText = "Membership-Organization Duplicate Merge Webtest";
- // fill in Source
- $this->type("source", $sourceText);
-
- // Let Join Date stay default
-
- // fill in Start Date
- $this->webtestFillDate('start_date');
-
- // Clicking save.
- $this->click("_qf_Membership_upload");
- $this->waitForElementPresent('crm-notification-container');
- // page was loaded
- $this->waitForTextPresent($sourceText);
- // Is status message correct?
- $this->waitForText('crm-notification-container', "membership for $orgnaizationName has been added.");
-
- // add relationship "Employer of"
- // click through to the relationship view screen
- $this->waitForAjaxContent();
- $this->click("css=li#tab_rel a");
-
- // wait for add Relationship link
- $this->waitForElementPresent('link=Add Relationship');
- $this->click('link=Add Relationship');
-
- //choose the created relationship type
- $this->waitForElementPresent("relationship_type_id");
- $this->select('relationship_type_id', "value=5_b_a");
-
- //fill in the individual
- $this->waitForElementPresent('related_contact_id');
- $this->select2('related_contact_id', $sortName, TRUE, FALSE);
-
- $this->waitForElementPresent("_qf_Relationship_upload");
-
- //fill in the relationship start date
- //$this->webtestFillDate('start_date', '-2 year');
- //$this->webtestFillDate('end_date', '+1 year');
-
- $description = "Well here is some description !!!!";
- $this->type("description", $description);
-
- //save the relationship
- $this->click("_qf_Relationship_upload");
- $this->isTextPresent("Current Relationships");
-
- //check the status message
- $this->waitForText('crm-notification-container', "Relationship created.");
- $this->waitForElementPresent("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[9]/span/a[text()='View']");
- $this->waitForAjaxContent();
- $this->click("xpath=//a[text()='$sortName']");
- $this->waitForAjaxContent();
-
- // Check if Membership for the individual is created
- $this->waitForElementPresent("xpath=//li[@id='tab_member']/a/em");
- $this->verifyText("xpath=//li[@id='tab_member']/a/em", 1);
-
- //create a New Individual to be related to duplicate organization
- $firstNameOther = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstNameOther, "Harmison", "$firstNameOther@harmison.name");
- $sortNameOther = "Harmison, $firstNameOther";
-
- // go to main organization contact to add membership
- $this->openCiviPage("contact/view", "reset=1&cid={$contactIds['duplicateId']}");
-
- // add relationship "Employer of"
- // click through to the relationship view screen
- $this->waitForAjaxContent();
- $this->click("css=li#tab_rel a");
-
- // wait for add Relationship link
- $this->waitForElementPresent('link=Add Relationship');
- $this->click('link=Add Relationship');
-
- //choose the created relationship type
- $this->waitForElementPresent("relationship_type_id");
- $this->select('relationship_type_id', "value=5_b_a");
-
- //fill in the individual
- $this->waitForElementPresent('related_contact_id');
- $this->select2('related_contact_id', $sortNameOther, TRUE, FALSE);
-
- $this->waitForElementPresent("_qf_Relationship_upload");
-
- //fill in the relationship start date
- $this->webtestFillDate('start_date', '-2 year');
- $this->webtestFillDate('end_date', '+1 year');
-
- $description = "Well here is some description !!!!";
- $this->type("description", $description);
-
- //save the relationship
- //$this->click("_qf_Relationship_upload");
- $this->click("_qf_Relationship_upload");
- $this->isTextPresent("Current Relationships");
-
- //check the status message
- $this->isTextPresent("Relationship created.");
-
- $this->waitForElementPresent("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[9]/span/a[text()='View']");
-
- // go directly to contact merge page.
- $this->openCiviPage("contact/merge", "reset=1&cid={$contactIds['mainId']}&oid={$contactIds['duplicateId']}&action=update&rgid=2");
-
- $this->waitForElementPresent('_qf_Merge_cancel-bottom');
- $this->click('_qf_Merge_next-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // click through to the relationship view screen
- $this->waitForAjaxContent();
- $this->click("css=li#tab_rel a");
-
- // wait for add Relationship link
- $this->waitForElementPresent("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody//tr//td//a[text()='$sortName']");
- // go to duplicate organization's related contact
- // to check if membership is added to that contact
- $this->click("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody//tr//td//a[text()='$sortName']");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Check if Membership for the individual is created
- $this->waitForElementPresent("xpath=//li[@id='tab_member']/a/em");
- $this->verifyText("xpath=//li[@id='tab_member']/a/em", 0);
- }
-
- /**
- * Test for CRM-15658 fix
- */
- public function testMergeEmailAndAddress() {
- $this->webtestLogin();
- $this->openCiviPage("contact/add", "reset=1&ct=Individual");
- $firstName = substr(sha1(rand()), 0, 7);
- $this->type('first_name', $firstName);
-
- //fill in last name
- $lastName = substr(sha1(rand()), 0, 7);
- $this->type('last_name', $lastName);
-
- //fill in email id
- $this->type('email_1_email', "{$firstName}.{$lastName}@example.com");
-
- //address section
- $this->click("addressBlock");
- $this->waitForElementPresent("address_1_street_address");
- $this->type("address_1_street_address", "902C El Camino Way SW");
- $this->type("address_1_city", "Dumfries");
- $this->type("address_1_postal_code", "1234");
-
- // Clicking save.
- $this->click("_qf_Contact_upload_view");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForText('crm-notification-container', "Contact Saved");
-
- //duplicate contact with same email id
- $this->openCiviPage("contact/add", "reset=1&ct=Individual");
- $firstName2 = substr(sha1(rand()), 0, 7);
- $this->type('first_name', $firstName2);
-
- //fill in last name
- $lastName2 = substr(sha1(rand()), 0, 7);
- $this->type('last_name', $lastName2);
-
- //fill in email id
- $this->type('email_1_email', "{$firstName}.{$lastName}@example.com");
-
- //address section
- $this->click("addressBlock");
- $this->waitForElementPresent("address_1_street_address");
- $this->type("address_1_street_address", "2782Y Dowlen Path W");
- $this->type("address_1_city", "Birmingham");
- $this->type("address_1_postal_code", "3456");
-
- // Clicking save.
- $this->click("_qf_Contact_upload_view");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForText('crm-notification-container', "Contact Saved");
-
- $this->openCiviPage("contact/dedupefind", "reset=1&action=update&rgid=4");
- $this->click("//a/span[contains(text(),'Refresh Duplicates')]");
- $this->assertTrue((bool) preg_match("/This will refresh the duplicates list. Click OK to proceed./", $this->getConfirmation()));
- $this->chooseOkOnNextConfirmation();
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForElementPresent("xpath=//table[@id='dupePairs']/tbody//tr/td[3]/a[text()='$firstName $lastName']/../../td[8]//a[text()='merge']");
- $this->click("xpath=//table[@id='dupePairs']/tbody//tr/td[3]/a[text()='$firstName $lastName']/../../td[8]//a[text()='merge']");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- //merge without specifying any criteria
- $this->click("_qf_Merge_next-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->assertTrue($this->isTextPresent('Contacts Merged'));
- $this->assertTrue($this->isElementPresent("xpath=//div[@id='email-block']/div/div/div[2]/div[1][contains(text(), 'Home')]"));
- $this->verifyElementNotPresent("xpath=//div[@id='email-block']/div/div/div[3]/div[1][contains(text(), 'Home')]");
- $this->assertTrue($this->isElementPresent("xpath=//div[@id='email-block']/div/div/div[2]/div[2]/a[contains(text(), '{$firstName}.{$lastName}@example.com')]"));
- $this->verifyElementNotPresent("xpath=//div[@id='email-block']/div/div/div[3]/div[2]/a[contains(text(), '{$firstName}.{$lastName}@example.com')]");
-
- $this->assertElementContainsText('address-block-1', "902C El Camino Way SW");
- $this->assertElementContainsText('address-block-1', "Dumfries");
- $this->assertElementContainsText('address-block-1', "1234");
-
- $this->assertElementNotContainsText("address-block-2", "2782Y Dowlen Path W");
- $this->assertElementNotContainsText("address-block-2", "Birmingham");
- $this->assertElementNotContainsText("address-block-2", "3456");
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Contact_MultipleContactSubTypes
- */
-class WebTest_Contact_MultipleContactSubTypes extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testIndividualAdd() {
- $this->webtestLogin();
-
- $selection1 = 'Student';
- $selection2 = 'Parent';
- $selection3 = 'Staff';
-
- //Create custom group for contact sub-types
- list($groupTitleForStudent, $customGroupIdForStudent) = $this->_addCustomData($selection1);
- list($groupTitleForParent, $customGroupIdForParent) = $this->_addCustomData($selection2);
- list($groupTitleForStaff, $customGroupIdForStaff) = $this->_addCustomData($selection3);
-
- $this->openCiviPage("contact/add", "reset=1&ct=Individual");
-
- //contact details section
- //select prefix
- $this->click("prefix_id");
- $this->select("prefix_id", "value=" . $this->webtestGetFirstValueForOptionGroup('individual_prefix'));
-
- $this->addSelection('contact_sub_type', "value={$selection1}");
- $this->addSelection('contact_sub_type', "value={$selection2}");
-
- //fill in first name
- $this->type("first_name", substr(sha1(rand()), 0, 7) . "John");
-
- //fill in middle name
- $this->type("middle_name", "Bruce");
-
- //fill in last name
- $this->type("last_name", substr(sha1(rand()), 0, 7) . "Smith");
-
- //select suffix
- $this->select("suffix_id", "value=3");
-
- //fill in nick name
- $this->type("nick_name", "jsmith");
-
- //fill in email
- $this->type("email_1_email", substr(sha1(rand()), 0, 7) . "john@gmail.com");
-
- //fill in phone
- $this->type("phone_1_phone", "2222-4444");
-
- //fill in IM
- $this->type("im_1_name", "testYahoo");
-
- //fill in website
- $this->type("website_1_url", "http://www.john.com");
-
- //fill in source
- $this->type("contact_source", "johnSource");
-
- //fill in external identifier
- $indExternalId = substr(sha1(rand()), 0, 4);
- $this->type("external_identifier", $indExternalId);
-
- $this->waitForElementPresent("customData$customGroupIdForStudent");
- $this->waitForElementPresent("customData$customGroupIdForParent");
-
- // Make sure our staff custom set does NOT show up
- $this->assertFalse($this->isElementPresent("customData$customGroupIdForStaff"), "A custom field showed up for the wrong subtype!");
-
- $this->type("xpath=//div[@id='customData{$customGroupIdForStudent}']/table/tbody/tr//td/input", "dummy text for customData{$customGroupIdForStudent}");
- $this->type("xpath=//div[@id='customData{$customGroupIdForParent}']/table/tbody/tr//td/input", "dummy text for customData{$customGroupIdForParent}");
-
- //address section
- $this->click("addressBlock");
- $this->waitForElementPresent("address_1_street_address");
- //fill in address 1
- $this->type("address_1_street_address", "902C El Camino Way SW");
- $this->type("address_1_city", "Dumfries");
- $this->type("address_1_postal_code", "1234");
-
- $this->click("address_1_country_id");
- $this->select("address_1_country_id", "value=" . $this->webtestGetValidCountryID());
-
- if ($this->isElementPresent("address_1_geo_code_1")) {
- $this->type("address_1_geo_code_1", "1234");
- $this->type("address_1_geo_code_2", "5678");
- }
-
- //fill in address 2
- $this->click("//div[@id='addMoreAddress1']/a/span");
- $this->waitForElementPresent("address_2_street_address");
- $this->type("address_2_street_address", "2782Y Dowlen Path W");
- $this->type("address_2_city", "Birmingham");
- $this->type("address_2_postal_code", "3456");
-
- $this->click("address_2_country_id");
- $this->select("address_2_country_id", "value=" . $this->webtestGetValidCountryID());
-
- if ($this->isElementPresent("address_2_geo_code_1")) {
- $this->type("address_2_geo_code_1", "1234");
- $this->type("address_2_geo_code_2", "5678");
- }
-
- //Communication Preferences section
- $this->click("//div[@class='crm-accordion-header' and contains(.,'Communication Preferences')]");
-
- //select greeting/addressee options
- $this->waitForElementPresent("email_greeting_id");
- $this->select("email_greeting_id", "value=2");
- $this->select("postal_greeting_id", "value=3");
-
- //Select preferred method for Privacy
- $this->click("privacy[do_not_trade]");
- $this->click("privacy[do_not_sms]");
-
- //Select preferred method(s) of communication
- $this->click("preferred_communication_method[1]");
- $this->click("preferred_communication_method[2]");
-
- //select preferred language
- $this->waitForElementPresent("preferred_language");
- $this->select("preferred_language", "value=en_US");
-
- //Demographics section
- $this->click("//div[@class='crm-accordion-header' and contains(.,'Demographics')]");
- $this->waitForElementPresent("birth_date");
-
- $this->webtestFillDate('birth_date', "-1 year");
-
- //Tags and Groups section
- $this->click("//div[@class='crm-accordion-header' and contains(.,'Tags and Groups')]");
-
- $this->click("group[{$this->webtestGetValidEntityID('Group')}]");
- $this->click("tag[{$this->webtestGetValidEntityID('Tag')}]");
-
- // Clicking save.
- $this->click("_qf_Contact_upload_view");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- //checking the contact sub-type of newly created individual
- $this->waitForText('crm-notification-container', "Contact Saved");
- $this->assertElementContainsText('css=.crm-contact_type_label', "Student");
- $this->assertElementContainsText('css=.crm-contact_type_label', "Parent");
-
- //custom data check
- $this->waitForText("custom-set-content-{$customGroupIdForParent}", "dummy text for customData{$customGroupIdForParent}");
- $this->waitForText("custom-set-content-{$customGroupIdForStudent}", "dummy text for customData{$customGroupIdForStudent}");
-
- // Get contact id
- $cid = $this->urlArg('cid');
-
- //editing contact sub-type
- $this->openCiviPage('contact/add', "reset=1&action=update&cid=$cid");
-
- //edit contact sub-type
- $this->removeSelection("contact_sub_type", "value={$selection1}");
- $this->addSelection('contact_sub_type', "value={$selection3}");
-
- $this->waitForElementPresent("customData$customGroupIdForStaff");
-
- // Make sure our staff custom set does NOT show up
- $this->assertFalse($this->isElementPresent("customData$customGroupIdForStudent"), "A custom field showed up for the wrong subtype!");
-
- $this->type("xpath=//div[@id='customData{$customGroupIdForParent}']/table/tbody/tr//td/input", "dummy text for customData{$customGroupIdForParent}");
- $this->type("xpath=//div[@id='customData{$customGroupIdForStaff}']/table/tbody/tr//td/input", "dummy text for customData{$customGroupIdForStaff}");
-
- $this->click("_qf_Contact_upload_view-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Check confirmation alert.
- $this->assertTrue((bool) preg_match("/One or more contact subtypes have been de-selected from the list for this contact. Any custom data associated with de-selected subtype will be removed. Click OK to proceed, or Cancel to review your changes before saving./", $this->getConfirmation()));
- $this->chooseOkOnNextConfirmation();
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Verify contact types
- $this->waitForText('crm-notification-container', "Contact Saved");
- $this->assertElementNotContainsText('css=.crm-contact_type_label', "Student");
- $this->assertElementContainsText('css=.crm-contact_type_label', "Staff");
- $this->assertElementContainsText('css=.crm-contact_type_label', "Parent");
-
- //custom data check
- $this->waitForText("custom-set-content-{$customGroupIdForParent}", "dummy text for customData{$customGroupIdForParent}");
- $this->waitForText("custom-set-content-{$customGroupIdForStaff}", "dummy text for customData{$customGroupIdForStaff}");
- }
-
- /**
- * Add custom fields for a contact sub-type
- * @param $contactSubType
- * @return array
- */
- public function _addCustomData($contactSubType) {
- $this->openCiviPage("admin/custom/group", "action=add&reset=1");
-
- //fill custom group title
- $customGroupTitle = "Custom group For {$contactSubType}" . substr(sha1(rand()), 0, 4);
- $this->click("title");
- $this->type("title", $customGroupTitle);
-
- //custom group extends
- $this->click("extends_0");
- $this->select("extends_0", "value=Individual");
- $this->addSelection("extends_1", "label={$contactSubType}");
-
- // Don't collapse
- $this->uncheck('collapse_display');
-
- // Save
- $this->click('_qf_Group_next-bottom');
- $this->waitForElementPresent('_qf_Field_cancel-bottom');
-
- //Is custom group created?
- $this->waitForText('crm-notification-container', "Your custom field set '{$customGroupTitle}' has been added.");
- $gid = $this->urlArg('gid');
-
- // Add field
- $this->openCiviPage('admin/custom/group/field/add', "reset=1&action=add&gid=$gid");
- $fieldLabel = "custom_field_for_{$contactSubType}" . substr(sha1(rand()), 0, 4);
- $this->type('label', $fieldLabel);
- $this->click('_qf_Field_done-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $customGroupTitle = preg_replace('/\s/', '_', trim($customGroupTitle));
- return array($customGroupTitle, $gid);
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Contact_PrevNextTest
- */
-class WebTest_Contact_PrevNextTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testPrevNext() {
- $this->webtestLogin();
-
- /* add new group */
-
- $this->openCiviPage('group/add', 'reset=1', '_qf_Edit_upload');
-
- $groupName = 'group_' . substr(sha1(rand()), 0, 7);
- $this->type("title", $groupName);
-
- // fill description
- $this->type("description", "Adding new group.");
-
- // check Access Control
- $this->click("group_type[1]");
-
- // Clicking save.
- $this->click("_qf_Edit_upload");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- /* add contacts */
-
- // Individual 1
- $contact1 = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($contact1, "AAA", "{$contact1}@example.com");
-
- // Add Individual 1 to group
- $this->click('css=li#tab_group a');
- $this->waitForElementPresent('_qf_GroupContact_next');
- $this->select('group_id', "label={$groupName}");
- $this->click('_qf_GroupContact_next');
- $this->waitForText('crm-notification-container', "Added to Group");
-
- // Individual 2
- $contact2 = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($contact2, "BBB", "{$contact2}@example.com");
-
- // Add Individual 2 to group
- $this->click('css=li#tab_group a');
- $this->waitForElementPresent('_qf_GroupContact_next');
- $this->select('group_id', "label={$groupName}");
- $this->click('_qf_GroupContact_next');
- $this->waitForText('crm-notification-container', "Added to Group");
-
- // Individual 3
- $contact3 = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($contact3, "CCC", "{$contact3}@example.com");
-
- // Add Individual 3 to group
- $this->click('css=li#tab_group a');
- $this->waitForElementPresent('_qf_GroupContact_next');
- $this->select('group_id', "label={$groupName}");
- $this->click('_qf_GroupContact_next');
- $this->waitForText('crm-notification-container', "Added to Group");
-
- // Search contacts
- $this->openCiviPage('contact/search', 'reset=1', '_qf_Basic_refresh');
-
- $this->select('group', "label={$groupName}");
- $this->click("_qf_Basic_refresh");
- $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
- $this->assertElementContainsText('search-status', "3 Contacts");
-
- $this->click("xpath=//div[@class='crm-search-results']//table/tbody/tr[1]/td[3]/a");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->assertElementContainsText('css=div.crm-summary-display_name', "{$contact1} AAA");
- $this->assertElementContainsText('css=li.crm-next-action a span', "Next");
-
- $this->click("xpath=//ul[@id='actions']/li[@class='crm-next-action']/a");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->assertElementContainsText('css=div.crm-summary-display_name', "{$contact2} BBB");
- $this->assertElementContainsText('css=li.crm-next-action a span', "Next");
- $this->assertElementContainsText('css=li.crm-previous-action a span', "Previous");
-
- $this->click("xpath=//ul[@id='actions']/li[@class='crm-next-action']/a");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->assertElementContainsText('css=div.crm-summary-display_name', "{$contact3} CCC");
- $this->assertElementContainsText('css=li.crm-previous-action a span', "Previous");
-
- $this->click("xpath=//ul[@id='actions']/li[@class='crm-previous-action']/a");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->assertElementContainsText('css=div.crm-summary-display_name', "{$contact2} BBB");
- $this->assertElementContainsText('css=li.crm-next-action a span', "Next");
- $this->assertElementContainsText('css=li.crm-previous-action a span', "Previous");
-
- $this->click("xpath=//ul[@id='actions']/li[@class='crm-previous-action']/a");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->assertElementContainsText('css=div.crm-summary-display_name', "{$contact1} AAA");
- $this->assertElementContainsText('css=li.crm-next-action a span', "Next");
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Contact_PrivacyOptionSearchTest
- */
-class WebTest_Contact_PrivacyOptionSearchTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testPrivacyOptionSearch() {
- $this->webtestLogin();
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Add new group.
- $this->openCiviPage('group/add', 'reset=1', "_qf_Edit_upload");
-
- $groupName = 'group_' . substr(sha1(rand()), 0, 7);
- $this->type("title", $groupName);
-
- // Fill description.
- $this->type("description", "Adding new group.");
-
- // Check Access Control.
- $this->click("group_type[1]");
-
- // Clicking save.
- $this->click("_qf_Edit_upload");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Add Contact1.
- $fname1 = substr(sha1(rand()), 0, 7);
- $lname1 = substr(sha1(rand()), 0, 7);
- $this->openCiviPage("contact/add", "reset=1&ct=Individual", '_qf_Contact_upload_view-bottom');
- $this->type('first_name', $fname1);
- $this->type('last_name', $lname1);
- $email1 = $fname1 . '@example.org';
- $this->type('email_1_email', $email1);
-
- //click 'Communication Preferences' Panel
- $this->click("commPrefs");
- $this->waitForElementPresent("preferred_mail_format");
- $this->click("privacy_do_not_phone");
- $this->click("privacy_do_not_email");
- $this->click("privacy_do_not_mail");
- $this->click("privacy_do_not_sms");
-
- $this->click('_qf_Contact_upload_view-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Add contact to the group.
- $this->click("css=li#tab_group a");
- $this->waitForElementPresent("group_id");
- $this->select("group_id", "label=$groupName");
- $this->click("_qf_GroupContact_next");
-
- // Add Contact2.
- $fname2 = substr(sha1(rand()), 0, 7);
- $lname2 = substr(sha1(rand()), 0, 7);
- $this->openCiviPage("contact/add", "reset=1&ct=Individual", '_qf_Contact_upload_view-bottom');
- $this->type('first_name', $fname2);
- $this->type('last_name', $lname2);
- $email2 = $fname2 . '@example.org';
- $this->type('email_1_email', $email2);
-
- //click 'Communication Preferences' Panel
- $this->click("commPrefs");
- $this->waitForElementPresent("preferred_mail_format");
- $this->click("privacy_do_not_phone");
- $this->click("privacy_do_not_email");
- $this->click("privacy_do_not_trade");
-
- $this->click('_qf_Contact_upload_view-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Add contact to the group.
- $this->click("css=li#tab_group a");
- $this->waitForElementPresent("group_id");
- $this->select("group_id", "label=$groupName");
- $this->click("_qf_GroupContact_next");
-
- // Go to advance search, check for 'Exclude' option.
- $this->openCiviPage("contact/search/advanced", "reset=1");
-
- $this->select("group", "label={$groupName}");
- $this->waitForTextPresent($groupName);
-
- $this->multiselect2('privacy_options', array('Do not phone', 'Do not email'));
-
- $this->click("_qf_Advanced_refresh");
- $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
-
- $this->assertTrue($this->isTextPresent("None found."));
-
- // Go to advance search, check for 'Include' + 'OR' options.
- $this->openCiviPage("contact/search/advanced", "reset=1");
-
- $this->select("group", "label={$groupName}");
- $this->waitForTextPresent($groupName);
-
- $this->click("CIVICRM_QFID_2_privacy_toggle");
-
- $this->multiselect2('privacy_options', array('Do not phone', 'Do not email'));
-
- $this->click("_qf_Advanced_refresh");
- $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
- $this->assertTrue($this->isTextPresent("2 Contacts"));
- $this->assertTrue($this->isTextPresent("$lname1, $fname1"));
- $this->assertTrue($this->isTextPresent("$lname2, $fname2"));
-
- // Go to advance search, check for 'Include' + 'AND' options.
- $this->openCiviPage("contact/search/advanced", "reset=1");
-
- $this->select("group", "label={$groupName}");
- $this->waitForTextPresent($groupName);
-
- $this->click("CIVICRM_QFID_2_privacy_toggle");
-
- $this->multiselect2('privacy_options', array('Do not phone', 'Do not trade'));
-
- $this->select('privacy_operator', 'value=AND');
-
- $this->click("_qf_Advanced_refresh");
- $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
- $this->assertTrue($this->isTextPresent("1 Contact"));
- $this->assertTrue($this->isTextPresent("$lname2, $fname2"));
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Contact_ProfileChecksumTest
- */
-class WebTest_Contact_ProfileChecksumTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testProfileChecksum() {
- $this->webtestLogin('admin');
-
- // Profile fields.
- $fields = array(
- 'first_name' => array(
- 'type' => 'Individual',
- 'label' => 'First Name',
- 'default_value' => substr(sha1(rand()), 0, 7),
- 'update_value' => substr(sha1(rand()), 0, 7),
- 'element_name' => 'first_name',
- ),
- 'last_name' => array(
- 'type' => 'Individual',
- 'label' => 'Last Name',
- 'default_value' => substr(sha1(rand()), 0, 7),
- 'update_value' => substr(sha1(rand()), 0, 7),
- 'element_name' => 'last_name',
- ),
- 'email' => array(
- 'type' => 'Contact',
- 'label' => 'Email',
- 'location' => 0,
- 'default_value' => substr(sha1(rand()), 0, 5) . '@example.com',
- 'update_value' => substr(sha1(rand()), 0, 7) . '@example.com',
- 'element_name' => 'email-Primary',
- ),
- 'city' => array(
- 'type' => 'Contact',
- 'label' => 'City',
- 'location' => 0,
- 'default_value' => substr(sha1(rand()), 0, 7),
- 'update_value' => substr(sha1(rand()), 0, 7),
- 'element_name' => 'city-Primary',
- ),
- 'country' => array(
- 'type' => 'Contact',
- 'label' => 'Country',
- 'location' => 0,
- 'default_value' => '1228',
- 'update_value' => '1228',
- 'update_value_label' => 'UNITED STATES',
- 'element_name' => 'country-Primary',
- 'html_type' => 'select',
- ),
- 'state_province' => array(
- 'type' => 'Contact',
- 'label' => 'State',
- 'location' => 0,
- 'default_value' => '1004',
- 'update_value' => '1031',
- 'update_value_label' => 'NY',
- 'element_name' => 'state_province-Primary',
- 'html_type' => 'select',
- ),
- );
-
- // Create a contact.
- $this->webtestAddContact($fields['first_name']['default_value'], $fields['last_name']['default_value'], $fields['email']['default_value']);
-
- // Get contact id from url.
- $contactId = $this->urlArg('cid');
-
- // Create profile for contact
- $profileName = "Profile_" . substr(sha1(rand()), 0, 7);
- $profileId = $this->_testCreateContactProfile($fields, $profileName);
-
- // Check for profile create/edit permissions.
- $permission = array(
- 'edit-1-profile-edit',
- 'edit-1-profile-create',
- 'edit-1-access-all-custom-data',
- 'edit-1-edit-all-contacts',
- );
- $this->changePermissions($permission);
-
- // Get checksum of the newly created contact.
- $cs = CRM_Contact_BAO_Contact_Utils::generateChecksum($contactId);
-
- // logout.
- $this->webtestLogout();
-
- // Go to edit profile page of the created contact.
- $this->openCiviPage("profile/edit", "id={$contactId}&gid={$profileId}&reset=1&cs={$cs}", NULL);
- $this->waitForTextPresent($profileName);
-
- // Check all profile fields, update their values.
- foreach ($fields as $field) {
- $this->assertTrue($this->isElementPresent($field['element_name']), "Missing Field: {$field['label']}.");
- if (isset($field['html_type']) && $field['html_type'] == 'select') {
- $this->waitForElementPresent($field['element_name']);
- $this->select($field['element_name'], "value={$field['update_value']}");
- }
- else {
- $this->type($field['element_name'], $field['update_value']);
- }
- }
- // Save profile.
- $this->click("_qf_Edit_next");
- $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
-
- // Check profile view page.
- $this->waitForTextPresent($profileName);
-
- // Check updated values of all fields.
- $checkFieldValues = array();
- foreach ($fields as $field) {
- $checkFieldValues[] = isset($field['update_value_label']) ? $field['update_value_label'] : $field['update_value'];
- }
- $this->assertStringsPresent($checkFieldValues);
- }
-
- /**
- * @param $fields
- * @param string $profileName
- *
- * @return null
- */
- public function _testCreateContactProfile($fields, $profileName) {
- // Add new profile.
- $this->openCiviPage("admin/uf/group", "reset=1");
- $this->click('newCiviCRMProfile-top');
- $this->waitForElementPresent('_qf_Group_next-top');
-
- // Name of the profile.
- $this->type('title', $profileName);
- $this->click('uf_group_type_Profile');
- $this->click('_qf_Group_next-top');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $profileId = $this->urlArg('gid');
-
- // Add field to the profile.
- foreach ($fields as $key => $values) {
- $this->openCiviPage("admin/uf/group/field/add", "reset=1&action=add&gid=$profileId");
-
- $this->select("field_name[0]", "value={$values['type']}");
- // Because it tends to cause problems, all uses of sleep() must be justified in comments
- // Sleep should never be used for wait for anything to load from the server
- // Justification for this instance: FIXME
- sleep(1);
- $this->select("field_name[1]", "value={$key}");
- if (isset($values['location'])) {
- // Because it tends to cause problems, all uses of sleep() must be justified in comments
- // Sleep should never be used for wait for anything to load from the server
- // Justification for this instance: FIXME
- sleep(1);
- $this->select("field_name[2]", "value={$values['location']}");
- }
- $this->type("label", $values['label']);
- $this->click('_qf_Field_next-top');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- }
- return $profileId;
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Contact_RelationshipAddTest
- */
-class WebTest_Contact_RelationshipAddTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testRelationshipAddTest() {
- $this->webtestLogin();
-
- //create a relationship type between different contact types
- $params = array(
- 'label_a_b' => 'Owner of ' . rand(),
- 'label_b_a' => 'Belongs to ' . rand(),
- 'contact_type_a' => 'Individual',
- 'contact_type_b' => 'Household',
- 'description' => 'The company belongs to this individual',
- );
-
- $this->webtestAddRelationshipType($params);
-
- //create a New Individual
- $firstName = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName, "Anderson", "$firstName@anderson.name");
- $sortName = "Anderson, $firstName";
-
- $this->openCiviPage("contact/add", "reset=1&ct=Household");
-
- //fill in Household name
- $this->click("household_name");
- $name = "Fraddie Grant's home " . substr(sha1(rand()), 0, 7);
- $this->type("household_name", $name);
-
- // Clicking save.
- $this->click("_qf_Contact_upload_view");
- $this->waitForElementPresent("css=.crm-contact-tabs-list");
-
- // visit relationship tab of the household
- $this->click("css=li#tab_rel a");
-
- // wait for add Relationship link
- $this->waitForElementPresent('link=Add Relationship');
- $this->click('link=Add Relationship');
-
- //choose the created relationship type
- $this->waitForElementPresent("relationship_type_id");
- $this->select('relationship_type_id', "label={$params['label_b_a']}");
-
- //fill in the individual
- $this->select2('related_contact_id', $sortName, TRUE);
-
- //fill in the relationship start date
- $this->webtestFillDate('start_date', '-2 year');
- $this->webtestFillDate('end_date', '+1 year');
-
- $description = "Well here is some description !!!!";
- $this->type("description", $description);
-
- //save the relationship
- //$this->click("_qf_Relationship_upload");
- $this->click('_qf_Relationship_upload-bottom');
-
- //check the status message
- $this->waitForText('crm-notification-container', 'Relationship created.');
- $this->waitForElementPresent("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[9]//span//a[text()='View']");
- $this->click("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[9]//span//a[text()='View']");
-
- $this->webtestVerifyTabularData(
- array(
- 'Description' => $description,
- 'Status' => 'Enabled',
- )
- );
-
- $this->assertTrue($this->isTextPresent($params['label_b_a']));
-
- //create a New Individual subtype
- $this->openCiviPage('admin/options/subtype', "action=add&reset=1");
- $label = "IndividualSubtype" . substr(sha1(rand()), 0, 4);
- $this->type("label", $label);
- $this->type("description", "here is individual subtype");
- $this->click("_qf_ContactType_next-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- //create a new contact of individual subtype
- $this->openCiviPage('contact/add', "ct=Individual&cst={$label}&reset=1", '_qf_Contact_upload_view');
- $firstName = substr(sha1(rand()), 0, 7);
- $lastName = 'And' . substr(sha1(rand()), 0, 7);
- $this->click("first_name");
- $this->type("first_name", $firstName);
- $this->click("last_name");
- $this->type("last_name", $lastName);
- $sortName = "$lastName, $firstName";
-
- // Clicking save.
- $this->click("_qf_Contact_upload_view");
- $this->waitForElementPresent("css=.crm-contact-tabs-list");
-
- //create a New household subtype
- $this->openCiviPage("admin/options/subtype", "action=add&reset=1");
-
- $label = "HouseholdSubtype" . substr(sha1(rand()), 0, 4);
- $householdSubtypeName = $label;
- $this->click("label");
- $this->type("label", $label);
- $this->select("parent_id", "label=Household");
- $this->type("description", "here is household subtype");
- $this->click("_qf_ContactType_next-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- //create a new contact of household subtype
- $this->openCiviPage('contact/add', "ct=Household&cst={$label}&reset=1", '_qf_Contact_upload_view');
-
- //fill in Household name
- $householdName = substr(sha1(rand()), 0, 4) . 'home';
- $this->click("household_name");
- $this->type("household_name", $householdName);
-
- // Clicking save.
- $this->click("_qf_Contact_upload_view");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- //choose the created relationship type
- $this->click('css=li#tab_rel a');
-
- // wait for add Relationship link
- $this->waitForElementPresent('link=Add Relationship');
- $this->click('link=Add Relationship');
- $this->waitForElementPresent("relationship_type_id");
- $this->select('relationship_type_id', "label={$params['label_b_a']}");
-
- //fill in the individual
- $this->waitForElementPresent("related_contact_id");
- $this->select2('related_contact_id', $sortName, TRUE);
-
- //fill in the relationship start date
- $this->webtestFillDate('start_date', '-2 year');
- $this->webtestFillDate('end_date', '+1 year');
-
- $description = "Well here is some description !!!!";
- $this->type("description", $description);
-
- //save the relationship
- $this->click('_qf_Relationship_upload-bottom');
-
- $this->waitForElementPresent("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[9]//span//a[text()='View']");
- $this->click("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[9]//span//a[text()='View']");
-
- $this->webtestVerifyTabularData(
- array(
- 'Description' => $description,
- 'Status' => 'Enabled',
- )
- );
-
- $this->assertTrue($this->isTextPresent($params['label_b_a']));
-
- //test for individual contact and household subtype contact
- //relationship
- $typeb = "Household__" . $householdSubtypeName;
-
- //create a relationship type between different contact types
- $params = array(
- 'label_a_b' => 'Owner of ' . rand(),
- 'label_b_a' => 'Belongs to ' . rand(),
- 'contact_type_a' => 'Individual',
- 'contact_type_b' => $typeb,
- 'description' => 'The company belongs to this individual',
- );
-
- //create relationship type
- $this->openCiviPage('admin/reltype', 'reset=1&action=add');
- $this->type('label_a_b', $params['label_a_b']);
- $this->type('label_b_a', $params['label_b_a']);
- $this->select('contact_types_a', "value={$params['contact_type_a']}");
- $this->select('contact_types_b', "value={$params['contact_type_b']}");
- $this->type('description', $params['description']);
-
- $params['contact_type_b'] = preg_replace('/__/', ' - ', $params['contact_type_b']);
-
- //save the data.
- $this->click('_qf_RelationshipType_next-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- //does data saved.
- $this->assertTrue($this->isTextPresent('The Relationship Type has been saved.'),
- "Status message didn't show up after saving!"
- );
-
- $this->openCiviPage("admin/reltype", "reset=1");
-
- //validate data on selector.
- $data = $params;
- if (isset($data['description'])) {
- unset($data['description']);
- }
- $this->assertStringsPresent($data);
-
- //create a New Individual
- $firstName = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName, "Anderson", "$firstName@anderson.name");
- $sortName = "Anderson, $firstName";
-
- //create a new contact of household subtype
- $this->openCiviPage('contact/add', "ct=Household&cst={$householdSubtypeName}&reset=1", '_qf_Contact_upload_view');
-
- //fill in Household name
- $householdName = substr(sha1(rand()), 0, 4) . 'home';
- $this->click("household_name");
- $this->type("household_name", $householdName);
-
- // Clicking save.
- $this->click("_qf_Contact_upload_view");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- //choose the created relationship type
- $this->click('css=li#tab_rel a');
-
- // wait for add Relationship link
- $this->waitForElementPresent('link=Add Relationship');
- $this->click('link=Add Relationship');
- $this->waitForElementPresent("relationship_type_id");
- $this->select('relationship_type_id', "label={$params['label_b_a']}");
-
- //fill in the individual
-
- $this->select2('related_contact_id', $sortName, TRUE);
-
- //fill in the relationship start date
- $this->webtestFillDate('start_date', '-2 year');
- $this->webtestFillDate('end_date', '+1 year');
- $description = "Well here is some description !!!!";
- $this->type("description", $description);
-
- //save the relationship
- $this->click('_qf_Relationship_upload-bottom');
-
- $this->waitForElementPresent("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[9]//span//a[text()='View']");
- $this->click("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[9]//span//a[text()='View']");
-
- $this->webtestVerifyTabularData(
- array(
- 'Description' => $description,
- 'Status' => 'Enabled',
- )
- );
-
- $this->assertTrue($this->isTextPresent($params['label_b_a']));
- }
-
- public function testRelationshipAddNewIndividualTest() {
- $this->webtestLogin();
-
- //create a relationship type between different contact types
- $params = array(
- 'label_a_b' => 'Board Member of ' . rand(),
- 'label_b_a' => 'Board Member is' . rand(),
- 'contact_type_a' => 'Individual',
- 'contact_type_b' => 'Organization',
- 'description' => 'Board members of organizations.',
- );
-
- $this->webtestAddRelationshipType($params);
-
- //create a New Individual
- $firstName = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName, "Anderson", "$firstName@anderson.name");
-
- // visit relationship tab of the Individual
- $this->click("css=li#tab_rel a");
-
- // wait for add Relationship link
- $this->waitForElementPresent('link=Add Relationship');
- $this->click('link=Add Relationship');
-
- //choose the created relationship type
- $this->waitForElementPresent("relationship_type_id");
- $this->select('relationship_type_id', "label={$params['label_a_b']}");
- $this->waitForAjaxContent();
-
- // create a new organization
- $orgName = 'WestsideCoop' . substr(sha1(rand()), 0, 7);
-
- $this->click("//*[@id='related_contact_id']/../div/ul/li/input");
- $this->click("xpath=//li[@class='select2-no-results']//a[contains(text(),' New Organization')]");
- $this->waitForElementPresent('_qf_Edit_next');
- $this->type('organization_name', $orgName);
- $this->type('email-Primary', "info@" . $orgName . ".com");
- $this->click('_qf_Edit_next');
- $this->waitForText("xpath=//div[@id='s2id_related_contact_id']", "$orgName");
-
- //fill in the relationship start date
- $this->webtestFillDate('start_date', '-2 year');
- $this->webtestFillDate('end_date', '+1 year');
-
- $description = "Long-standing board member.";
- $this->type("description", $description);
-
- //save the relationship
- //$this->click("_qf_Relationship_upload");
- $this->click("_qf_Relationship_upload-bottom");
-
- //check the status message
- $this->waitForText('crm-notification-container', 'Relationship created.');
- $this->waitForElementPresent("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[9]/span[1]//a[text()='View']");
- $this->click("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[9]/span[1]//a[text()='View']");
-
- $this->webtestVerifyTabularData(
- array(
- 'Description' => $description,
- 'Status' => 'Enabled',
- )
- );
- $this->assertTrue($this->isTextPresent($params['label_a_b']));
- }
-
- public function testAjaxCustomGroupLoad() {
- $this->webtestLogin();
-
- //create a New Individual
- $firstName = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName, "Anderson", "$firstName@anderson.name");
- $contactId = explode('cid=', $this->getLocation());
-
- $triggerElement = array('name' => 'relationship_type_id', 'type' => 'select');
- $customSets = array(
- array('entity' => 'Relationship', 'subEntity' => 'Partner of', 'triggerElement' => $triggerElement),
- array('entity' => 'Relationship', 'subEntity' => 'Spouse of', 'triggerElement' => $triggerElement),
- );
-
- $pageUrl = array('url' => 'contact/view/rel', 'args' => "cid={$contactId[1]}&action=add&reset=1");
- $this->customFieldSetLoadOnTheFlyCheck($customSets, $pageUrl);
- }
-
- public function testRelationshipAddCurrentEmployerTest() {
- $this->webtestLogin();
-
- //create a New Individual
- $firstName = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName, "Anderson", "$firstName@anderson.name");
-
- // visit relationship tab of the Individual
- $this->click("css=li#tab_rel a");
-
- // wait for add Relationship link
- $this->waitForElementPresent('link=Add Relationship');
- $this->click('link=Add Relationship');
-
- //choose the created relationship type
- $this->waitForElementPresent("relationship_type_id");
- $this->select('relationship_type_id', "label=Employee of");
- $this->waitForAjaxContent();
-
- // create a new organization
-
- $orgName = 'WestsideCoop' . substr(sha1(rand()), 0, 7);
- $this->click("//*[@id='related_contact_id']/../div/ul/li/input");
- $this->click("xpath=//li[@class='select2-no-results']//a[contains(text(),' New Organization')]");
- $this->waitForElementPresent('_qf_Edit_next');
- $this->type('organization_name', $orgName);
- $this->type('email-Primary', "info@" . $orgName . ".com");
- $this->click('_qf_Edit_next');
- $this->waitForText("xpath=//div[@id='s2id_related_contact_id']", "$orgName");
-
- //fill in the relationship start date
- $this->webtestFillDate('start_date', '-2 year');
- $this->webtestFillDate('end_date', '+1 year');
-
- $description = "Current employee test.";
- $this->type("description", $description);
-
- //save the relationship
- //$this->click("_qf_Relationship_upload");
- $this->click('_qf_Relationship_upload-bottom');
-
- //check the status message
- $this->waitForText('crm-notification-container', 'Relationship created.');
-
- $this->waitForElementPresent("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[9]//span//a[text()='View']");
- $this->click("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[9]//span//a[text()='View']");
-
- $this->webtestVerifyTabularData(
- array(
- 'Description' => $description,
- 'Current Employee?' => 'Yes',
- 'Status' => 'Enabled',
- )
- );
- $this->assertTrue($this->isTextPresent("Employee of"), "Employee of relationship type not visible on View Relationship page.");
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Contact_SearchBuilderTest
- */
-class WebTest_Contact_SearchBuilderTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testSearchBuilderOptions() {
- $this->webtestLogin();
-
- $groupName = $this->WebtestAddGroup();
-
- // Open the search builder
- $this->openCiviPage('contact/search/builder', 'reset=1');
-
- $this->enterValues(1, 1, 'Contacts', 'Group(s)', NULL, '=', array($groupName));
- $this->enterValues(1, 2, 'Contacts', 'Country', NULL, '=', array('UNITED STATES'));
- $this->enterValues(1, 3, 'Individual', 'Gender', NULL, '=', array('Male'));
- $this->click('_qf_Builder_refresh');
- $this->waitForPageToLoad();
-
- // We should get no results. But check the options are all still set
- $this->waitForTextPresent('No matches found for:');
- foreach (array($groupName, 'UNITED STATES', 'Male') as $i => $label) {
- $this->waitForElementPresent("//span[@id='crm_search_value_1_$i']/select/option[2]");
- $this->assertSelectedLabel("//span[@id='crm_search_value_1_$i']/select", $label);
- }
- }
-
- public function testSearchBuilderRLIKE() {
- $this->webtestLogin();
-
- // Adding contact
- // We're using Quick Add block on the main page for this.
- $firstName = substr(sha1(rand()), 0, 7);
- $this->createDetailContact($firstName);
-
- $sortName = "adv$firstName, $firstName";
- $displayName = "$firstName adv$firstName";
-
- $this->_searchBuilder("Postal Code", "100[0-9]", $sortName, "RLIKE");
- }
-
- /**
- * function to create contact with details (contact details, address, Constituent information ...)
- * @param null $firstName
- */
- public function createDetailContact($firstName = NULL) {
-
- if (!$firstName) {
- $firstName = substr(sha1(rand()), 0, 7);
- }
-
- // create contact type Individual with subtype
- // with most of values to required to search
- $Subtype = "Student";
- $this->openCiviPage('contact/add', array('reset' => 1, 'ct' => 'Individual'), '_qf_Contact_cancel');
-
- // --- fill few values in Contact Detail block
- $this->type("first_name", "$firstName");
- $this->type("middle_name", "mid$firstName");
- $this->type("last_name", "adv$firstName");
- $this->select("contact_sub_type", "label=$Subtype");
- $this->type("email_1_email", "$firstName@advsearch.co.in");
- $this->type("phone_1_phone", "123456789");
- $this->type("external_identifier", "extid$firstName");
-
- // --- fill few values in address
- $this->click("//form[@id='Contact']/div[2]/div[4]/div[1]");
- $this->waitForElementPresent("address_1_geo_code_2");
- $this->type("address_1_street_address", "street 1 $firstName");
- $this->type("address_1_supplemental_address_1", "street supplement 1 $firstName");
- $this->type("address_1_supplemental_address_2", "street supplement 2 $firstName");
- $this->type("address_1_supplemental_address_3", "street supplement 3 $firstName");
- $this->type("address_1_city", "city$firstName");
- $this->type("address_1_postal_code", "100100");
- $this->select("address_1_country_id", "UNITED STATES");
- $this->select("address_1_state_province_id", "Alaska");
-
- // save contact
- $this->click("_qf_Contact_upload_view");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->assertTrue($this->isTextPresent("$firstName adv$firstName"));
- }
-
- public function testSearchBuilderContacts() {
- $this->webtestLogin();
-
- //Individual
- $firstName = substr(sha1(rand()), 0, 7);
- $streetName = "street $firstName";
- $sortName = "adv$firstName, $firstName";
- $this->_createContact('Individual', $firstName, "$firstName@advsearch.co.in", $streetName);
- // search using search builder and advanced search
- $this->_searchBuilder('Street Address', $streetName, $sortName, '=', '1');
- $this->_advancedSearch($streetName, $sortName, 'Individual', '1', 'street_address');
-
- //Organization
- $orgName = substr(sha1(rand()), 0, 7) . "org";
- $orgEmail = "ab" . rand() . "@{$orgName}.com";
- $this->_createContact('Organization', $orgName, $orgEmail, "street $orgName");
- // search using search builder and advanced search
- $this->_searchBuilder('Email', $orgEmail, $orgName, '=', '1');
- $this->_advancedSearch($orgEmail, $orgName, 'Organization', '1', 'email');
-
- //Household
- $householdName = "household" . substr(sha1(rand()), 0, 7);
- $householdEmail = "h1" . rand() . "@{$householdName}.com";
- $this->_createContact('Household', $householdName, $householdEmail, "street $householdName");
- // search using search builder and advanced search
- $this->_searchBuilder('Email', $householdEmail, $householdName, '=', '1');
- $this->_advancedSearch($householdEmail, $householdName, 'Household', '1', 'email');
-
- $this->openCiviPage("contact/add", "reset=1&ct=Individual");
-
- // searching contacts whose email is not set
- $firstName1 = "00a1" . substr(sha1(rand()), 0, 7);
- $this->type("first_name", $firstName1);
- $this->type("last_name", "01adv$firstName1");
- // save contact
- $this->click("_qf_Contact_upload_view");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->openCiviPage("contact/add", "reset=1&ct=Individual");
-
- $firstName2 = "00a2" . substr(sha1(rand()), 0, 7);
- $this->type("first_name", $firstName2);
- $this->type("last_name", "02adv$firstName2");
- // save contact
- $this->click("_qf_Contact_upload_view");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->openCiviPage("contact/add", "reset=1&ct=Individual");
-
- $firstName3 = "00a3" . substr(sha1(rand()), 0, 7);
- $this->type("first_name", $firstName3);
- $this->type("last_name", "03adv$firstName3");
- // save contact
- $this->click("_qf_Contact_upload_view");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->_searchBuilder('Email', NULL, NULL, 'IS NULL');
- $names = array(
- 1 => $firstName1,
- 2 => $firstName2,
- 3 => $firstName3,
- );
- foreach ($names as $key => $value) {
- $this->assertTrue($this->isTextPresent($value));
- }
- //searching contacts whose phone field is empty
- $this->_searchBuilder('Phone', NULL, NULL, 'IS EMPTY');
- foreach ($names as $key => $value) {
- $this->assertTrue($this->isTextPresent($value));
- }
- //searching contacts whose phone field is not empty
- $this->_searchBuilder('Phone', NULL, $firstName, 'IS NOT EMPTY');
- $this->assertTrue($this->isTextPresent($firstName));
-
- $firstName4 = "AB" . substr(sha1(rand()), 0, 7);
- $postalCode = rand();
- $this->_createContact('Individual', $firstName4, "$firstName4@advsearch.co.in", NULL, $postalCode);
- $firstName5 = "CD" . substr(sha1(rand()), 0, 7);
- $this->_createContact('Individual', $firstName5, "$firstName5@advsearch.co.in", NULL, $postalCode);
- $firstName6 = "EF" . substr(sha1(rand()), 0, 7);
- $this->_createContact('Organization', $firstName6, "$firstName6@advsearch.co.in", NULL, $postalCode);
- $firstName7 = "GH" . substr(sha1(rand()), 0, 7);
- $this->_createContact('Household', $firstName7, "$firstName7@advsearch.co.in", NULL, $postalCode);
-
- // check if the resultset of search builder and advanced search match for the postal code
- $this->_searchBuilder('Postal Code', $postalCode, NULL, 'LIKE', '4');
- $this->_advancedSearch($postalCode, NULL, NULL, '4', 'postal_code');
-
- $firstName8 = "abcc" . substr(sha1(rand()), 0, 7);
- $this->_createContact('Individual', $firstName8, "$firstName8@advsearch.co.in", NULL);
- $this->_searchBuilder('Note(s): Body and Subject', "this is notes by $firstName8 adv$firstName8", $firstName8, 'LIKE');
- $this->_searchBuilder('Note(s): Subject Only', "this is subject by $firstName8 adv$firstName8", $firstName8, 'LIKE');
- $this->_searchBuilder('Note(s): Body Only', "this is notes by $firstName8 adv$firstName8", $firstName8, 'LIKE');
- $this->_advancedSearch("this is notes by $firstName8 adv$firstName8", $firstName8, NULL, NULL, 'note_body', 'notes');
- $this->_advancedSearch("this is subject by $firstName8 adv$firstName8", $firstName8, NULL, NULL, 'note_subject', 'notes');
- $this->_advancedSearch("this is notes by $firstName8 adv$firstName8", $firstName8, NULL, NULL, 'note_both', 'notes');
- $this->_advancedSearch("this is notes by $firstName8 adv$firstName8", $firstName8, NULL, NULL, 'note_both', 'notes');
- }
-
- /**
- * @param $field
- * @param null $fieldValue
- * @param null $name
- * @param string $op
- * @param null $count
- */
- public function _searchBuilder($field, $fieldValue = NULL, $name = NULL, $op = '=', $count = NULL) {
- // search builder using contacts(not using contactType)
- $this->openCiviPage("contact/search/builder", "reset=1");
- $this->enterValues(1, 1, 'Contacts', $field, NULL, $op, "$fieldValue");
- $this->click("id=_qf_Builder_refresh");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- if (($op == '=' || $op == 'LIKE') && $fieldValue) {
- $this->assertElementContainsText('css=.crm-search-results > table.row-highlight', "$fieldValue");
- }
- if ($name) {
- $this->assertElementContainsText('css=.crm-search-results > table.row-highlight', "$name");
- }
- if ($count) {
- $this->assertElementContainsText('search-status', "$count Contact");
- }
- }
-
- /**
- * Enter form values in a Search Builder row.
- * @param $set
- * @param $row
- * @param $entity
- * @param $field
- * @param $loc
- * @param $op
- * @param string $value
- */
- public function enterValues($set, $row, $entity, $field, $loc, $op, $value = '') {
- if ($set > 1 && $row == 1) {
- $this->click('addBlock');
- }
- if ($row > 1) {
- $this->click("addMore_{$set}");
- }
- // In the DOM rows are 0 indexed and sets are 1 indexed, so normalizing
- $row--;
-
- $this->waitForElementPresent("mapper_{$set}_{$row}_0");
- $this->select("mapper_{$set}_{$row}_0", "label=$entity");
- $this->select("mapper_{$set}_{$row}_1", "label=$field");
- if ($loc) {
- $this->select("mapper_{$set}_{$row}_2", "label=$loc");
- }
- $this->select("operator_{$set}_{$row}", "value=$op");
- if (is_array($value)) {
- $this->waitForElementPresent("css=#crm_search_value_{$set}_{$row} select option + option");
- foreach ($value as $val) {
- if ($op != 'IN') {
- $select = 'select';
-
- }
- else {
- $select = 'addSelection';
-
- }
- $this->$select("css=#crm_search_value_{$set}_{$row} select", "label=$val");
- }
- }
- elseif ($value && substr($value, 0, 5) == 'date:') {
- $this->webtestFillDate("value_{$set}_{$row}", trim(substr($value, 5)));
- }
- elseif ($value) {
- $this->type("value_{$set}_{$row}", $value);
- }
- }
-
- /**
- * @param null $fieldValue
- * @param null $name
- * @param null $contactType
- * @param null $count
- * @param $field
- */
- public function _advancedSearch($fieldValue = NULL, $name = NULL, $contactType = NULL, $count = NULL, $field) {
- //advanced search by selecting the contactType
- $this->openCiviPage("contact/search/advanced", "reset=1");
- if (isset($contactType)) {
- $this->select("id=contact_type", "value=$contactType");
- }
- if (substr($field, 0, 5) == 'note_') {
- $this->click("notes");
- $this->waitForElementPresent("xpath=//div[@id='notes-search']/table/tbody/tr/td[2]/input[3]");
- if ($field == 'note_body') {
- $this->click("CIVICRM_QFID_2_note_option");
- }
- elseif ($field == 'note_subject') {
- $this->click("CIVICRM_QFID_3_note_option");
- }
- else {
- $this->click("CIVICRM_QFID_6_note_option");
- }
- $this->type("note", $fieldValue);
- }
- else {
- $this->click("location");
- $this->waitForElementPresent("$field");
- if ($contactType == 'Individual') {
- $this->type("$field", $fieldValue);
- }
- else {
- $this->type("$field", $fieldValue);
- }
- }
- $this->click("_qf_Advanced_refresh");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- //the search result should be same as the one that we got in search builder
- if ($fieldValue) {
- $this->assertElementContainsText('Advanced', "$fieldValue");
- }
- if ($name) {
- $this->assertElementContainsText('css=.crm-search-results > table.row-highlight', "$name");
- }
- if ($count) {
- $this->assertElementContainsText('search-status', "$count Contact");
- }
- }
-
- /**
- * @param $contactType
- * @param string $name
- * @param $email
- * @param null $streetName
- * @param null $postalCode
- */
- public function _createContact($contactType, $name, $email, $streetName = NULL, $postalCode = NULL) {
- $this->openCiviPage('contact/add', array('reset' => 1, 'ct' => $contactType), '_qf_Contact_cancel');
-
- if ($contactType == 'Individual') {
- $this->type("first_name", "$name");
- $this->type("last_name", "adv$name");
- $name = "$name adv$name";
- }
- elseif ($contactType == 'Organization') {
- $this->type("organization_name", $name);
- }
- else {
- $this->type("household_name", $name);
- }
- $this->click("//form[@id='Contact']/div[2]/div[4]/div[1]");
- $this->waitForElementPresent("address_1_geo_code_2");
- $this->type("email_1_email", $email);
- $this->type("phone_1_phone", "9876543210");
- $this->type("address_1_street_address", $streetName);
- $this->select("address_1_country_id", "UNITED STATES");
- $this->select("address_1_state_province_id", "Alaska");
- $this->type("address_1_postal_code", $postalCode);
-
- $this->click("//form[@id='Contact']/div[2]/div[6]/div[1]");
- $this->waitForElementPresent("note");
- $this->type("subject", "this is subject by $name");
- $this->type("note", "this is notes by $name");
-
- // save contact
- $this->click("_qf_Contact_upload_view");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->assertTrue($this->isTextPresent("$name has been created."));
- }
-
- /**
- * Webtest for CRM-12148
- */
- public function testSearchBuilderfinancialType() {
- $this->webtestLogin();
-
- // add financial type
- $financialTypeName1 = 'Financial Type' . substr(sha1(rand()), 0, 5);;
- $financialTypeName2 = 'Financial Type' . substr(sha1(rand()), 0, 5);;
- $financialType = array(
- 'name' => $financialTypeName1,
- 'is_reserved' => FALSE,
- 'is_deductible' => FALSE,
- );
- $this->addeditFinancialType($financialType);
- $financialType['name'] = $financialTypeName2;
- $this->addeditFinancialType($financialType);
- //create 6 contribution
- $this->openCiviPage("contribute/add", "reset=1&action=add&context=standalone", "_qf_Contribution_upload");
- for ($i = 1; $i <= 6; $i++) {
- if ($i % 2 == 0) {
- $financialType = $financialTypeName1;
- }
- else {
- $financialType = $financialTypeName2;
- }
- // create new contact using dialog
- $this->createDialogContact();
- $this->select('financial_type_id', $financialType);
- $this->type('total_amount', 100 * $i);
- $this->clickLink('_qf_Contribution_upload_new', '_qf_Contribution_upload_new');
- }
- $this->openCiviPage("contact/search/builder", "reset=1", "_qf_Builder_refresh");
-
- $this->enterValues(1, 1, 'Contribution', 'Financial Type', NULL, '=', array($financialTypeName1));
- $this->clickLink('_qf_Builder_refresh');
-
- $this->assertTrue($this->isTextPresent('3 Contacts'), 'Missing text: ' . '3 Contacts');
-
- $this->click("xpath=//div[@class='crm-accordion-header crm-master-accordion-header']");
- $this->enterValues(1, 1, 'Contribution', 'Financial Type', NULL, '=', array($financialTypeName2));
- $this->clickLink('_qf_Builder_refresh');
-
- $this->assertTrue($this->isTextPresent('3 Contacts'), 'Missing text: ' . '3 Contacts');
-
- $this->click("xpath=//div[@class='crm-accordion-header crm-master-accordion-header']");
- $this->enterValues(1, 1, 'Contribution', 'Financial Type', NULL, 'IN', array(
- $financialTypeName1,
- $financialTypeName2,
- ));
- $this->clickLink('_qf_Builder_refresh');
-
- $this->assertTrue($this->isTextPresent('6 Contacts'), 'Missing text: ' . '6 Contacts');
- }
-
- /**
- * Webtest for CRM-12588
- */
- public function testSearchBuilderMembershipType() {
- $this->webtestLogin();
-
- // create first contact
- $firstName1 = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName1, "Memberson", "Memberson{$firstName1}@memberson.name");
- $contactName1 = "Memberson, $firstName1";
-
- // create Second contact
- $firstName2 = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName2, "Memberson", "Memberson{$firstName2}@memberson.name");
- $contactName2 = "Memberson, $firstName2";
-
- // add membership type
- $membershipTypes = $this->webtestAddMembershipType();
-
- // now add membership
- $this->openCiviPage("member/add", "reset=1&action=add&context=standalone", "_qf_Membership_upload");
-
- // select contact
- $this->webtestFillAutocomplete($firstName1);
-
- // fill in Membership Organization
- $this->waitForElementPresent("membership_type_id[0]");
- $this->select("membership_type_id[0]", "label={$membershipTypes['member_of_contact']}");
-
- // select membership type
- $this->waitForElementPresent("membership_type_id[1]");
- $this->select("membership_type_id[1]", "label={$membershipTypes['membership_type']}");
-
- // fill in Source
- $this->type("source", "Membership StandaloneAddTest Webtest");
-
- // fill in Start Date
- $this->webtestFillDate('start_date');
-
- // Clicking save.
- $this->clickLink("_qf_Membership_upload");
-
- // page was loaded
- $this->waitForTextPresent("Membership StandaloneAddTest Webtest");
-
- // now add membership for second contact
- $this->openCiviPage("member/add", "reset=1&action=add&context=standalone", "_qf_Membership_upload");
- $this->webtestFillAutocomplete($firstName2);
- $this->select("membership_type_id[0]", "label={$membershipTypes['member_of_contact']}");
- $this->select("membership_type_id[1]", "label={$membershipTypes['membership_type']}");
- $this->type("source", "Membership StandaloneAddTest Webtest");
- $this->webtestFillDate('start_date');
-
- // fill in Status Override?
- $this->click("is_override");
- $this->waitForElementPresent("status_id");
- $this->select("status_id", "label=Grace");
-
- // Clicking save.
- $this->clickLink("_qf_Membership_upload");
- $this->waitForTextPresent("Membership StandaloneAddTest Webtest");
-
- // Open the search builder
- $this->openCiviPage('contact/search/builder', 'reset=1');
- $this->enterValues(1, 1, 'Membership', 'Membership Type', NULL, '=', array($membershipTypes['membership_type']));
-
- $this->clickLink('_qf_Builder_refresh');
- $this->waitForAjaxContent();
- $this->assertElementContainsText("xpath=//div[@id='search-status']/table/tbody/tr[1]/td", "2 Contacts");
-
- $this->click("xpath=//div[@class='crm-accordion-header crm-master-accordion-header']");
- $this->enterValues(1, 2, 'Membership', 'Membership Status', NULL, '=', array('New'));
- $this->clickLink('_qf_Builder_refresh');
- $this->waitForAjaxContent();
- $this->assertElementContainsText("xpath=//div[@id='search-status']/table/tbody/tr[1]/td", "1 Contact");
-
- $this->enterValues(1, 2, 'Membership', 'Membership Status', NULL, '=', array('Grace'));
- $this->clickLink('_qf_Builder_refresh');
- $this->waitForAjaxContent();
- $this->assertElementContainsText("xpath=//div[@id='search-status']/table/tbody/tr[1]/td", "1 Contact");
-
- $this->click("xpath=//div[@class='crm-accordion-header crm-master-accordion-header']");
- $this->waitForElementPresent("xpath=//div[@id='map-field']/div[1]/table/tbody/tr[2]/td/a");
- $this->click("xpath=//div[@id='map-field']/div[1]/table/tbody/tr[2]/td/a");
- $this->enterValues(1, 2, 'Membership', 'Membership Status', NULL, 'IN', array('New', 'Grace'));
- $this->clickLink('_qf_Builder_refresh');
- $this->waitForAjaxContent();
- $this->assertElementContainsText("xpath=//div[@id='search-status']/table/tbody/tr[1]/td", "2 Contacts");
-
- $this->click("xpath=//div[@class='crm-accordion-header crm-master-accordion-header']");
- $this->waitForElementPresent("xpath=//div[@id='map-field']/div[1]/table/tbody/tr[2]/td/a");
- $this->click("xpath=//div[@id='map-field']/div[1]/table/tbody/tr[2]/td/a");
- $this->enterValues(1, 2, 'Membership', 'Membership Status', NULL, 'IN', array('Current', 'Expired'));
- $this->clickLink('_qf_Builder_refresh');
- $this->waitForText("xpath=//form[@id='Builder']/div[3]/div/div", "No matches found for");
-
- // Find Membership
- $this->openCiviPage("member/search", "reset=1", "_qf_Search_refresh");
- $this->select2('membership_type_id', $membershipTypes['membership_type'], TRUE);
- $this->clickLink('_qf_Search_refresh');
- $this->assertElementContainsText("xpath=//div[@id='search-status']/table/tbody/tr[1]/td[1]", "2 Result");
-
- $this->click("xpath=//div[@class='crm-accordion-header crm-master-accordion-header']");
- $this->multiselect2("membership_status_id", array("New", "Grace"));
- $this->clickLink('_qf_Search_refresh');
- $this->waitForAjaxContent();
- $this->assertElementContainsText("xpath=//div[@id='search-status']/table/tbody/tr[1]/td", "2 Results");
-
- $this->openCiviPage("member/search", "reset=1", "_qf_Search_refresh");
- $this->waitForAjaxContent();
- $this->click("xpath=//div[@class='crm-accordion-header crm-master-accordion-header']");
- $this->select2('membership_type_id', $membershipTypes['membership_type'], TRUE);
- $this->multiselect2("membership_status_id", array("New"));
- $this->click('_qf_Search_refresh');
- $this->waitForAjaxContent();
- $this->assertElementContainsText("xpath=//div[@id='search-status']/table/tbody/tr[1]/td", "1 Result");
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Contact_SearchTest
- */
-class WebTest_Contact_SearchTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testQuickSearch() {
- $this->webtestLogin();
-
- // Adding contact
- // We're using Quick Add block on the main page for this.
- $firstName = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName, "Anderson", "$firstName.anderson@example.org");
-
- $sortName = "Anderson, $firstName";
- $displayName = "$firstName Anderson";
-
- $this->openCiviPage("dashboard", "reset=1");
-
- // type sortname in autocomplete
- $this->click("css=input#sort_name_navigation");
- $this->type("css=input#sort_name_navigation", $sortName);
- $this->typeKeys("css=input#sort_name_navigation", $sortName);
-
- // wait for result list
- $this->waitForElementPresent("xpath=//li[contains(text(), '$sortName :: $firstName.anderson@example.org')]");
-
- // visit contact summary page
- $this->click("xpath=//li[contains(text(), '$sortName :: $firstName.anderson@example.org')]");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Is contact present?
- $this->assertTrue($this->isTextPresent("$displayName"), "Contact did not find!");
- }
-
- public function testQuickSearchPartial() {
- $this->webtestLogin();
-
- // Adding contact
- // We're using Quick Add block on the main page for this.
- $firstName = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName, "Adams", "{$firstName}.adams@example.org");
-
- $sortName = "Adams, {$firstName}";
-
- $this->openCiviPage("dashboard", "reset=1");
-
- // type partial sortname in autocomplete
- $this->click("css=input#sort_name_navigation");
- $this->type("css=input#sort_name_navigation", 'ada');
- $this->typeKeys("css=input#sort_name_navigation", 'ada');
-
- $this->clickLink("_qf_Advanced_refresh");
-
- // make sure we're on search results page
- $this->waitForElementPresent("alpha-filter");
-
- // Is contact present in search result?
- $this->assertElementContainsText('css=.crm-search-results > table.row-highlight', $sortName);
- }
-
- public function testContactSearch() {
- $this->webtestLogin();
-
- // Create new tag.
- $tagName = 'tag_' . substr(sha1(rand()), 0, 7);
- self::addTag($tagName, $this);
-
- // Create new group
- $groupName = 'group_' . substr(sha1(rand()), 0, 7);
- $this->WebtestAddGroup($groupName);
-
- // Adding contact
- // We're using Quick Add block on the main page for this.
- $firstName = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName, "Smith", "$firstName.smith@example.org");
-
- $sortName = "Smith, $firstName";
- $displayName = "$firstName Smith";
-
- // add contact to group
- // visit group tab
- $this->click("css=li#tab_group a");
- $this->waitForElementPresent("group_id");
-
- // add to group
- $this->select("group_id", "label=$groupName");
- $this->click("_qf_GroupContact_next");
- $this->waitForText("crm-notification-container", "Contact has been added to '$groupName'.");
-
- // tag a contact
- // visit tag tab
- $this->click("css=li#tab_tag a");
- $this->waitForElementPresent("css=div#tagtree");
-
- // select tag
- $this->click("xpath=//ul/li/span/label[text()=\"$tagName\"]");
- $this->checkCRMStatus();
-
- // visit contact search page
- $this->openCiviPage("contact/search", "reset=1");
-
- // fill name as first_name
- $this->type("sort_name", $firstName);
-
- // select contact type as Indiividual
- $this->select("contact_type", "value=Individual");
-
- // select group
- $this->select("group", "label=$groupName");
-
- // select tag
- $this->select("tag", "label=$tagName");
-
- // click to search
- $this->click("_qf_Basic_refresh");
- $this->waitForElementPresent("xpath=//div[@class='crm-search-results']");
-
- // Is contact present in search result?
- $this->assertElementContainsText('css=.crm-search-results > table.row-highlight', $sortName);
- }
-
- /**
- * This code is reused with advanced search, hence the reference to $self
- *
- * @param string $tagName
- * @param $self
- */
- public static function addTag($tagName = 'New Tag', $self) {
- $self->openCiviPage('admin/tag', array('reset' => 1, 'action' => 'add'), '_qf_Tag_next');
-
- // fill tag name
- $self->type("name", $tagName);
-
- // fill description
- $self->type("description", "Adding new tag.");
-
- // select used for contact
- $self->select("used_for", "value=civicrm_contact");
-
- // check reserved
- $self->click("is_reserved");
-
- // Clicking save.
- $self->click("_qf_Tag_next");
- $self->waitForPageToLoad($self->getTimeoutMsec());
-
- // Is status message correct?
- $self->assertTrue($self->isTextPresent("The tag '$tagName' has been saved."));
- }
-
- /**
- * CRM-6586
- */
- public function testContactSearchExport() {
- $this->webtestLogin();
-
- // Create new group
- $parentGroupName = 'Parentgroup_' . substr(sha1(rand()), 0, 7);
- $this->WebtestAddGroup($parentGroupName);
-
- // Create new group and select the previously selected group as parent group for this new group.
- $childGroupName = 'Childgroup_' . substr(sha1(rand()), 0, 7);
- $this->WebtestAddGroup($childGroupName, $parentGroupName);
-
- // Adding Parent group contact
- $firstName = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName, "Smith", "$firstName.smith@example.org");
-
- $sortName = "Smith, $firstName";
- $displayName = "$firstName Smith";
-
- // add contact to parent group
- // visit group tab
- $this->click("css=li#tab_group a");
- $this->waitForElementPresent("group_id");
-
- // add to group
- $this->select("group_id", "label=$parentGroupName");
- $this->click("_qf_GroupContact_next");
- $this->waitForText("crm-notification-container", "Contact has been added to '$parentGroupName'.");
-
- // Adding child group contact
- // We're using Quick Add block on the main page for this.
- $childName = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($childName, "John", "$childName.john@example.org");
-
- $childSortName = "John, $childName";
- $childDisplayName = "$childName John";
-
- // add contact to child group
- // visit group tab
- $this->click("css=li#tab_group a");
- $this->waitForElementPresent("group_id");
-
- // add to child group
- $this->select("group_id", "*$childGroupName");
- $this->click("_qf_GroupContact_next");
- $this->waitForText("crm-notification-container", "Contact has been added to '$childGroupName'.");
-
- // visit contact search page
- $this->openCiviPage("contact/search", "reset=1");
-
- // select contact type as Indiividual
- $this->select("contact_type", "value=Individual");
-
- // select group
- $this->select("group", "label=$parentGroupName");
-
- // click to search
- $this->clickLink("_qf_Basic_refresh");
-
- // Is contact present in search result?
- $this->assertElementContainsText('css=.crm-search-results > table.row-highlight', $sortName);
- $this->assertElementContainsText('css=.crm-search-results > table.row-highlight', $childSortName);
-
- // CRM-18284 - Test Task after sorting with state
- $this->clickAjaxLink("xpath=//div[@class='crm-search-results']//table/thead/tr//th/a[contains(text(), 'State')]");
- $this->waitForElementPresent("xpath=//div[@class='crm-search-results']//table/thead/tr//th/a[contains(text(), 'State')]");
-
- // select to export all the contact from search result
- $this->click("CIVICRM_QFID_ts_all_4");
-
- // Select the task action to export
- $this->click("task");
- $this->select("task", "label=Export contacts");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->click("_qf_Select_next-bottom");
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Contact_SearchbyDateFilterTest
- */
-class WebTest_Contact_SearchbyDateFilterTest extends CiviSeleniumTestCase {
-
- /**
- * @inheritDoc
- */
- protected function setUp() {
- parent::setUp();
- }
-
- /**
- * test individual pane seperatly.
- */
- public function testAdvancedSearch() {
- $this->markTestSkipped('Skipping for now as it works fine locally.');
- $this->webtestLogin();
-
- // Get all default advance search panes.
- $allpanes = $this->_advanceSearchPanesDateFilter();
-
- // Test Individual panes.
- foreach (array_keys($allpanes) as $pane) {
- // Go to the Advance Search
- $this->openCiviPage("contact/search/advanced", "reset=1");
-
- // Select some fields from pane.
- $this->_selectPaneFields($pane);
-
- $this->click('_qf_Advanced_refresh');
-
- $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
- // check the opened panes.
- $this->_checkOpenedPanes(array($pane));
- }
-
- }
-
- public function testIndividualSearchPage() {
- $this->webtestLogin();
-
- $this->openCiviPage("contribute/search", "reset=1");
- $this->select("contribution_date_relative", "value=previous_before.quarter");
- $this->click("_qf_Search_refresh");
- $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
- $this->select("contribution_date_relative", "value=previous_2.quarter");
- $this->click("_qf_Search_refresh");
- $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
- $this->select("contribution_date_relative", "value=earlier.quarter");
- $this->click("_qf_Search_refresh");
- $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
- $this->select("contribution_date_relative", "value=ending.year");
-
- $this->click("_qf_Search_refresh");
- $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
-
- $this->openCiviPage("member/search", "reset=1");
- $this->select("member_end_date_relative", "value=previous_before.month");
- $this->click("_qf_Search_refresh");
- $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
- $this->select("member_end_date_relative", "value=previous_2.month");
- $this->click("_qf_Search_refresh");
- $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
- $this->select("member_end_date_relative", "value=earlier.month");
- $this->click("_qf_Search_refresh");
- $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
- $this->select("member_end_date_relative", "value=ending.month");
- $this->click("_qf_Search_refresh");
- $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
-
- $this->openCiviPage("event/search", "reset=1");
- $this->select("event_relative", "value=previous_before.week");
- $this->click("_qf_Search_refresh");
- $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
- $this->select("event_relative", "value=previous_2.week");
- $this->click("_qf_Search_refresh");
- $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
- $this->select("event_relative", "value=earlier.week");
- $this->click("_qf_Search_refresh");
- $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
- $this->select("event_relative", "value=ending.week");
- $this->click("_qf_Search_refresh");
- $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
-
- $this->openCiviPage("activity/search", "reset=1");
- $this->select("activity_date_relative", "value=previous_before.day");
- $this->click("_qf_Search_refresh");
- $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
- $this->select("activity_date_relative", "value=previous_2.day");
- $this->click("_qf_Search_refresh");
- $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
- $this->select("activity_date_relative", "value=earlier.day");
- $this->click("_qf_Search_refresh");
- $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
- $this->select("activity_date_relative", "value=ending.quarter");
- $this->click("_qf_Search_refresh");
- $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
-
- $this->openCiviPage("pledge/search", "reset=1");
- $this->select("pledge_payment_date_relative", "value=greater.week");
- $this->click("_qf_Search_refresh");
- $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
- $this->click("xpath=//form[@id='Search']/div[2]/div/div");
- $this->select("pledge_payment_date_relative", "value=greater.day");
- $this->click("_qf_Search_refresh");
- $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
- $this->click("xpath=//form[@id='Search']/div[2]/div/div");
- $this->select("pledge_payment_date_relative", "value=greater.quarter");
- $this->click("_qf_Search_refresh");
- $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
- $this->click("xpath=//form[@id='Search']/div[2]/div/div");
- $this->select("pledge_payment_date_relative", "value=greater.month");
- $this->click("_qf_Search_refresh");
- $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
-
- $this->openCiviPage("mailing", "reset=1");
- $this->select("mailing_relative", "value=previous_before.year");
- $this->click("_qf_Search_refresh");
- $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
- $this->select("mailing_relative", "value=previous_2.year");
- $this->click("_qf_Search_refresh");
- $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
- $this->select("mailing_relative", "value=earlier.year");
- $this->click("_qf_Search_refresh");
- $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
- $this->select("mailing_relative", "value=greater.year");
- $this->click("_qf_Search_refresh");
- $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
- }
-
- /**
- * @param array $openedPanes
- */
- public function _checkOpenedPanes($openedPanes = array()) {
- if (!$this->isTextPresent('None found.')) {
- $this->click('css=div.crm-advanced_search_form-accordion div.crm-accordion-header');
- }
-
- $allPanes = $this->_advanceSearchPanesDateFilter();
-
- foreach ($allPanes as $paneRef => $pane) {
- if (in_array($paneRef, $openedPanes)) {
- // assert for element present.
- $this->waitForElementPresent("css=div.crm-accordion-wrapper div.crm-accordion-body {$pane['bodyLocator']}");
- }
- else {
- $this->assertTrue(!$this->isElementPresent("css=div.crm-accordion-wrapper div.crm-accordion-body {$pane['bodyLocator']}"));
- }
- }
- }
-
- /**
- * @param $paneRef
- * @param array $selectFields
- */
- public function _selectPaneFields($paneRef, $selectFields = array()) {
- $pane = $this->_advanceSearchPanesDateFilter($paneRef);
-
- $this->click("css=div.crm-accordion-wrapper {$pane['headerLocator']}");
- $this->waitForElementPresent("css=div.crm-accordion-wrapper div.crm-accordion-body {$pane['bodyLocator']}");
-
- foreach ($pane['fields'] as $fld => $field) {
- if (!empty($selectFields) && !in_array($fld, $selectFields)) {
- continue;
- }
-
- $fldLocator = isset($field['locator']) ? $field['locator'] : '';
-
- switch ($field['type']) {
- case 'text':
- $this->type($fldLocator, current($field['values']));
- break;
-
- case 'select':
- foreach ($field['values'] as $op) {
- $this->select($fldLocator, 'label=' . $op);
- }
- break;
-
- case 'checkbox':
- foreach ($field['values'] as $op) {
- if (!$this->isChecked($op)) {
- $this->click($op);
- }
- }
- break;
-
- case 'radio':
- foreach ($field['values'] as $op) {
- $this->click($op);
- }
- break;
-
- case 'date':
- $this->webtestFillDate($fldLocator, current($field['values']));
- break;
- }
- }
- }
-
- /**
- * @param null $paneRef
- *
- * @return array
- */
- public function _advanceSearchPanesDateFilter($paneRef = NULL) {
- static $_advance_search_panes;
-
- if (!isset($_advance_search_panes) || empty($_advance_search_panes)) {
- $_advance_search_panes = array(
- 'activity' => array(
- 'headerLocator' => 'div#activity',
- 'bodyLocator' => 'select#activity_date_relative',
- 'title' => 'Activities',
- 'fields' => array(
- 'Activity Dates' => array(
- 'type' => 'select',
- 'locator' => 'activity_date_relative',
- 'values' => array('This Year'),
- ),
- ),
- ),
- 'demographics' => array(
- 'headerLocator' => 'div#demographics',
- 'bodyLocator' => 'input#birth_date_low',
- 'title' => 'Demographics',
- 'fields' => array(
- 'Deceased Dates' => array(
- 'type' => 'select',
- 'locator' => 'deceased_date_relative',
- 'values' => array('This Quarter'),
- ),
- ),
- ),
- 'change_log' => array(
- 'headerLocator' => 'div#changeLog',
- 'bodyLocator' => 'input#changed_by',
- 'title' => 'Change Log',
- 'fields' => array(
- 'Modified Between' => array(
- 'type' => 'select',
- 'locator' => 'log_date_relative',
- 'values' => array('This Week'),
- ),
- ),
- ),
- 'mailing' => array(
- 'headerLocator' => 'div#CiviMail',
- 'bodyLocator' => 'select#mailing_date_relative',
- 'title' => 'Mailings',
- 'fields' => array(
- 'Mailing Date' => array(
- 'type' => 'select',
- 'locator' => 'mailing_date_relative',
- 'values' => array('Prior to Previous Quarter'),
- ),
- ),
- ),
- 'contribution' => array(
- 'headerLocator' => 'div#CiviContribute',
- 'bodyLocator' => 'select#financial_type_id',
- 'title' => 'Contributions',
- 'fields' => array(
- 'Date Received' => array(
- 'type' => 'select',
- 'locator' => 'contribution_date_relative',
- 'values' => array('Today'),
- ),
- ),
- ),
- 'pledge' => array(
- 'headerLocator' => 'div#CiviPledge',
- 'bodyLocator' => 'select#pledge_payment_date_relative',
- 'title' => 'Pledges',
- 'fields' => array(
- 'Date Received' => array(
- 'type' => 'select',
- 'locator' => 'pledge_payment_date_relative',
- 'values' => array('Prior to Previous Month'),
- ),
- ),
- ),
- 'membership' => array(
- 'headerLocator' => 'div#CiviMember',
- 'bodyLocator' => 'input#member_source',
- 'title' => 'Memberships',
- 'fields' => array(
- 'Member Since' => array(
- 'type' => 'select',
- 'locator' => 'member_join_date_relative',
- 'values' => array('Previous Year'),
- ),
-
- ),
- ),
- 'event' => array(
- 'headerLocator' => 'div#CiviEvent',
- 'bodyLocator' => 'input#event_id',
- 'title' => 'Events',
- 'fields' => array(
- 'Event Dates' => array(
- 'type' => 'select',
- 'locator' => 'event_relative',
- 'values' => array('Previous Week'),
- ),
- ),
- ),
-
- );
- }
-
- if ($paneRef) {
- return $_advance_search_panes[$paneRef];
- }
-
- return $_advance_search_panes;
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Contact_SignatureTest
- */
-class WebTest_Contact_SignatureTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- /**
- * Test Signature in CKEditor.
- */
- public function testCKEditor() {
- $this->webtestLogin();
-
- $this->openCiviPage('dashboard', 'reset=1', 'crm-recently-viewed');
- $this->click("//div[@id='crm-recently-viewed']/ul/li/a");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $name = $this->getText("xpath=//div[@class='crm-summary-display_name']");
-
- // Get contact id from url.
- $contactId = $this->urlArg('cid');
-
- // Select Your Editor
- $this->_selectEditor('CKEditor');
-
- $this->openCiviPage("contact/add", "reset=1&action=update&cid={$contactId}");
- $this->click("//tr[@id='Email_Block_1']/td[1]/div[3]/div[1]");
-
- // HTML format message
- $signature = 'Contact Signature in html';
- $this->fireEvent('email_1_signature_html', 'focus');
- $this->fillRichTextField('email_1_signature_html', $signature, 'CKEditor');
-
- // TEXT Format Message
- $this->type('email_1_signature_text', 'Contact Signature in text');
- $this->click('_qf_Contact_upload_view-top');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Is status message correct?
- $this->waitForText('crm-notification-container', "{$name} has been updated.");
-
- // Go for Ckeck Your Editor, Click on Send Mail
- $this->click("//a[@id='crm-contact-actions-link']/span");
- $this->clickLink('link=Send an Email', 'subject', FALSE);
-
- $this->click('subject');
- $subject = 'Subject_' . substr(sha1(rand()), 0, 7);
- $this->type('subject', $subject);
-
- // Is signature correct? in Editor
- $this->_checkSignature('html_message', $signature, 'CKEditor');
-
- $this->click('_qf_Email_upload-top');
- $this->waitForElementPresent("//a[@id='crm-contact-actions-link']/span");
-
- // Go for Activity Search
- $this->_checkActivity($subject, $signature);
- }
-
- /**
- * Helper function to select Editor.
- * @param $editor
- */
- public function _selectEditor($editor) {
- $this->openCiviPage('admin/setting/preferences/display', 'reset=1');
-
- // Change editor if not already selected
- if ($this->getSelectedLabel('editor_id') != $editor) {
- $this->click('editor_id');
- $this->select('editor_id', "label=$editor");
- $this->click('_qf_Display_next-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- }
- }
-
- /**
- * Helper function for Check Signature in Editor.
- * @param $fieldName
- * @param $signature
- * @param $editor
- */
- public function _checkSignature($fieldName, $signature, $editor) {
- if ($editor == 'CKEditor') {
- $this->waitForElementPresent("xpath=//div[@id='cke_{$fieldName}']//iframe");
- $this->selectFrame("xpath=//div[@id='cke_{$fieldName}']//iframe");
- }
- else {
- $this->selectFrame("xpath=//iframe[@id='{$fieldName}_ifr']");
- }
-
- $this->assertElementContainsText("//html/body", "$signature");
- $this->selectFrame('relative=top');
- }
-
- /**
- * Helper function for Check Signature in Activity.
- * @param $subject
- * @param $signature
- */
- public function _checkActivity($subject, $signature) {
- $this->openCiviPage('activity/search', 'reset=1', '_qf_Search_refresh');
-
- $this->type('activity_subject', $subject);
-
- $this->clickLink('_qf_Search_refresh', 'Search');
-
- // View your Activity
- $this->clickLink("xpath=id('Search')/div[3]/div/div[2]/table/tbody/tr[2]/td[9]/span/a[text()='View']", '_qf_ActivityView_cancel-bottom', FALSE);
-
- // Is signature correct? in Activity
- $this->assertTextPresent($signature);
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Contact_TagAddTest
- */
-class WebTest_Contact_TagAddTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testAddTag() {
- $this->webtestLogin();
-
- $this->openCiviPage("admin/tag", "action=add&reset=1", "_qf_Tag_next");
-
- // take a tag name
- $tagName = 'tag_' . substr(sha1(rand()), 0, 7);
-
- // fill tag name
- $this->type("name", $tagName);
-
- // fill description
- $this->type("description", "Adding new tag.");
-
- // select used for contact
- $this->select("used_for", "value=civicrm_contact");
-
- // check reserved
- $this->click("is_reserved");
-
- // Clicking save.
- $this->click("_qf_Tag_next");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Is status message correct?
- $this->assertTrue($this->isTextPresent("The tag '$tagName' has been saved."));
-
- // sort by ID desc
- $this->click("xpath=//div[@id='cat']/div/table/thead/tr/th[2]/div[text()='ID']");
- $this->waitForElementPresent("css=table.display tbody tr td");
-
- // verify text
- $this->assertTrue($this->isTextPresent($tagName), 'Missing text: ' . $tagName);
- $this->assertTrue($this->isTextPresent('Adding new tag.'), 'Missing text: ' . 'Adding new tag.');
- $this->assertTrue($this->isTextPresent('Contacts'), 'Missing text: ' . 'Contacts');
- $this->assertTrue($this->isTextPresent('Edit'), 'Missing text: ' . 'Edit');
- }
-
- public function testAddTagSet() {
- $this->webtestLogin();
-
- $this->openCiviPage("admin/tag", "action=add&reset=1&tagset=1");
-
- // take a tagset name
- $tagSetName = 'tagset_' . substr(sha1(rand()), 0, 7);
-
- // fill tagset name
- $this->type("name", $tagSetName);
-
- // fill description
- $this->type("description", "Adding new tag set.");
-
- // select used for contact
- $this->select("used_for", "value=civicrm_contact");
-
- // check reserved
- $this->click("is_reserved");
-
- // Clicking save.
- $this->click("_qf_Tag_next");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Is status message correct?
- $this->assertTrue($this->isTextPresent("The tag '$tagSetName' has been saved."));
-
- // sort by ID desc
- $this->click("xpath=//table[@class='display dataTable no-footer']/thead/tr/th[2]/div[text()='ID']");
- $this->waitForElementPresent("css=table.display tbody tr td");
-
- // verify text
- $this->assertTrue($this->isTextPresent($tagSetName), 'Missing text: ' . $tagSetName);
- $this->assertTrue($this->isTextPresent('Adding new tag set.'), 'Missing text: ' . 'Adding new tag set.');
- $this->assertTrue($this->isTextPresent('Contacts'), 'Missing text: ' . 'Contacts');
- $this->assertTrue($this->isTextPresent('Edit'), 'Missing text: ' . 'Edit');
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Contact_TagSetSearchTest
- */
-class WebTest_Contact_TagSetSearchTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testTagSetSearch() {
- $this->webtestLogin();
-
- $tagSet1 = $this->_testAddTagSet();
- $tagSet2 = $this->_testAddTagSet();
-
- // Individual 1
- $contact1 = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($contact1, "Anderson", "{$contact1}@example.com");
-
- $this->click('css=li#tab_tag a');
- $this->waitForElementPresent("xpath=//*[@id='contact_taglist_{$tagSet1}']/../div/ul/li[1]/input");
-
- // Add tag1 for Individual 1
- $tag1 = substr(sha1(rand()), 0, 5);
- $this->click("xpath=//*[@id='contact_taglist_{$tagSet1}']/../div/ul/li[1]/input");
- $this->keyDown("xpath=//*[@id='contact_taglist_{$tagSet1}']/../div/ul/li[1]/input", " ");
- $this->type("xpath=//*[@id='contact_taglist_{$tagSet1}']/../div/ul/li[1]/input", $tag1);
- $this->typeKeys("xpath=//*[@id='contact_taglist_{$tagSet1}']/../div/ul/li[1]/input", $tag1);
- // ...waiting for drop down with results to show up...
- $this->waitForElementPresent("xpath=//div[@class='select2-result-label']");
- // ...need to use mouseDownAt on first result (which is a li element), click does not work
- $this->clickAt("xpath=//div[@class='select2-result-label']");
- $this->waitForTextPresent($tag1);
-
- // Add tag2 for Individual 1
- $tag2 = substr(sha1(rand()), 0, 5);
- $this->click("xpath=//*[@id='contact_taglist_{$tagSet2}']/../div/ul/li[1]/input");
- $this->keyDown("xpath=//*[@id='contact_taglist_{$tagSet2}']/../div/ul/li[1]/input", " ");
- $this->type("xpath=//*[@id='contact_taglist_{$tagSet2}']/../div/ul/li[1]/input", $tag2);
- $this->typeKeys("xpath=//*[@id='contact_taglist_{$tagSet2}']/../div/ul/li[1]/input", $tag2);
- // ...waiting for drop down with results to show up...
- $this->waitForElementPresent("xpath=//div[@class='select2-result-label']");
- // ...need to use mouseDownAt on first result (which is a li element), click does not work
- $this->clickAt("xpath=//div[@class='select2-result-label']");
- $this->waitForTextPresent($tag2);
-
- // Individual 2
- $contact2 = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($contact2, "Anderson", "{$contact2}@example.com");
-
- $this->click('css=li#tab_tag a');
- $this->waitForElementPresent("xpath=//*[@id='contact_taglist_{$tagSet1}']/../div/ul/li[1]/input");
-
- // Add tag1 for Individual 2
- $this->click("xpath=//*[@id='contact_taglist_{$tagSet1}']/../div/ul/li[1]/input");
- $this->keyDown("xpath=//*[@id='contact_taglist_{$tagSet1}']/../div/ul/li[1]/input", " ");
- $this->type("xpath=//*[@id='contact_taglist_{$tagSet1}']/../div/ul/li[1]/input", $tag1);
- $this->typeKeys("xpath=//*[@id='contact_taglist_{$tagSet1}']/../div/ul/li[1]/input", $tag1);
- // ...waiting for drop down with results to show up...
- $this->waitForElementPresent("xpath=//div[@class='select2-result-label']");
- // ...need to use mouseDownAt on first result (which is a li element), click does not work
- $this->clickAt("xpath=//div[@class='select2-result-label']");
- $this->waitForTextPresent($tag1);
-
- // Go to Advance search.
- $this->openCiviPage('contact/search/advanced', 'reset=1');
-
- // Check both the tagset.
- $this->assertTrue($this->isElementPresent("contact_taglist_{$tagSet1}"));
- $this->assertTrue($this->isElementPresent("contact_taglist_{$tagSet2}"));
-
- // Search contact using tags.
- $this->select2("contact_taglist_{$tagSet1}", $tag1, TRUE);
-
- $this->waitForTextPresent($tag1);
- $this->select2("contact_taglist_{$tagSet2}", $tag2, TRUE);
-
- $this->waitForTextPresent($tag2);
-
- $this->click("_qf_Advanced_refresh");
- $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
-
- // Check result.
- $this->assertElementContainsText('search-status', "2 Contacts");
- $this->assertElementContainsText('css=.crm-search-results table.selector', "Anderson, $contact1");
- $this->assertElementContainsText('css=.crm-search-results table.selector', "Anderson, $contact2");
- }
-
- /**
- * @return array
- */
- public function _testAddTagSet() {
- // Go to add tag set url.
- $this->openCiviPage('admin/tag', 'action=add&reset=1&tagset=1');
-
- // take a tagset name
- $tagSetName = 'tagset_' . substr(sha1(rand()), 0, 7);
-
- // fill tagset name
- $this->type("name", $tagSetName);
-
- // fill description
- $this->type("description", "Adding new tag set.");
-
- // select used for contact
- $this->select("used_for", "value=civicrm_contact");
-
- // check reserved
- $this->click("is_reserved");
-
- // Clicking save.
- $this->click("_qf_Tag_next");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Is status message correct?
- $this->waitForText('crm-notification-container', "The tag '$tagSetName' has been saved.");
-
- // sort by ID desc
- $this->click("xpath=//div[@id='cat']/div/table/thead/tr/th[2]/div[text()='ID']");
- $this->waitForElementPresent("css=table.display tbody tr td");
-
- // verify text
- $this->assertTrue($this->isTextPresent($tagSetName), 'Missing text: ' . $tagSetName);
-
- $tagid = explode('&id=', $this->getAttribute("xpath=//table[@class='display dataTable no-footer']/tbody//tr/td[1]/div[text()= '$tagSetName']/../../td[8]/span/a[text()= 'Edit']@href"));
- $tagid = explode('&', $tagid[1]);
- $tagid = $tagid[0];
-
- return $tagid;
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Contact_TaskActionAddToGroupTest
- */
-class WebTest_Contact_TaskActionAddToGroupTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testAddContactsToGroup() {
-
- $this->webtestLogin();
- $newGroupName = 'Group_' . substr(sha1(rand()), 0, 7);
- $this->WebtestAddGroup($newGroupName);
-
- // Create two new contacts with a common random string in email address
- $emailString = substr(sha1(rand()), 0, 7) . '@example.com';
- $cids = array();
- for ($i = 0; $i < 2; $i++) {
- // create new contact
- $this->webtestAddContact();
-
- // get cid of new contact
- $cids[] = $this->urlArg('cid');
-
- // update email of new contact
- $this->click("xpath=//ul[@id='actions']/li[2]/a");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->type("email_1_email", $emailString . $i . 'webtest');
- $this->click("_qf_Contact_upload_view");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- }
-
- // goto advanced search
- $this->openCiviPage("contact/search/advanced", "reset=1", "email");
-
- $this->type("email", $emailString);
- $this->click("_qf_Advanced_refresh");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Verify exactly two contacts found
- $this->assertTrue($this->isTextPresent("2 Contacts"), 'Looking for 2 results with email like ' . $emailString);
-
- // Click "check all" box and act on "Add to group" action
- $this->waitForAjaxContent();
- $this->click('toggleSelect');
- $this->waitForAjaxContent();
- $this->waitForText("xpath=//input[@value='ts_sel']/following-sibling::label/span", '2');
- $this->waitForAjaxContent();
- $this->select("task", "label=Group - add contacts");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Select the new group and click to add
- $this->click("group_id");
- $this->select("group_id", "label=" . $newGroupName);
- $this->click("_qf_AddToGroup_next-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Check status messages are as expected
- $this->waitForText('crm-notification-container', "Added Contacts to {$newGroupName}");
- $this->waitForText('crm-notification-container', "2 contacts added to group");
-
- // Search by group membership in newly created group
- $this->openCiviPage('contact/search/advanced', 'reset=1');
- $this->select("group", "label=" . $newGroupName);
- $this->click("_qf_Advanced_refresh");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Verify those two contacts (and only those two) are in the group
- if (!$this->isTextPresent("2 Contacts")) {
- die("nothing found for group $newGroupName");
- }
-
- $this->assertTrue($this->isTextPresent("2 Contacts"), 'Looking for 2 results belonging to group: ' . $newGroupName);
- foreach ($cids as $cid) {
- $this->assertTrue($this->isElementPresent('rowid' . $cid));
- }
-
- }
-
- public function testMultiplePageContactSearchAddContactsToGroup() {
- $this->webtestLogin();
- $newGroupName = 'Group_' . substr(sha1(rand()), 0, 7);
- $this->WebtestAddGroup($newGroupName);
-
- $this->openCiviPage('contact/search', 'reset=1');
- $this->clickLink("_qf_Basic_refresh");
- $this->waitForElementPresent("xpath=//*[@id='CRM_Contact_Form_Search_Basic-rows-per-page-select']");
- $this->type("xpath=//*[@id='CRM_Contact_Form_Search_Basic-rows-per-page-select']", '25');
- $this->waitForElementPresent("toggleSelect");
- $this->click("toggleSelect");
- $this->waitForAjaxContent();
- $this->waitForText("xpath=//div[@class='crm-content-block']/div/div[2]/div/span[2]/a", "Next >");
- $this->click("toggleSelect");
- $this->waitForAjaxContent();
- $this->waitForText("xpath=//input[@value='ts_sel']/following-sibling::label/span", '50');
- $this->select("task", "label=Group - add contacts");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Select the new group and click to add
- $this->waitForElementPresent("group_id");
- $this->click("group_id");
- $this->select("group_id", "label=" . $newGroupName);
- $this->click("_qf_AddToGroup_next-bottom");
-
- // Check status messages are as expected
- $this->waitForText('crm-notification-container', "Added Contacts to {$newGroupName}");
- $this->waitForText('crm-notification-container', "50 contacts added to group");
-
- $this->openCiviPage('contact/search/advanced', 'reset=1');
- $this->select("group", "label=" . $newGroupName);
- $this->click("_qf_Advanced_refresh");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->assertTrue($this->isTextPresent("50 Contacts"), 'Looking for 50 results belonging to group: ' . $newGroupName);
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Contact_TaskActionSendMassMailing
- */
-class WebTest_Contact_TaskActionSendMassMailing extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testSelectedContacts() {
- $this->webtestLogin();
-
- // make group
- $groupName = 'group_' . substr(sha1(rand()), 0, 7);
- $this->WebtestAddGroup($groupName);
-
- // Use class names for menu items since li array can change based on which components are enabled
- $this->click("css=ul#civicrm-menu li.crm-Search");
- $this->clickLink("css=ul#civicrm-menu li.crm-Advanced_Search a", "email");
-
- $this->click("_qf_Advanced_refresh");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Click "check all" box and act on "Add to group" action
- $this->click("//form[@id='Advanced']/div[3]/div/div[2]/table/thead/tr/th[1]/input");
- $this->waitForText('search-status', "50 Selected records only");
- $this->select("task", "label=Email - schedule/send via CiviMail");
- $this->clickLink("Go");
-
- //-------select recipients----------
-
- $mailingName = 'Selected Contact Mailing Test ' . substr(sha1(rand()), 0, 7);
-
- $this->waitForElementPresent("name");
- $this->type("name", "$mailingName");
- $this->select("baseGroup", "label=$groupName");
- $this->click("//option[@value='4']");
- $this->click("_qf_Group_next");
-
- //--------track and respond----------
-
- $this->waitForElementPresent("_qf_Settings_next");
-
- // check for default settings options
- $this->assertChecked("url_tracking");
- $this->assertChecked("open_tracking");
-
- $this->click("_qf_Settings_next");
-
- //--------Mailing content------------
- // fill subject for mailing
- $this->waitForElementPresent("subject");
- $this->type("subject", "Test subject {$mailingName} for Webtest");
-
- // check for default option enabled
- $this->assertChecked("CIVICRM_QFID_1_upload_type");
-
- // HTML format message
- $HTMLMessage = "This is HTML formatted content for Mailing {$mailingName} Webtest.";
- $this->fillRichTextField("html_message", $HTMLMessage);
-
- // Open Plain-text Format pane and type text format msg
- $this->click("//fieldset[@id='compose_id']/div[2]/div[1]");
- $this->type("text_message", "This is text formatted content for Mailing {$mailingName} Webtest.");
-
- // select default header and footer ( with label )
- $this->select("header_id", "label=Mailing Header");
- $this->select("footer_id", "label=Mailing Footer");
- $this->click("_qf_Upload_upload");
-
- $this->waitForElementPresent("_qf_Test_next");
- $this->click("_qf_Test_next");
-
- //----------Schedule or Send------------
-
- $this->waitForElementPresent("_qf_Schedule_next");
-
- $this->assertChecked("now");
-
- $this->click("_qf_Schedule_next");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- //----------end New Mailing-------------
-
- //check redirected page to Scheduled and Sent Mailings and verify for mailing name
- $this->waitForText('page-title', "Scheduled and Sent Mailings");
- $this->waitForText('css=.selector', "$mailingName");
-
- //--------- mail delivery verification---------
-
- // test undelivered report
-
- // click report link of created mailing
- $this->click("xpath=//table//tbody/tr[td[1]/text()='$mailingName']/descendant::a[text()='Report']");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // verify undelivered status message
- $this->waitForText("css=.messages", "Delivery has not yet begun for this mailing. If the scheduled delivery date and time is past, ask the system administrator or technical support contact for your site to verify that the automated mailer task \('cron job'\) is running - and how frequently.");
-
- // directly send schedule mailing -- not working right now
- $this->openCiviPage("mailing/queue", "reset=1");
-
- //click report link of created mailing
- $this->click("xpath=//table//tbody/tr[td[1]/text()='$mailingName']/descendant::a[text()='Report']");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Contact_TaskActionSendSMS
- */
-class WebTest_Contact_TaskActionSendSMS extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testSMSToContacts() {
- $this->webtestLogin();
-
- // ADD a New Group
- $this->openCiviPage("group/add", "reset=1", "_qf_Edit_upload");
-
- $smsGroupName = 'group_' . substr(sha1(rand()), 0, 7);
-
- $this->type("title", $smsGroupName);
- $this->type("description", "New sms group for Webtest");
- $this->select("visibility", "value=Public Pages");
-
- $this->click("_qf_Edit_upload");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // ADD contact1
- $this->openCiviPage("contact/add", "reset=1&ct=Individual");
- $firstName = substr(sha1(rand()), 0, 7);
- $this->type('first_name', $firstName);
-
- $lastName = substr(sha1(rand()), 0, 7);
- $this->type('last_name', $lastName);
-
- $this->waitForElementPresent('phone_1_phone');
- $this->type('phone_1_phone', "911234567890");
-
- $this->select('phone_1_phone_type_id', 'label=Mobile');
-
- $this->click("_qf_Contact_upload_view");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForText('crm-notification-container', "Contact Saved");
-
- $this->click('css=li#tab_group a');
- $this->waitForElementPresent('_qf_GroupContact_next');
- $this->select('group_id', "label=$smsGroupName");
- $this->click('_qf_GroupContact_next');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForText('crm-notification-container', "Added to Group");
-
- // ADD contact2
- $this->openCiviPage("contact/add", "reset=1&ct=Individual");
- $firstName = substr(sha1(rand()), 0, 7);
- $this->type('first_name', $firstName);
-
- $lastName = substr(sha1(rand()), 0, 7);
- $this->type('last_name', $lastName);
-
- $this->waitForElementPresent('phone_1_phone');
- $this->type('phone_1_phone', "911234567891");
-
- $this->select('phone_1_phone_type_id', 'label=Mobile');
-
- $this->click("_qf_Contact_upload_view");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForText('crm-notification-container', "Contact Saved");
-
- $this->click('css=li#tab_group a');
- $this->waitForElementPresent('_qf_GroupContact_next');
- $this->select('group_id', "label=$smsGroupName");
- $this->click('_qf_GroupContact_next');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForText('crm-notification-container', "Added to Group");
-
- // Do an advanced search
- $this->click("css=ul#civicrm-menu li.crm-Search");
- $this->clickLink("css=ul#civicrm-menu li.crm-Advanced_Search a", "email");
-
- $this->select("crmasmSelect1", "label=$smsGroupName");
-
- $this->clickLink("_qf_Advanced_refresh", 'CIVICRM_QFID_ts_all_12');
- $this->click('CIVICRM_QFID_ts_all_12');
-
- // Perform a task action
- $this->select("task", "label=SMS - schedule/send");
- $this->clickLink("Go", 'activity_subject');
- $this->type('activity_subject', "Send SMS to Contacts of {$smsGroupName}");
- $this->type('text_message', "Test SMS to Contacts of {$smsGroupName}");
- $this->click("_qf_SMS_upload-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->assertTrue($this->isTextPresent('Your message has been sent.'), "Test SMS could not be sent!");
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Contact_UpdateProfileTest
- */
-class WebTest_Contact_UpdateProfileTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testUpdateProfile() {
- // Create new via profile
- $this->webtestAddViaCreateProfile();
-
- // Open profile for editing
- $locationUrl = $this->getLocation();
- $editUrl = str_replace('/view?', '/edit?', $locationUrl);
- $this->open($editUrl);
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Modify profile field values
- // contact details section
- // name fields
- $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
- $lastName = 'An' . substr(sha1(rand()), 0, 7);
-
- $this->type("first_name", $firstName);
- $this->type("last_name", $lastName);
-
- //Address Details
- $street = substr(sha1(rand()), 0, 4) . ' Main St.';
- $this->type("street_address-1", $street);
- $city = 'Ci ' . substr(sha1(rand()), 0, 4);
- $this->type("city-1", $city);
- $postalCode = substr(sha1(rand()), 0, 4);
- $this->type("postal_code-1", $postalCode);
- // Hard-coding to Arkansas, not sure best way to get random state.
- $this->select("state_province-1", "value=1003");
-
- // Clicking save.
- $this->click("_qf_Edit_next");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Confirm save was done.
- $this->assertTrue($this->isTextPresent("Thank you. Your information has been saved."));
- $this->assertTrue($this->isTextPresent($firstName));
- $this->assertTrue($this->isTextPresent($lastName));
- $this->assertTrue($this->isTextPresent($street));
- $this->assertTrue($this->isTextPresent($city));
- $this->assertTrue($this->isTextPresent($postalCode));
- $this->assertTrue($this->isElementPresent("//div[@id='profilewrap1']/div[@id='crm-container']/div/div[7]/div[2][contains(text(), 'AR')]"));
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Contribute_AddBatchesTest
- */
-class WebTest_Contribute_AddBatchesTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testBatchAddContribution() {
- $this->webtestLogin();
- $itemCount = 5;
- // create contact
- $contact = array();
-
- //Open Live Contribution Page
- $this->openCiviPage("batch", "reset=1");
- $this->click("xpath=//div[@class='crm-submit-buttons']/a");
- $this->waitForElementPresent("_qf_Batch_next");
- $this->type("item_count", $itemCount);
- $this->type("total", 500);
- $this->click("_qf_Batch_next");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $softCreditTypes = CRM_Core_OptionGroup::values("soft_credit_type", FALSE);
- $softCreditAmount = array(1 => 50, 2 => 60, 3 => 40, 4 => 70, 5 => 35);
- // Add Contact Details
- $data = array();
- for ($i = 1; $i <= $itemCount; $i++) {
- $data[$i] = array(
- 'first_name' => 'Ma' . substr(sha1(rand()), 0, 7),
- 'last_name' => 'An' . substr(sha1(rand()), 0, 7),
- 'financial_type' => 'Donation',
- 'amount' => 100,
- 'soft_credit_first_name' => 'Ar' . substr(sha1(rand()), 0, 7),
- 'soft_credit_last_name' => 'Ki' . substr(sha1(rand()), 0, 7),
- 'soft_credit_amount' => $softCreditAmount[$i],
- 'soft_credit_type' => $softCreditTypes[$i],
-
- );
- $this->_fillData($data[$i], $i, "Contribution");
- }
-
- $this->click("_qf_Entry_cancel");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->_verifyData($data, "Contribution");
- }
-
- public function testBatchAddMembership() {
- $this->webtestLogin();
- $itemCount = 5;
- $softCreditTypes = CRM_Core_OptionGroup::values("soft_credit_type", FALSE);
- $softCreditAmount = array(1 => 50, 2 => 60, 3 => 40, 4 => 70, 5 => 35);
- // create contact
- $contact = array();
- $batchTitle = 'Batch-' . substr(sha1(rand()), 0, 7);
-
- //Open Live Contribution Page
- $this->openCiviPage("batch", "reset=1");
- $this->click("xpath=//div[@class='crm-submit-buttons']/a");
- $this->waitForElementPresent("_qf_Batch_next");
- $this->click("title");
- $this->type("title", $batchTitle);
- $this->select("type_id", "Membership");
- $this->type("item_count", $itemCount);
- $this->type("total", 500);
- $this->click("_qf_Batch_next");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Add Contact Details
- $data = array();
- for ($i = 1; $i <= $itemCount; $i++) {
- $data[$i] = array(
- 'first_name' => 'Ma' . substr(sha1(rand()), 0, 7),
- 'last_name' => 'An' . substr(sha1(rand()), 0, 7),
- 'membership_type' => 'General',
- 'amount' => 100,
- 'financial_type' => 'Member Dues',
- 'soft_credit_first_name' => 'Ar' . substr(sha1(rand()), 0, 7),
- 'soft_credit_last_name' => 'Ki' . substr(sha1(rand()), 0, 7),
- 'soft_credit_amount' => $softCreditAmount[$i],
- 'soft_credit_type' => $softCreditTypes[$i],
- );
- $this->_fillData($data[$i], $i, "Membership");
- }
- $this->click("_qf_Entry_cancel");
-
- $this->_verifyData($data, "Membership");
- }
-
-
- public function testBatchAddPledge() {
- $this->webtestLogin();
-
- // create a new pledge for contact
- $contact = $this->webtestStandalonePledgeAdd();
-
- $itemCount = 2;
- $softCreditTypes = CRM_Core_OptionGroup::values("soft_credit_type", FALSE);
- // create contact
- $batchTitle = 'Batch-' . substr(sha1(rand()), 0, 7);
-
- //Open Live Contribution Page
- $this->openCiviPage("batch", "reset=1");
- $this->click("xpath=//div[@class='crm-submit-buttons']/a");
- $this->waitForElementPresent("_qf_Batch_next");
- $this->click("title");
- $this->type("title", $batchTitle);
- $this->select("type_id", "Pledge Payment");
- $this->type("item_count", $itemCount);
- $this->type("total", 200);
- $this->click("_qf_Batch_next");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Add Contact Details
- $data = array();
- for ($i = 1; $i <= $itemCount; $i++) {
- if ($i == 2) {
- $data[$i] = array('contact' => $contact, 'amount' => 100);
- }
- else {
- $data[$i] = array(
- 'first_name' => 'Ma' . substr(sha1(rand()), 0, 7),
- 'last_name' => 'An' . substr(sha1(rand()), 0, 7),
- 'amount' => 100,
- );
- }
- $data[$i] += array(
- 'membership_type' => 'General',
- 'financial_type' => 'Member Dues',
- 'soft_credit_first_name' => 'Ar' . substr(sha1(rand()), 0, 7),
- 'soft_credit_last_name' => 'Ki' . substr(sha1(rand()), 0, 7),
- 'soft_credit_amount' => 10,
- 'soft_credit_type' => $softCreditTypes[$i],
- );
- $this->_fillData($data[$i], $i, "Pledge Payment");
- }
- $this->click("_qf_Entry_cancel");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->_verifyData($data, "Pledge");
- }
-
- /**
- * @param $data
- * @param $row
- * @param $type
- */
- public function _fillData($data, $row, $type) {
- if (!empty($data['contact'])) {
- $this->select2("s2id_primary_contact_id_{$row}", $data['contact']['email']);
- }
- else {
- $email = $data['first_name'] . '@example.com';
- $this->webtestNewDialogContact($data['first_name'], $data['last_name'], $email, 4, "s2id_primary_contact_id_{$row}", $row, 'primary');
- }
-
- if ($type == "Pledge Payment") {
- $this->select("field_{$row}_financial_type", $data['financial_type']);
- $this->type("field_{$row}_total_amount", $data['amount']);
- $this->webtestFillDateTime("field_{$row}_receive_date", "+1 week");
- $this->type("field_{$row}_contribution_source", substr(sha1(rand()), 0, 10));
- $this->select("field_{$row}_payment_instrument", "Check");
- $this->type("field_{$row}_check_number", rand());
- $this->click("field[{$row}][send_receipt]");
- $this->click("field_{$row}_invoice_id");
- $this->type("field_{$row}_invoice_id", substr(sha1(rand()), 0, 10));
- $softcreditemail = $data['soft_credit_first_name'] . '@example.com';
- $this->webtestNewDialogContact($data['soft_credit_first_name'],
- $data['soft_credit_last_name'],
- $softcreditemail, 4,
- "s2id_soft_credit_contact_id_{$row}",
- $row,
- 'soft_credit'
- );
- $this->type("soft_credit_amount_{$row}", $data['soft_credit_amount']);
- $this->select("soft_credit_type_{$row}", $data['soft_credit_type']);
- if (!empty($data['contact'])) {
- $pledgeID = CRM_Pledge_BAO_Pledge::getContactPledges($data['contact']['id']);
- $this->select("open_pledges_{$row}", "value={$pledgeID[0]}");
- $this->click("css=span#{$row}.pledge-adjust-option a");
- sleep(5);
- $this->select("option_type_{$row}", "value=1");
- $this->click("css=span#{$row}.pledge-adjust-option a");
- $this->type("field_{$row}_total_amount", $data['amount']);
- }
- }
- elseif ($type == "Contribution") {
- $this->select("field_{$row}_financial_type", $data['financial_type']);
- $this->type("field_{$row}_total_amount", $data['amount']);
- $this->webtestFillDateTime("field_{$row}_receive_date", "+1 week");
- $this->type("field_{$row}_contribution_source", substr(sha1(rand()), 0, 10));
- $this->select("field_{$row}_payment_instrument", "Check");
- $this->type("field_{$row}_check_number", rand());
- $this->click("field[{$row}][send_receipt]");
- $this->click("field_{$row}_invoice_id");
- $this->type("field_{$row}_invoice_id", substr(sha1(rand()), 0, 10));
- $softcreditemail = $data['soft_credit_first_name'] . '@example.com';
- $this->webtestNewDialogContact($data['soft_credit_first_name'],
- $data['soft_credit_last_name'],
- $softcreditemail, 4,
- "s2id_soft_credit_contact_id_{$row}",
- $row,
- 'soft_credit'
- );
- $this->type("soft_credit_amount_{$row}", $data['soft_credit_amount']);
- $this->select("soft_credit_type_{$row}", $data['soft_credit_type']);
-
- }
- elseif ($type == "Membership") {
- $this->select("field[{$row}][membership_type][0]", "value=1");
- $this->select("field[{$row}][membership_type][1]", $data['membership_type']);
- $this->webtestFillDate("field_{$row}_join_date", "now");
- $this->webtestFillDate("field_{$row}_membership_start_date", "now");
- $this->webtestFillDate("field_{$row}_membership_end_date", "+1 month");
- $this->type("field_{$row}_membership_source", substr(sha1(rand()), 0, 10));
- $this->click("field[{$row}][send_receipt]");
- $this->select("field_{$row}_financial_type", $data['financial_type']);
-
- $this->webtestFillDateTime("field_{$row}_receive_date", "+1 week");
- $this->select("field_{$row}_payment_instrument", "Check");
- $this->type("field_{$row}_check_number", rand());
- $this->select("field_{$row}_contribution_status_id", "Completed");
- $softcreditemail = $data['soft_credit_first_name'] . '@example.com';
- $this->webtestNewDialogContact($data['soft_credit_first_name'],
- $data['soft_credit_last_name'],
- $softcreditemail, 4,
- "s2id_soft_credit_contact_id_{$row}",
- $row, 'soft_credit'
- );
- $this->type("soft_credit_amount_{$row}", $data['soft_credit_amount']);
- $this->select("soft_credit_type_{$row}", $data['soft_credit_type']);
- }
- }
-
- /**
- * @param $data
- * @param $type
- */
- public function _checkResult($data, $type) {
- if ($type == "Contribution") {
- $this->openCiviPage("contribute/search", "reset=1", "contribution_date_low");
- $this->type("sort_name", "{$data['last_name']} {$data['first_name']}");
- $this->clickLink("_qf_Search_refresh", "xpath=//table[@class='selector row-highlight']/tbody/tr[1]/td[10]/span//a[text()='View']", FALSE);
- $this->clickLink("xpath=//table[@class='selector row-highlight']/tbody/tr[1]/td[10]/span//a[text()='View']", "_qf_ContributionView_cancel-bottom", FALSE);
- $expected = array(
- 'From' => "{$data['first_name']} {$data['last_name']}",
- 'Financial Type' => $data['financial_type'],
- 'Total Amount' => $data['amount'],
- 'Contribution Status' => 'Completed',
- );
-
- $this->webtestVerifyTabularData($expected);
- $expectedSoft = array(
- 'Soft Credit To' => "{$data['soft_credit_first_name']} {$data['soft_credit_last_name']}",
- 'Amount (Soft Credit Type)' => "{$data['soft_credit_amount']}",
- 'Soft Credit Type' => $data['soft_credit_type'],
- );
- foreach ($expectedSoft as $value) {
- $this->assertElementContainsText("css=table.crm-soft-credit-listing", $value);
- }
- }
- elseif ($type == "Membership") {
- $this->openCiviPage("member/search", "reset=1", "member_join_date_low");
-
- // select contact
- $this->type("sort_name", "{$data['last_name']} {$data['first_name']}");
- $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='memberSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']");
- $this->click("xpath=//div[@id='memberSearch']//table/tbody/tr[1]/td[11]/span/a[text()='View']");
- $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
- $expected = array(
- 2 => 'General',
- 4 => 'New',
- );
- foreach ($expected as $label => $value) {
- $this->assertElementContainsText("xpath=id('MembershipView')/div[2]/div/table[1]/tbody/tr[$label]/td[2]", $value);
- }
- //View Contribution
- $this->waitForElementPresent("xpath=//form[@id='MembershipView']/div[2]/div/div[2]/div[2]/table/tbody/tr[1]/td[8]/span/a[1][text()='View']");
- $this->click("xpath=//form[@id='MembershipView']/div[2]/div/div[2]/div[2]/table/tbody/tr[1]/td[8]/span/a[1][text()='View']");
- $this->waitForElementPresent("_qf_ContributionView_cancel-bottom");
- $expected = array(
- 'From' => "{$data['first_name']} {$data['last_name']}",
- 'Financial Type' => $data['financial_type'],
- 'Total Amount' => $data['amount'],
- 'Contribution Status' => 'Completed',
- );
-
- $this->webtestVerifyTabularData($expected);
- $expectedSoft = array(
- 'Soft Credit To' => "{$data['soft_credit_first_name']} {$data['soft_credit_last_name']}",
- 'Amount (Soft Credit Type)' => "{$data['soft_credit_amount']}",
- 'Soft Credit Type' => $data['soft_credit_type'],
- );
- foreach ($expectedSoft as $value) {
- $this->assertElementContainsText("css=table.crm-soft-credit-listing", $value);
- }
- }
- }
-
- /**
- * @param $data
- * @param $type
- */
- public function _verifyData($data, $type) {
- $this->waitForElementPresent("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody//tr//td/span/a[1][contains(text(),'Enter records')]");
- $this->click("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody//tr//td/span/a[1]");
- $this->waitForElementPresent('_qf_Entry_upload');
- $this->click("_qf_Entry_upload");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- foreach ($data as $value) {
- $this->_checkResult($value, $type);
- }
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Contribute_AddPricesetTest
- */
-class WebTest_Contribute_AddPricesetTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testAddPriceSet() {
- // Log in using webtestLogin() method
- $this->webtestLogin();
-
- //add financial type of account type expense
-
- $financialType = $this->_testAddFinancialType();
-
- $setTitle = 'Conference Fees - ' . substr(sha1(rand()), 0, 7);
- $usedFor = 'Contribution';
- $setHelp = 'Select your conference options.';
- $this->_testAddSet($setTitle, $usedFor, $setHelp, $financialType);
-
- // Get the price set id ($sid) by retrieving and parsing the URL of the New Price Field form
- // which is where we are after adding Price Set.
- $sid = $this->urlArg('sid');
- $this->assertType('numeric', $sid);
-
- $validStrings = array();
-
- $fields = array(
- 'Full Conference' => 'Text',
- 'Meal Choice' => 'Select',
- 'Pre-conference Meetup?' => 'Radio',
- 'Evening Sessions' => 'CheckBox',
- );
- $this->_testAddPriceFields($fields, $validateStrings, $financialType);
- // var_dump($validateStrings);
-
- // load the Price Set Preview and check for expected values
- $this->_testVerifyPriceSet($validateStrings, $sid);
- }
-
- /**
- * @return string
- */
- public function _testAddFinancialType() {
- //Add new Financial Type
- $financialType['name'] = 'FinancialType ' . substr(sha1(rand()), 0, 4);
- $financialType['is_deductible'] = TRUE;
- $financialType['is_reserved'] = FALSE;
- $this->addeditFinancialType($financialType);
- return $financialType['name'];
- }
-
- /**
- * @param $validateStrings
- * @param int $sid
- */
- public function _testVerifyPriceSet($validateStrings, $sid) {
- // verify Price Set at Preview page
- // start at Manage Price Sets listing
- $this->openCiviPage("admin/price", "reset=1");
-
- // Use the price set id ($sid) to pick the correct row
- $this->clickLink("//*[@id='price_set-{$sid}']/td[4]/span[1]/a[1]", 'Link=Add Price Field');
- // Check for expected price set field strings
- $this->assertStringsPresent($validateStrings);
- }
-
- public function testContributeOfflineWithPriceSet() {
- // Log in using webtestLogin() method
- $this->webtestLogin();
-
- //add financial type of account type expense
- $financialType = $this->_testAddFinancialType();
-
- $setTitle = 'Conference Fees - ' . substr(sha1(rand()), 0, 7);
- $usedFor = 'Contribution';
- $setHelp = 'Select your conference options.';
- $this->_testAddSet($setTitle, $usedFor, $setHelp, $financialType);
-
- // Get the price set id ($sid) by retrieving and parsing the URL of the New Price Field form
- // which is where we are after adding Price Set.
- $sid = $this->urlArg('sid');
- $this->assertType('numeric', $sid);
-
- $validStrings = array();
- $fields = array(
- 'Full Conference' => 'Text',
- 'Meal Choice' => 'Select',
- 'Pre-conference Meetup?' => 'Radio',
- 'Evening Sessions' => 'CheckBox',
- );
- $this->_testAddPriceFields($fields, $validateStrings, $financialType);
-
- // load the Price Set Preview and check for expected values
- $this->_testVerifyPriceSet($validateStrings, $sid);
- $this->openCiviPage("contribute/add", "reset=1&action=add&context=standalone", '_qf_Contribution_upload');
-
- // create new contact using dialog
- $this->createDialogContact();
-
- // select financial type
- $this->select('financial_type_id', "label={$financialType}");
-
- // fill in Received Date
- $this->webtestFillDate('receive_date');
-
- // source
- $this->type('source', 'Mailer 1');
-
- // select price set items
- $this->select('price_set_id', "label=$setTitle");
- $this->type("xpath=//input[@class='four crm-form-text required']", "1");
- $this->click("xpath=//input[@class='crm-form-radio']");
- $this->click("xpath=//input[@class='crm-form-checkbox']");
- // select payment instrument type = Check and enter chk number
- $this->select('payment_instrument_id', 'value=4');
- $this->waitForElementPresent('check_number');
- $this->type('check_number', 'check #1041');
-
- $this->type('trxn_id', 'P20901X1' . rand(100, 10000));
-
- //Additional Detail section
- $this->click('AdditionalDetail');
- $this->waitForElementPresent('thankyou_date');
-
- $this->type('note', 'This is a test note.');
- $this->type('non_deductible_amount', '10');
- $this->type('fee_amount', '0');
- $this->type('net_amount', '0');
- $this->type('invoice_id', time());
- $this->webtestFillDate('thankyou_date');
-
- // Clicking save.
- $this->click('_qf_Contribution_upload');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Is status message correct?
- $this->assertTrue($this->isTextPresent('The contribution record has been saved.'), "Status message didn't show up after saving!");
- $this->waitForElementPresent("xpath=//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span//a[text()='View']");
-
- //click through to the Membership view screen
- $this->click("xpath=//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span//a[text()='View']");
- $this->waitForElementPresent('_qf_ContributionView_cancel-bottom');
- $expected = array(
- 2 => $financialType,
- 3 => '590.00',
- 9 => 'Completed',
- 10 => 'Check',
- 11 => 'check #1041',
- );
- foreach ($expected as $label => $value) {
- $this->assertElementContainsText("xpath=id('ContributionView')/div[2]/table[1]/tbody/tr[$label]/td[2]", $value);
- }
-
- $exp = array(
- 2 => '$ 525.00',
- 3 => '$ 50.00',
- 4 => '$ 15.00',
- );
-
- foreach ($exp as $lab => $val) {
- $this->assertElementContainsText("xpath=id('ContributionView')/div[2]/table[1]/tbody/tr[3]/td[2]/table/tbody/tr[$lab]/td[3]", $val);
- }
- }
-
- public function testContributeOnlineWithPriceSet() {
- $this->webtestLogin();
-
- //add financial type of account type expense
- $financialType = $this->_testAddFinancialType();
-
- $setTitle = 'Conference Fees - ' . substr(sha1(rand()), 0, 7);
- $usedFor = 'Contribution';
- $setHelp = 'Select your conference options.';
- $this->_testAddSet($setTitle, $usedFor, $setHelp, $financialType);
-
- // Get the price set id ($sid) by retrieving and parsing the URL of the New Price Field form
- // which is where we are after adding Price Set.
- $sid = $this->urlArg('sid');
- $this->assertType('numeric', $sid);
-
- $validStrings = array();
- $fields = array(
- 'Full Conference' => 'Text',
- 'Meal Choice' => 'Select',
- 'Pre-conference Meetup?' => 'Radio',
- 'Evening Sessions' => 'CheckBox',
- );
-
- $this->_testAddPriceFields($fields, $validateStrings, $financialType);
-
- // load the Price Set Preview and check for expected values
- $this->_testVerifyPriceSet($validateStrings, $sid);
-
- // Use default payment processor
- $processorName = 'Test Processor';
- $this->webtestAddPaymentProcessor($processorName);
-
- $this->openCiviPage("admin/contribute/add", "reset=1&action=add");
-
- $contributionTitle = substr(sha1(rand()), 0, 7);
- $rand = 2 * rand(2, 50);
-
- // fill in step 1 (Title and Settings)
- $contributionPageTitle = "Title $contributionTitle";
- $this->type('title', $contributionPageTitle);
- $this->fillRichTextField('intro_text', 'This is Test Introductory Message', 'CKEditor');
- $this->fillRichTextField('footer_text', 'This is Test Footer Message', 'CKEditor');
-
- $this->select('financial_type_id', "label={$financialType}");
-
- // Submit form
- $this->clickLink('_qf_Settings_next', "_qf_Amount_next-bottom");
-
- // Get contribution page id
- $pageId = $this->urlArg('id');
-
- //this contribution page for online contribution
- $this->click("xpath=//tr[@class='crm-contribution-contributionpage-amount-form-block-payment_processor']/td/label[text()='$processorName']");
- $this->select('price_set_id', 'label=' . $setTitle);
- $this->click('_qf_Amount_next-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- //logout
- $this->webtestLogout();
-
- //Open Live Contribution Page
- $this->openCiviPage('contribute/transact', "reset=1&id=$pageId&action=preview", '_qf_Main_upload-bottom');
-
- $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
- $lastName = 'An' . substr(sha1(rand()), 0, 7);
- $email = $firstName . "@example.com";
- $this->waitForElementPresent('_qf_Main_upload-bottom');
- $this->type("email-5", $email);
- $this->type("xpath=//input[@class='four crm-form-text required']", "1");
- $this->click("xpath=//input[@class='crm-form-radio']");
- $this->click("xpath=//input[@class='crm-form-checkbox']");
-
- $streetAddress = '100 Main Street';
- $this->type('billing_street_address-5', $streetAddress);
- $this->type('billing_city-5', 'San Francisco');
- $this->type('billing_postal_code-5', '94117');
- $this->waitForAjaxContent();
- $this->select('billing_country_id-5', 'value=1228');
- $this->select('billing_state_province_id-5', 'value=1001');
-
- //Credit Card Info
- $this->select('credit_card_type', 'value=Visa');
- $this->type('credit_card_number', '4111111111111111');
- $this->type('cvv2', '000');
- $this->select('credit_card_exp_date[M]', 'value=1');
- $this->select('credit_card_exp_date[Y]', 'value=2020');
-
- //Billing Info
- $this->type('billing_first_name', $firstName);
- $this->type('billing_last_name', $lastName);
- $this->type('billing_street_address-5', '15 Main St.');
- $this->type('billing_city-5', 'San Jose');
- $this->select('billing_country_id-5', 'value=1228');
- $this->select('billing_state_province_id-5', 'value=1004');
- $this->type('billing_postal_code-5', '94129');
- $this->clickLink('_qf_Main_upload-bottom', '_qf_Confirm_next-bottom');
-
- $this->click('_qf_Confirm_next-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- //login to check contribution
-
- // Log in using webtestLogin() method
- $this->webtestLogin();
-
- //Find Contribution
- $this->openCiviPage("contribute/search", "reset=1", 'contribution_date_low');
-
- $this->click("xpath=//tr/td[1]/label[contains(text(), 'Contribution is a Test?')]/../../td[2]/label[contains(text(), 'Yes')]/preceding-sibling::input[1]");
- $this->type("sort_name", "$email");
- $this->waitForAjaxContent();
- $this->click("xpath=//div[@class='crm-accordion-wrapper crm-contribution_search_form-accordion ']/div[2]/table/tbody/tr[8]/td[1]/table/tbody/tr[3]/td[2]/label[1]");
- $this->clickLink('_qf_Search_refresh', "xpath=//table[@class='selector row-highlight']/tbody/tr[1]/td[10]/span//a[text()='View']");
- $this->clickLink("xpath=//table[@class='selector row-highlight']/tbody/tr[1]/td[10]/span//a[text()='View']", "_qf_ContributionView_cancel-bottom", FALSE);
-
- // View Contribution Record and test for expected values
- $expected = array(
- 'From' => "{$firstName} {$lastName}",
- 'Financial Type' => $financialType,
- // as per changes made in CRM-15407
- 'Fee Amount' => '$ 1.50',
- 'Net Amount' => '$ 588.50',
- 'Contribution Status' => 'Completed',
- );
- $this->webtestVerifyTabularData($expected);
-
- }
-
- public function testContributeWithDateSpecificPriceSet() {
- $this->webtestLogin();
-
- //add financial type of account type expense
- $financialType = $this->_testAddFinancialType();
-
- $setTitle = 'Conference Fees - ' . substr(sha1(rand()), 0, 7);
- $usedFor = 'Contribution';
- $setHelp = 'Select your conference options.';
- $this->_testAddSet($setTitle, $usedFor, $setHelp, $financialType);
-
- // Get the price set id ($sid) by retrieving and parsing the URL of the New Price Field form
- // which is where we are after adding Price Set.
- $sid = $this->urlArg('sid');
- $this->assertType('numeric', $sid);
-
- $validStrings = array();
- $fields = array(
- 'Full Conference' => 'Text',
- 'Meal Choice' => 'Select',
- 'Pre-conference Meetup?' => 'Radio',
- 'Evening Sessions' => 'CheckBox',
- );
- $this->_testAddPriceFields($fields, $validateStrings, $financialType, TRUE);
-
- // load the Price Set Preview and check for expected values
- $this->_testVerifyPriceSet($validateStrings, $sid);
-
- // Use default payment processor
- $processorName = 'Test Processor';
- $this->webtestAddPaymentProcessor($processorName);
-
- $this->openCiviPage("admin/contribute/add", "reset=1&action=add");
-
- $contributionTitle = substr(sha1(rand()), 0, 7);
- $rand = 2 * rand(2, 50);
-
- // fill in step 1 (Title and Settings)
- $contributionPageTitle = "Title $contributionTitle";
- $this->type('title', $contributionPageTitle);
- $this->select('financial_type_id', "label={$financialType}");
- $this->fillRichTextField('intro_text', 'This is Test Introductory Message', 'CKEditor');
- $this->fillRichTextField('footer_text', 'This is Test Footer Message', 'CKEditor');
-
- // Submit form
- $this->clickLink('_qf_Settings_next', "_qf_Amount_next-bottom");
-
- // Get contribution page id
- $pageId = $this->urlArg('id');
-
- //this contribution page for online contribution
- $this->waitForElementPresent("xpath=//tr[@class='crm-contribution-contributionpage-amount-form-block-payment_processor']/td");
- $this->click("xpath=//tr[@class='crm-contribution-contributionpage-amount-form-block-payment_processor']/td/label[text()='$processorName']");
- $this->select('price_set_id', 'label=' . $setTitle);
- $this->clickLink('_qf_Amount_next-bottom');
-
- //logout
- $this->webtestLogout();
-
- //Open Live Contribution Page
- $this->openCiviPage('contribute/transact', "reset=1&id=$pageId&action=preview", '_qf_Main_upload-bottom');
-
- $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
- $lastName = 'An' . substr(sha1(rand()), 0, 7);
- $email = $firstName . "@example.com";
- $this->waitForElementPresent('_qf_Main_upload-bottom');
- $this->type('email-5', $email);
- $this->click("xpath=//input[@class='crm-form-radio']");
- $this->click("xpath=//input[@class='crm-form-checkbox']");
-
- $streetAddress = '100 Main Street';
- $this->type('billing_street_address-5', $streetAddress);
- $this->type('billing_city-5', 'San Francisco');
- $this->type('billing_postal_code-5', '94117');
- $this->select('billing_country_id-5', 'value=1228');
- $this->select('billing_state_province_id-5', 'value=1001');
-
- //Credit Card Info
- $this->select('credit_card_type', 'value=Visa');
- $this->type('credit_card_number', '4111111111111111');
- $this->type('cvv2', '000');
- $this->select('credit_card_exp_date[M]', 'value=1');
- $this->select('credit_card_exp_date[Y]', 'value=2020');
-
- //Billing Info
- $this->type('billing_first_name', $firstName);
- $this->type('billing_last_name', $lastName);
- $this->type('billing_street_address-5', '15 Main St.');
- $this->type(' billing_city-5', 'San Jose');
- $this->select('billing_country_id-5', 'value=1228');
- $this->select('billing_state_province_id-5', 'value=1004');
- $this->type('billing_postal_code-5', '94129');
- $this->clickLink('_qf_Main_upload-bottom', '_qf_Confirm_next-bottom');
-
- $this->click('_qf_Confirm_next-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- //login to check contribution
- $this->webtestLogin();
-
- //Find Contribution
- $this->openCiviPage("contribute/search", "reset=1", 'contribution_date_low');
- $this->click("xpath=//tr/td[1]/label[contains(text(), 'Contribution is a Test?')]/../../td[2]/label[contains(text(), 'Yes')]/preceding-sibling::input[1]");
- $this->type("sort_name", "$email");
- $this->waitForAjaxContent();
- $this->click("xpath=//div[@class='crm-accordion-wrapper crm-contribution_search_form-accordion ']/div[2]/table/tbody/tr[8]/td[1]/table/tbody/tr[3]/td[2]/label[1]");
- $this->clickLink('_qf_Search_refresh', "xpath=//table[@class='selector row-highlight']/tbody/tr[1]/td[10]/span//a[text()='View']", FALSE);
- $this->clickLink("xpath=//table[@class='selector row-highlight']/tbody/tr[1]/td[10]/span//a[text()='View']", '_qf_ContributionView_cancel-bottom', FALSE);
-
- // View Contribution Record and test for expected values
- $expected = array(
- 'From' => "{$firstName} {$lastName}",
- 'Financial Type' => $financialType,
- // as per changes made in CRM-15407
- 'Fee Amount' => '$ 1.50',
- 'Net Amount' => '$ 63.50',
- 'Contribution Status' => 'Completed',
- );
- $this->webtestVerifyTabularData($expected);
- }
-
- public function testContributeOfflineforSoftcreditwithApi() {
- // Log in using webtestLogin() method
- $this->webtestLogin();
-
- //create a contact and return the contact id
- $firstNameSoft = "John_" . substr(sha1(rand()), 0, 5);
- $lastNameSoft = "Doe_" . substr(sha1(rand()), 0, 5);
- $this->webtestAddContact($firstNameSoft, $lastNameSoft);
- $url = $this->parseURL();
- $cid = $url['queryString']['cid'];
- $this->assertType('numeric', $cid);
-
- $setTitle = 'Conference Fees - ' . substr(sha1(rand()), 0, 7);
- $usedFor = 'Contribution';
- $setHelp = 'Select your conference options.';
- $financialType = $this->_testAddFinancialType();
- $this->_testAddSet($setTitle, $usedFor, $setHelp, $financialType);
-
- // Get the price set id ($sid) by retrieving and parsing the URL of the New Price Field form
- // which is where we are after adding Price Set.
- $sid = $this->urlArg('sid');
- $this->assertType('numeric', $sid);
-
- $validStrings = array();
- $fields = array(
- 'Full Conference' => 'Text',
- 'Meal Choice' => 'Select',
- 'Pre-conference Meetup?' => 'Radio',
- 'Evening Sessions' => 'CheckBox',
- );
- $this->_testAddPriceFields($fields, $validateStrings, $financialType);
-
- // load the Price Set Preview and check for expected values
- $this->_testVerifyPriceSet($validateStrings, $sid);
-
- $this->openCiviPage("contribute/add", "reset=1&action=add&context=standalone", '_qf_Contribution_upload');
-
- // create new contact using dialog
- $contact = $this->createDialogContact();
-
- // select contribution type
- $this->select('financial_type_id', "label={$financialType}");
-
- // fill in Received Date
- $this->webtestFillDate('receive_date');
-
- // source
- $this->type('source', 'Mailer 1');
-
- // select price set items
- $this->select('price_set_id', "label=$setTitle");
- $this->type("xpath=//input[@class='four crm-form-text required']", "1");
- $this->click("xpath=//input[@class='crm-form-radio']");
- $this->click("xpath=//input[@class='crm-form-checkbox']");
- // select payment instrument type = Check and enter chk number
- $this->select('payment_instrument_id', 'value=4');
- $this->waitForElementPresent('check_number');
- $this->type('check_number', '1041');
-
- $this->type('trxn_id', 'P20901X1' . rand(100, 10000));
-
- $this->webtestFillAutocomplete("{$lastNameSoft}, {$firstNameSoft}", 'soft_credit_contact_id_1');
-
- $this->type('soft_credit_amount_1', "65");
- //Additional Detail section
- $this->click('AdditionalDetail');
- $this->waitForElementPresent('thankyou_date');
-
- $this->type('note', 'This is a test note.');
- $this->type('invoice_id', time());
- $this->webtestFillDate('thankyou_date');
-
- // Clicking save.
- $this->clickLink('_qf_Contribution_upload', "xpath=//table[@class='selector row-highlight']//tbody/tr[1]/td[8]/span//a[text()='View']", FALSE);
- $this->assertTrue($this->isTextPresent('The contribution record has been saved.'), "Status message didn't show up after saving!");
-
- //click through to the Contribution view screen
- $this->click("xpath=//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='View']");
- $this->waitForElementPresent('_qf_ContributionView_cancel-bottom');
-
- // View Contribution Record and test for expected values
- $expected = array(
- 'From' => $contact['display_name'],
- 'Financial Type' => $financialType,
- 'Contribution Amount' => 'Contribution Total: $ 590.00',
- 'Payment Method' => 'Check',
- 'Check Number' => '1041',
- 'Contribution Status' => 'Completed',
- );
- $this->webtestVerifyTabularData($expected);
-
- $exp = array(
- 2 => '$ 525.00',
- 3 => '$ 50.00',
- 4 => '$ 15.00',
- );
-
- foreach ($exp as $lab => $val) {
- $this->assertElementContainsText("xpath=id('ContributionView')/div[2]/table[1]/tbody/tr[3]/td[2]/table/tbody/tr[$lab]/td[3]", $val);
- }
-
- // verify if soft credit was created successfully
- $softCreditValues = array(
- 'Soft Credit To' => "{$firstNameSoft} {$lastNameSoft}",
- 'Amount' => '65.00',
- );
-
- foreach ($softCreditValues as $value) {
- $this->assertElementContainsText("css=table.crm-soft-credit-listing", $value);
- }
-
- // Check for Soft contact created
- $this->click("css=input#sort_name_navigation");
- $this->type("css=input#sort_name_navigation", "$lastNameSoft, $firstNameSoft");
- $this->typeKeys("css=input#sort_name_navigation", "$lastNameSoft, $firstNameSoft");
- // wait for result list
- $this->waitForElementPresent("css=ul.ui-autocomplete li");
-
- // visit contact summary page
- $this->click("css=ul.ui-autocomplete li");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->click('css=li#tab_contribute a');
- $this->waitForElementPresent('link=Record Contribution (Check, Cash, EFT ...)');
-
- $id = explode('id=', $this->getAttribute("xpath=//table[@class='selector row-highlight']/tbody//tr[@id='rowid']/td[8]/a[text()='View']@href"));
- $id = substr($id[1], 0, strpos($id[1], '&'));
- $this->click("xpath=//table[@class='selector row-highlight']/tbody//tr[@id='rowid']/td[8]/a");
- $this->waitForElementPresent('_qf_ContributionView_cancel-bottom');
-
- $this->webtestVerifyTabularData($expected);
-
- $params = array(
- 'contribution_id' => $id,
- 'version' => 3,
- );
-
- // Retrieve contribution from the DB via api and verify DB values against view contribution page
- $fields = $this->webtest_civicrm_api('contribution', 'get', $params);
-
- $params['id'] = $params['contact_id'] = $fields['values'][$fields['id']]['soft_credit_to'];
- $softCreditContact = CRM_Contact_BAO_Contact::retrieve($params, $defaults, TRUE);
-
- // View Contribution Record and test for expected values
- $expected = array(
- 'From' => $fields['values'][$fields['id']]['display_name'],
- 'Financial Type' => $fields['values'][$fields['id']]['financial_type'],
- 'Contribution Amount' => $fields['values'][$fields['id']]['total_amount'],
- 'Contribution Status' => $fields['values'][$fields['id']]['contribution_status'],
- 'Payment Method' => $fields['values'][$fields['id']]['payment_instrument'],
- 'Check Number' => $fields['values'][$fields['id']]['contribution_check_number'],
- );
-
- $this->webtestVerifyTabularData($expected);
-
- // verify if soft credit
- $softCreditValues = array(
- 'Soft Credit To' => $softCreditContact->display_name,
- 'Amount' => '65.00',
- );
-
- foreach ($softCreditValues as $value) {
- $this->assertElementContainsText("css=table.crm-soft-credit-listing", $value);
- }
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Contribute_ConfirmOptionalTest
- */
-class WebTest_Contribute_ConfirmOptionalTest extends CiviSeleniumTestCase {
- protected $pageId = 0;
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testWithConfirm() {
- $this->_addContributionPage(TRUE);
- $this->_fillOutContributionPage();
-
- // confirm contribution
- $this->assertFalse($this->isTextPresent("Your transaction has been processed successfully"), "Loaded thank you page");
- $this->waitForElementPresent("_qf_Confirm_next-bottom");
- $this->assertTrue($this->isTextPresent("Please verify the information below carefully"), "Should load confirmation page");
- $this->click("_qf_Confirm_next-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // thank you page
- $this->assertTrue($this->isTextPresent("Your transaction has been processed successfully"), "Should load thank you page");
- }
-
- public function testWithoutConfirm() {
- $this->_addContributionPage(FALSE);
- $this->_fillOutContributionPage();
-
- // thank you page
- $this->assertTrue($this->isTextPresent("Your transaction has been processed successfully"), "Didn't load thank you page after main page");
- $this->assertFalse($this->isTextPresent("Your contribution will not be completed until"), "Loaded confirmation page");
- }
-
- /**
- * @param $isConfirmEnabled
- */
- protected function _addContributionPage($isConfirmEnabled) {
- // log in
- $this->webtestLogin();
-
- // create new contribution page
- $hash = substr(sha1(rand()), 0, 7);
- $this->pageId = $this->webtestAddContributionPage(
- $hash,
- $rand = NULL,
- $pageTitle = "Test Confirm ($hash)",
- $processor = array("Dummy ($hash)" => 'Dummy'),
- $amountSection = TRUE,
- $payLater = FALSE,
- $onBehalf = FALSE,
- $pledges = FALSE,
- $recurring = FALSE,
- $membershipTypes = FALSE,
- $memPriceSetId = NULL,
- $friend = FALSE,
- $profilePreId = NULL,
- $profilePostId = NULL,
- $premiums = FALSE,
- $widget = FALSE,
- $pcp = FALSE,
- $isAddPaymentProcessor = TRUE,
- $isPcpApprovalNeeded = FALSE,
- $isSeparatePayment = FALSE,
- $honoreeSection = FALSE,
- $allowOtherAmount = TRUE,
- $isConfirmEnabled = $isConfirmEnabled
- );
- }
-
- protected function _fillOutContributionPage() {
- // load contribution page
- $this->openCiviPage("contribute/transact", "reset=1&id={$this->pageId}&action=preview", "_qf_Main_upload-bottom");
-
- // fill out info
- $this->type("xpath=//div[@class='crm-section other_amount-section']//div[2]/input", "30");
- $this->webtestAddCreditCardDetails();
- list($firstName, $middleName, $lastName) = $this->webtestAddBillingDetails();
- $this->type('email-5', "$lastName@example.com");
-
- // submit contribution
- $this->click("_qf_Main_upload-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Contribute_ContactContextAddTest
- */
-class WebTest_Contribute_ContactContextAddTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testContactContextAdd() {
-
- // Log in using webtestLogin() method
- $this->webtestLogin();
-
- // Create a contact to be used as soft creditor
- $softCreditFname = substr(sha1(rand()), 0, 7);
- $softCreditLname = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($softCreditFname, $softCreditLname, FALSE);
-
- // Adding contact with randomized first name (so we can then select that contact when creating contribution.)
- // We're using Quick Add block on the main page for this.
- $firstName = substr(sha1(rand()), 0, 7);
- // Add new Financial Account
- $orgName = 'Alberta ' . substr(sha1(rand()), 0, 7);
- $financialAccountTitle = 'Financial Account ' . substr(sha1(rand()), 0, 4);
- $financialAccountDescription = "{$financialAccountTitle} Description";
- $accountingCode = 1033;
- $financialAccountType = 'Asset';
- $taxDeductible = FALSE;
- $isActive = FALSE;
- $isTax = TRUE;
- $taxRate = 9.99999999;
- $isDefault = FALSE;
-
- //Add new organisation
- if ($orgName) {
- $this->webtestAddOrganization($orgName);
- }
- $this->_testAddFinancialAccount($financialAccountTitle,
- $financialAccountDescription,
- $accountingCode,
- $orgName,
- $financialAccountType,
- $taxDeductible,
- $isActive,
- $isTax,
- $taxRate,
- $isDefault
- );
-
- $this->webtestAddContact($firstName, "Anderson", TRUE);
-
- // Get the contact id of the new contact
- $contactUrl = $this->parseURL();
- $cid = $contactUrl['queryString']['cid'];
- $this->assertType('numeric', $cid);
-
- // go to contribution tab and add contribution.
- $this->click("css=li#tab_contribute a");
-
- // wait for Record Contribution elenment.
- $this->waitForElementPresent("link=Record Contribution (Check, Cash, EFT ...)");
- $this->click("link=Record Contribution (Check, Cash, EFT ...)");
-
- $this->waitForElementPresent("_qf_Contribution_cancel-bottom");
- // fill financial type.
- $this->select("financial_type_id", "Donation");
-
- // fill in Received Date
- $this->webtestFillDate('receive_date');
-
- // source
- $this->type("source", "Mailer 1");
-
- // total amount
- $this->type("total_amount", "100");
-
- // select payment instrument type = Check and enter chk number
- $this->select("payment_instrument_id", "value=4");
- $this->waitForElementPresent("check_number");
- $this->type("check_number", "check #1041");
-
- $this->type("trxn_id", "P20901X1" . rand(100, 10000));
-
- // soft credit
- $this->webtestFillAutocomplete("{$softCreditLname}, {$softCreditFname}", 'soft_credit_contact_id_1');
- $this->type("soft_credit_amount_1", "100");
-
- //Custom Data
- //$this->waitForElementPresent('CIVICRM_QFID_3_6');
- //$this->click('CIVICRM_QFID_3_6');
-
- //Additional Detail section
- $this->click("AdditionalDetail");
- $this->waitForElementPresent("thankyou_date");
-
- $this->type("note", "Test note for {$firstName}.");
- $this->type("fee_amount", "0");
- $this->type("net_amount", "0");
- $this->type("invoice_id", time());
- $this->webtestFillDate('thankyou_date');
-
- //Premium section
- $this->click("Premium");
- $this->waitForElementPresent("fulfilled_date");
- $this->select("product_name[0]", "label=Coffee Mug ( MUG-101 )");
- $this->select("product_name[1]", "label=Black");
- $this->webtestFillDate('fulfilled_date');
-
- // Clicking save.
- $this->clickLink("_qf_Contribution_upload-bottom", 'civicrm-footer', FALSE);
- // Is status message correct?
- $this->waitForText('crm-notification-container', "The contribution record has been saved");
- $this->waitForElementPresent("xpath=//form[@class='CRM_Contribute_Form_Search crm-search-form']/div[2]/table[2]/tbody/tr/td[8]/span//a[text()='View']");
- $viewUrl = $this->parseURL($this->getAttribute("xpath=//form[@class='CRM_Contribute_Form_Search crm-search-form']/div[2]/table[2]/tbody/tr/td[8]/span//a[text()='View']@href"));
- $id = $viewUrl['queryString']['id'];
- $this->assertType('numeric', $id);
-
- // click through to the Contribution view screen
- $this->click("xpath=//div[@class='view-content']/table[2]/tbody/tr/td[8]/span/a[text()='View']");
- $this->waitForElementPresent('_qf_ContributionView_cancel-bottom');
-
- // verify Contribution created. Non-deductible amount derived from market value of selected 'sample' coffee mug premium (CRM-11956)
- $verifyData = array(
- 'From' => $firstName . " Anderson",
- 'Financial Type' => 'Donation',
- 'Contribution Status' => 'Completed',
- 'Payment Method' => 'Check',
- 'Total Amount' => '$ 100.00',
- 'Non-deductible Amount' => '$ 12.50',
- 'Check Number' => 'check #1041',
- );
- foreach ($verifyData as $label => $value) {
- $this->assertElementContainsText("xpath=//form[@id='ContributionView']//table/tbody/tr/td[text()='{$label}']/following-sibling::td", $value);
- }
-
- // check values of contribution record in the DB
-
- $searchParams = array('id' => $id);
- $compareParams = array(
- 'contact_id' => $cid,
- 'total_amount' => '100.00',
- );
- $this->assertDBCompareValues('CRM_Contribute_DAO_Contribution', $searchParams, $compareParams);
-
- // go to soft creditor contact view page
- $this->clickLink("css=table.crm-soft-credit-listing tbody tr td a");
-
- // go to contribution tab
- $this->waitForElementPresent("css=li#tab_contribute a");
- $this->click("css=li#tab_contribute a");
- $this->waitForElementPresent("link=Record Contribution (Check, Cash, EFT ...)");
-
- // verify soft credit details
- $expected = array(
- 4 => 'Donation',
- 2 => '100.00',
- 6 => 'Completed',
- 1 => "{$firstName} Anderson",
- );
- foreach ($expected as $value => $label) {
- $this->assertElementContainsText("xpath=id('Search')/div[2]/table[2]/tbody//tr/td[$value]", $label);
- }
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Contribute_ContributionPageAddTest
- */
-class WebTest_Contribute_ContributionPageAddTest extends CiviSeleniumTestCase {
- public function testContributionPageAdd() {
- // open browser, login
- $this->webtestLogin();
-
- // a random 7-char string and an even number to make this pass unique
- $hash = substr(sha1(rand()), 0, 7);
- $rand = 2 * rand(2, 50);
- $pageTitle = 'Donate Online ' . $hash;
- // create contribution page with randomized title and default params
- $pageId = $this->webtestAddContributionPage($hash, $rand, $pageTitle, array('Test Processor' => 'Dummy'), TRUE, TRUE, 'required');
-
- $this->openCiviPage("admin/contribute", "reset=1");
-
- // search for the new contrib page and go to its test version
- $this->type('title', $pageTitle);
- $this->click('_qf_SearchContribution_refresh');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // select testdrive mode
- $this->isTextPresent($pageTitle);
- $this->openCiviPage("contribute/transact", "reset=1&action=preview&id=$pageId", '_qf_Main_upload-bottom');
-
- // verify whatever’s possible to verify
- // FIXME: ideally should be expanded
- $texts = array(
- "Title - New Membership $hash",
- "This is introductory message for $pageTitle",
- 'Student - $ 50.00',
- "Label $hash - $ $rand.00",
- "Pay later label $hash",
- 'Organization Details',
- 'Other Amount',
- 'I pledge to contribute this amount every',
- 'Name and Address',
- 'Summary Overlay',
- );
- foreach ($texts as $text) {
- $this->assertTrue($this->isTextPresent($text), 'Missing text: ' . $text);
- $this->waitForAjaxContent();
- }
-
- // Disable and re-enable Other Amounts (verify fix for CRM-15021)
- $this->openCiviPage("admin/contribute/amount", "reset=1&action=update&id=$pageId", '_qf_Amount_next-bottom');
- $this->click("is_allow_other_amount");
- $this->clickLink("_qf_Amount_upload_done-bottom");
- $this->openCiviPage("contribute/transact", "reset=1&action=preview&id=$pageId", '_qf_Main_upload-bottom');
- $this->assertFalse($this->isTextPresent('Other Amount'), 'Other Amount present but not expected.');
- $this->openCiviPage("admin/contribute/amount", "reset=1&action=update&id=$pageId", '_qf_Amount_next-bottom');
- $this->click("is_allow_other_amount");
- $this->clickLink("_qf_Amount_upload_done-bottom");
- $this->openCiviPage("contribute/transact", "reset=1&action=preview&id=$pageId", '_qf_Main_upload-bottom');
- $this->assertTrue($this->isTextPresent('Other Amount'), 'Other Amount not present but expected.');
- $this->isElementPresent("xpath=//div[@class='content other_amount-content']/input");
- }
-
- /**
- * CRM-12510 Test copy contribution page
- */
- public function testContributionPageCopy() {
- // open browser, login
- $this->webtestLogin();
-
- // a random 7-char string and an even number to make this pass unique
- $hash = substr(sha1(rand()), 0, 7);
- $rand = 2 * rand(2, 50);
- $pageTitle = 'Donate Online ' . $hash;
- // create contribution page with randomized title and default params
- $pageId = $this->webtestAddContributionPage($hash, $rand, $pageTitle, array('Test Processor' => 'Dummy'), TRUE, TRUE, 'required');
-
- $this->openCiviPage("admin/contribute", "reset=1");
-
- // search for the new contrib page and go to its test version
- $this->type('title', $pageTitle);
- $this->click('_qf_SearchContribution_refresh');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->isTextPresent($pageTitle);
-
- // Call URL to make a copy of the page
- $this->openCiviPage("admin/contribute", "action=copy&gid=$pageId");
-
- // search for the new copy page and go to its test version
- $this->type('title', 'Copy of ' . $pageTitle);
- $this->click('_qf_SearchContribution_refresh');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->isTextPresent('Copy of ' . $pageTitle);
- // get page id of the copy
- // $copyPageId = $this->getText("xpath=//div[@id='configure_contribution_page']/tr[@id='row_4']/td[2]");
- $copyPageId = $this->getText("xpath=//div[@id='option11_wrapper']/table[@id='option11']/tbody/tr[1]/td[2]");
- // select testdrive mode
- $this->openCiviPage("contribute/transact", "reset=1&action=preview&id=$copyPageId", '_qf_Main_upload-bottom');
-
- // verify whatever’s possible to verify
- // FIXME: ideally should be expanded
- $texts = array(
- "Title - New Membership $hash",
- "This is introductory message for $pageTitle",
- 'Student - $ 50.00',
- "Label $hash - $ $rand.00",
- "Pay later label $hash",
- 'Organization Details',
- 'Other Amount',
- 'I pledge to contribute this amount every',
- 'Name and Address',
- 'Summary Overlay',
- );
- foreach ($texts as $text) {
- $this->assertTrue($this->isTextPresent($text), 'Missing text: ' . $text);
- $this->waitForAjaxContent();
- }
- }
-
- /**
- * Check CRM-7943
- */
- public function testContributionPageSeparatePayment() {
- // open browser, login
- $this->webtestLogin();
-
- // a random 7-char string and an even number to make this pass unique
- $hash = substr(sha1(rand()), 0, 7);
- $rand = 2 * rand(2, 50);
- $pageTitle = 'Donate Online ' . $hash;
-
- // create contribution page with randomized title, default params and separate payment for Membership and Contribution
- $pageId = $this->webtestAddContributionPage($hash, $rand, $pageTitle, array('Test Processor' => 'Dummy'),
- TRUE, TRUE, 'required', TRUE, FALSE, TRUE, NULL, TRUE,
- 1, 7, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE
- );
-
- $this->openCiviPage("admin/contribute", "reset=1");
-
- // search for the new contrib page and go to its test version
- $this->type('title', $pageTitle);
- $this->click('_qf_SearchContribution_refresh');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // select testdrive mode
- $this->isTextPresent($pageTitle);
- $this->openCiviPage("contribute/transact", "reset=1&action=preview&id=$pageId", '_qf_Main_upload-bottom');
-
- $texts = array(
- "Title - New Membership $hash",
- "This is introductory message for $pageTitle",
- "Label $hash - $ $rand.00",
- "Pay later label $hash",
- 'Organization Details',
- 'Other Amount',
- 'I pledge to contribute this amount every',
- 'Name and Address',
- 'Summary Overlay',
- );
- foreach ($texts as $text) {
- $this->assertTrue($this->isTextPresent($text), 'Missing text: ' . $text);
- $this->waitForAjaxContent();
- }
- }
-
- /**
- * Check CRM-7949
- */
- public function testContributionPageSeparatePaymentPayLater() {
- // open browser, login
- $this->webtestLogin();
-
- // a random 7-char string and an even number to make this pass unique
- $hash = substr(sha1(rand()), 0, 7);
- $rand = 2 * rand(2, 50);
- $pageTitle = 'Donate Online ' . $hash;
-
- // create contribution page with randomized title, default params and separate payment for Membership and Contribution
- $pageId = $this->webtestAddContributionPage($hash, $rand, $pageTitle, NULL,
- TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, NULL, FALSE,
- 1, 0, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE
- );
-
- $this->openCiviPage("admin/contribute", "reset=1");
-
- // search for the new contrib page and go to its test version
- $this->type('title', $pageTitle);
- $this->click('_qf_SearchContribution_refresh');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- //logout
- $this->webtestLogout();
-
- //Open Live Contribution Page
- $this->openCiviPage('contribute/transact', "reset=1&id=$pageId", '_qf_Main_upload-bottom');
-
- $firstName = 'Ya' . substr(sha1(rand()), 0, 4);
- $lastName = 'Cha' . substr(sha1(rand()), 0, 7);
-
- $this->type('email-5', $firstName . '@example.com');
- $this->type('first_name', $firstName);
- $this->type('last_name', $lastName);
-
- $this->select('state_province-1', "value=1002");
- $this->clickLink('_qf_Main_upload-bottom', '_qf_Confirm_next-bottom');
-
- $this->click('_qf_Confirm_next-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- //login to check contribution
- $this->webtestLogin();
-
- //Find Contribution
- $this->openCiviPage("contribute/search", "reset=1", 'contribution_date_low');
-
- $this->type('sort_name', "$lastName $firstName");
- $this->select('financial_type_id', "label=Member Dues");
- $this->clickLink('_qf_Search_refresh', "xpath=//table[@class='selector row-highlight']/tbody/tr[1]/td[10]/span//a[text()='View']", FALSE);
- $this->clickLink("xpath=//table[@class='selector row-highlight']/tbody/tr[1]/td[10]/span//a[text()='View']", '_qf_ContributionView_cancel-bottom', FALSE);
- $expected = array(
- 'From' => "{$firstName} {$lastName}",
- 'Financial Type' => 'Member Dues',
- 'Total Amount' => '$ 50.00',
- 'Contribution Status' => 'Pending : Pay Later',
- );
- $this->webtestVerifyTabularData($expected);
- $this->click('_qf_ContributionView_cancel-bottom');
-
- //View Contribution for separate contribution
- $this->waitForElementPresent("xpath=//table[@class='selector row-highlight']/tbody/tr[1]/td[10]/span//a[text()='View']");
- // Open search criteria again
- $this->click("xpath=id('Search')/div[2]/div/div[1]");
- $this->waitForElementPresent("financial_type_id");
- $this->type("sort_name", $firstName);
- $this->select('financial_type_id', "label=Donation");
- $this->clickLink('_qf_Search_refresh', "xpath=//table[@class='selector row-highlight']/tbody/tr/td[4][text()='Donation']/../td[10]/span//a[text()='View']", FALSE);
- $this->click("xpath=//table[@class='selector row-highlight']/tbody/tr/td[4][text()='Donation']/../td[10]/span//a[text()='View']");
- $this->waitForElementPresent("xpath=//table/tbody/tr/td[text()='From']/following-sibling::td");
- $this->waitForAjaxContent();
- $expected = array(
- 'From' => "{$firstName} {$lastName}",
- 'Financial Type' => 'Donation',
- 'Contribution Status' => 'Pending : Pay Later',
- );
- $this->webtestVerifyTabularData($expected);
- $this->click('_qf_ContributionView_cancel-bottom');
-
- //Find Member
- $this->openCiviPage("member/search", "reset=1", 'member_source');
- $this->type('sort_name', "$lastName $firstName");
- $this->clickLink('_qf_Search_refresh', "xpath=//table[@class='selector row-highlight']/tbody/tr[1]/td[11]/span//a[text()='View']", FALSE);
- $this->click("xpath=//table[@class='selector row-highlight']/tbody/tr[1]/td[11]/span//a[text()='View']");
- $this->waitForAjaxContent();
-
- //View Membership Record
- $expected = array(
- 'Member' => "{$firstName} {$lastName}",
- 'Membership Type' => 'Student',
- 'Status' => 'Pending',
- );
- $this->webtestVerifyTabularData($expected);
- $this->click('_qf_MembershipView_cancel-bottom');
- }
-
- /**
- * CRM-12994
- */
- public function testContributionPageAddPremiumRequiredField() {
- // open browser, login
- $this->webtestLogin();
-
- // a random 7-char string and an even number to make this pass unique
- $hash = substr(sha1(rand()), 0, 7);
- $rand = 2 * rand(2, 50);
- $pageTitle = 'Donate Online ' . $hash;
- $processor = array('Test Processor' => 'Dummy');
-
- // Create a new payment processor
- while (list($processorName, $processorType) = each($processor)) {
- $this->webtestAddPaymentProcessor($processorName, $processorType);
- }
-
- // go to the New Contribution Page page
- $this->openCiviPage('admin/contribute', 'action=add&reset=1');
-
- // fill in Title and Settings
- $this->type('title', $pageTitle);
-
- // to select financial type
- $this->select('financial_type_id', "label=Donation");
-
- $this->click('is_organization');
- $this->select("xpath=//*[@class='crm-contribution-onbehalf_profile_id']//span[@class='crm-profile-selector-select']//select", 'label=On Behalf Of Organization');
- $this->type('for_organization', "On behalf $hash");
- // make onBehalf optional
- $this->click('CIVICRM_QFID_1_2');
-
- $this->fillRichTextField('intro_text', 'This is introductory message for ' . $pageTitle, 'CKEditor');
- $this->fillRichTextField('footer_text', 'This is footer message for ' . $pageTitle, 'CKEditor');
-
- $this->type('goal_amount', 10 * $rand);
-
- // Submit form
- $this->clickLink('_qf_Settings_next', "_qf_Amount_next-bottom");
-
- // Get contribution page id
- $pageId = $this->urlArg('id');
-
- // fill in Processor, Amounts
- if (!empty($processor)) {
- reset($processor);
- while (list($processorName) = each($processor)) {
- // select newly created processor
- $xpath = "xpath=//label[text() = '{$processorName}']/preceding-sibling::input[1]";
- $this->assertTrue($this->isTextPresent($processorName));
- $this->check($xpath);
- }
- }
-
- // fill in labels & values in Fixed Contribution Options
- $this->type('label_1', 'Fixed Amount 1');
- $this->type('value_1', 1);
- $this->type('label_2', 'Fixed Amount 2');
- $this->type('value_2', 2);
- $this->type('label_3', 'Fixed Amount 3');
- $this->type('value_3', 3);
- $this->click('CIVICRM_QFID_1_4');
- $this->click('_qf_Amount_submit_savenext-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // click through to the membership view screen
- $this->click("css=li#tab_thankyou a");
- $this->waitForElementPresent('_qf_ThankYou_next-bottom');
-
- // fill in Receipt details
- $this->type('thankyou_title', "Thank-you Page Title $hash");
- $this->fillRichTextField('thankyou_text', 'This is thankyou message for ' . $pageTitle, 'CKEditor', TRUE);
- $this->fillRichTextField('thankyou_footer', 'This is thankyou footer message for ' . $pageTitle, 'CKEditor', TRUE);
- $this->click('is_email_receipt');
- $this->waitForElementPresent('bcc_receipt');
- $this->type('receipt_from_name', "Receipt From Name $hash");
- $this->type('receipt_from_email', "$hash@example.org");
- $this->type('receipt_text', "Receipt Message $hash");
- $this->type('cc_receipt', "$hash@example.net");
- $this->type('bcc_receipt', "$hash@example.com");
-
- $this->click('_qf_ThankYou_next');
- $this->waitForElementPresent('_qf_ThankYou_next-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $receiptText = "'ThankYou' information has been saved.";
- $this->assertTrue($this->isTextPresent($receiptText), 'Missing text: ' . $receiptText);
-
- $this->click('link=Premiums');
- $this->waitForElementPresent('_qf_Premium_submit_savenext-bottom');
- $assertPremiumsCheck = FALSE;
- if (!$this->isChecked('premiums_active')) {
- $assertPremiumsCheck = TRUE;
- }
- $this->assertTrue($assertPremiumsCheck, 'Premiums Section is not unchecked by default.');
- $this->click('_qf_Premium_submit_savenext-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $premiumText = "'Premium' information has been saved.";
- // check if clicking Save & Next button
- // Premium is saved rather than required validation error
- // for No Thank-you Label textfield
- $this->assertTrue($this->isTextPresent($premiumText));
-
- $this->openCiviPage("admin/contribute", "reset=1");
-
- // search for the new contrib page and go to its test version
- $this->type('title', $pageTitle);
- $this->click('_qf_SearchContribution_refresh');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->isElementPresent("xpath=//table[@class='display dataTable no-footer']/tbody/tr/td[1]/strong[text()='$pageTitle']");
- $this->waitForElementPresent("xpath=//table[@class='display dataTable no-footer']/tbody/tr/td[4]/div[@class='crm-contribution-page-configure-actions']/span[text()='Configure']");
- $this->click("xpath=//table[@id='option11']/tbody/tr/td[4]/div[@class='crm-contribution-page-configure-actions']/span[text()='Configure']");
- $this->waitForElementPresent("xpath=//table[@id='option11']/tbody/tr/td[4]/div[@class='crm-contribution-page-configure-actions']/span[text()='Configure']/ul[@class='panel']/li[8]/a[@title='Premiums']");
- $this->click("xpath=//table[@id='option11']/tbody/tr/td[4]/div[@class='crm-contribution-page-configure-actions']/span[text()='Configure']/ul[@class='panel']/li[8]/a[@title='Premiums']");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForElementPresent('premiums_active');
- $this->waitForElementPresent('_qf_Premium_cancel-bottom');
-
- // click on Premiums Section Enabled? checkbox
- $this->click('premiums_active');
- $this->waitForElementPresent("xpath=//div[@id='premiumSettings']");
- $this->waitForElementPresent('premiums_nothankyou_position');
- $this->type('premiums_intro_title', 'Premiums Intro Title');
- $this->type('premiums_intro_text', 'Premiums Into Text');
- $this->type('premiums_contact_email', "$hash@example.net");
-
- // let No Thank-you Label text be blank
- // so that validation error appears
- // $this->type('premiums_nothankyou_label', );
- $this->select('premiums_nothankyou_position', 'value=2');
-
- // click on save & next button
- $this->click('_qf_Premium_submit_savenext-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $premiumRequiredText = "No Thank-you Label is a required field.";
- // check if clicking Save & Next button
- // required validation error appears
- // for No Thank-you Label textfield
- $this->waitForElementPresent("xpath=//*[@id='premiumSettings']/div/div[2]/table/tbody/tr[6]/td[2]/span[1]");
- $this->assertTrue($this->isTextPresent($premiumRequiredText));
-
- // fill in value for Premiums No Thank-you Label textfield
- $this->type('premiums_nothankyou_label', 'Premiums No Thank-you Label');
- $this->waitForElementPresent('_qf_Premium_upload_done-bottom');
-
- // click save & done button
- $this->click('_qf_Premium_upload_done-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $premiumSavedText = "'Premium' information has been saved.";
- // check if clicking Save & Done button
- // contribution page is saved.
- $this->assertTrue($this->isTextPresent($premiumSavedText));
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Contribute_OfflineContributionTest
- */
-class WebTest_Contribute_OfflineContributionTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testStandaloneContributeAdd() {
- $this->webtestLogin();
-
- // Create a contact to be used as soft creditor
- $softCreditFname = substr(sha1(rand()), 0, 7);
- $softCreditLname = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($softCreditFname, $softCreditLname, FALSE);
-
- //financial account for check
- $this->openCiviPage("admin/options/payment_instrument", "reset=1");
- $financialAccount = $this->getText("xpath=//div[@id='payment_instrument']/table/tbody//tr/td[1]/div[text()='Check']/../../td[3]");
-
- // Add new Financial Account
- $orgName = 'Alberta ' . substr(sha1(rand()), 0, 7);
- $financialAccountTitle = 'Financial Account ' . substr(sha1(rand()), 0, 4);
- $financialAccountDescription = "{$financialAccountTitle} Description";
- $accountingCode = 1033;
- $financialAccountType = 'Asset';
- $taxDeductible = FALSE;
- $isActive = FALSE;
- $isTax = TRUE;
- $taxRate = 9;
- $isDefault = FALSE;
-
- //Add new organisation
- if ($orgName) {
- $this->webtestAddOrganization($orgName);
- }
-
- $this->_testAddFinancialAccount($financialAccountTitle,
- $financialAccountDescription,
- $accountingCode,
- $orgName,
- $financialAccountType,
- $taxDeductible,
- $isActive,
- $isTax,
- $taxRate,
- $isDefault
- );
-
- $firstName = 'John' . substr(sha1(rand()), 0, 7);
- $lastName = 'Dsouza' . substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName, $lastName);
-
- $this->waitForElementPresent("css=li#tab_contribute a");
- $this->click("css=li#tab_contribute a");
- $this->waitForElementPresent("link=Record Contribution (Check, Cash, EFT ...)");
- $this->clickLink("link=Record Contribution (Check, Cash, EFT ...)", "_qf_Contribution_cancel-bottom", FALSE);
-
- // select financial type
- $this->select("financial_type_id", "value=1");
-
- // fill in Received Date
- $this->webtestFillDate('receive_date');
-
- // source
- $this->type("source", "Mailer 1");
-
- // total amount
- $this->type("total_amount", "100");
- // revenue recognition date (CRM-16189)
- if (CRM_Contribute_BAO_Contribution::checkContributeSettings('deferred_revenue_enabled')) {
- $this->webtestFillDate('revenue_recognition_date', 'now+4');
- }
-
- // select payment instrument type = Check and enter chk number
- $this->select("payment_instrument_id", "value=4");
- $this->waitForElementPresent("check_number");
- $this->type("check_number", "check #1041");
-
- $this->type("trxn_id", "P20901X1" . rand(100, 10000));
-
- // create first soft credit
- $this->click("softCredit");
- $this->waitForElementPresent("soft_credit_amount_1");
- $this->webtestFillAutocomplete("{$softCreditLname}, {$softCreditFname}", 's2id_soft_credit_contact_id_1');
- $this->type("soft_credit_amount_1", "50");
-
- // add second soft credit field
- $this->click("addMoreSoftCredit");
- $this->waitForElementPresent("soft_credit_amount_2");
- // create new individual via soft credit
- $softCreditSecondFname = substr(sha1(rand()), 0, 7);
- $softCreditSecondLname = substr(sha1(rand()), 0, 7);
- $this->webtestNewDialogContact($softCreditSecondFname, $softCreditSecondLname, NULL, 4, 's2id_soft_credit_contact_id_2', 'soft_credit_1');
- // enter the second soft credit
- $this->verifyText("soft_credit_amount_2", ""); // it should be blank cause first soft credit != total_amount
- $this->type("soft_credit_amount_2", "100"); //the sum of the soft credit amounts can exceed total_amount
- $this->select("soft_credit_type[2]", "In Honor of");
-
- //Custom Data
- // $this->click('CIVICRM_QFID_3_6');
-
- //Additional Detail section
- $this->click("AdditionalDetail");
- $this->waitForElementPresent("thankyou_date");
-
- $this->type("note", "This is a test note.");
- $this->type("non_deductible_amount", "10.00");
- $this->type("fee_amount", "0");
- $this->type("net_amount", "0");
- $this->type("invoice_id", time());
- $this->webtestFillDate('thankyou_date');
-
- //Premium section
- $this->click("Premium");
- $this->waitForElementPresent("fulfilled_date");
- $this->select("product_name[0]", "label=Coffee Mug ( MUG-101 )");
- $this->select("product_name[1]", "label=Black");
- $this->webtestFillDate('fulfilled_date');
-
- // Clicking save.
- $this->click("_qf_Contribution_upload");
-
- // Is status message correct?
- //$this->assertTrue($this->isTextPresent("The contribution record has been saved."), "Status message didn't show up after saving!");
-
- // verify if Contribution is created
- $this->waitForElementPresent("xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[8]/span/a[text()='View']");
-
- //click through to the Contribution view screen
- $this->click("xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[8]/span/a[text()='View']");
- $this->waitForElementPresent("_qf_ContributionView_cancel-bottom");
-
- $expected = array(
- 'Financial Type' => 'Donation',
- 'Total Amount' => '100.00',
- 'Contribution Status' => 'Completed',
- 'Payment Method' => 'Check',
- 'Check Number' => 'check #1041',
- 'Non-deductible Amount' => '10.00',
- 'Received Into' => $financialAccount,
- );
-
- $this->waitForElementPresent("xpath=//*[@id='ContributionView']/div[2]");
- foreach ($expected as $value) {
- $this->assertElementContainsText("xpath=//*[@id='ContributionView']/div[2]", $value);
- }
-
- // verify if soft credit was created successfully
- $expected = array(
- 'Soft Credit To 1' => "{$softCreditFname} {$softCreditLname}",
- 'Soft Credit To 2' => "{$softCreditSecondFname} {$softCreditSecondLname}",
- 'Amount (Soft Credit Type)' => '100.00 (In Honor of)',
- );
-
- foreach ($expected as $value) {
- $this->assertElementContainsText("css=table.crm-soft-credit-listing", $value);
- }
-
- // go to first soft creditor contact view page
- $this->clickLink("xpath=//*[@id='ContributionView']/div[2]/div[2]/div[2]/table/tbody/tr[1]/td[1]/a", "css=li#tab_contribute a");
-
- // go to contribution tab
- $this->click("css=li#tab_contribute a");
- $this->waitForElementPresent("link=Record Contribution (Check, Cash, EFT ...)");
-
- // verify soft credit details
- $expected = array(
- 3 => 'Solicited',
- 4 => 'Donation',
- 2 => '50.00',
- 6 => 'Completed',
- 1 => "{$firstName} {$lastName}",
- );
- foreach ($expected as $value => $label) {
- $this->assertElementContainsText("xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[2]/td[$value]", $label);
- }
- }
-
- public function testDeductibleAmount() {
- $this->webtestLogin();
-
- // disable verify ssl when using authorize .net
- $this->openCiviPage("admin/setting/url", "reset=1");
- $this->click("id=CIVICRM_QFID_0_verifySSL");
- $this->click("id=_qf_Url_next-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- //add authorize .net payment processor
- $processorName = 'Webtest AuthNet' . substr(sha1(rand()), 0, 7);
- $this->webtestAddPaymentProcessor($processorName, 'AuthNet');
-
- $this->openCiviPage("admin/contribute/managePremiums", "action=add&reset=1");
- $premiumName = 'test Premium' . substr(sha1(rand()), 0, 7);
- $this->addPremium($premiumName, 'SKU', 3, 12, NULL, NULL);
-
- $firstName = 'John' . substr(sha1(rand()), 0, 7);
- $lastName = 'Dsouza' . substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName, $lastName);
-
- //scenario 1 : is_deductible = 0 and non deductible amount is entered
- $scenario1 = array(
- 'financial_type' => 'Campaign Contribution',
- 'total_amount' => 111,
- 'non_deductible_amount' => 15,
- 'sort_name' => "$lastName, $firstName",
- );
- $this->_doOfflineContribution($scenario1, $firstName, $lastName, $processorName);
-
- $checkScenario1 = array(
- 'From' => "{$firstName} {$lastName}",
- 'Financial Type' => 'Campaign Contribution',
- 'Total Amount' => 111,
- 'Non-deductible Amount' => 15,
- 'sort_name' => "$lastName, $firstName",
- );
- $this->_verifyAmounts($checkScenario1);
-
- //scenario 2 : is_deductible = TRUE and premium is set and premium is greater than total amount
- $scenario2 = array(
- 'financial_type' => 'Donation',
- 'total_amount' => 10,
- 'premium' => "{$premiumName} ( SKU )",
- 'sort_name' => "$lastName, $firstName",
- );
- $this->_doOfflineContribution($scenario2, $firstName, $lastName, $processorName);
-
- $checkScenario2 = array(
- 'From' => "{$firstName} {$lastName}",
- 'Financial Type' => 'Donation',
- 'Total Amount' => 10,
- 'Non-deductible Amount' => 10,
- 'sort_name' => "$lastName, $firstName",
- );
- $this->_verifyAmounts($checkScenario2);
-
- //scenario 3 : is_deductible = TRUE and premium is set and premium is less than total amount
- $scenario3 = array(
- 'financial_type' => 'Donation',
- 'total_amount' => 123,
- 'premium' => "{$premiumName} ( SKU )",
- 'sort_name' => "$lastName, $firstName",
- );
- $this->_doOfflineContribution($scenario3, $firstName, $lastName, $processorName);
-
- $checkScenario3 = array(
- 'From' => "{$firstName} {$lastName}",
- 'Financial Type' => 'Donation',
- 'Total Amount' => 123,
- 'Non-deductible Amount' => 12,
- 'sort_name' => "$lastName, $firstName",
- );
- $this->_verifyAmounts($checkScenario3);
-
- //scenario 4 : is_deductible = TRUE and premium is not set
- $scenario4 = array(
- 'financial_type' => 'Donation',
- 'total_amount' => 123,
- 'sort_name' => "$lastName, $firstName",
- );
- $this->_doOfflineContribution($scenario4, $firstName, $lastName, $processorName);
-
- $checkScenario4 = array(
- 'From' => "{$firstName} {$lastName}",
- 'Financial Type' => 'Donation',
- 'Total Amount' => 123,
- 'Non-deductible Amount' => '0.00',
- 'sort_name' => "$lastName, $firstName",
- );
- $this->_verifyAmounts($checkScenario4);
-
- //scenario 5 : is_deductible = FALSE, non_deductible_amount = the total amount
- $scenario5 = array(
- 'financial_type' => 'Campaign Contribution',
- 'total_amount' => 555,
- 'sort_name' => "$lastName, $firstName",
- );
- $this->_doOfflineContribution($scenario5, $firstName, $lastName, $processorName);
-
- $checkScenario5 = array(
- 'From' => "{$firstName} {$lastName}",
- 'Financial Type' => 'Campaign Contribution',
- 'Total Amount' => 555,
- 'Non-deductible Amount' => 555,
- 'sort_name' => "$lastName, $firstName",
- );
- $this->_verifyAmounts($checkScenario5);
- }
-
- /**
- * common function for doing offline contribution.
- * @param array $params
- * @param string $firstName
- * @param string $lastName
- * @param $processorName
- */
- public function _doOfflineContribution($params, $firstName, $lastName, $processorName) {
-
- $this->waitForElementPresent("css=li#tab_contribute a");
- $this->click("css=li#tab_contribute a");
- $this->waitForElementPresent("link=Record Contribution (Check, Cash, EFT ...)");
-
- // since we don't have live credentials we will switch to test mode
- $url = $this->getAttribute("xpath=//*[@id='Search']/div[2]/div[2]/a[1]@href");
- $url .= '&mode=test';
- $this->open($url);
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // start filling out contribution form
- $this->waitForElementPresent('payment_processor_id');
- $this->select('payment_processor_id', "label={$processorName}");
-
- // select financial type
- $this->select("financial_type_id", "label={$params['financial_type']}");
-
- // total amount
- $this->type("total_amount", "{$params['total_amount']}");
-
- // enter credit card info on form
- $this->webtestAddCreditCardDetails();
-
- // billing address
- $this->webtestAddBillingDetails($firstName, NULL, $lastName);
-
- if ($nonDeductibleAmt = CRM_Utils_Array::value('non_deductible_amount', $params)) {
- $this->click("AdditionalDetail");
- $this->waitForElementPresent("thankyou_date");
- $this->type("note", "This is a test note.");
- $this->type("non_deductible_amount", "{$nonDeductibleAmt}");
- }
-
- if (!empty($params['premium'])) {
- //Premium section
- $this->click("Premium");
- $this->waitForElementPresent("fulfilled_date");
- $this->select("product_name[0]", "label={$params['premium']}");
- }
- // Clicking save.
- $this->click("_qf_Contribution_upload-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Is status message correct?
- $this->assertTrue($this->isTextPresent("The contribution record has been saved."), "Status message didn't show up after saving!");
- }
-
- /**
- * common function for verifing total_amount, and non_deductible_amount
- * @param $verifyData
- */
- public function _verifyAmounts($verifyData) {
- // since we are doing test contributions we need to search for test contribution and select first contribution
- // record for the contact
- $this->openCiviPage("contribute/search", "reset=1", "contribution_date_low");
- $this->type("sort_name", $verifyData['sort_name']);
-
- // select show test contributions
- $this->click("contribution_test", "value=1");
- $this->clickLink("_qf_Search_refresh", "xpath=//table[@class='selector row-highlight']/tbody/tr[1]/td[10]/span//a[text()='View']", FALSE);
- $this->clickLink("xpath=//table[@class='selector row-highlight']/tbody/tr[1]/td[10]/span//a[text()='View']", "_qf_ContributionView_cancel-bottom", FALSE);
-
- foreach ($verifyData as $label => $value) {
- if ($label == 'sort_name') {
- continue;
- }
- $this->assertElementContainsText("xpath=//form[@id='ContributionView']//table/tbody/tr/td[text()='{$label}']/following-sibling::td", "{$value}");
- }
-
- // now find contact and go back to contact summary
- $this->openCiviPage("contact/search", "reset=1", "sort_name");
- $this->type("sort_name", $verifyData['sort_name']);
- $this->clickLink("_qf_Basic_refresh",
- "xpath=//form[@id='Basic']/div[3]/div[1]/div[2]/table/tbody/tr[1]/td[11]/span/a[text()='View']");
-
- $this->clickLink("xpath=//form[@id='Basic']/div[3]/div[1]/div[2]/table/tbody/tr[1]/td[11]/span/a[text()='View']",
- 'crm-contact-actions-link', FALSE);
- }
-
- public function testOnlineContributionWithZeroAmount() {
- $this->webtestLogin();
-
- // Create a contact to be used as soft creditor
- $firstName = 'John' . substr(sha1(rand()), 0, 7);
- $lastName = 'Peterson' . substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName, $lastName);
- $this->waitForElementPresent("css=li#tab_contribute a");
- $this->click("css=li#tab_contribute a");
- $this->waitForElementPresent("link=Record Contribution (Check, Cash, EFT ...)");
- $this->clickLink("link=Record Contribution (Check, Cash, EFT ...)", "_qf_Contribution_cancel-bottom", FALSE);
-
- // select financial type
- $this->select("financial_type_id", "value=1");
-
- // total amount
- $this->type("total_amount", "0.00");
-
- // select payment instrument
- $this->select("payment_instrument_id", "value=1");
-
- $this->type("trxn_id", "X20901X1" . rand(100, 10000));
- $this->click('_qf_Contribution_upload-bottom');
- $this->waitForText("crm-notification-container", "The contribution record has been saved.");
-
- $this->waitForElementPresent("xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[8]/span/a[text()='View']");
- $this->clickLink("xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[8]/span/a[text()='View']", "_qf_ContributionView_cancel-bottom", FALSE);
- $expected = array(
- 'Financial Type' => 'Donation',
- 'Total Amount' => '0.00',
- 'Contribution Status' => 'Completed',
- 'Payment Method' => 'Credit Card',
- );
- $this->webtestVerifyTabularData($expected);
- }
-
- public function testDefaultCurrancy() {
- $this->webtestLogin();
- $this->enableCurrency(array('GBP', 'EUR'));
-
- //Create a contact.
- $firstName = 'John' . substr(sha1(rand()), 0, 7);
- $lastName = 'Peterson' . substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName, $lastName);
-
- //Create contribution for contact
- $this->waitForElementPresent("css=li#tab_contribute a");
- $this->click("css=li#tab_contribute a");
- $this->waitForElementPresent("link=Record Contribution (Check, Cash, EFT ...)");
- $this->click("link=Record Contribution (Check, Cash, EFT ...)");
- $this->waitForElementPresent("financial_type_id");
- $this->select("financial_type_id", "value=1");
- $this->select("currency", "value=GBP");
- $this->type("total_amount", "100");
- $this->click("xpath=//div[@class='ui-dialog-buttonset']//button//span[text()='Save']");
- $this->waitForAjaxContent();
- $this->waitForElementPresent("xpath=//table[@class='selector row-highlight']");
- $this->assertElementContainsText("xpath=//table[@class='selector row-highlight']/tbody/tr//td/a", "£ 100.00");
- $this->click("xpath=//table[@class='selector row-highlight']/tbody/tr//td/a", "£ 100.00");
- $this->waitForElementPresent("xpath=//table[@id='info']");
- $this->assertElementContainsText("xpath=//table[@id='info']/tbody/tr[2]/td[1]", "£ 100.00");
- }
-
- public function testRevenueRecognitionDateAdd() {
- $this->webtestLogin();
- $this->openCiviPage("admin/setting/preferences/contribute", "reset=1");
- $this->waitForElementPresent("_qf_Contribute_next");
- $this->click('deferred_revenue_enabled');
- $this->click('_qf_Contribute_next');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Create a contact to be used as soft creditor
- $softCreditFname = substr(sha1(rand()), 0, 7);
- $softCreditLname = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($softCreditFname, $softCreditLname, FALSE);
-
- //financial account for check
- $this->openCiviPage("admin/options/payment_instrument", "reset=1");
- $financialAccount = $this->getText("xpath=//div[@id='payment_instrument']/table/tbody//tr/td[1]/div[text()='Check']/../../td[3]");
-
- // Add new Financial Account
- $orgName = 'Alberta ' . substr(sha1(rand()), 0, 7);
- $financialAccountTitle = 'Financial Account ' . substr(sha1(rand()), 0, 4);
- $financialAccountDescription = "{$financialAccountTitle} Description";
- $accountingCode = 1033;
- $financialAccountType = 'Asset';
- $taxDeductible = FALSE;
- $isActive = FALSE;
- $isTax = TRUE;
- $taxRate = 9;
- $isDefault = FALSE;
-
- //Add new organisation
- if ($orgName) {
- $this->webtestAddOrganization($orgName);
- }
-
- $this->_testAddFinancialAccount($financialAccountTitle,
- $financialAccountDescription,
- $accountingCode,
- $orgName,
- $financialAccountType,
- $taxDeductible,
- $isActive,
- $isTax,
- $taxRate,
- $isDefault
- );
-
- $firstName = 'John' . substr(sha1(rand()), 0, 7);
- $lastName = 'Dsouza' . substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName, $lastName);
-
- $this->waitForElementPresent("css=li#tab_contribute a");
- $this->click("css=li#tab_contribute a");
- $this->waitForElementPresent("link=Record Contribution (Check, Cash, EFT ...)");
- $this->clickLink("link=Record Contribution (Check, Cash, EFT ...)", "_qf_Contribution_cancel-bottom", FALSE);
-
- // select financial type
- $this->select("financial_type_id", "value=1");
-
- // fill in Received Date
- $this->webtestFillDate('receive_date');
-
- // source
- $this->type("source", "Mailer 1");
-
- // total amount
- $this->type("total_amount", "100");
-
- // revenue recognition date (CRM-16189)
- $this->webtestFillDate('revenue_recognition_date', 'now');
-
- // select payment instrument type = Check and enter chk number
- $this->select("payment_instrument_id", "value=4");
- $this->waitForElementPresent("check_number");
- $this->type("check_number", "check #1041");
-
- $this->type("trxn_id", "P20901X1" . rand(100, 10000));
-
- //Additional Detail section
- $this->click("AdditionalDetail");
- $this->waitForElementPresent("thankyou_date");
-
- $this->type("note", "This is a test note.");
- $this->type("non_deductible_amount", "10.00");
- $this->type("fee_amount", "0");
- $this->type("net_amount", "0");
- $this->type("invoice_id", time());
- $this->webtestFillDate('thankyou_date');
-
- // Clicking save.
- $this->click("_qf_Contribution_upload");
-
- // verify if Contribution is created
- $this->waitForElementPresent("xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[8]/span/a[text()='Edit']");
-
- //click through to the Contribution edit screen
- $this->click("xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[8]/span/a[text()='Edit']");
- $this->waitForElementPresent("_qf_Contribution_cancel");
- $val = $this->getValue("xpath=//input[@id='revenue_recognition_date']");
- $this->assertEquals(date('m/d/Y'), $val);
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Contribute_OfflineRecurContributionTest
- */
-class WebTest_Contribute_OfflineRecurContributionTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testOfflineRecurContribution() {
- $this->webtestLogin();
-
- // We need a payment processor
- $processorName = 'Webtest AuthNet' . substr(sha1(rand()), 0, 7);
- $this->webtestAddPaymentProcessor($processorName, 'AuthNet');
-
- // create a new contact for whom recurring contribution is to be created
- $firstName = 'Jane' . substr(sha1(rand()), 0, 7);
- $middleName = 'Middle';
- $lastName = 'Recuroff_' . substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName, $lastName, "{$firstName}@example.com");
- $contactName = "$firstName $lastName";
-
- $this->click('css=li#tab_contribute a');
-
- $this->waitForElementPresent('link=Record Contribution (Check, Cash, EFT ...)');
- // since we don't have live credentials we will switch to test mode
- $url = $this->getAttribute("xpath=//*[@id='Search']/div[2]/div[2]/a[1]@href");
- $url .= '&mode=test';
- $this->open($url);
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // start filling out contribution form
- $this->waitForElementPresent('payment_processor_id');
- $this->select('payment_processor_id', "label={$processorName}");
-
- $this->click('financial_type_id');
- $this->select('financial_type_id', 'label=Donation');
- $this->type('total_amount', '10');
-
- // recurring contribution fields
- $this->click('is_recur');
- $this->type('frequency_interval', '1');
- $this->select('frequency_unit', 'label=month(s)');
- $this->type('installments', '12');
-
- $this->click('is_email_receipt');
- $this->waitForElementPresent('credit_card_type');
-
- // enter credit card info on form
- $this->webtestAddCreditCardDetails();
-
- // billing address
- $this->webtestAddBillingDetails($firstName, $middleName, $lastName);
- $this->click('_qf_Contribution_upload-bottom');
- $this->waitForElementPresent('link=Edit');
- $this->waitForText('crm-notification-container', "The contribution record has been saved.");
- // Use Find Contributions to make sure test recurring contribution exists
- $this->openCiviPage("contribute/search", "reset=1", 'contribution_currency_type');
-
- $this->type('sort_name', "$lastName, $firstName");
- $this->click('contribution_test');
- $this->click('_qf_Search_refresh');
-
- $this->waitForElementPresent('css=#contributionSearch table tbody tr td span a.action-item:first-child');
- $this->click('css=#contributionSearch table tbody tr td span a.action-item:first-child');
- $this->waitForElementPresent('_qf_ContributionView_cancel-bottom');
-
- // View Recurring Contribution Record
- $verifyData = array(
- 'From' => "$contactName",
- 'Financial Type' => 'Donation (test)',
- 'Total Amount' => 'Installments: 12, Interval: 1 month(s)',
- 'Contribution Status' => 'Pending : Incomplete Transaction',
- 'Payment Method' => 'Credit Card',
- );
-
- foreach ($verifyData as $label => $value) {
- $this->assertElementContainsText("xpath=//form[@id='ContributionView']//table/tbody/tr/td[text()='{$label}']/following-sibling::td", $value);
- }
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Contribute_OnBehalfOfOrganization
- */
-class WebTest_Contribute_OnBehalfOfOrganization extends CiviSeleniumTestCase {
- protected $pageno = '';
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testOnBehalfOfOrganization() {
- $this->webtestLogin();
-
- // create new individual
- $firstName = 'John_' . substr(sha1(rand()), 0, 7);
- $lastName = 'Anderson_' . substr(sha1(rand()), 0, 7);
- $email = "{$firstName}.{$lastName}@example.com";
- $contactParams = array(
- 'first_name' => $firstName,
- 'last_name' => $lastName,
- 'email-5' => $email,
- );
- $streetAddress = "100 Main Street";
-
- //adding contact for membership sign up
- $this->webtestAddContact($firstName, $lastName, $email);
- $cid = $this->urlArg('cid');
-
- // Use default payment processor
- $processorName = 'Test Processor';
- $processorType = 'Dummy';
- $pageTitle = substr(sha1(rand()), 0, 7);
- $rand = 100;
- $hash = substr(sha1(rand()), 0, 7);
- $amountSection = TRUE;
- $payLater = TRUE;
- $onBehalf = 'optional';
- $pledges = FALSE;
- $recurring = FALSE;
- $memberships = FALSE;
- $memPriceSetId = NULL;
- $friend = TRUE;
- $profilePreId = NULL;
- $profilePostId = NULL;
- $premiums = FALSE;
- $widget = FALSE;
- $pcp = FALSE;
- $honoreeSection = FALSE;
- $isAddPaymentProcessor = TRUE;
- $isPcpApprovalNeeded = FALSE;
- $isSeparatePayment = FALSE;
-
- // create a new online contribution page
- // create contribution page with randomized title and default params
- $pageId = $this->webtestAddContributionPage($hash,
- $rand,
- $pageTitle,
- array($processorName => $processorType),
- $amountSection,
- $payLater,
- $onBehalf,
- $pledges,
- $recurring,
- $memberships,
- $memPriceSetId,
- $friend,
- $profilePreId,
- $profilePostId,
- $premiums,
- $widget,
- $pcp,
- $isAddPaymentProcessor,
- $isPcpApprovalNeeded,
- $isSeparatePayment,
- $honoreeSection
- );
-
- //logout
- $this->webtestLogout();
- //$this->_testAnomoyousOganization($pageId, $cid, $pageTitle);
- $this->webtestLogout();
- $this->_testUserWithOneRelationship($pageId, $cid, $pageTitle);
- $this->webtestLogout();
- $this->_testUserWithMoreThanOneRelationship($pageId, $cid, $pageTitle);
- }
-
- public function testOnBehalfOfOrganizationWithMembershipData() {
- $this->webtestLogin();
-
- // Create three new individual
- $individuals = $organizations = array();
- for ($i = 0; $i < 3; $i++) {
- $firstName = 'John_x_' . substr(sha1(rand()), 0, 7);
- $individuals[] = $firstName;
- $this->webtestAddContact($firstName, "Memberson", "{$firstName}@memberson.com");
- }
-
- // Create two organisations, one used for new Membership Type, and other for inherited membership purpose
- for ($i = 0; $i < 2; $i++) {
- $orgName1 = "Org WebAccess" . substr(sha1(rand()), 0, 7);
- $orgEmail1 = substr(sha1(rand()), 0, 7) . "@web.com";
- $organizations[] = array('name' => $orgName1, 'email' => $orgEmail1);
- $this->webtestAddOrganization($orgName1, $orgEmail1);
- }
-
- // Create Employee relationship of last created organization $organizations[1] with all three $individuals
- $this->waitForAjaxContent();
- $this->click("css=li#tab_rel a");
- $this->waitForElementPresent('link=Add Relationship');
- $this->click('link=Add Relationship');
- $this->waitForElementPresent('relationship_type_id');
- $this->click("relationship_type_id");
- $this->select("relationship_type_id", "label=Employer of");
- // search organization
- $this->select2('related_contact_id', $individuals, TRUE);
- // give permission
- //$this->click("is_permission_a_b");
- //$this->click("is_permission_b_a");
- // save relationship
- $this->click("_qf_Relationship_upload");
- $this->waitForAjaxContent();
-
- $title = 'Membership Type' . substr(sha1(rand()), 0, 7);
- //Create membership type
- $this->openCiviPage("admin/member/membershipType", "reset=1&action=browse");
- $this->click("link=Add Membership Type");
- $this->waitForElementPresent('_qf_MembershipType_cancel-bottom');
- $this->type('name', $title);
- $this->select2('member_of_contact_id', $organizations[0]['name']);
- $this->type('minimum_fee', '100');
- $this->select('financial_type_id', 'value=2');
- $this->type('duration_interval', 1);
- $this->select('duration_unit', "label=year");
- $this->select('period_type', "value=rolling");
- //Choose 'Employer of' relationship
- $this->select('relationship_type_id', 'value=5_b_a');
- $this->click('_qf_MembershipType_upload-bottom');
- $this->waitForAjaxContent();
- $this->waitForText('crm-notification-container', "The membership type '$title' has been saved.");
- //Retrieve membership type ID from newly created membership type
- $memTypeId = explode('&id=', $this->getAttribute("xpath=//div[@id='membership_type']/table/tbody//tr/td[1]/div[text()='{$title}']/../../td[12]/span/a[3]@href"));
- $memTypeId = $memTypeId[1];
-
- // Use default payment processor
- $processorName = 'Test Processor';
- $processorType = 'Dummy';
- $pageTitle = substr(sha1(rand()), 0, 7);
- $rand = 100;
- $hash = substr(sha1(rand()), 0, 7);
- $amountSection = TRUE;
- $payLater = TRUE;
- $onBehalf = 'optional';
- $pledges = FALSE;
- $recurring = FALSE;
- $memberships = array(array('id' => $memTypeId, 'name' => $title, 'default' => 1));
- $memPriceSetId = NULL;
- $friend = TRUE;
- $profilePreId = NULL;
- $profilePostId = NULL;
- $premiums = FALSE;
- $widget = FALSE;
- $pcp = FALSE;
- $honoreeSection = FALSE;
- $isAddPaymentProcessor = TRUE;
- $isPcpApprovalNeeded = FALSE;
- $isSeparatePayment = FALSE;
-
- // create a new online contribution page
- // create contribution page with randomized title and default params
- $pageId = $this->webtestAddContributionPage($hash,
- $rand,
- $pageTitle,
- array($processorName => $processorType),
- $amountSection,
- $payLater,
- $onBehalf,
- $pledges,
- $recurring,
- $memberships,
- $memPriceSetId,
- $friend,
- $profilePreId,
- $profilePostId,
- $premiums,
- $widget,
- $pcp,
- $isAddPaymentProcessor,
- $isPcpApprovalNeeded,
- $isSeparatePayment,
- $honoreeSection
- );
-
- $this->_testAnomoyousOrganization($pageId, $organizations[1], $pageTitle);
-
- //Check if all three of the individuals has inherited membership
- $this->openCiviPage("member/search", "reset=1");
- $this->multiselect2("membership_type_id", array($title));
- $this->click("CIVICRM_QFID_0_member_is_primary");
- $this->click('_qf_Search_refresh');
- // It suppose to be 3 but since we are registring contribution onBehalf of anonymous contact(email-5)
- $this->waitForText('search-status', "4 Results");
- foreach ($individuals as $individual) {
- $this->isTextPresent($individual);
- }
- }
-
- public function testOnBehalfOfOrganizationWithOrgData() {
- $this->webtestLogin();
-
- $this->openCiviPage("profile/edit", "reset=1&gid=4");
- $firstName = 'John_x_' . substr(sha1(rand()), 0, 7);
- $lastName = 'Anderson_c_' . substr(sha1(rand()), 0, 7);
-
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForElementPresent("_qf_Edit_next");
- $this->type("first_name", $firstName);
- $this->type("last_name", $lastName);
- $this->clickLink("_qf_Edit_next", "profilewrap4");
-
- $cid = $this->urlArg('id');
- // Is status message correct?
- $this->assertTextPresent("Thank you. Your information has been saved.", "Save successful status message didn't show up after saving profile to update testUserName!");
-
- //add org fields to profile
- $this->openCiviPage("admin/uf/group", "reset=1");
- $this->click("link=Reserved Profiles");
-
- $this->click("xpath=//div[@id='reserved-profiles']/div/div/table/tbody//tr/td[1][text()='On Behalf Of Organization']/../td[5]/span/a[text()='Fields']");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->click("link=Add Field");
- $this->waitForElementPresent('_qf_Field_next-bottom');
-
- $this->select('field_name[0]', 'value=Organization');
- $this->select('field_name[1]', 'label=Legal Identifier');
- $this->click('field_name[1]');
- $this->click('_qf_Field_next_new-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->select('field_name[0]', 'value=Organization');
- $this->select('field_name[1]', 'label=Legal Name');
- $this->click('field_name[1]');
- $this->click('_qf_Field_next-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- //create organisation
- $orgName = "Org WebAccess " . substr(sha1(rand()), 0, 7);
- $orgEmail = "org" . substr(sha1(rand()), 0, 7) . "@web.com";
- $this->webtestAddOrganization($orgName, $orgEmail);
-
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->click("css=li#tab_rel a");
-
- $this->waitForElementPresent('link=Add Relationship');
- $this->click('link=Add Relationship');
-
- $this->waitForElementPresent('relationship_type_id');
- $this->click("relationship_type_id");
- $this->select("relationship_type_id", "label=Employer of");
- // search organization
- $this->type('contact_1', $firstName);
- $this->click("contact_1");
- $this->waitForElementPresent("css=div.ac_results-inner li");
- $this->click("css=div.ac_results-inner li");
- $this->assertContains($firstName, $this->getValue('contact_1'), "autocomplete expected $firstName but didn’t find it in " . $this->getValue('contact_1'));
-
- // give permission
- $this->click("is_permission_a_b");
- $this->click("is_permission_b_a");
-
- // save relationship
- $this->waitForElementPresent("details-save");
- $this->click("details-save");
- $this->waitForElementPresent("Relationships");
-
- $pageTitle = substr(sha1(rand()), 0, 7);
- $rand = 100;
- $hash = substr(sha1(rand()), 0, 7);
- $amountSection = TRUE;
- $payLater = TRUE;
- $onBehalf = TRUE;
- $pledges = FALSE;
- $recurring = FALSE;
- $memberships = TRUE;
- $memPriceSetId = NULL;
- $friend = TRUE;
- $profilePreId = NULL;
- $profilePostId = NULL;
- $premiums = FALSE;
- $widget = FALSE;
- $pcp = FALSE;
- $honoreeSection = FALSE;
- $isAddPaymentProcessor = FALSE;
- $isPcpApprovalNeeded = FALSE;
- $isSeparatePayment = FALSE;
-
- // create a new online contribution page
- // create contribution page with randomized title and default params
- $pageId = $this->webtestAddContributionPage($hash,
- $rand,
- $pageTitle,
- NULL,
- $amountSection,
- $payLater,
- $onBehalf,
- $pledges,
- $recurring,
- $memberships,
- $memPriceSetId,
- $friend,
- $profilePreId,
- $profilePostId,
- $premiums,
- $widget,
- $pcp,
- $isAddPaymentProcessor,
- $isPcpApprovalNeeded,
- $isSeparatePayment,
- $honoreeSection
- );
-
- $this->_testOrganization($pageId, $cid, $pageTitle);
- }
-
- public function testWithContactSubtypeDupe() {
- $this->webtestLogin();
-
- //create organisation
- $orgName = "Org WebAccess " . substr(sha1(rand()), 0, 7);
- $orgEmail = "org" . substr(sha1(rand()), 0, 7) . "@web.com";
- $contactSubType = 'Sponsor';
- $this->webtestAddOrganization($orgName, $orgEmail, $contactSubType);
-
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $cid = $this->urlArg('cid');
-
- $pageTitle = substr(sha1(rand()), 0, 7);
- $rand = 100;
- $hash = substr(sha1(rand()), 0, 7);
- $amountSection = TRUE;
- $payLater = TRUE;
- $onBehalf = TRUE;
- $pledges = FALSE;
- $recurring = FALSE;
- $memberships = FALSE;
- $memPriceSetId = NULL;
- $friend = FALSE;
- $profilePreId = NULL;
- $profilePostId = NULL;
- $premiums = FALSE;
- $widget = FALSE;
- $pcp = FALSE;
- $honoreeSection = FALSE;
- $isAddPaymentProcessor = FALSE;
- $isPcpApprovalNeeded = FALSE;
- $isSeparatePayment = FALSE;
-
- // create a new online contribution page
- // create contribution page with randomized title and default params
- $pageId = $this->webtestAddContributionPage($hash,
- $rand,
- $pageTitle,
- NULL,
- $amountSection,
- $payLater,
- $onBehalf,
- $pledges,
- $recurring,
- $memberships,
- $memPriceSetId,
- $friend,
- $profilePreId,
- $profilePostId,
- $premiums,
- $widget,
- $pcp,
- $isAddPaymentProcessor,
- $isPcpApprovalNeeded,
- $isSeparatePayment,
- $honoreeSection
- );
-
- //Open Live Contribution Page
- $this->openCiviPage("contribute/transact", "reset=1&id=$pageId", "_qf_Main_upload-bottom");
- $this->waitForElementPresent("onbehalf_state_province-3");
-
- $this->type("onbehalf_organization_name", $orgName);
- $this->waitForElementPresent("onbehalf_phone-3-1");
- $this->type("onbehalf_phone-3-1", 9999999999);
- $this->waitForElementPresent("onbehalf_email-3");
- $this->type("onbehalf_email-3", "org@example.com");
- $this->type("onbehalf_street_address-3", "Test Street Address");
- $this->type("onbehalf_city-3", "Test City");
- $this->type("onbehalf_postal_code-3", substr(sha1(rand()), 0, 6));
- $this->click("onbehalf_country-3");
- $this->select("onbehalf_country-3", "label=UNITED STATES");
- $this->click("onbehalf_state_province-3");
- $this->select("onbehalf_state_province-3", "label=Alabama");
-
- $this->waitForElementPresent("_qf_Main_upload-bottom");
- $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
-
- $this->click("_qf_Confirm_next-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->openCiviPage("contact/view", "reset=1&cid=$cid", "xpath=//div[@class='crm-content crm-contact_type_label']");
-
- $this->verifyText("xpath=//div[@class='crm-content crm-contact_type_label']", $contactSubType);
- }
-
- /**
- * @param int $pageId
- * @param int $cid
- * @param $pageTitle
- */
- public function _testOrganization($pageId, $cid, $pageTitle) {
- //Open Live Contribution Page
- $this->openCiviPage("contribute/transact", "reset=1&id=$pageId", "_qf_Main_upload-bottom");
-
- $this->waitForElementPresent("onbehalf_state_province-3");
-
- $this->_fillOnbehalfForm();
- $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
-
- $this->click("_qf_Confirm_next-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- }
-
- public function _fillOnbehalfForm() {
- $this->waitForElementPresent("onbehalf_phone-3-1");
- $this->type("onbehalf_phone-3-1", 9999999999);
- $this->waitForElementPresent("onbehalf_email-3");
- $this->type("onbehalf_email-3", "org@example.com");
- $this->type("onbehalf_street_address-3", "Test Street Address");
- $this->type("onbehalf_city-3", "Test City");
- $this->type("onbehalf_postal_code-3", substr(sha1(rand()), 0, 6));
- $this->click("onbehalf_country-3");
- $this->select("onbehalf_country-3", "label=UNITED STATES");
- $this->click("onbehalf_state_province-3");
- $this->select("onbehalf_state_province-3", "label=Alabama");
- }
-
- /**
- * @param int $pageId
- * @param int $orgName
- * @param $pageTitle
- */
- public function _testAnomoyousOrganization($pageId, $orgName, $pageTitle) {
- $this->webtestLogout();
- //Open Live Contribution Page
- $this->openCiviPage("contribute/transact", "reset=1&id=$pageId", "_qf_Main_upload-bottom");
-
- $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
- $lastName = 'An' . substr(sha1(rand()), 0, 7);
- $this->type("email-5", $firstName . "@example.com");
-
- $this->click('CIVICRM_QFID_0_12');
- $this->type('css=div.other_amount-section input', 60);
-
- // enable onbehalforganization block
- $this->click("is_for_organization");
- $this->waitForElementPresent("onbehalf_state_province-3");
-
- // onbehalforganization info
- $this->type("onbehalf_organization_name", $orgName['name']);
- $this->type("onbehalf_phone-3-1", 9999999999);
- $this->type("onbehalf_email-3", $orgName['email']);
- $this->type("onbehalf_street_address-3", "Test Street Address");
- $this->type("onbehalf_city-3", "Test City");
- $this->type("onbehalf_postal_code-3", substr(sha1(rand()), 0, 6));
- $this->click("onbehalf_country-3");
- $this->select("onbehalf_country-3", "label=UNITED STATES");
- $this->click("onbehalf_state_province-3");
- $this->select("onbehalf_state_province-3", "label=Alabama");
-
- // Credit Card Info
- $this->select("credit_card_type", "value=Visa");
- $this->type("credit_card_number", "4111111111111111");
- $this->type("cvv2", "000");
- $this->select("credit_card_exp_date[M]", "value=1");
- $this->select("credit_card_exp_date[Y]", "value=2020");
-
- //Billing Info
- $this->type("billing_first_name", $firstName . 'billing');
- $this->type("billing_last_name", $lastName . 'billing');
- $this->type("billing_street_address-5", "0121 Mount Highschool.");
- $this->type(" billing_city-5", "Shangai");
- $this->select("billing_country_id-5", "value=1228");
- $this->select("billing_state_province_id-5", "value=1004");
- $this->type("billing_postal_code-5", "94129");
- $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
-
- $this->click("_qf_Confirm_next-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Log in using webtestLogin() method
- $this->webtestLogin();
-
- // TODO: webtestVerifyTabularData function is causing timeout error, reason why most of the Webtests are failing
- // where its been called to assert tabular data
-
- /**
- //Find Contribution
- $this->openCiviPage("contribute/search", "reset=1");
- $this->type("sort_name", $orgName['name']);
- $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']");
- $this->clickLink("xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']", "_qf_ContributionView_cancel-bottom");
-
- // verify contrb created
- $expected = array(
- 'From' => $orgName['name'],
- 'Financial Type' => 'Donation',
- 'Online Contribution Page' => $pageTitle,
- );
- $this->webtestVerifyTabularData($expected);
- */
- }
-
- /**
- * @param int $pageId
- * @param int $cid
- * @param $pageTitle
- */
- public function _testUserWithOneRelationship($pageId, $cid, $pageTitle) {
- $this->webtestLogin('admin');
-
- // Create new group
- $groupName = $this->WebtestAddGroup();
- $this->openCiviPage("group", "reset=1", "_qf_Search_refresh");
- $groupId = $this->getText("xpath=//table[@id='crm-group-selector']/tbody//tr/td[text()='{$groupName}']/../td[2]");
-
- $this->openCiviPage("contact/view", "reset=1&cid={$cid}");
-
- $this->click('link=Edit');
- $this->waitForElementPresent('_qf_Contact_cancel-bottom');
- $this->click('addressBlock');
- $this->waitForElementPresent('link=Another Address');
-
- //Billing Info
- $this->select('address_1_location_type_id', 'label=Billing');
- $this->type('address_1_street_address', '0121 Mount Highschool.');
- $this->type('address_1_city', "Shangai");
- $this->type('address_1_postal_code', "94129");
- $this->select('address_1_country_id', "value=1228");
- $this->select('address_1_state_province_id', "value=1004");
- $this->click('_qf_Contact_upload_view-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // add contact to group
- // visit group tab
- $this->click("css=li#tab_group a");
- $this->waitForElementPresent("group_id");
-
- // add to group
- $this->select("group_id", "label={$groupName}");
- $this->click("_qf_GroupContact_next");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->openCiviPage("admin/custom/group", "action=add&reset=1", "_qf_Group_next-bottom");
-
- // fill in a unique title for the custom group
- $groupTitle = "Custom Group" . substr(sha1(rand()), 0, 7);
- $this->type("title", $groupTitle);
-
- // select the group this custom data set extends
- $this->select("extends[0]", "value=Contribution");
- $this->waitForElementPresent("extends[1]");
-
- // save the custom group
- $this->click("_qf_Group_next-bottom");
- $this->waitForElementPresent("_qf_Field_next_new-bottom");
- $this->assertTrue($this->isTextPresent("Your custom field set '$groupTitle' has been added. You can add custom fields now."));
-
- // add a custom field to the custom group
- $fieldTitle = "Custom Field " . substr(sha1(rand()), 0, 7);
- $this->type("label", $fieldTitle);
-
- $this->select("data_type[1]", "value=Text");
- $this->click('_qf_Field_next-bottom');
-
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->assertTrue($this->isTextPresent("Custom field '$fieldTitle' has been saved."));
- $fieldId = $this->urlArg('id', $this->getAttribute("xpath=//div[@id='field_page']/div[2]/table/tbody//tr/td[1][text()='$fieldTitle']/../td[8]/span/a@href"));
-
- // Enable CiviCampaign module if necessary
- $this->enableComponents("CiviCampaign");
-
- // add the required permission
- $permission = array('edit-2-administer-civicampaign');
- $this->changePermissions($permission);
-
- // Log in as normal user
- $this->webtestLogin();
-
- $this->openCiviPage("campaign/add", "reset=1", "_qf_Campaign_upload-bottom");
-
- $title = 'Campaign ' . substr(sha1(rand()), 0, 7);
- $this->type("title", $title);
-
- // select the campaign type
- $this->select("campaign_type_id", "value=2");
-
- // fill in the description
- $this->type("description", "This is a test campaign");
-
- // include groups for the campaign
- $this->addSelection("includeGroups-f", "label={$groupName}");
- $this->click("//option[@value={$groupId}]");
- $this->click("add");
-
- // fill the end date for campaign
- $this->webtestFillDate("end_date", "+1 year");
-
- // select campaign status
- $this->select("status_id", "value=2");
-
- // click save
- $this->click("_qf_Campaign_upload-bottom");
- $this->waitForElementPresent("xpath=//div[@id='campaigns_wrapper']//table[@id='campaigns']/tbody//tr/td[3][text()='{$title}']");
- $this->assertTrue($this->isTextPresent("Campaign {$title} has been saved."), "Status message didn't show up after saving!");
-
- $this->openCiviPage("admin/uf/group", "reset=1");
- $this->click("link=Reserved Profiles");
-
- $this->click("xpath=//div[@id='reserved-profiles']/div/div/table/tbody//tr/td[1][text()='On Behalf Of Organization']/../td[5]/span/a[text()='Fields']");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->click("link=Add Field");
- $this->waitForElementPresent('_qf_Field_next-bottom');
- $this->select('field_name[0]', 'value=Contribution');
- $this->select('field_name[1]', 'label=Campaign');
- $this->click('field_name[1]');
- $this->click('_qf_Field_next_new-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->select('field_name[0]', 'value=Contribution');
- $this->select('field_name[1]', "label=$fieldTitle :: $groupTitle");
- $this->click('field_name[1]');
- $this->click('_qf_Field_next-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->assertTrue($this->isTextPresent("Your CiviCRM Profile Field '{$fieldTitle}' has been saved to 'On Behalf Of Organization'."));
-
- // Open Page to create Organization
- $this->openCiviPage("contact/add", "reset=1&ct=Organization", "_qf_Contact_upload_view-bottom");
- $orgName1 = 'org1_' . substr(sha1(rand()), 0, 7);
-
- // Type Organization name
- $this->type("organization_name", $orgName1);
-
- // Type Organizatio email for main
- $this->type("email_1_email", "{$orgName1}@example.com");
- $this->select("email_1_location_type_id", "value=3");
-
- // type phone no for main
- $this->type("phone_1_phone", 9999999999);
- $this->select("phone_1_location_type_id", "value=3");
-
- //address section
- $this->click("addressBlock");
- $this->waitForElementPresent("address_1_street_address");
-
- //fill in address 1 for main
- $this->select("address_1_location_type_id", "value=3");
- $this->type("address_1_street_address", "{$orgName1} street address");
- $this->type("address_1_city", "{$orgName1} city");
- $this->type("address_1_postal_code", substr(sha1(rand()), 0, 4));
- $this->assertTrue($this->isTextPresent("- select - UNITED STATES"));
- $this->select("address_1_state_province_id", "value=1019");
- $this->type("address_1_geo_code_1", "1234");
- $this->type("address_1_geo_code_2", "5678");
-
- // Save the Organization
- $this->click("_qf_Contact_upload_view-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // open contact
- $this->openCiviPage("contact/view/rel", "cid={$cid}&action=add&reset=1");
-
- // select relationship type
- $this->click("relationship_type_id");
- $this->select("relationship_type_id", "value=4_a_b");
-
- // search organization
- $this->type('contact_1', $orgName1);
- $this->click("contact_1");
- $this->waitForElementPresent("css=div.ac_results-inner li");
- $this->click("css=div.ac_results-inner li");
- $this->assertContains($orgName1, $this->getValue('contact_1'), "autocomplete expected $orgName1 but didn’t find it in " . $this->getValue('contact_1'));
-
- $this->waitForElementPresent("add_current_employer");
- $this->click("add_current_employer");
-
- // give permission
- $this->click("is_permission_a_b");
- $this->click("is_permission_b_a");
-
- // save relationship
- $this->waitForElementPresent("details-save");
- $this->click("details-save");
-
- //Open Live Contribution Page
- $this->openCiviPage("contribute/transact", "reset=1&id={$pageId}&cid=$cid", "onbehalf_state_province-3");
- $this->click('CIVICRM_QFID_amount_other_radio_4');
- $this->type('amount_other', 60);
- $this->click('onbehalf_contribution_campaign_id');
- $this->select('onbehalf_contribution_campaign_id', "label={$title}");
- $this->type("onbehalf_custom_{$fieldId}", 'Test Subject');
-
- // Credit Card Info
- $this->select("credit_card_type", "value=Visa");
- $this->type("credit_card_number", "4111111111111111");
- $this->type("cvv2", "000");
- $this->select("credit_card_exp_date[M]", "value=1");
- $this->select("credit_card_exp_date[Y]", "value=2020");
-
- //Billing Info
- $this->type("billing_street_address-5", "0121 Mount Highschool.");
- $this->type(" billing_city-5", "Shangai");
- $this->select("billing_country_id-5", "value=1228");
- $this->select("billing_state_province_id-5", "value=1004");
- $this->type("billing_postal_code-5", "94129");
-
- $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
- $this->click("_qf_Confirm_next-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- //Find Contribution
- $this->openCiviPage("contribute/search", "reset=1");
- $this->type("sort_name", $orgName1);
- $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']");
- $this->clickLink("xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']", "_qf_ContributionView_cancel-bottom");
-
- // verify contrb created
- $expected = array(
- 1 => $orgName1,
- 2 => 'Donation',
- 10 => $title,
- 11 => $pageTitle,
- );
- foreach ($expected as $value => $label) {
- $this->verifyText("xpath=id( 'ContributionView' )/div[2]/table[1]/tbody/tr[$value]/td[2]", preg_quote($label));
- }
-
- $this->openCiviPage("admin/uf/group", "reset=1");
- $this->click("link=Reserved Profiles");
-
- $this->click("xpath=//div[@id='reserved-profiles']/div/div/table/tbody//tr/td[1][text()='On Behalf Of Organization']/../td[5]/span/a[text()='Fields']");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->click("xpath=//div[@id='field_page']/div[3]/table/tbody//tr/td[1][text()='Campaign']/../td[9]/span[2][text()='more ']/ul/li[2]/a[text()='Delete']");
- $this->waitForElementPresent('_qf_Field_next-bottom');
-
- $this->click('_qf_Field_next-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->assertTrue($this->isTextPresent('Selected Profile Field has been deleted.'), "Status message didn't show up after saving!");
-
- $this->click("xpath=//div[@id='field_page']/div[3]/table/tbody//tr/td[1][text()='{$fieldTitle}']/../td[9]/span[2][text()='more ']/ul/li[2]/a[text()='Delete']");
- $this->waitForElementPresent('_qf_Field_next-bottom');
-
- $this->click('_qf_Field_next-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->assertTrue($this->isTextPresent('Selected Profile Field has been deleted.'), "Status message didn't show up after saving!");
- }
-
- /**
- * @param int $pageId
- * @param int $cid
- * @param $pageTitle
- */
- public function _testUserWithMoreThanOneRelationship($pageId, $cid, $pageTitle) {
- $this->webtestLogin('admin');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Create new group
- $groupName = $this->WebtestAddGroup();
- $this->openCiviPage("group", "reset=1", '_qf_Search_refresh');
- $this->click('_qf_Search_refresh');
- $this->waitForElementPresent("xpath=//div[@id='group']/div[3]/table/tbody//tr/td[text()='{$groupName}']/../td[2]");
- $groupId = $this->getText("xpath=//div[@id='group']/div[3]/table/tbody//tr/td[text()='{$groupName}']/../td[2]");
-
- $this->openCiviPage("contact/view", "reset=1&cid={$cid}");
-
- $this->click('link=Edit');
- $this->waitForElementPresent('_qf_Contact_cancel-bottom');
- $this->click('addressBlock');
- $this->waitForElementPresent('link=Another Address');
-
- //Billing Info
- $this->select('address_1_location_type_id', 'label=Billing');
- $this->type('address_1_street_address', '0121 Mount Highschool.');
- $this->type('address_1_city', "Shangai");
- $this->type('address_1_postal_code', "94129");
- $this->select('address_1_country_id', "value=1228");
- $this->select('address_1_state_province_id', "value=1004");
- $this->click('_qf_Contact_upload_view-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // add contact to group
- // visit group tab
- $this->click("css=li#tab_group a");
- $this->waitForElementPresent("group_id");
-
- // add to group
- $this->select("group_id", "label=$groupName");
- $this->click("_qf_GroupContact_next");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->openCiviPage("admin/custom/group", "action=add&reset=1", "_qf_Group_next-bottom");
-
- // fill in a unique title for the c$groupIdustom group
- $groupTitle = "Members Custom Group" . substr(sha1(rand()), 0, 7);
- $this->type("title", $groupTitle);
-
- // select the group this custom data set extends
- $this->select("extends[0]", "value=Membership");
- $this->waitForElementPresent("extends[1]");
-
- // save the custom group
- $this->click("_qf_Group_next-bottom");
-
- $this->waitForElementPresent("_qf_Field_next_new-bottom");
- $this->assertTrue($this->isTextPresent("Your custom field set '$groupTitle' has been added. You can add custom fields now."));
-
- // add a custom field to the custom group
- $fieldTitle = "Member Custom Field " . substr(sha1(rand()), 0, 7);
- $this->type("label", $fieldTitle);
-
- $this->select("data_type[1]", "value=Text");
- $this->click('_qf_Field_next-bottom');
-
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->assertTrue($this->isTextPresent("Custom field '$fieldTitle' has been saved."));
- $fieldId = $this->urlArg('id', $this->getAttribute("xpath=//div[@id='field_page']/div[2]/table/tbody//tr/td[1]/span[text()='$fieldTitle']/../td[8]/span/a@href"));
-
- // Enable CiviCampaign module if necessary
- $this->enableComponents("CiviCampaign");
-
- // add the required permission
- $permission = array('edit-2-administer-civicampaign');
- $this->changePermissions($permission);
-
- // Log in as normal user
- $this->webtestLogin();
-
- $this->openCiviPage("campaign/add", "reset=1", "_qf_Campaign_upload-bottom");
-
- $title = 'Campaign ' . substr(sha1(rand()), 0, 7);
- $this->type("title", $title);
-
- // select the campaign type
- $this->select("campaign_type_id", "value=2");
-
- // fill in the description
- $this->type("description", "This is a test campaign");
-
- // include groups for the campaign
- $this->addSelection("includeGroups-f", "label={$groupName}");
- $this->click("//option[@value={$groupId}]");
- $this->click("add");
-
- // fill the end date for campaign
- $this->webtestFillDate("end_date", "+1 year");
-
- // select campaign status
- $this->select("status_id", "value=2");
-
- // click save
- $this->click("_qf_Campaign_upload-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->assertTrue($this->isTextPresent("Campaign {$title} has been saved."), "Status message didn't show up after saving!");
-
- $this->openCiviPage("admin/uf/group", "reset=1");
- $this->click("link=Reserved Profiles");
- $this->click("xpath=//div[@id='reserved-profiles']/div/div/table/tbody//tr/td[1][text()='On Behalf Of Organization']/../td[5]/span/a[text()='Fields']");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->click("link=Add Field");
- $this->waitForElementPresent('_qf_Field_next-bottom');
- $this->select('field_name[0]', 'value=Membership');
- $this->select('field_name[1]', 'label=Campaign');
- $this->click('field_name[1]');
- $this->clickLink('_qf_Field_next_new-bottom', '_qf_Field_cancel-bottom');
-
- $this->select('field_name[0]', 'value=Membership');
- $this->select('field_name[1]', "label=$fieldTitle :: $groupTitle");
- $this->click('field_name[1]');
- $this->click('_qf_Field_next-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->assertTrue($this->isTextPresent("Your CiviCRM Profile Field '{$fieldTitle}' has been saved to 'On Behalf Of Organization'."),
- "Status message didn't show up after saving!"
- );
-
- // Open Page to create Organization 1
- $this->openCiviPage("contact/add", "reset=1&ct=Organization", "_qf_Contact_upload_view-bottom");
- $orgName1 = 'org1_' . substr(sha1(rand()), 0, 7);
-
- // Type Organization name
- $this->type("organization_name", $orgName1);
-
- // Type Organizatio email for main
- $this->type("email_1_email", "{$orgName1}@example.com");
- $this->select("email_1_location_type_id", "value=3");
-
- // type phone no for main
- $this->type("phone_1_phone", substr(sha1(rand()), 0, 4));
- $this->select("phone_1_location_type_id", "value=3");
-
- //address section
- $this->click("addressBlock");
- $this->waitForElementPresent("address_1_street_address");
-
- //fill in address 1 for main
- $this->select("address_1_location_type_id", "value=3");
- $this->type("address_1_street_address", "{$orgName1} street address");
- $this->type("address_1_city", "{$orgName1} city");
- $this->type("address_1_postal_code", "9999999999");
- $this->assertTrue($this->isTextPresent("- select - UNITED STATES"));
- $this->select("address_1_state_province_id", "value=1019");
- $this->type("address_1_geo_code_1", "1234");
- $this->type("address_1_geo_code_2", "5678");
-
- // Save the Organization
- $this->click("_qf_Contact_upload_view-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // create second orzanization
- $this->openCiviPage("contact/add", "reset=1&ct=Organization", "_qf_Contact_upload_view-bottom");
- $orgName2 = 'org2_' . substr(sha1(rand()), 0, 7);
-
- // Type Organization name
- $this->type("organization_name", $orgName2);
-
- // Type Organizatio email for main
- $this->type("email_1_email", "{$orgName2}@example.com");
- $this->select("email_1_location_type_id", "value=3");
-
- // type phone no for main
- $this->type("phone_1_phone", substr(sha1(rand()), 0, 4));
- $this->select("phone_1_location_type_id", "value=3");
-
- //address section
- $this->click("addressBlock");
- $this->waitForElementPresent("address_1_street_address");
-
- //fill in address 1 for main
- $this->select("address_1_location_type_id", "value=3");
- $this->type("address_1_street_address", "{$orgName2} street address");
- $this->type("address_1_city", "{$orgName2} city");
- $this->type("address_1_postal_code", "7777777777");
- $this->assertTrue($this->isTextPresent("- select - UNITED STATES"));
- $this->select("address_1_state_province_id", "value=1019");
- $this->type("address_1_geo_code_1", "1224");
- $this->type("address_1_geo_code_2", "5628");
-
- // Save the Organization
- $this->click("_qf_Contact_upload_view-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // create Membership type
- $title1 = "Membership Type" . substr(sha1(rand()), 0, 7);
- $this->openCiviPage("admin/member/membershipType", "reset=1&action=browse");
-
- $this->click("link=Add Membership Type");
- $this->waitForElementPresent('_qf_MembershipType_cancel-bottom');
-
- $this->type('name', $title1);
- $this->type('member_org', $orgName1);
- $this->click('_qf_MembershipType_refresh');
- $this->waitForElementPresent("xpath=//div[@id='membership_type_form']/fieldset/table[2]/tbody/tr[2]/td[2]");
-
- $this->type('minimum_fee', '50');
-
- $this->select('financial_type_id', 'value=2');
-
- $this->type('duration_interval', 1);
- $this->select('duration_unit', "label=year");
-
- $this->select('period_type', "label=fixed");
- $this->waitForElementPresent('fixed_period_rollover_day[d]');
-
- $this->select('fixed_period_start_day[M]', 'value=4');
- $this->select('fixed_period_rollover_day[M]', 'value=1');
-
- $this->select('relationship_type_id', 'value=4_b_a');
-
- $this->click('_qf_MembershipType_upload-bottom');
- $this->waitForElementPresent('link=Add Membership Type');
- $this->assertTrue($this->isTextPresent("The membership type '$title1' has been saved."));
- $typeId = $this->urlArg('id', $this->getAttribute("xpath=//div[@id='membership_type']/div[2]/table/tbody//tr/td[1][text()='{$title1}']/../td[10]/span/a[3]@href"));
-
- // open contact
- $this->openCiviPage("contact/view/rel", "cid={$cid}&action=add&reset=1");
-
- // select relationship type
- $this->click("relationship_type_id");
- $this->select("relationship_type_id", "value=4_a_b");
-
- // search organization
- $this->type('contact_1', $orgName1);
- $this->click("contact_1");
- $this->waitForElementPresent("css=div.ac_results-inner li");
- $this->click("css=div.ac_results-inner li");
- $this->assertContains($orgName1, $this->getValue('contact_1'), "autocomplete expected $orgName1 but didn’t find it in " . $this->getValue('contact_1'));
-
- // give permission
- $this->click("is_permission_a_b");
- $this->click("is_permission_b_a");
-
- // save relationship
- $this->click("details-save");
-
- // open contact
- $this->openCiviPage("contact/view/rel", "cid={$cid}&action=add&reset=1");
-
- // select relationship type
- $this->click("relationship_type_id");
- $this->select("relationship_type_id", "value=4_a_b");
-
- // search organization
- $this->type('contact_1', $orgName2);
- $this->click("contact_1");
- $this->waitForElementPresent("css=div.ac_results-inner li");
- $this->click("css=div.ac_results-inner li");
- $this->assertContains($orgName2, $this->getValue('contact_1'), "autocomplete expected $orgName2 but didn’t find it in " . $this->getValue('contact_1'));
-
- // give permission
- $this->click("is_permission_a_b");
- $this->click("is_permission_b_a");
-
- // save relationship
- $this->click("details-save");
-
- // set membership type
- $this->openCiviPage("admin/contribute/membership", "reset=1&action=update&id=$pageId", "_qf_MembershipBlock_upload_done-bottom");
- $this->click("member_is_active");
- $this->click("membership_type[{$typeId}]");
- $this->click("xpath=//div[@id='memberFields']//table[@class='report']/tbody//tr/td[1]/label[text()='{$title1}']/../../td[2]/input");
- $this->click('_qf_MembershipBlock_upload_done-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- //Open Live Membership Page
- $this->openCiviPage('contribute/transact', "reset=1&id=$pageId&cid=$cid", "_qf_Main_upload-bottom");
- $this->click('CIVICRM_QFID_amount_other_radio_4');
- $this->type('amount_other', 60);
- $this->click('onbehalf_organization_name');
- $this->type('onbehalf_organization_name', $orgName1);
- $this->typeKeys('onbehalf_organization_name', $orgName1);
- $this->click("onbehalf_organization_name");
- $this->waitForElementPresent("css=div.ac_results-inner li");
- $this->click("css=div.ac_results-inner li");
- // Because it tends to cause problems, all uses of sleep() must be justified in comments
- // Sleep should never be used for wait for anything to load from the server
- // Justification for this instance: FIXME
- sleep(5);
- $this->click('onbehalf_member_campaign_id');
- $this->select('onbehalf_member_campaign_id', "label={$title}");
- $this->type("onbehalf_custom_{$fieldId}", 'Test Subject');
-
- $this->assertContains($orgName1, $this->getValue('onbehalf_organization_name'), "autocomplete expected $orgName1 but didn’t find it in " . $this->getValue('onbehalf_organization_name'));
-
- // Credit Card Info
- $this->select("credit_card_type", "value=Visa");
- $this->type("credit_card_number", "4111111111111111");
- $this->type("cvv2", "000");
- $this->select("credit_card_exp_date[M]", "value=1");
- $this->select("credit_card_exp_date[Y]", "value=2020");
-
- $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
- $this->click("_qf_Confirm_next-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- //Find Membership for organization
- $this->openCiviPage("member/search", "reset=1");
- $this->type("sort_name", $orgName1);
- $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='memberSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']");
- $this->clickLink("xpath=//div[@id='memberSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']", "_qf_MembershipView_cancel-bottom");
-
- //verify contrb created
- $expected = array(
- 1 => $orgName1,
- 2 => $title1,
- 3 => 'New',
- );
- foreach ($expected as $value => $label) {
- $this->verifyText("xpath=//form[@id='MembershipView']/div[2]/div/table/tbody/tr[$value]/td[2]", preg_quote($label));
- }
-
- // find membership for contact in relationship
- $this->openCiviPage("contact/view", "reset=1&force=1&cid={$cid}");
- $this->click("css=li#tab_member a");
- $this->waitForElementPresent("xpath=//div[@id='memberships']/div/table//tbody//tr/td[1][text()='{$title1}']");
- $this->click("xpath=//div[@id='memberships']/div/table//tbody//tr/td[1][text()='{$title1}']/../td[7]/span/a[text()='View']");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- //verify contrb created
- $expected = array(
- 3 => $title1,
- 4 => 'New',
- );
- foreach ($expected as $value => $label) {
- $this->verifyText("xpath=//form[@id='MembershipView']/div[2]/div/table/tbody/tr[$value]/td[2]", preg_quote($label));
- }
-
- $this->openCiviPage("admin/uf/group", "reset=1");
- $this->click("link=Reserved Profiles");
- $this->click("xpath=//div[@id='reserved-profiles']/div/div/table/tbody//tr/td[1][text()='On Behalf Of Organization']/../td[5]/span/a[text()='Fields']");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->click("xpath=//div[@id='field_page']/div[3]/table/tbody//tr/td[1][text()='Campaign']/../td[9]/span[2][text()='more ']/ul/li[2]/a[text()='Delete']");
- $this->waitForElementPresent('_qf_Field_next-bottom');
-
- $this->click('_qf_Field_next-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->assertTrue($this->isTextPresent('Selected Profile Field has been deleted.'),
- "Status message didn't show up after saving!"
- );
-
- $this->click("xpath=//div[@id='field_page']/div[3]/table/tbody//tr/td[1][text()='{$fieldTitle}']/../td[9]/span[2][text()='more ']/ul/li[2]/a[text()='Delete']");
- $this->waitForElementPresent('_qf_Field_next-bottom');
-
- $this->click('_qf_Field_next-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->assertTrue($this->isTextPresent('Selected Profile Field has been deleted.'),
- "Status message didn't show up after saving!"
- );
-
- $this->openCiviPage("contact/view", "reset=1&cid={$cid}");
- $this->click("css=li#tab_rel a");
-
- $this->waitForElementPresent("xpath=//div[@id='current-relationships']/div/table/tbody//tr/td[2]/a[text()='{$orgName1}']");
- $this->click("xpath=//div[@id='current-relationships']/div/table/tbody//tr/td[2]/a[text()='{$orgName1}']/../../td[9]/span[2][text()='more ']/ul/li[2]/a[text()='Delete']");
-
- // Check confirmation alert.
- $this->assertTrue((bool) preg_match("/^Are you sure you want to delete this relationship?/",
- $this->getConfirmation()
- ));
- $this->chooseOkOnNextConfirmation();
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->assertTrue($this->isTextPresent('Selected relationship has been deleted successfully.'),
- "Status message didn't show up after saving!"
- );
- }
-
- public function testOnBehalfOfOrganizationWithImage() {
- $this->webtestLogin();
-
- $this->openCiviPage("profile/edit", "reset=1&gid=4");
- $firstName = 'John_x_' . substr(sha1(rand()), 0, 7);
- $lastName = 'Anderson_c_' . substr(sha1(rand()), 0, 7);
-
- $this->waitForElementPresent("_qf_Edit_next");
- $this->type("first_name", $firstName);
- $this->type("last_name", $lastName);
- $this->clickLink("_qf_Edit_next", "profilewrap4");
-
- $cid = $this->urlArg('id');
- $this->assertType('numeric', $cid);
- // Is status message correct?
- $this->assertTextPresent("Thank you. Your information has been saved.", "Save successful status message didn't show up after saving profile to update testUserName!");
-
- $this->openCiviPage("admin/uf/group", "reset=1");
- $this->click("link=Reserved Profiles");
-
- $this->click("xpath=//div[@id='reserved-profiles']/div/div/table/tbody//tr/td[1][text()='On Behalf Of Organization']/../td[5]/span/a[text()='Fields']");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->click("link=Add Field");
- $this->waitForElementPresent('_qf_Field_next-bottom');
-
- $this->select('field_name[0]', 'value=Contact');
- $this->select('field_name[1]', 'label=Image Url');
- $this->click('field_name[1]');
- $this->click('_qf_Field_next-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Use default payment processor
- $processorName = 'Test Processor';
- $processorType = 'Dummy';
- $pageTitle = substr(sha1(rand()), 0, 7);
- $rand = 100;
- $hash = substr(sha1(rand()), 0, 7);
- $amountSection = TRUE;
- $payLater = TRUE;
- $onBehalf = TRUE;
- $pledges = FALSE;
- $recurring = FALSE;
- $memberships = FALSE;
- $memPriceSetId = NULL;
- $friend = TRUE;
- $profilePreId = NULL;
- $profilePostId = NULL;
- $premiums = FALSE;
- $widget = FALSE;
- $pcp = FALSE;
- $honoreeSection = FALSE;
- $isAddPaymentProcessor = TRUE;
- $isPcpApprovalNeeded = FALSE;
- $isSeparatePayment = FALSE;
-
- // create a new online contribution page
- // create contribution page with randomized title and default params
- $pageId = $this->webtestAddContributionPage($hash,
- $rand,
- $pageTitle,
- array($processorName => $processorType),
- $amountSection,
- $payLater,
- $onBehalf,
- $pledges,
- $recurring,
- $memberships,
- $memPriceSetId,
- $friend,
- $profilePreId,
- $profilePostId,
- $premiums,
- $widget,
- $pcp,
- $isAddPaymentProcessor,
- $isPcpApprovalNeeded,
- $isSeparatePayment,
- $honoreeSection
- );
-
- $this->_testOrganizationWithImageUpload($pageId, $cid, $pageTitle);
-
- $this->openCiviPage("admin/uf/group", "reset=1");
- $this->click("link=Reserved Profiles");
-
- $this->click("xpath=//div[@id='reserved-profiles']/div/div/table/tbody//tr/td[1][text()='On Behalf Of Organization']/../td[5]/span/a[text()='Fields']");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->click("xpath=//table[@id='option11']/tbody//tr/td/span[text()='Image Url']/../following-sibling::td[8]/span[2]/ul/li[2]/a");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->click('_qf_Field_next-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForText('crm-notification-container', "Selected Profile Field has been deleted.");
- }
-
- /**
- * @param int $pageId
- * @param int $cid
- * @param $pageTitle
- */
- public function _testOrganizationWithImageUpload($pageId, $cid, $pageTitle) {
- //Open Live Contribution Page
- $this->openCiviPage("contribute/transact", "reset=1&id=$pageId", '_qf_Main_upload-bottom');
-
- $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
- $lastName = 'An' . substr(sha1(rand()), 0, 7);
- $orgName = 'org_11_' . substr(sha1(rand()), 0, 7);
- $this->type("email-5", $firstName . "@example.com");
-
- // onbehalforganization info
- $this->type("onbehalf_organization_name", $orgName);
- $this->type("onbehalf_phone-3-1", 9999999999);
- $this->type("onbehalf_email-3", "{$orgName}@example.com");
- $this->type("onbehalf_street_address-3", "Test Street Address");
- $this->type("onbehalf_city-3", "Test City");
- $this->type("onbehalf_postal_code-3", substr(sha1(rand()), 0, 6));
- $this->click("onbehalf_country-3");
- $this->select("onbehalf_country-3", "label=UNITED STATES");
- $this->click("onbehalf_state_province-3");
- $this->select("onbehalf_state_province-3", "label=Alabama");
-
- // check for upload field.
- $this->waitForElementPresent("onbehalf_image_URL");
-
- //header("Content-Type: image/png");
- $im = imagecreate(110, 20)
- or die("Cannot Initialize new GD image stream");
- $background_color = imagecolorallocate($im, 0, 0, 0);
- $text_color = imagecolorallocate($im, 233, 14, 91);
- imagestring($im, 1, 5, 5, "On Behalf-Org Logo", $text_color);
- imagepng($im, "/tmp/file.png");
-
- $imagePath = "/tmp/file.png";
- $this->webtestAttachFile('onbehalf_image_URL', $imagePath);
- unlink($imagePath);
-
- // Credit Card Info
- $this->select("credit_card_type", "value=Visa");
- $this->type("credit_card_number", "4111111111111111");
- $this->type("cvv2", "000");
- $this->select("credit_card_exp_date[M]", "value=1");
- $this->select("credit_card_exp_date[Y]", "value=2020");
-
- //Billing Info
- $this->type("billing_first_name", $firstName . 'billing');
- $this->type("billing_last_name", $lastName . 'billing');
- $this->type("billing_street_address-5", "0121 Mount Highschool.");
- $this->type(" billing_city-5", "Shangai");
- $this->select("billing_country_id-5", "value=1228");
- $this->select("billing_state_province_id-5", "value=1004");
- $this->type("billing_postal_code-5", "94129");
- $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
-
- $this->click("_qf_Confirm_next-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Type search name in autocomplete.
- $this->click('sort_name_navigation');
- $this->type('css=input#sort_name_navigation', $orgName);
- $this->typeKeys('css=input#sort_name_navigation', $orgName);
-
- // Wait for result list.
- $this->waitForElementPresent("css=div.ac_results-inner li");
-
- // Visit organization page.
- $this->click("css=div.ac_results-inner li");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- //check whether the image is present
- $this->assertTrue($this->isElementPresent("xpath=//div[@id='crm-contact-thumbnail']/div/a/img"));
- }
-
- public function testOnBehalfSetDefaults() {
- $this->webtestLogin();
- $hash = substr(sha1(rand()), 0, 7);
- $pageTitle = 'Donate Online ' . $hash;
- $rand = 2 * rand(2, 50);
-
- // go to the New Contribution Page page
- $this->openCiviPage('admin/contribute', 'action=add&reset=1');
-
- // fill in step 1 (Title and Settings)
- $this->type('title', $pageTitle);
-
- //to select financial type
- $this->select('financial_type_id', "label=Donation");
- $this->clickLink('_qf_Settings_next');
-
- $this->click('link=Profiles');
- $this->waitForElementPresent('_qf_Custom_next-bottom');
- $this->select('css=tr.crm-contribution-contributionpage-custom-form-block-custom_pre_id span.crm-profile-selector-select select', "value=1");
- $this->click('_qf_Custom_next-bottom');
- $this->waitForElementPresent('_qf_Custom_next-bottom');
-
- $this->click('link=Title');
- $this->waitForElementPresent('_qf_Settings_next');
- $this->click('is_organization');
- $this->clickLink('_qf_Settings_next');
- $this->waitForElementPresent('_qf_Settings_next');
- $this->click('is_organization');
- $this->clickLink('_qf_Settings_next');
- $this->waitForElementPresent('_qf_Settings_next');
- $this->click('is_organization');
- $this->waitForElementPresent("xpath=//*[@id='select2-chosen-2']");
- $sel = $this->getText("xpath=//*[@id='select2-chosen-2']");
- $this->assertEquals($sel, 'On Behalf Of Organization');
- }
-
- public function testOnBehalfOfOrganizationWithCustomFields() {
- $this->webtestLogin();
- $pageId = 1;
- //enable on behalf for contribution page.
- $this->openCiviPage('admin/contribute/settings', "reset=1&action=update&id={$pageId}");
- $this->click('is_organization');
- $this->select("xpath=//*[@class='crm-contribution-onbehalf_profile_id']//span[@class='crm-profile-selector-select']//select", 'label=On Behalf Of Organization');
- $this->click('CIVICRM_QFID_2_4');
- $this->clickLink('_qf_Settings_upload_done-bottom');
-
- //create custom group
- $this->openCiviPage('admin/custom/group', "reset=1");
- $this->clickLink('newCustomDataGroup', '');
- $customGroupTitle = "custom_" . substr(sha1(rand()), 0, 4);
- $this->type("title", $customGroupTitle);
- $this->click("extends[0]");
- $this->select("extends[0]", "value=Contact");
- $this->click("//option[@value='Contact']");
- $this->clickLink("_qf_Group_next-bottom");
- $this->waitForText('crm-notification-container', "Your custom field set '{$customGroupTitle}' has been added. You can add custom fields now.");
- $this->waitForElementPresent("label");
-
- //create custom field checkbox
- $checkboxFieldLabel = 'custom_field' . substr(sha1(rand()), 0, 4);
- $this->type("label", $checkboxFieldLabel);
- $this->select("data_type[1]", "value=CheckBox");
- $checkboxOptionLabel1 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
- $this->type("option_label_1", $checkboxOptionLabel1);
- $checkboxOptionLabel2 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
- $this->type("option_label_2", $checkboxOptionLabel2);
- $this->clickAjaxLink("_qf_Field_next_new-bottom", "data_type[1]");
-
- //create custom field radio
- $this->select("data_type[1]", "value=Radio");
- $radioFieldLabel = 'custom_field' . substr(sha1(rand()), 0, 4);
- $this->type("label", $radioFieldLabel);
- $radioOptionLabel1 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
- $this->type("option_label_1", $radioOptionLabel1);
- $radioOptionLabel2 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
- $this->type("option_label_2", $radioOptionLabel2);
- $this->clickAjaxLink("_qf_Field_done-bottom", 'newCustomField');
-
- $custom1 = explode('&id=', $this->getAttribute("xpath=//div[@id='field_page']//table/tbody//tr[1]/td[8]/span/a[text()='Edit Field']/@href"));
- $custom2 = explode('&id=', $this->getAttribute("xpath=//div[@id='field_page']//table/tbody//tr[2]/td[8]/span/a[text()='Edit Field']/@href"));
- $checkboxFieldId = $custom1[1];
- $radioFieldId = $custom2[1];
-
- //Add this fields to organization profile
- $this->openCiviPage("admin/uf/group", "reset=1");
- $this->waitForElementPresent("link=Reserved Profiles");
- $this->click("link=Reserved Profiles");
- $this->waitForElementPresent("xpath=//div[@id='reserved-profiles']/div/div/table/tbody//tr/td[1][text()='On Behalf Of Organization']");
- $this->click("xpath=//div[@id='reserved-profiles']/div/div/table/tbody//tr/td[1][text()='On Behalf Of Organization']/../td[7]/span/a[text()='Fields']");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->clickPopupLink("link=Add Field", '_qf_Field_next-bottom');
- $this->select('field_name[0]', 'value=Contact');
-
- $label = "{$checkboxFieldLabel} :: {$customGroupTitle}";
- $this->select('field_name[1]', "label={$label}");
- $this->waitForAjaxContent();
- $this->clickAjaxLink('_qf_Field_next_new-bottom', 'field_name[0]');
- $this->select('field_name[0]', 'value=Contact');
- $this->waitForAjaxContent();
- $label2 = "{$radioFieldLabel} :: {$customGroupTitle}";
- $this->select('field_name[1]', "label={$label2}");
- $this->clickAjaxLink('_qf_Field_next-bottom');
-
- //Open Live Contribution Page
- $this->openCiviPage("contribute/transact", "reset=1&id=$pageId", '_qf_Main_upload-bottom');
- $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
- $lastName = 'An' . substr(sha1(rand()), 0, 7);
- $orgName = 'org_11_' . substr(sha1(rand()), 0, 7);
- $this->type("email-5", $firstName . "@example.com");
-
- $this->type("onbehalf_organization_name", $orgName);
- $this->_fillOnbehalfForm();
- $this->click("xpath=//label[text()='{$checkboxOptionLabel1}']");
- $this->click("xpath=//label[text()='{$checkboxOptionLabel2}']");
- $this->click("xpath=//label[text()='{$radioOptionLabel2}']");
-
- // Credit Card Info
- $this->webtestAddCreditCardDetails();
- $this->webtestAddBillingDetails($firstName, $lastName);
- $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
-
- //assert custom radio and checkbox are correctly submitted
- $this->assertElementNotContainsText("editrow-custom_{$checkboxFieldId}", '[ ]');
- $this->assertElementContainsText("editrow-custom_{$checkboxFieldId}", '[x]');
- $this->assertElementContainsText("editrow-custom_{$radioFieldId}", '( )');
- $this->assertElementContainsText("editrow-custom_{$radioFieldId}", '(x)');
-
- $this->click("_qf_Confirm_next-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Contribute_OnlineContributionTest
- */
-class WebTest_Contribute_OnlineContributionTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testOnlineContributionAdd() {
- $this->webtestLogin();
-
- // Use default payment processor
- $processorName = 'Test Processor';
- $processorType = 'Dummy';
- $pageTitle = substr(sha1(rand()), 0, 7);
- $rand = 2 * rand(10, 50);
- $hash = substr(sha1(rand()), 0, 7);
- $amountSection = TRUE;
- $payLater = FALSE;
- $onBehalf = FALSE;
- $pledges = FALSE;
- $recurring = FALSE;
- $memberships = FALSE;
- $friend = TRUE;
- $profilePreId = 1;
- $profilePostId = NULL;
- $premiums = FALSE;
- $widget = FALSE;
- $pcp = FALSE;
- $memPriceSetId = NULL;
-
- // create a new online contribution page
- // create contribution page with randomized title and default params
- $pageId = $this->webtestAddContributionPage($hash,
- $rand,
- $pageTitle,
- array($processorName => $processorType),
- $amountSection,
- $payLater,
- $onBehalf,
- $pledges,
- $recurring,
- $memberships,
- $memPriceSetId,
- $friend,
- $profilePreId,
- $profilePostId,
- $premiums,
- $widget,
- $pcp
- );
-
- //logout
- $this->webtestLogout();
-
- //Open Live Contribution Page
- $this->openCiviPage("contribute/transact", "reset=1&id=$pageId&action=preview", "_qf_Main_upload-bottom");
-
- $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
- $lastName = 'An' . substr(sha1(rand()), 0, 7);
- $honorFirstName = 'In' . substr(sha1(rand()), 0, 4);
- $honorLastName = 'Hon' . substr(sha1(rand()), 0, 7);
- $honorEmail = $honorFirstName . "@example.com";
- $honorSortName = $honorLastName . ', ' . $honorFirstName;
- $honorDisplayName = 'Ms. ' . $honorFirstName . ' ' . $honorLastName;
-
- $this->type("email-5", $firstName . "@example.com");
-
- $this->type("first_name", $firstName);
- $this->type("last_name", $lastName);
-
- $this->click("xpath=//div[@class='crm-section other_amount-section']//div[2]/input");
- $this->type("xpath=//div[@class='crm-section other_amount-section']//div[2]/input", 100);
-
- $streetAddress = "100 Main Street";
- $this->type("street_address-1", $streetAddress);
- $this->type("city-1", "San Francisco");
- $this->type("postal_code-1", "94117");
- $this->select("country-1", "value=1228");
- $this->select("state_province-1", "value=1001");
- // Honoree Info
- $this->click("xpath=id('Main')/div[3]/fieldset/div[2]/div/label[text()='In Honor of']");
-
- $this->select("honor[prefix_id]", "label=Ms.");
- $this->type("honor[first_name]", $honorFirstName);
- $this->type("honor[last_name]", $honorLastName);
- $this->type("honor[email-1]", $honorEmail);
-
- //Credit Card Info
- $this->select("credit_card_type", "value=Visa");
- $this->type("credit_card_number", "4111111111111111");
- $this->type("cvv2", "000");
- $this->select("credit_card_exp_date[M]", "value=1");
- $this->select("credit_card_exp_date[Y]", "value=2020");
-
- //Billing Info
- $this->type("billing_first_name", $firstName . "billing");
- $this->type("billing_last_name", $lastName . "billing");
- $this->type("billing_street_address-5", "15 Main St.");
- $this->type(" billing_city-5", "San Jose");
- $this->select("billing_country_id-5", "value=1228");
- $this->select("billing_state_province_id-5", "value=1004");
- $this->type("billing_postal_code-5", "94129");
- $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
- $this->waitForElementPresent("xpath=//div[@class='crm-group billing_name_address-group']//div[@class='crm-section no-label billing_name-section']");
- $this->assertElementContainsText("xpath=//div[@class='crm-group billing_name_address-group']//div[@class='crm-section no-label billing_name-section']", $firstName . "billing");
- $this->assertElementContainsText("xpath=//div[@class='crm-group billing_name_address-group']//div[@class='crm-section no-label billing_name-section']", $lastName . "billing");
-
- $stateText = CRM_Core_PseudoConstant::stateProvinceAbbreviation(1004);
- $countryText = CRM_Core_PseudoConstant::countryIsoCode(1228);
- $billingDetails = array('15 Main St.', 'San Jose', '94129', $stateText, $countryText);
- foreach ($billingDetails as $field) {
- $this->assertElementContainsText("xpath=//div[@class='crm-group billing_name_address-group']//div[@class='crm-section no-label billing_address-section']", $field);
- }
-
- $this->click("_qf_Confirm_next-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->waitForElementPresent("xpath=//div[@class='crm-group billing_name_address-group']//div[@class='crm-section no-label billing_name-section']");
- $this->assertElementContainsText("xpath=//div[@class='crm-group billing_name_address-group']//div[@class='crm-section no-label billing_name-section']", $firstName . "billing");
- $this->assertElementContainsText("xpath=//div[@class='crm-group billing_name_address-group']//div[@class='crm-section no-label billing_name-section']", $lastName . "billing");
-
- //login to check contribution
-
- // Log in using webtestLogin() method
- $this->webtestLogin();
-
- //Find Contribution
- $this->openCiviPage("contribute/search", "reset=1", "contribution_date_low");
- $this->type("sort_name", "$lastName $firstName");
- $this->click("xpath=//tr/td[1]/label[contains(text(), 'Contribution is a Test?')]/../../td[2]/label[contains(text(), 'Yes')]/preceding-sibling::input[1]");
- $this->clickLink("_qf_Search_refresh", "xpath=//table[@class='selector row-highlight']/tbody/tr[1]/td[10]/span//a[text()='View']", FALSE);
- $this->clickLink("xpath=//table[@class='selector row-highlight']/tbody/tr[1]/td[10]/span//a[text()='View']", "_qf_ContributionView_cancel-bottom", FALSE);
-
- //View Contribution Record and verify data
- $expected = array(
- 'From' => "{$firstName} {$lastName}",
- 'Financial Type' => 'Donation',
- 'Total Amount' => '100.00',
- 'Contribution Status' => 'Completed',
- );
- $this->webtestVerifyTabularData($expected);
- //View Soft Credit record of type 'Honor of'
- $this->waitForTextPresent($honorDisplayName);
- $this->waitForTextPresent('100.00 (In Honor of)');
-
- // Check for Honoree contact created
- $this->click("css=input#sort_name_navigation");
- $this->type("css=input#sort_name_navigation", $honorSortName);
- $this->typeKeys("css=input#sort_name_navigation", $honorSortName);
-
- // wait for result list
- $this->waitForElementPresent("css=ul.ui-autocomplete li");
-
- // visit contact summary page
- $this->click("css=ul.ui-autocomplete li");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Is contact present?
- $this->assertTrue($this->isTextPresent("$honorDisplayName"), "Honoree contact not found.");
-
- // CRM-16064 - Contributions pricesets charge $1 more than selected
- $contributionAmt = number_format($rand, 2);
- $label = "Label $hash";
- $this->_verifyContributionAmt($pageId, $contributionAmt, $label);
-
- }
-
- public function testOnlineContributionWithZeroAmount() {
- $this->webtestLogin();
-
- // Use default payment processor
- $processorName = 'Test Processor';
- $processorType = 'Dummy';
- $pageTitle = substr(sha1(rand()), 0, 7);
- $rand = 2 * rand(10, 50);
- $hash = substr(sha1(rand()), 0, 7);
- $amountSection = TRUE;
- $payLater = FALSE;
- $onBehalf = FALSE;
- $pledges = FALSE;
- $recurring = FALSE;
- $memberships = FALSE;
- $friend = FALSE;
- $profilePreId = NULL;
- $profilePostId = NULL;
- $premiums = FALSE;
- $widget = FALSE;
- $pcp = FALSE;
- $memPriceSetId = NULL;
-
- // create a new online contribution page
- // create contribution page with randomized title and default params
- $pageId = $this->webtestAddContributionPage($hash,
- $rand,
- $pageTitle,
- array($processorName => $processorType),
- $amountSection,
- $payLater,
- $onBehalf,
- $pledges,
- $recurring,
- $memberships,
- $memPriceSetId,
- $friend,
- $profilePreId,
- $profilePostId,
- $premiums,
- $widget,
- $pcp
- );
-
- $this->openCiviPage("admin/contribute/amount", "reset=1&action=update&id=$pageId", '_qf_Amount_cancel-bottom');
- $this->type('label_1', "Label $hash");
- $this->type('value_1', 0);
- $this->clickLink('_qf_Amount_upload_done-top');
-
- //Contribution using Contribution Options
- $this->_doContributionAndVerifyData($pageId);
-
- //add priceset
- $this->openCiviPage("admin/price", "reset=1&action=add", '_qf_Set_next-bottom');
- $this->type('title', "Test Priceset $rand");
- $this->check('extends_2');
- $this->select("financial_type_id", "label=Donation");
- $this->clickLink('_qf_Set_next-bottom', '_qf_Field_next-bottom', FALSE);
- $sid = $this->urlArg('sid');
- //add field
- $this->type('label', "Testfield");
- $this->select('html_type', "value=Radio");
- $this->type('option_label_1', 'test Label');
- $this->type('option_amount_1', 0.00);
- $this->clickLink('_qf_Field_next_new-bottom', '_qf_Field_next-bottom', FALSE);
- $this->openCiviPage("admin/contribute/amount", "reset=1&action=update&id=$pageId", '_qf_Amount_cancel-bottom');
- $this->select('price_set_id', "value=$sid");
- $this->clickLink('_qf_Amount_upload_done-bottom', FALSE);
-
- //Contribution using priceset
- $this->_doContributionAndVerifyData($pageId, TRUE);
- }
-
- /**
- * @param int $pageId
- * @param bool $priceSet
- */
- public function _doContributionAndVerifyData($pageId, $priceSet = FALSE) {
- //logout
- $this->webtestLogout();
- $amountLabel = 'Total Amount';
- $amountValue = '0.00';
- //Open Live Contribution Page
- $this->openCiviPage("contribute/transact", "reset=1&id=$pageId&action=preview", "_qf_Main_upload-bottom");
-
- $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
- $lastName = 'An' . substr(sha1(rand()), 0, 7);
- $email = $firstName . "@example.com";
- $this->type("email-5", $email);
-
- if ($priceSet) {
- $this->click("xpath=//div[@id='priceset']/div/div[2]/div/span/input");
- $amountLabel = 'Contribution Amount';
- $amountValue = 'Contribution Total: $ 0.00';
- }
-
- //Credit Card Info
- $this->select("credit_card_type", "value=Visa");
- $this->type("credit_card_number", "4111111111111111");
- $this->type("cvv2", "000");
- $this->select("credit_card_exp_date[M]", "value=1");
- $this->select("credit_card_exp_date[Y]", "value=2020");
-
- //Billing Info
- $this->type("billing_first_name", $firstName);
- $this->type("billing_last_name", $lastName);
- $this->type("billing_street_address-5", "15 Main St.");
- $this->type(" billing_city-5", "San Jose");
- $this->select("billing_country_id-5", "value=1228");
- $this->select("billing_state_province_id-5", "value=1004");
- $this->type("billing_postal_code-5", "94129");
- $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
-
- $this->clickLink("_qf_Confirm_next-bottom", NULL);
-
- //login to check contribution
-
- // Log in using webtestLogin() method
- $this->webtestLogin();
-
- //Find Contribution
- $this->openCiviPage("contribute/search", "reset=1", "contribution_date_low");
- $this->type("sort_name", "$email");
- $this->click("xpath=//tr/td[1]/label[contains(text(), 'Contribution is a Test?')]/../../td[2]/label[contains(text(), 'Yes')]/preceding-sibling::input[1]");
- $this->waitForAjaxContent();
- $this->click("xpath=//div[@class='crm-accordion-wrapper crm-contribution_search_form-accordion ']/div[2]/table/tbody/tr[8]/td[1]/table/tbody/tr[3]/td[2]/label[1]");
- $this->clickLink("_qf_Search_refresh", "xpath=//table[@class='selector row-highlight']/tbody/tr[1]/td[10]/span//a[text()='View']", FALSE);
- $this->clickLink("xpath=//table[@class='selector row-highlight']/tbody/tr[1]/td[10]/span//a[text()='View']", "_qf_ContributionView_cancel-bottom", FALSE);
-
- //View Contribution Record and verify data
- $expected = array(
- 'From' => "{$firstName} {$lastName}",
- 'Financial Type' => 'Donation',
- $amountLabel => $amountValue,
- 'Contribution Status' => 'Completed',
- );
- $this->webtestVerifyTabularData($expected);
- }
-
- public function _verifyContributionAmt($pageId, $contributionAmt, $label) {
- // logout
- $this->webtestLogout();
-
- //Open Live Contribution Page
- $this->openCiviPage("contribute/transact", "reset=1&id=$pageId&action=preview", "_qf_Main_upload-bottom");
- $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
- $lastName = 'An' . substr(sha1(rand()), 0, 7);
- $this->type("email-5", $firstName . "@example.com");
-
- $this->type("first_name", $firstName);
- $this->type("last_name", $lastName);
- $this->check("xpath=//div[@id='priceset']/div[contains(@class, 'contribution_amount-section')]//div[contains(@class, 'contribution_amount-row1')]/span/input");
- $streetAddress = "100 Main Street";
- $this->type("street_address-1", $streetAddress);
- $this->type("city-1", "San Francisco");
- $this->type("postal_code-1", "94117");
- $this->select("country-1", "value=1228");
- $this->select("state_province-1", "value=1001");
-
- //Credit Card Info
- $this->select("credit_card_type", "value=Visa");
- $this->type("credit_card_number", "4111111111111111");
- $this->type("cvv2", "000");
- $this->select("credit_card_exp_date[M]", "value=1");
- $this->select("credit_card_exp_date[Y]", "value=2020");
-
- //Billing Info
- $this->type("billing_first_name", $firstName . "billing");
- $this->type("billing_last_name", $lastName . "billing");
- $this->type("billing_street_address-5", "15 Main St.");
- $this->type(" billing_city-5", "San Jose");
- $this->select("billing_country_id-5", "value=1228");
- $this->select("billing_state_province_id-5", "value=1004");
- $this->type("billing_postal_code-5", "94129");
- $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
-
- $this->assertElementContainsText("xpath=//div[contains(@class, 'amount_display-group')]//div[@class='display-block']/strong", "$ $contributionAmt - $label", "Contribution amount does not match");
- $this->clickLink("_qf_Confirm_next-bottom");
- $this->assertElementContainsText("xpath=//div[contains(@class, 'amount_display-group')]//div[@class='display-block']/strong", "$ $contributionAmt - $label", "Contribution amount does not match");
- // Log in using webtestLogin() method
- $this->webtestLogin();
- $this->openCiviPage("contribute/search", "reset=1", "contribution_date_low");
-
- $this->type("sort_name", "$lastName $firstName");
- $this->click("xpath=//tr/td[1]/label[contains(text(), 'Contribution is a Test?')]/../../td[2]/label[contains(text(), 'Yes')]/preceding-sibling::input[1]");
- $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='contributionSearch']//table[@class='selector row-highlight']//tbody/tr[1]/td[10]/span/a[text()='View']");
- $this->clickLink("xpath=//div[@id='contributionSearch']//table[@class='selector row-highlight']//tbody/tr[1]/td[10]/span/a[text()='View']", "_qf_ContributionView_cancel-bottom", FALSE);
-
- //View Contribution Record and verify data
- $expected = array(
- 'From' => "{$firstName} {$lastName}",
- 'Financial Type' => 'Donation',
- 'Total Amount' => $contributionAmt,
- 'Contribution Status' => 'Completed',
- );
- $this->webtestVerifyTabularData($expected);
- }
-
- public function testOnlineContributionWithPremium() {
- //CRM-16713: Contribution search by premiums on find contribution form.
- $this->webtestLogin();
-
- // Use default payment processor
- $processorName = 'Test Processor';
- $processorType = 'Dummy';
- $pageTitle = substr(sha1(rand()), 0, 7);
- $rand = 2 * rand(10, 50);
- $hash = substr(sha1(rand()), 0, 7);
- $amountSection = TRUE;
- $payLater = FALSE;
- $onBehalf = FALSE;
- $pledges = FALSE;
- $recurring = FALSE;
- $memberships = FALSE;
- $friend = TRUE;
- $profilePreId = 1;
- $profilePostId = NULL;
- $premiums = TRUE;
- $widget = FALSE;
- $pcp = FALSE;
- $memPriceSetId = NULL;
-
- // create a new online contribution page
- // create contribution page with randomized title and default params
- $pageId = $this->webtestAddContributionPage($hash,
- $rand,
- $pageTitle,
- array($processorName => $processorType),
- $amountSection,
- $payLater,
- $onBehalf,
- $pledges,
- $recurring,
- $memberships,
- $memPriceSetId,
- $friend,
- $profilePreId,
- $profilePostId,
- $premiums,
- $widget,
- $pcp
- );
-
- //logout
- $this->webtestLogout();
-
- //Open Live Contribution Page
- $this->openCiviPage("contribute/transact", "reset=1&id=$pageId&action=preview", "_qf_Main_upload-bottom");
-
- $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
- $lastName = 'An' . substr(sha1(rand()), 0, 7);
-
- $this->type("email-5", $firstName . "@example.com");
-
- $this->waitForAjaxContent();
- $this->click("xpath=//div[@id='premiums-listings']/div[2]/div[1]");
- $this->waitForAjaxContent();
- $this->select("xpath=//div[@id='premiums']/fieldset/div[@id='premiums-listings']/div[2]/div[2]/div[2]/div[4]/p/select", "value=Black");
-
- $this->type("first_name", $firstName);
- $this->type("last_name", $lastName);
-
- $this->click("xpath=//div[@class='crm-section other_amount-section']//div[2]/input");
- $this->type("xpath=//div[@class='crm-section other_amount-section']//div[2]/input", 100);
-
- $streetAddress = "100 Main Street";
- $this->type("street_address-1", $streetAddress);
- $this->type("city-1", "San Francisco");
- $this->type("postal_code-1", "94117");
- $this->select("country-1", "value=1228");
- $this->select("state_province-1", "value=1001");
-
- //Credit Card Info
- $this->select("credit_card_type", "value=Visa");
- $this->type("credit_card_number", "4111111111111111");
- $this->type("cvv2", "000");
- $this->select("credit_card_exp_date[M]", "value=1");
- $this->select("credit_card_exp_date[Y]", "value=2020");
-
- //Billing Info
- $this->type("billing_first_name", $firstName . "billing");
- $this->type("billing_last_name", $lastName . "billing");
- $this->type("billing_street_address-5", "15 Main St.");
- $this->type(" billing_city-5", "San Jose");
- $this->select("billing_country_id-5", "value=1228");
- $this->select("billing_state_province_id-5", "value=1004");
- $this->type("billing_postal_code-5", "94129");
- $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
-
- $this->click("_qf_Confirm_next-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Log in using webtestLogin() method
- $this->webtestLogin();
-
- //Find Contribution
- $this->openCiviPage("contribute/search", "reset=1", "contribution_date_low");
- $this->click("xpath=//tr/td[1]/label[contains(text(), 'Contribution is a Test?')]/../../td[2]/label[contains(text(), 'Yes')]/preceding-sibling::input[1]");
- $this->type("sort_name", "$lastName $firstName");
- $this->multiselect2('contribution_product_id', array('Coffee Mug'));
- $this->click("_qf_Search_refresh");
- $this->waitForAjaxContent();
- $this->waitForElementPresent("xpath=//table[@class='selector row-highlight']/tbody//tr/td[10]/span//a[text()='View']");
- $this->click("xpath=//table[@class='selector row-highlight']/tbody//tr/td[2]/a[text()='{$lastName}, {$firstName}']/../../td[10]/span//a[text()='View']");
- $this->waitForElementPresent("xpath=//button//span[contains(text(),'Done')]");
-
- //View Contribution Record and verify data
- $expected = array(
- 'From' => "{$firstName} {$lastName}",
- 'Financial Type' => 'Donation',
- 'Total Amount' => '100.00',
- 'Contribution Status' => 'Completed',
- 'Premium' => 'Coffee Mug',
- );
- $this->webtestVerifyTabularData($expected);
- }
-
- /**
- * CRM-19263 - Test online pay now functionality
- */
- public function testOnlineContributionWithPayNowLink() {
- $this->webtestLogin();
- $pageId = 1;
- $this->openCiviPage("admin/contribute/amount", "reset=1&action=update&id=$pageId", 'is_pay_later');
- $this->check('is_pay_later');
- $this->type('pay_later_text', "I will send payment by check");
- $this->fillRichTextField('pay_later_receipt', "I will send payment by check");
- $this->clickLink("_qf_Amount_upload_done-bottom");
-
- //add financial type of account type expense
- $financialType = 'Donation';
- $setTitle = 'Conference Fees - ' . substr(sha1(rand()), 0, 7);
- $usedFor = 'Contribution';
- $setHelp = 'Select your conference options.';
- $this->_testAddSet($setTitle, $usedFor, $setHelp, $financialType);
- $sid = $this->urlArg('sid');
-
- $validateStrings = array();
- $fields = array(
- 'Full Conference' => 'Text',
- 'Meal Choice' => 'Select',
- 'Pre-conference Meetup?' => 'Radio',
- 'Evening Sessions' => 'CheckBox',
- );
-
- $this->_testAddPriceFields($fields, $validateStrings, $financialType);
-
- //Add profile Details
- $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
- $lastName = 'An' . substr(sha1(rand()), 0, 7);
- $name = $this->_testCreateUser($firstName, $lastName);
- $this->openCiviPage("admin/synchUser", "reset=1", NULL);
- $this->clickLink("_qf_CMSUser_next-bottom");
-
- $this->openCiviPage("admin/setting/preferences/contribute", "reset=1", "deferred_revenue_enabled");
- $this->check('deferred_revenue_enabled');
- $this->waitForElementPresent('default_invoice_page');
- $this->select('default_invoice_page', "value=$pageId");
- $this->clickLink("_qf_Contribute_next-bottom");
-
- $this->webtestLogin($name, "Test12345");
- $this->_testContributeWithPayLater($pageId, $firstName);
-
- $this->_testContributeWithPayNow($firstName);
-
- $this->openCiviPage("user", "reset=1");
- $this->assertFalse($this->isTextPresent("Pay Now"));
-
- $this->webtestLogin();
-
- $this->openCiviPage("admin/contribute/amount", "reset=1&action=update&id=$pageId", 'price_set_id');
- $this->select('price_set_id', "value=9");
- $this->clickLink("_qf_Amount_upload_done-bottom");
-
- $this->webtestLogin($name, "Test12345");
-
- $this->_testContributeWithPayLater($pageId, $firstName, TRUE);
-
- $this->_testContributeWithPayNow($firstName, TRUE);
-
- $this->openCiviPage("user", "reset=1");
- $this->assertFalse($this->isTextPresent("Pay Now"));
-
- // Type search name in autocomplete.
- $this->webtestLogin();
- $this->openCiviPage("civicrm/dashboard", "reset=1", 'sort_name_navigation');
- $this->click('sort_name_navigation');
- $this->type('css=input#sort_name_navigation', $firstName);
- $this->typeKeys('css=input#sort_name_navigation', $firstName);
- $this->waitForElementPresent("css=ul.ui-autocomplete li");
- $this->clickLink("css=ul.ui-autocomplete li", 'tab_contribute');
-
- $this->click('css=li#tab_contribute a');
- $this->waitForElementPresent('link=Record Contribution (Check, Cash, EFT ...)');
-
- $amountValues = array(
- 1 => '$ 588.50',
- 2 => '$ 98.50',
- );
- foreach ($amountValues as $row => $amount) {
- $this->clickLink("xpath=//table[@class='selector row-highlight']/tbody/tr[{$row}]/td[8]/span//a[text()='View']", "_qf_ContributionView_cancel-bottom", FALSE);
-
- // View Contribution Record and test for expected values
- $expected = array(
- 'From' => "{$firstName} {$lastName}",
- 'Financial Type' => $financialType,
- 'Fee Amount' => '$ 1.50',
- 'Net Amount' => $amount,
- 'Received Into' => 'Payment Processor Account',
- 'Payment Method' => 'Credit Card (Test Processor)',
- 'Contribution Status' => 'Completed',
- );
- $this->webtestVerifyTabularData($expected);
-
- $this->clickAjaxLink("xpath=//span[text()='Done']");
- }
- }
-
- /**
- * Contribute using pay now link
- * @param string $firstName
- * @param bool $priceSet
- */
- public function _testContributeWithPayNow($firstName, $priceSet = FALSE) {
- //user dashboard
- $this->openCiviPage("user", "reset=1");
- $this->waitForElementPresent("xpath=//a/span[contains(text(), 'Pay Now')]");
- $this->clickLink("xpath=//a/span[contains(text(), 'Pay Now')]");
-
- if (empty($priceSet)) {
- $this->waitForElementPresent("total_amount");
- $this->assertTrue($this->isElementPresent("xpath=//input[@id='total_amount'][@readonly=1][@value='100.00']"));
- }
- else {
- $this->assertElementContainsText("xpath=//div[@class='header-dark']", "Contribution Information");
- $this->assertElementContainsText("xpath=//div[@class='crm-section no-label total_amount-section']", "Contribution Total: $ 590.00");
- }
-
- $this->assertFalse($this->isElementPresent("priceset"));
- $this->assertFalse($this->isElementPresent("xpath=//div[@class='crm-public-form-item crm-section is_pledge-section']"));
- $this->assertFalse($this->isElementPresent("xpath=//div[@class='crm-public-form-item crm-section premium_block-section']"));
- $this->assertFalse($this->isElementPresent("xpath=//div[@class='crm-public-form-item crm-group custom_pre_profile-group']"));
- $this->assertFalse($this->isElementPresent("xpath=//input[@id=email-5]"));
- $this->assertFalse($this->isElementPresent("xpath=//input[@name='payment_processor_id'][@value=0]"));
- $this->click("xpath=//input[@name='payment_processor_id'][@value=1]");
- $this->waitForAjaxContent();
-
- $this->webtestAddCreditCardDetails();
- $this->webtestAddBillingDetails();
- $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
-
- $this->clickLink("_qf_Confirm_next-bottom");
- $firstName = strtolower($firstName);
- $emailText = "An email receipt has also been sent to {$firstName}@example.com";
- $this->waitForTextPresent($emailText);
-
- }
-
- /**
- * Contribute with pay later
- *
- * @param int $pageId
- * @param string $firstName
- * @param bool $priceSet
- */
- public function _testContributeWithPayLater($pageId, $firstName, $priceSet = FALSE) {
- $this->openCiviPage("contribute/transact", "reset=1&action=preview&id=$pageId", NULL);
- $this->waitForElementPresent("email-5");
-
- $this->type("email-5", $firstName . "@example.com");
-
- if (empty($priceSet)) {
- $this->click("xpath=//div[@class='crm-section other_amount-section']//div[2]/input");
- $this->type("xpath=//div[@class='crm-section other_amount-section']//div[2]/input", 100);
- $this->typeKeys("xpath=//div[@class='crm-section other_amount-section']//div[2]/input", 100);
- }
- else {
- $this->type("xpath=//input[@class='four crm-form-text required']", "1");
- $this->click("xpath=//input[@class='crm-form-radio']");
- $this->click("xpath=//input[@class='crm-form-checkbox']");
- }
-
- $this->waitForTextPresent("Payment Method");
- $payLaterText = "I will send payment by check";
- $this->click("xpath=//label[text() = '{$payLaterText}']/preceding-sibling::input[1]");
-
- $this->waitForAjaxContent();
- $this->clickLink("_qf_Main_upload-bottom");
- $this->waitForElementPresent("xpath=//div[@class='bold pay_later_receipt-section']");
-
- $payLaterInstructionsText = "I will send payment by check";
- $this->assertElementContainsText("xpath=//div[@class='bold pay_later_receipt-section']/p", $payLaterInstructionsText);
- $this->clickLink("_qf_Confirm_next-bottom");
-
- $this->waitForElementPresent("xpath=//div[@class='help']/div/p");
- $this->assertElementContainsText("xpath=//div[@class='help']/div/p", $payLaterInstructionsText);
- }
-
- /**
- * Create test user
- *
- * @param string $firstName
- * @param string $lastName
- *
- * @return string
- */
- public function _testCreateUser($firstName, $lastName) {
- $this->open($this->sboxPath . "admin/people/create");
-
- $this->waitForElementPresent("edit-submit");
-
- $name = "TestUser" . substr(sha1(rand()), 0, 4);
- $this->type("edit-name", $name);
-
- $emailId = substr(sha1(rand()), 0, 7) . '@web.com';
- $this->type("edit-mail", $emailId);
- $this->type("edit-pass-pass1", "Test12345");
- $this->type("edit-pass-pass2", "Test12345");
-
- $this->type("first_name", $firstName);
- $this->type("last_name", $lastName);
-
- //Address Details
- $this->type("street_address-1", "902C El Camino Way SW");
- $this->type("city-1", "Dumfries");
- $this->type("postal_code-1", "1234");
- $this->select("state_province-1", "value=1019");
-
- $this->click("edit-submit");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- return $name;
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Contribute_OnlineMultiplePaymentProcessorTest
- */
-class WebTest_Contribute_OnlineMultiplePaymentProcessorTest extends CiviSeleniumTestCase {
- protected function setUp() {
- parent::setUp();
- }
-
- public function testOnlineMultpiplePaymentProcessor() {
-
- // Log in using webtestLogin() method
- $this->webtestLogin();
-
- $proProcessorName = "Pro " . substr(sha1(rand()), 0, 7);
- $standardProcessorName = "Standard " . substr(sha1(rand()), 0, 7);
- $donationPageTitle = "Donation" . substr(sha1(rand()), 0, 7);
- $pageId = $this->webtestAddContributionPage($hash = NULL,
- $rand = NULL,
- $pageTitle = $donationPageTitle,
- $processor = array($proProcessorName => 'Dummy', $standardProcessorName => 'PayPal_Standard'),
- $amountSection = TRUE,
- $payLater = TRUE,
- $onBehalf = FALSE,
- $pledges = TRUE,
- $recurring = FALSE,
- $membershipTypes = FALSE,
- $memPriceSetId = NULL,
- $friend = FALSE,
- $profilePreId = 1,
- $profilePostId = NULL,
- $premiums = FALSE,
- $widget = FALSE,
- $pcp = FALSE,
- $isAddPaymentProcessor = TRUE,
- $isPcpApprovalNeeded = FALSE,
- $isSeparatePayment = FALSE,
- $honoreeSection = FALSE,
- $allowOtherAmmount = TRUE
- );
-
- $this->openCiviPage("contribute/transact", "reset=1&action=preview&id=$pageId", NULL);
- $this->waitForTextPresent($donationPageTitle);
-
- $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
- $lastName = 'An' . substr(sha1(rand()), 0, 7);
-
- $this->type("email-5", $firstName . "@example.com");
-
- $this->type("first_name", $firstName);
- $this->type("last_name", $lastName);
-
- $this->type("xpath=//div[@class='crm-section other_amount-section']//div/input", 100);
-
- $streetAddress = "100 Main Street";
- $this->type("street_address-1", $streetAddress);
- $this->type("city-1", "San Francisco");
- $this->type("postal_code-1", "94117");
- $this->select("country-1", "value=1228");
- $this->waitForElementPresent("state_province-1");
- $this->select("state_province-1", "value=1001");
-
- $this->assertTrue($this->isTextPresent("Payment Method"));
- $this->waitForElementPresent("xpath=//label[text() = '{$proProcessorName}']/preceding-sibling::input[1]");
- $this->click("xpath=//label[text() = '{$proProcessorName}']/preceding-sibling::input[1]");
-
- $this->waitForElementPresent("credit_card_type");
-
- //Credit Card Info
- $this->select("credit_card_type", "value=Visa");
- $this->type("credit_card_number", "4111111111111111");
- $this->type("cvv2", "000");
- $this->select("credit_card_exp_date[M]", "value=1");
- $this->select("credit_card_exp_date[Y]", "value=2020");
-
- //Billing Info
- $this->type("billing_first_name", $firstName . "billing");
- $this->type("billing_last_name", $lastName . "billing");
- $this->type("billing_street_address-5", "15 Main St.");
- $this->type(" billing_city-5", "San Jose");
- $this->select("billing_country_id-5", "value=1228");
- $this->select("billing_state_province_id-5", "value=1004");
- $this->type("billing_postal_code-5", "94129");
- $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
-
- $this->click("_qf_Confirm_next-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- //login to check contribution
-
- }
-
- public function testOnlineMultiplePaymentProcessorWithPayLater() {
-
- // Log in using webtestLogin() method
- $this->webtestLogin();
-
- $proProcessorName = "Pro " . substr(sha1(rand()), 0, 7);
- $standardProcessorName = "Standard " . substr(sha1(rand()), 0, 7);
- $donationPageTitle = "Donation" . substr(sha1(rand()), 0, 7);
- $hash = substr(sha1(rand()), 0, 7);
- $pageId = $this->webtestAddContributionPage($hash,
- $rand = NULL,
- $pageTitle = $donationPageTitle,
- $processor = array($proProcessorName => 'Dummy'),
- $amountSection = TRUE,
- $payLater = TRUE,
- $onBehalf = FALSE,
- $pledges = TRUE,
- $recurring = FALSE,
- $membershipTypes = FALSE,
- $memPriceSetId = NULL,
- $friend = FALSE,
- $profilePreId = 1,
- $profilePostId = NULL,
- $premiums = FALSE,
- $widget = FALSE,
- $pcp = FALSE,
- $isAddPaymentProcessor = TRUE,
- $isPcpApprovalNeeded = FALSE,
- $isSeparatePayment = FALSE,
- $honoreeSection = FALSE,
- $allowOtherAmount = TRUE
- );
-
- $this->openCiviPage("contribute/transact", "reset=1&action=preview&id=$pageId", NULL);
- $this->waitForTextPresent($donationPageTitle);
-
- $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
- $lastName = 'An' . substr(sha1(rand()), 0, 7);
-
- $this->type("email-5", $firstName . "@example.com");
-
- $this->type("first_name", $firstName);
- $this->type("last_name", $lastName);
-
- $this->type("xpath=//div[@class='crm-section other_amount-section']//div/input", 100);
-
- $streetAddress = "100 Main Street";
- $this->type("street_address-1", $streetAddress);
- $this->type("city-1", "San Francisco");
- $this->type("postal_code-1", "94117");
- $this->select("country-1", "value=1228");
- $this->waitForElementPresent("state_province-1");
- $this->select("state_province-1", "value=1001");
-
- $this->assertTrue($this->isTextPresent("Payment Method"));
- $payLaterText = "Pay later label $hash";
- $xpath = "xpath=//label[text() = '{$payLaterText}']/preceding-sibling::input[1]";
- $this->click($xpath);
-
- $this->waitForAjaxContent();
- $this->click("_qf_Main_upload-bottom");
- $this->waitForElementPresent("xpath=//div[@class='bold pay_later_receipt-section']");
-
- $payLaterInstructionsText = "Pay later instructions $hash";
- $this->assertElementContainsText("xpath=//div[@class='bold pay_later_receipt-section']/p", $payLaterInstructionsText);
- $this->click("_qf_Confirm_next-bottom");
-
- $this->waitForElementPresent("xpath=//div[@class='help']/div/p");
- $this->assertElementContainsText("xpath=//div[@class='help']/div/p", $payLaterInstructionsText);
-
- //login to check contribution
- $this->openCiviPage("contribute/search", "reset=1", 'contribution_date_low');
- $this->waitForAjaxContent();
- $this->type('sort_name', "$lastName $firstName");
- $this->check('contribution_test');
- $this->click('_qf_Search_refresh');
- $this->waitForElementPresent("xpath=//table[@class='selector row-highlight']/tbody/tr[1]/td[10]/span//a[text()='View']");
- $this->click("xpath=//table[@class='selector row-highlight']/tbody/tr[1]/td[10]/span//a[text()='View']");
- $this->waitForElementPresent("_qf_ContributionView_cancel-bottom");
- $expected = array(
- 'From' => "{$firstName} {$lastName}",
- 'Financial Type' => 'Donation',
- 'Contribution Status' => 'Pending : Pay Later',
- );
- $this->webtestVerifyTabularData($expected);
- $this->click('_qf_ContributionView_cancel-bottom');
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Contribute_OnlineRecurContributionTest
- */
-class WebTest_Contribute_OnlineRecurContributionTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testOnlineRecurContribution() {
- require_once 'ContributionPageAddTest.php';
-
- // a random 7-char string and an even number to make this pass unique
- $hash = substr(sha1(rand()), 0, 7);
- $rand = $contributionAmount = 2 * rand(2, 50);
- $pageTitle = 'Donate Online Recurring ' . $hash;
- $processorType = 'AuthNet';
- $processorName = "Webtest AuthNet " . substr(sha1(rand()), 0, 7);
- $amountSection = TRUE;
- $payLater = FALSE;
- $onBehalf = FALSE;
- $pledges = FALSE;
- $recurring = TRUE;
- $memberships = FALSE;
- $memPriceSetId = NULL;
- $friend = TRUE;
- $profilePreId = NULL;
- $profilePostId = NULL;
- $premiums = FALSE;
- $widget = FALSE;
- $pcp = FALSE;
-
- // open browser, login
- $this->webtestLogin('admin');
-
- // create a new online contribution page with recurring enabled (using a newly created AuthNet processor)
- // create contribution page with randomized title and default params
- $pageId = $this->webtestAddContributionPage($hash,
- $rand,
- $pageTitle,
- array($processorName => $processorType),
- $amountSection,
- $payLater,
- $onBehalf,
- $pledges,
- $recurring,
- $memberships,
- $memPriceSetId,
- $friend,
- $profilePreId,
- $profilePostId,
- $premiums,
- $widget,
- $pcp
- );
-
- //now do the test online recurring contribution as an anonymous user.
- $anonymous = TRUE;
- $firstName = 'Jane' . substr(sha1(rand()), 0, 7);
- $middleName = 'Middle';
- $lastName = 'Recuron_' . substr(sha1(rand()), 0, 7);
- $email = $firstName . '@example.com';
- $contactName = "$firstName $lastName";
-
- // logout
- $this->webtestLogout();
-
- $this->openCiviPage("contribute/transact", "reset=1&action=preview&id=$pageId", "_qf_Main_upload-bottom");
-
- // helper AddContributionPage sets Minimum Other Amout = $rand / 2 so must contribute more than that
- $this->click("xpath=//div[@class='crm-section other_amount-section']//div[2]/input");
- $this->type("xpath=//div[@class='crm-section other_amount-section']//div[2]/input", $contributionAmount);
-
- // recurring contribution - each month for 12 months
- $this->click("is_recur");
- $this->type("frequency_interval", "1");
- $this->type("installments", "12");
-
- $this->type("email-5", $email);
-
- $this->webtestAddCreditCardDetails();
- $this->webtestAddBillingDetails($firstName, $middleName, $lastName);
- $this->click("_qf_Main_upload-bottom");
-
- // Confirmation page
- $this->waitForElementPresent("_qf_Confirm_next-bottom");
- $text = 'I want to contribute this amount every month for 12 installments.';
- $this->assertTrue($this->isTextPresent($text), 'Missing recurring contribution text (confirmation): ' . $text);
- $text = $rand;
- $this->assertTrue($this->isTextPresent($contributionAmount), 'Missing contribution amount (confirmation): ' . $contributionAmount);
- $this->click("_qf_Confirm_next-bottom");
-
- // Thank-you page
- $this->waitForElementPresent("thankyou_footer");
- $this->assertTrue($this->isElementPresent('tell-a-friend'), 'Missing tell-a-friend div');
- $text = 'This recurring contribution will be automatically processed every month for a total 12 installments';
- $this->assertTrue($this->isTextPresent($text), 'Missing recurring contribution text (thank-you): ' . $text);
- $this->assertTrue($this->isTextPresent($contributionAmount), 'Missing contribution amount (thank-you): ' . $contributionAmount);
-
- // Log back in and verify that test contribution has been recorded
- $this->webtestLogin();
- $this->openCiviPage("contribute/search", "reset=1", "contribution_currency_type");
-
- $this->type("sort_name", "{$lastName}, {$firstName}");
- $this->click("contribution_test");
- $this->click("_qf_Search_refresh");
-
- $this->waitForElementPresent('css=#contributionSearch table tbody tr td a.action-item:first-child');
- $this->click('css=#contributionSearch table tbody tr td a.action-item:first-child');
- $this->waitForElementPresent("_qf_ContributionView_cancel-bottom");
-
- // View Recurring Contribution Record
- $verifyData = array(
- 'From' => "$contactName",
- 'Financial Type' => 'Donation (test)',
- 'Total Amount' => 'Installments: 12, Interval: 1 month(s)',
- 'Contribution Status' => 'Pending : Incomplete Transaction',
- 'Payment Method' => 'Credit Card',
- 'Online Contribution Page' => $pageTitle,
- );
- foreach ($verifyData as $label => $value) {
- $this->verifyText("xpath=//form[@id='ContributionView']//table/tbody/tr/td[text()='{$label}']/following-sibling::td",
- preg_quote($value)
- );
- }
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Contribute_PCPAddTest
- */
-class WebTest_Contribute_PCPAddTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testPCPAdd() {
- // open browser, login
- $this->webtestLogin();
-
- // set pcp supporter name and email
- $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
- $lastName = 'An' . substr(sha1(rand()), 0, 7);
- $middleName = 'Mid' . substr(sha1(rand()), 0, 7);
- $email = substr(sha1(rand()), 0, 7) . '@example.org';
-
- $this->openCiviPage("admin/domain", "action=update&reset=1", '_qf_Domain_cancel-bottom');
- $this->type('name', 'DefaultDomain');
- $this->type('email_name', $firstName);
- $this->type('email_address', $email);
-
- $this->click('_qf_Domain_next_view-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->assertTrue($this->isTextPresent("Domain information for 'DefaultDomain' has been saved."),
- "Status message didn't show up after saving!"
- );
-
- require_once 'ContributionPageAddTest.php';
-
- // a random 7-char string and an even number to make this pass unique
- $hash = substr(sha1(rand()), 0, 7);
- $rand = $contributionAmount = 2 * rand(2, 50);
- $pageTitle = 'PCP Contribution' . $hash;
- $amountSection = TRUE;
- $payLater = TRUE;
- $onBehalf = FALSE;
- $pledges = FALSE;
- $recurring = FALSE;
- $memberships = FALSE;
- $memPriceSetId = NULL;
- $friend = FALSE;
- $profilePreId = NULL;
- $profilePostId = NULL;
- $premiums = FALSE;
- $widget = FALSE;
- $pcp = TRUE;
- $isAprovalNeeded = TRUE;
-
- // create a new online contribution page with pcp enabled
- // create contribution page with randomized title and default params
- $pageId = $this->webtestAddContributionPage($hash,
- $rand,
- $pageTitle,
- array('Test Processor' => 'Dummy'),
- $amountSection,
- $payLater,
- $onBehalf,
- $pledges,
- $recurring,
- $memberships,
- $memPriceSetId,
- $friend,
- $profilePreId,
- $profilePostId,
- $premiums,
- $widget,
- $pcp,
- TRUE,
- $isAprovalNeeded
- );
-
- // logout
- $this->webtestLogout();
-
- $this->openCiviPage('contribute/transact', "reset=1&id=$pageId", "_qf_Main_upload-bottom");
-
- $this->click("xpath=//div[@class='crm-section other_amount-section']//div[2]/input");
- $this->type("xpath=//div[@class='crm-section other_amount-section']//div[2]/input", $contributionAmount);
- $this->typeKeys("xpath=//div[@class='crm-section other_amount-section']//div[2]/input", $contributionAmount);
- $this->type("email-5", $email);
- $this->click("xpath=//label[text()='Test Processor']");
- $this->waitForAjaxContent();
-
- $this->webtestAddCreditCardDetails();
- $this->webtestAddBillingDetails($firstName, $middleName, $lastName);
-
- $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
- $this->click("_qf_Confirm_next-bottom");
-
- $this->waitForElementPresent("thankyou_footer");
- $this->openCiviPage("contribute/campaign", "action=add&reset=1&pageId={$pageId}&component=contribute", "_qf_PCPAccount_next-bottom");
-
- $cmsUserName = 'CmsUser' . substr(sha1(rand()), 0, 7);
- $this->type("cms_name", $cmsUserName);
- $this->click("checkavailability");
- $this->type("first_name", $firstName);
- $this->type("last_name", $lastName);
- $this->type("email-Primary", $email);
- if ($this->isElementPresent("cms_pass")) {
- $pass = 'myBigPassword';
- $this->type("cms_pass", $pass);
-
- $this->type("cms_confirm_pass", $pass);
-
- }
- $this->clickLink("_qf_PCPAccount_next-bottom", "_qf_Campaign_upload-bottom");
-
- $pcpTitle = 'PCPTitle' . substr(sha1(rand()), 0, 7);
- $this->type("pcp_title", $pcpTitle);
- $this->type("pcp_intro_text", "Welcome Text $hash");
- $this->type("goal_amount", $contributionAmount);
- $this->clickLink("_qf_Campaign_upload-bottom", '_qf_Main_upload-bottom');
-
- $this->webtestLogin();
- $this->openCiviPage("admin/pcp", "reset=1", "_qf_PCP_refresh");
- $this->select('status_id', 'value=1');
- $this->clickLink("_qf_PCP_refresh", "_qf_PCP_refresh");
- $id = explode('id=', $this->getAttribute("xpath=//div[@id='option11_wrapper']/table[@id='option11']/tbody/tr/td/a[text()='$pcpTitle']@href"));
- $pcpId = trim($id[1]);
- $pcpUrl = "civicrm/contribute/pcp/info?reset=1&id=$pcpId";
- $this->clickLink("xpath=//td[@id=$pcpId]/span[1]/a[2]");
- // logout
- $this->webtestLogout();
-
- // Set pcp contributor name
- $donorFirstName = 'Donor' . substr(sha1(rand()), 0, 4);
- $donorLastName = 'Person' . substr(sha1(rand()), 0, 7);
- $middleName = 'Mid' . substr(sha1(rand()), 0, 7);
-
- $this->open($this->sboxPath . $pcpUrl);
-
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->openCiviPage("contribute/transact", "reset=1&id=$pageId&pcpId=$id[1]", "_qf_Main_upload-bottom");
- $this->click("xpath=//div[@class='crm-section other_amount-section']//div[2]/input");
- $this->type("xpath=//div[@class='crm-section other_amount-section']//div[2]/input", $contributionAmount);
- $this->typeKeys("xpath=//div[@class='crm-section other_amount-section']//div[2]/input", $contributionAmount);
- $this->type("email-5", $donorFirstName . "@example.com");
- $this->click("xpath=//label[text()='Test Processor']");
- $this->waitForAjaxContent();
-
- $this->webtestAddCreditCardDetails();
- $this->webtestAddBillingDetails($donorFirstName, $middleName, $donorLastName);
- $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
- $this->click("_qf_Confirm_next-bottom");
-
- $this->waitForElementPresent("thankyou_footer");
-
- //login to check contribution
- $this->webtestLogin();
-
- //Find Contribution
- $this->openCiviPage("contribute/search", "reset=1", "contribution_date_low");
- $this->waitForElementPresent('contribution_pcp_made_through_id');
- $this->multiselect2('contribution_pcp_made_through_id', array($pcpTitle));
-
- $this->clickLink("_qf_Search_refresh", "xpath=//table[@class='selector row-highlight']/tbody/tr[1]//td/span/a[1][text()='View']");
- $this->click("xpath=//table[@class='selector row-highlight']/tbody/tr[1]//td/span/a[1][text()='View']");
- $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']/button[3]/span[2]");
-
- // View Contribution Record and test for expected values
- $expected = array(
- 'From' => "{$donorFirstName} {$donorLastName}",
- 'Financial Type' => 'Donation',
- 'Total Amount' => $contributionAmount,
- 'Contribution Status' => 'Completed',
- );
- $this->webtestVerifyTabularData($expected);
-
- //Check for SoftCredit
- $softCreditor = "{$firstName} {$lastName}";
- $this->verifyText("xpath=//div['PCPView']/div[2]/table[@class='crm-info-panel']/tbody/tr[2]/td[2]/a", preg_quote($softCreditor));
-
- // Check PCP Summary Report
- $this->openCiviPage('report/instance/17', 'reset=1');
- $this->assertElementContainsText("PCP", $pcpTitle);
- $this->assertElementContainsText("PCP", "{$lastName}, {$firstName}");
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Contribute_StandaloneAddTest
- */
-class WebTest_Contribute_StandaloneAddTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testStandaloneContributeAdd() {
- $this->webtestLogin();
-
- // Create a contact to be used as soft creditor
- $softCreditFname = substr(sha1(rand()), 0, 7);
- $softCreditLname = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($softCreditFname, $softCreditLname, FALSE);
-
- // Add new Financial Account
- $orgName = 'Alberta ' . substr(sha1(rand()), 0, 7);
- $financialAccountTitle = 'Financial Account ' . substr(sha1(rand()), 0, 4);
- $financialAccountDescription = "{$financialAccountTitle} Description";
- $accountingCode = 1033;
- $financialAccountType = 'Liability';
- $taxDeductible = TRUE;
- $isActive = FALSE;
- $isTax = TRUE;
- $taxRate = 10.00;
- $isDefault = FALSE;
-
- //Add new organisation
- $this->webtestAddOrganization($orgName);
-
- $this->_testAddFinancialAccount($financialAccountTitle,
- $financialAccountDescription,
- $accountingCode,
- $orgName,
- $financialAccountType,
- $taxDeductible,
- $isActive,
- $isTax,
- $taxRate,
- $isDefault
- );
-
- //Add new Financial Type
- $financialType['name'] = 'Taxable FinancialType ' . substr(sha1(rand()), 0, 4);
- $financialType['is_deductible'] = TRUE;
- $financialType['is_reserved'] = FALSE;
- $this->addeditFinancialType($financialType);
-
- // Assign the created Financial Account $financialAccountTitle to $financialType
- $this->waitForElementPresent("xpath=id('ltype')");
- $this->click("xpath=id('ltype')/div/table/tbody/tr/td[1]/div[text()='$financialType[name]']/../../td[7]//span//a[text()='Accounts']");
- $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']//button//span[contains(text(), 'Assign Account')]");
- $this->click("xpath=//div[@class='ui-dialog-buttonset']//button//span[contains(text(), 'Assign Account')]");
- $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']/button/span[text()='Save']");
- $this->select('account_relationship', "label=Sales Tax Account is");
- $this->waitForAjaxContent();
- $this->select('financial_account_id', "label=" . $financialAccountTitle);
- $this->click("xpath=//div[@class='ui-dialog-buttonset']/button/span[text()='Save']");
- $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']//button//span[contains(text(), 'Assign Account')]");
-
- $this->openCiviPage("contribute/add", "reset=1&context=standalone", "_qf_Contribution_upload");
-
- // create new contact using dialog
- $contact = $this->createDialogContact();
-
- // select financial type
- $this->select("financial_type_id", "label=" . $financialType['name']);
-
- // fill in Received Date
- $this->webtestFillDate('receive_date');
-
- // source
- $this->type("source", "Mailer 1");
-
- // total amount
- $this->type("total_amount", "100");
-
- // select payment instrument type = Check and enter chk number
- $this->select("payment_instrument_id", "value=4");
- $this->waitForElementPresent("check_number");
- $this->type("check_number", "check #1041");
- $this->click("is_email_receipt");
- $this->assertTrue($this->isChecked("is_email_receipt"), 'Send Receipt checkbox should be checked.');
- $this->type("trxn_id", "P20901X1" . rand(100, 10000));
-
- // soft credit
- $this->webtestFillAutocomplete("{$softCreditLname}, {$softCreditFname}", 's2id_soft_credit_contact_id_1');
- $this->type("soft_credit_amount_1", "100");
-
- //Additional Detail section
- $this->click("AdditionalDetail");
- $this->waitForElementPresent("thankyou_date");
-
- $this->type("note", "This is a test note.");
- $this->type("invoice_id", time());
- $this->webtestFillDate('thankyou_date');
-
- //Premium section
- $this->click("Premium");
- $this->waitForElementPresent("fulfilled_date");
- $this->select("product_name[0]", "label=Coffee Mug ( MUG-101 )");
- $this->select("product_name[1]", "label=Black");
- $this->webtestFillDate('fulfilled_date');
-
- // Clicking save.
- $this->click("_qf_Contribution_upload");
- // Ask for confirmation to send a receipt to the contributor on 'is_email_reciept' check
- $this->assertTrue((bool) preg_match("/^Click OK to save this contribution record AND send a receipt to the contributor now./", $this->getConfirmation()));
- $this->chooseOkOnNextConfirmation();
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Is status message correct?
- $this->waitForText("crm-notification-container", "The contribution record has been saved.");
-
- // verify if Membership is created
- $this->waitForElementPresent("xpath=//form[@class='CRM_Contribute_Form_Search crm-search-form']//div[2]/table[@class='selector row-highlight']//tbody/tr[1]/td[8]/span//a[text()='View']");
-
- $contriID = $this->urlArg('id', $this->getAttribute("xpath=//table[@class='selector row-highlight']//tbody/tr[1]/td[8]/span//a[text()='Edit']@href"));
- $contactID = $this->urlArg('cid', $this->getAttribute("xpath=//table[@class='selector row-highlight']//tbody/tr[1]/td[8]/span//a[text()='Edit']@href"));
-
- //click through to the Membership view screen
- $this->click("xpath=//form[@class='CRM_Contribute_Form_Search crm-search-form']//div[2]/table[@class='selector row-highlight']//tbody/tr[1]/td[8]/span//a[text()='View']");
- $this->waitForElementPresent("_qf_ContributionView_cancel-bottom");
-
- $expected = array(
- 'Financial Type' => $financialType['name'],
- 'Total Amount' => '$ 110.00',
- 'Contribution Status' => 'Completed',
- 'Payment Method' => 'Check',
- 'Check Number' => 'check #1041',
- );
-
- foreach ($expected as $label => $value) {
- $this->assertElementContainsText("xpath=id('ContributionView')/div[2]/table[1]/tbody//tr/td[1][text()='$label']/../td[2]", $value);
- }
-
- // verify if soft credit was created successfully
- $expected = array(
- 'Soft Credit To' => "{$softCreditFname} {$softCreditLname}",
- 'Amount' => '100.00',
- );
-
- foreach ($expected as $value) {
- $this->assertElementContainsText("css=table.crm-soft-credit-listing", $value);
- }
-
- // go to first soft creditor contact view page
- $this->clickLink("css=table.crm-soft-credit-listing tbody tr td a");
-
- // go to contribution tab
- $this->waitForElementPresent("css=li#tab_contribute a");
- $this->click("css=li#tab_contribute a");
- $this->waitForElementPresent("link=Record Contribution (Check, Cash, EFT ...)");
- $this->assertElementContainsText("xpath=id('Search')/div[2]/table[2]/tbody/tr[2]/td[1]/a", $contact['display_name']);
- // verify soft credit details
- $expected = array(
- 4 => $financialType['name'],
- 2 => '100.00',
- 6 => 'Completed',
- );
- foreach ($expected as $value => $label) {
- $this->assertElementContainsText("xpath=id('Search')/div[2]/table[2]/tbody/tr[2]/td[$value]", $label);
- }
-
- // CRM-17418 fix: Now cancel the contribution
- $this->openCiviPage("contact/view/contribution", "reset=1&action=update&id=$contriID&cid=$contactID&context=contribution", "_qf_Contribution_upload");
- $this->select('contribution_status_id', 'label=Cancelled');
- $this->waitForElementPresent('cancel_reason');
- $this->click("_qf_Contribution_upload");
- // Is status message correct?
- $this->waitForText("crm-notification-container", "The contribution record has been saved.");
-
- // 1. On first completed contribution the contribution_amount = 100 and Tax Amount = 10
- // 2. After Cancellation contribution_amount = -100 and Tax Amount = -10
- // So the sum of all the 4 created financial item's amount would be 0
- $query = "SELECT SUM( amount ) FROM `civicrm_financial_item` WHERE entity_id = %1";
- $sum = CRM_Core_DAO::singleValueQuery($query, array(1 => array($contriID, 'Integer')));
- $this->assertEquals($sum, 0.00);
- }
-
- public function testfinancialTypeSearch() {
- $this->webtestLogin();
-
- $financialType = array(
- 'name' => 'Financial type' . substr(sha1(rand()), 0, 7),
- 'is_reserved' => FALSE,
- 'is_deductible' => FALSE,
- );
-
- $this->addeditFinancialType($financialType);
- $this->addStandaloneContribution($financialType);
- $this->addStandaloneContribution($financialType);
-
- $this->openCiviPage("contribute/search", "reset=1", "_qf_Search_refresh");
- // select group
- $this->select("financial_type_id", "label={$financialType['name']}");
- $this->clickLink("_qf_Search_refresh");
- $this->assertElementContainsText("xpath=//div[@class='crm-content-block']//div[@id='search-status']/table/tbody/tr[1]/td[1]", "2 Result");
- $this->assertElementContainsText("xpath=//div[@class='crm-content-block']//div[@id='search-status']/table/tbody/tr[1]/td[2]", "Financial Type In {$financialType['name']}");
-
- $this->openCiviPage("contact/search/advanced", "reset=1", "_qf_Advanced_refresh-top");
- $this->clickAjaxLink('CiviContribute', "financial_type_id");
-
- // select group
- $this->select("financial_type_id", "label={$financialType['name']}");
- $this->clickLink("_qf_Advanced_refresh-top");
- $this->assertElementContainsText("xpath=//div[@class='crm-content-block']//div[@id='search-status']//table/tbody/tr[1]/td[1]", "2 Contacts");
- $this->assertElementContainsText("xpath=//div[@class='crm-content-block']//div[@id='search-status']//table/tbody/tr[1]/td[2]", "Financial Type In {$financialType['name']}");
- }
-
- /**
- * @param $financialType
- */
- public function addStandaloneContribution($financialType) {
-
- $this->openCiviPage("contribute/add", "reset=1&context=standalone", "_qf_Contribution_upload");
-
- // create new contact using dialog
- $this->createDialogContact();
-
- // select financial type
- $this->select("financial_type_id", "label={$financialType['name']}");
-
- // fill in Received Date
- $this->webtestFillDate('receive_date');
-
- // source
- $this->type("source", "Mailer 1");
-
- // total amount
- $this->type("total_amount", "100");
-
- // select payment instrument type = Check and enter chk number
- $this->select("payment_instrument_id", "value=4");
- $this->waitForElementPresent("check_number");
- $this->type("check_number", "check #1041");
-
- $this->type("trxn_id", "P20901X1" . rand(100, 10000));
-
- //Additional Detail section
- $this->click("AdditionalDetail");
- $this->waitForElementPresent("thankyou_date");
-
- $this->type("note", "This is a test note.");
- $this->waitForElementPresent("non_deductible_amount");
- $this->type("non_deductible_amount", "10");
- $this->type("fee_amount", "0");
- $this->type("net_amount", "0");
- $this->type("invoice_id", time());
- $this->webtestFillDate('thankyou_date');
-
- // Clicking save.
- $this->click("_qf_Contribution_upload");
-
- // Is status message correct?
- $this->checkCRMAlert("The contribution record has been saved.");
-
- // verify if Membership is created
- $this->waitForElementPresent("xpath=//table[@class='selector row-highlight']//tbody/tr[1]/td[8]/span//a[text()='View']");
-
- //click through to the Membership view screen
- $this->click("xpath=//table[@class='selector row-highlight']//tbody/tr[1]/td[8]/span//a[text()='View']");
- $this->waitForElementPresent("_qf_ContributionView_cancel-bottom");
-
- $expected = array(
- 'Financial Type' => $financialType['name'],
- 'Total Amount' => '$ 100.00',
- 'Contribution Status' => 'Completed',
- 'Payment Method' => 'Check',
- 'Check Number' => 'check #1041',
- );
-
- foreach ($expected as $label => $value) {
- $this->assertElementContainsText("xpath=id('ContributionView')/div[2]/table[1]/tbody//tr/td[1][text()='$label']/../td[2]", $value);
- }
- }
-
- public function testAjaxCustomGroupLoad() {
- $this->webtestLogin();
- $triggerElement = array('name' => 'financial_type_id', 'type' => 'select');
- $customSets = array(
- array('entity' => 'Contribution', 'subEntity' => 'Donation', 'triggerElement' => $triggerElement),
- array('entity' => 'Contribution', 'subEntity' => 'Member Dues', 'triggerElement' => $triggerElement),
- );
-
- $pageUrl = array('url' => 'contribute/add', 'args' => 'reset=1&action=add&context=standalone');
- $this->customFieldSetLoadOnTheFlyCheck($customSets, $pageUrl);
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Contribute_UpdateBatchPendingContributionTest
- */
-class WebTest_Contribute_UpdateBatchPendingContributionTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testBatchUpdatePendingContribution() {
- $this->webtestLogin();
- $this->_testOfflineContribution();
- $this->_testOfflineContribution();
- $this->_testOfflineContribution();
-
- $this->openCiviPage("contribute/search", "reset=1", "contribution_date_low");
-
- $this->type("sort_name", "Individual");
- $this->waitForElementPresent("contribution_status_id");
- $this->multiselect2('contribution_status_id', array("Pending"));
- $this->clickLink("_qf_Search_refresh");
-
- $this->click('radio_ts', 'ts_all');
- $this->waitForAjaxContent();
- $this->select('task', "label=Update pending contribution status");
- $this->waitForAjaxContent();
- $this->waitForElementPresent("contribution_status_id");
- $this->select('contribution_status_id', 'label=Completed');
- $this->waitForAjaxContent();
- $this->click('_qf_Status_next');
- $this->waitForElementPresent("_qf_Result_done");
- $this->click("_qf_Result_done");
-
- $this->waitForElementPresent("contribution_date_low");
-
- $this->type("sort_name", "Individual");
- $this->waitForElementPresent("contribution_status_id");
- $this->multiselect2('contribution_status_id', array("Completed"));
- $this->click("_qf_Search_refresh");
-
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->click("xpath=//table[@class='selector row-highlight']/tbody/tr[1]/td[10]/span//a[text()='View']");
- $this->waitForElementPresent("_qf_ContributionView_cancel-bottom");
- $expected = array(
- 'Received Into' => "Deposit Bank Account",
- 'Contribution Status' => "Completed",
- );
-
- $this->webtestVerifyTabularData($expected);
- }
-
- public function testParticipationAdd() {
- // Log in using webtestLogin() method
- $this->webtestLogin();
-
- // Adding contact with randomized first name (so we can then select that contact when creating event registration)
- // We're using Quick Add block on the main page for this.
- $firstName1 = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName1, 'Anderson', TRUE);
- $sortName1 = "Anderson, $firstName1";
- $this->_addParticipant($firstName1);
-
- $firstName2 = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName2, 'Anderson', TRUE);
- $sortName2 = "Anderson, $firstName2";
- $this->_addParticipant($firstName2);
-
- // Search the participants
- $this->openCiviPage("event/search", "reset=1", '_qf_Search_refresh');
-
- $eventName = 'Rain-forest Cup Youth Soccer Tournament';
- $this->select2("event_id", $eventName, TRUE);
- $this->click('_qf_Search_refresh');
-
- $this->openCiviPage("contribute/search", "reset=1", "contribution_date_low");
-
- $this->type("sort_name", "Anderson");
- $this->multiselect2('contribution_status_id', array("Pending"));
- $this->click("_qf_Search_refresh");
-
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->click('radio_ts', 'ts_all');
-
- $this->select('task', "label=Update pending contribution status");
- $this->waitForElementPresent("_qf_Search_next_action");
- $this->click("_qf_Search_next_action");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->select('contribution_status_id', 'label=Completed');
- $this->click('_qf_Status_next');
- $this->waitForElementPresent("_qf_Result_done");
- $this->click("_qf_Result_done");
-
- $this->waitForElementPresent("contribution_date_low");
-
- $this->type("sort_name", "Anderson");
- $this->multiselect2('contribution_status_id', array("Completed"));
- $this->click("_qf_Search_refresh");
-
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->click("xpath=//table[@class='selector row-highlight']/tbody/tr[1]/td[10]/span//a[text()='View']");
- $this->waitForElementPresent("_qf_ContributionView_cancel-bottom");
- $expected = array(
- 'Received Into' => "Deposit Bank Account",
- 'Contribution Status' => "Completed",
- );
-
- $this->webtestVerifyTabularData($expected);
- }
-
- /**
- * @param string $firstName
- */
- public function _addParticipant($firstName) {
-
- $this->openCiviPage("participant/add", "reset=1&action=add&context=standalone", '_qf_Participant_upload-bottom');
-
- // Type contact last name in contact auto-complete, wait for dropdown and click first result
- $this->webtestFillAutocomplete($firstName);
-
- // Select event. Based on label for now.
- $this->select2('event_id', "Rain-forest Cup Youth Soccer Tournament");
-
- // Select role
- $this->multiselect2('role_id', array('Volunteer'));
-
- // Select participant status
- $this->select('status_id', 'value=1');
-
- // Setting registration source
- $this->type('source', 'Event StandaloneAddTest Webtest');
-
- // Since we're here, let's check of screen help is being displayed properly
- $this->assertTrue($this->isTextPresent('Source for this registration (if applicable).'));
-
- // Select an event fee
- $this->waitForElementPresent('priceset');
-
- $this->click("xpath=//input[@class='crm-form-radio']");
-
- // Enter amount to be paid (note: this should default to selected fee level amount, s/b fixed during 3.2 cycle)
- $this->type('total_amount', '800');
-
- $this->select('contribution_status_id', "label=Pending");
-
- // Clicking save.
- $this->click('_qf_Participant_upload-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Is status message correct?
- $this->waitForText("crm-notification-container", "Event registration for $firstName Anderson has been added");
-
- $this->waitForElementPresent("xpath=//form[@class='CRM_Event_Form_Search crm-search-form']/table//tbody/tr[1]/td[8]/span/a[text()='View']");
- //click through to the participant view screen
- $this->click("xpath=//form[@class='CRM_Event_Form_Search crm-search-form']/table//tbody/tr[1]/td[8]/span/a[text()='View']");
- $this->waitForElementPresent('_qf_ParticipantView_cancel-bottom');
-
- $this->webtestVerifyTabularData(
- array(
- 'Event' => 'Rain-forest Cup Youth Soccer Tournament',
- 'Participant Role' => 'Attendee',
- 'Status' => 'Registered',
- 'Event Source' => 'Event StandaloneAddTest Webtest',
- 'Fees' => '$ 800.00',
- )
- );
- }
-
- public function _testOfflineContribution() {
- $this->openCiviPage("contribute/add", "reset=1&context=standalone", "_qf_Contribution_upload");
-
- // create new contact using dialog
- $this->createDialogContact();
-
- // select financial type
- $this->select("financial_type_id", "value=1");
-
- //Contribution status
- $this->waitForElementPresent("contribution_status_id");
- $this->select("contribution_status_id", "label=Pending");
-
- // total amount
- $this->type("total_amount", "100");
-
- // Clicking save.
- $this->click("_qf_Contribution_upload");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Is status message correct?
- $this->assertTrue($this->isTextPresent("The contribution record has been saved."), "Status message didn't show up after saving!");
-
- // verify if Membership is created
- $this->waitForElementPresent("xpath=//div[@class='view-content']//table[2]//tbody/tr[1]/td[8]/span/a[text()='View']");
-
- //click through to the Membership view screen
- $this->click("xpath=//div[@class='view-content']//table[2]/tbody/tr[1]/td[8]/span/a[text()='View']");
- $this->waitForElementPresent("_qf_ContributionView_cancel-bottom");
-
- $expected = array(
- 'Financial Type' => 'Donation',
- 'Total Amount' => '100.00',
- 'Contribution Status' => 'Pending',
- );
- foreach ($expected as $label => $value) {
- $this->assertElementContainsText("xpath=id('ContributionView')/div[2]/table[1]/tbody//tr/td[1][text()='$label']/../td[2]", $value);
- }
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Contribute_UpdateContributionTest
- */
-class WebTest_Contribute_UpdateContributionTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testChangeContributionAmount() {
- $this->webtestLogin();
- $amount = 100;
- //Offline Pay Later Contribution
- $contact = $this->_testOfflineContribution($amount, "Pending");
-
- $this->openCiviPage("contribute/search", "reset=1", "contribution_date_low");
-
- $this->type("sort_name", $contact['sort_name']);
- $this->click("_qf_Search_refresh");
-
- $this->waitForElementPresent("xpath=//*[@id='Search']//div[@id='contributionSearch']");
- $contriIDOff = explode('&', $this->getAttribute("xpath=//div[@id='contributionSearch']//table[@class='selector row-highlight']/tbody/tr[1]//td//span/a[1]@href"));
- if (!empty($contriIDOff)) {
- $contriIDOff = substr($contriIDOff[1], (strrpos($contriIDOff[1], '=') + 1));
- }
-
- $this->clickLink("xpath=//tr[@id='rowid{$contriIDOff}']//td//span/a[2]", "total_amount", FALSE);
- $this->waitForAjaxContent();
- $this->type("total_amount", "90");
- $this->clickLink('_qf_Contribution_upload', '', FALSE);
- $this->waitForAjaxContent();
- $this->waitForText('crm-notification-container', "The sum of fee amount and net amount must be equal to total amount");
- $this->type("net_amount", "90");
- $this->clickLink('_qf_Contribution_upload', '', FALSE);
-
- // Is status message correct?
- $this->waitForText('crm-notification-container', "The contribution record has been saved.");
-
- //For Contribution
- $searchParams = array('id' => $contriIDOff);
- $compareParams = array('total_amount' => '90.00');
- //For LineItem
- $lineItemSearchParams = array('entity_id' => $contriIDOff);
- $lineItemCompareParams = array('line_total' => '90.00');
-
- $this->assertDBCompareValues('CRM_Contribute_DAO_Contribution', $searchParams, $compareParams);
- $this->assertDBCompareValues('CRM_Price_DAO_LineItem', $lineItemSearchParams, $lineItemCompareParams);
-
- $total = $this->_getTotalContributedAmount($contriIDOff);
- $compare = array('total_amount' => $total);
- $this->assertDBCompareValues('CRM_Contribute_DAO_Contribution', $searchParams, $compare);
-
- $amount = $this->_getFinancialItemAmount($contriIDOff);
- $compare = array('total_amount' => $amount);
- $this->assertDBCompareValues('CRM_Contribute_DAO_Contribution', $searchParams, $compare);
-
- $financialTrxnAmount = $this->_getFinancialTrxnAmount($contriIDOff);
- $compare = array('total_amount' => $financialTrxnAmount);
- $this->assertDBCompareValues('CRM_Contribute_DAO_Contribution', $searchParams, $compare);
- }
-
- public function testPayLater() {
- $this->webtestLogin();
- $amount = 100.00;
- //Offline Pay Later Contribution
- $this->_testOfflineContribution($amount, "Pending");
- $this->waitForElementPresent("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']");
- $contId = $this->urlArg('id', $this->getAttribute("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']@href"));
- $this->clickAjaxLink("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']", '_qf_Contribution_cancel-bottom');
- $this->select("contribution_status_id", "label=Completed");
- $this->clickAjaxLink("_qf_Contribution_upload", "xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']");
- $this->checkCRMAlert("The contribution record has been saved.");
-
- //Assertions
- $search = array('id' => $contId);
- $compare = array('contribution_status_id' => 1);
- $this->assertDBCompareValues('CRM_Contribute_DAO_Contribution', $search, $compare);
-
- $lineItem = key(CRM_Price_BAO_LineItem::getLineItems($contId, 'contribution'));
- $search = array('entity_id' => $lineItem);
- $compare = array('status_id' => 1);
- $this->assertDBCompareValues("CRM_Financial_DAO_FinancialItem", $search, $compare);
-
- $status = $this->_getPremiumActualCost($contId, 'Accounts Receivable', 'Payment Processor Account', NULL, "'civicrm_contribution'", "ft.status_id as status");
- $this->assertEquals($status, '1', "Verify Completed Status");
- }
-
- public function testChangePremium() {
- $this->webtestLogin();
- $from = 'Premiums';
- $to = 'Premiums inventory';
- $financialType = array(
- 'name' => 'Test Financial' . substr(sha1(rand()), 0, 7),
- 'is_reserved' => 1,
- 'is_deductible' => 1,
- );
- $this->addeditFinancialType($financialType);
- $this->waitForElementPresent("xpath=//div[@id='ltype']/div/table/tbody//tr/td/div[text()='" . $financialType['name'] . "']/../../td[7]/span/a[text()='Accounts']");
- $this->click("xpath=//div[@id='ltype']/div/table/tbody//tr/td/div[text()='" . $financialType['name'] . "']/../../td[7]/span/a[text()='Accounts']");
- $this->waitForElementPresent("xpath=//a[@id='newfinancialTypeAccount']");
- $this->clickAjaxLink("xpath=//a[@id='newfinancialTypeAccount']", "_qf_FinancialTypeAccount_cancel-botttom");
- $this->select("account_relationship", "label=Premiums Inventory Account is");
- $this->waitForElementPresent("xpath=//select[@id='financial_account_id']/option[3][text()='Deposit Bank Account']");
- $this->select("financial_account_id", "label=$to");
- $this->clickAjaxLink("_qf_FinancialTypeAccount_next-botttom", "xpath=//a[@id='newfinancialTypeAccount']");
-
- $premiumName = 'Premium' . substr(sha1(rand()), 0, 7);
- $amount = 500;
- $sku = 'SKU';
- $price = 300;
- $cost = 3.00;
- $this->openCiviPage("admin/contribute/managePremiums", "action=add&reset=1");
- // add premium
- $this->addPremium($premiumName, $sku, $amount, $price, $cost, $financialType['name']);
-
- //add second premium
- $premiumName2 = 'Premium' . substr(sha1(rand()), 0, 7);
- $amount2 = 600;
- $sku2 = 'SKU';
- $price2 = 200;
- $cost2 = 2.00;
- $this->openCiviPage("admin/contribute/managePremiums", "action=add&reset=1");
- $this->addPremium($premiumName2, $sku2, $amount2, $price2, $cost2, $financialType['name']);
-
- // add contribution with premium
- $this->openCiviPage("contribute/add", "reset=1&action=add&context=standalone");
-
- // create new contact using dialog
- $this->createDialogContact();
- // select financial type
- $this->select("financial_type_id", "value=1");
- // total amount
- $this->type("total_amount", "100");
- // fill Premium information
- $this->clickAjaxLink("xpath=//div[@id='Premium']", "product_name_0");
- $this->select('product_name_0', "label=$premiumName ( $sku )");
- // Clicking save.
- $this->clickAjaxLink("_qf_Contribution_upload", "xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[8]/span/a[text()='View']");
- // Is status message correct?
- $this->checkCRMAlert("The contribution record has been saved.");
- // verify if Contribution is created
- //click through to the Contribution edit screen
- $contId = $this->urlArg('id', $this->getAttribute("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']@href"));
- $this->clickAjaxLink("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']", "product_name_0");
-
- $this->select('product_name_0', "label=$premiumName2 ( $sku2 )");
- // Clicking save.
- $this->clickAjaxLink("_qf_Contribution_upload", "xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[7][text()='$premiumName2']");
- $this->checkCRMAlert("The contribution record has been saved.");
-
- //Assertions
- $actualAmount = $this->_getPremiumActualCost($contId, $to, $from, $cost2, "'civicrm_contribution'");
- $this->assertEquals($actualAmount, $cost2, "Verify actual cost for changed premium");
-
- $deletedAmount = $this->_getPremiumActualCost($contId, $from, $to, $cost, "'civicrm_contribution'");
- $this->assertEquals($deletedAmount, $cost, "Verify actual cost for deleted premium");
- }
-
- public function testDeletePremium() {
- $this->webtestLogin();
- $from = 'Premiums';
- $to = 'Premiums inventory';
- $financialType = array(
- 'name' => 'Test Financial' . substr(sha1(rand()), 0, 7),
- 'is_reserved' => 1,
- 'is_deductible' => 1,
- );
- $this->addeditFinancialType($financialType);
- $this->waitForElementPresent("xpath=//div[@id='ltype']/div/table/tbody//tr/td/div[text()='" . $financialType['name'] . "']/../../td[7]/span/a[text()='Accounts']");
- $this->click("xpath=//div[@id='ltype']/div/table/tbody//tr/td/div[text()='" . $financialType['name'] . "']/../../td[7]/span/a[text()='Accounts']");
- $this->waitForElementPresent("xpath=//a[@id='newfinancialTypeAccount']");
- $this->clickLink("xpath=//a[@id='newfinancialTypeAccount']", "_qf_FinancialTypeAccount_cancel-botttom", FALSE);
-
- $this->select("account_relationship", "label=Premiums Inventory Account is");
- $this->waitForElementPresent("xpath=//select[@id='financial_account_id']/option[3][text()='Deposit Bank Account']");
- $this->select("financial_account_id", "label=$to");
- $this->clickLink("_qf_FinancialTypeAccount_next-botttom", "xpath=//a[@id='newfinancialTypeAccount']", FALSE);
- $premiumName = 'Premium' . substr(sha1(rand()), 0, 7);
- $amount = 500;
- $sku = 'SKU';
- $price = 300;
- $cost = 3.00;
- $this->openCiviPage("admin/contribute/managePremiums", "action=add&reset=1");
- // add premium
- $this->addPremium($premiumName, $sku, $amount, $price, $cost, $financialType['name']);
- // add contribution with premium
- $this->openCiviPage("contribute/add", "reset=1&action=add&context=standalone");
-
- // create new contact using dialog
- $this->createDialogContact();
- // select financial type
- $this->select("financial_type_id", "value=1");
- // total amount
- $this->type("total_amount", "100");
- // fill Premium information
- $this->click("xpath=//div[@id='Premium']");
- $this->waitForElementPresent("product_name_0");
- $this->select('product_name_0', "label=$premiumName ( $sku )");
- // Clicking save.
- $this->clickLink("_qf_Contribution_upload");
- // Is status message correct?
- $this->waitForText('crm-notification-container', "The contribution record has been saved.");
- // verify if Contribution is created
- $this->waitForElementPresent("xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[8]/span/a[text()='View']");
- //click through to the Contribution edit screen
- $contId = explode('&id=', $this->getAttribute("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']@href"));
- $contId = explode('&', $contId[1]);
- $contId = $contId[0];
- $this->clickLink("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']", "_qf_Contribution_upload-bottom", FALSE);
- $this->waitForElementPresent("product_name_0");
- $this->select('product_name_0', "value=0");
- // Clicking save.
- $this->click("_qf_Contribution_upload");
- $this->waitForElementPresent("xpath=//table[@class='selector row-highlight']/tbody/tr[1]/td[8]//span/a[text()='View']");
-
- //Assertions
- $actualAmount = $this->_getPremiumActualCost($contId, $from, $to, NULL, "'civicrm_contribution'");
- $this->assertEquals($actualAmount, NULL, "Verify actual cost for deleted premium");
- }
-
- public function testChangePaymentInstrument() {
- $this->webtestLogin();
- $label = 'TEST' . substr(sha1(rand()), 0, 7);
- $amount = 100.00;
- $financialAccount = CRM_Contribute_PseudoConstant::financialAccount();
- $to = array_search('Accounts Receivable', $financialAccount);
- $from = array_search('Deposit Bank Account', $financialAccount);
- $this->addPaymentInstrument($label, $to);
- $this->_testOfflineContribution($amount);
- $this->waitForElementPresent("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']");
- $this->clickLink("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']", '_qf_Contribution_cancel-bottom', FALSE);
- $contId = explode('&id=', $this->getAttribute("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']@href"));
- $contId = explode('&', $contId[1]);
- $contId = $contId[0];
- //change payment processor to newly created value
- $this->select("payment_instrument_id", "label=$label");
- $this->clickLink("_qf_Contribution_upload", "xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']", FALSE);
- $this->waitForAjaxContent();
- //Assertions
- $subtractedTotal = $this->_getPremiumActualCost($contId, NULL, 'Payment Processor Account');
- $this->assertEquals($subtractedTotal, -$amount, "Verify amount deleted from old account");
- $totalAmount = $this->_getPremiumActualCost($contId, NULL, 'Accounts Receivable');
- $this->assertEquals($totalAmount, $amount, "Verify amount for newly inserted values");
- }
-
- public function testRefundContribution() {
- $this->webtestLogin();
- $amount = 100.00;
- $this->_testOfflineContribution($amount);
- $this->waitForElementPresent("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span//a[text()='Edit']");
- $this->clickAjaxLink("xpath=//form[@class='CRM_Contribute_Form_Search crm-search-form']/div[2]/table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']", '_qf_Contribution_cancel-bottom');
- //Contribution status
- $this->select("contribution_status_id", "label=Refunded");
- $contId = explode('&id=', $this->getAttribute("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']@href"));
- $contId = explode('&', $contId[1]);
- $contId = $contId[0];
- $this->clickAjaxLink("_qf_Contribution_upload", "xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[6][text()='Refunded']");
-
- //Assertions
- $lineItem = key(CRM_Price_BAO_LineItem::getLineItems($contId, 'contribution'));
- $search = array('entity_id' => $lineItem);
- $compare = array(
- 'amount' => '100.00',
- 'status_id' => 1,
- );
- $this->assertDBCompareValues("CRM_Financial_DAO_FinancialItem", $search, $compare);
- $amount = $this->_getPremiumActualCost($contId, NULL, 'Payment Processor Account', -100.00, "'civicrm_contribution'");
- $this->assertEquals($amount, '-100.00', 'Verify Financial Trxn Amount.');
- }
-
- public function testCancelPayLater() {
- $this->webtestLogin();
- $amount = 100.00;
- $this->_testOfflineContribution($amount, "Pending");
- $this->waitForElementPresent("xpath=//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']");
- $this->clickLink("xpath=//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']", '_qf_Contribution_cancel-bottom', FALSE);
- //Contribution status
- $this->select("contribution_status_id", "label=Cancelled");
- $contId = explode('&id=', $this->getAttribute("xpath=//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']@href"));
- $contId = explode('&', $contId[1]);
- $contId = $contId[0];
- $this->clickLink("_qf_Contribution_upload", "xpath=//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']", FALSE);
- $this->waitForText('crm-notification-container', "The contribution record has been saved.");
-
- //Assertions
- $search = array('id' => $contId);
- $compare = array('contribution_status_id' => 3);
- $this->assertDBCompareValues('CRM_Contribute_DAO_Contribution', $search, $compare);
- $lineItem = key(CRM_Price_BAO_LineItem::getLineItems($contId, 'contribution'));
- $itemParams = array(
- 'amount' => '-100.00',
- 'entity_id' => $lineItem,
- );
- $defaults = array();
- $items = CRM_Financial_BAO_FinancialItem::retrieve($itemParams, $defaults);
- $this->assertEquals($items->amount, $itemParams['amount'], 'Verify Amount for financial Item');
- // CRM-17183 - check Financial Trxn in $to_financial_account_id
- $totalAmount = $this->_getPremiumActualCost($items->id, NULL, 'Accounts Receivable', "-100.00", "'civicrm_financial_item'");
- $this->assertEquals($totalAmount, "-$amount", 'Verify Amount for Financial Trxn');
- $totalAmount = $this->_getPremiumActualCost($contId, NULL, 'Accounts Receivable', "-100.00", "'civicrm_contribution'");
- $this->assertEquals($totalAmount, "-$amount", 'Verify Amount for Financial Trxn');
- }
-
- public function testChangeFinancialType() {
- $this->webtestLogin();
- $amount = 100.00;
- $this->_testOfflineContribution($amount);
- $this->waitForElementPresent("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']");
- $this->clickLink("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']", '_qf_Contribution_cancel-bottom', FALSE);
- //Contribution status
- $this->select("financial_type_id", "value=3");
- $contId = explode('&id=', $this->getAttribute("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']@href"));
- $contId = explode('&', $contId[1]);
- $contId = $contId[0];
- $this->clickLink("_qf_Contribution_upload", "xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']", FALSE);
- $this->waitForText('crm-notification-container', "The contribution record has been saved.");
-
- //Assertions
- $search = array('id' => $contId);
- $compare = array('financial_type_id' => 3);
- $this->assertDBCompareValues('CRM_Contribute_DAO_Contribution', $search, $compare);
-
- $lineItem = key(CRM_Price_BAO_LineItem::getLineItems($contId, 'contribution'));
- $itemParams = array(
- 'amount' => '-100.00',
- 'entity_id' => $lineItem,
- );
- $item1 = $item2 = array();
- CRM_Financial_BAO_FinancialItem::retrieve($itemParams, $item1);
- $this->assertEquals($item1['amount'], "-100.00", "Verify Amount for New Financial Item");
- $itemParams['amount'] = '100.00';
- CRM_Financial_BAO_FinancialItem::retrieve($itemParams, $item2);
- $this->assertEquals($item2['amount'], "100.00", "Verify Amount for New Financial Item");
-
- $cValue1 = $this->_getPremiumActualCost($contId, NULL, NULL, "-100.00", "'civicrm_contribution'");
- $fValue1 = $this->_getPremiumActualCost($item1['id'], NULL, NULL, "-100.00", "'civicrm_financial_item'");
- $this->assertEquals($cValue1, "-100.00", "Verify Amount");
- $this->assertEquals($fValue1, "-100.00", "Verify Amount");
- $cValue2 = $this->_getPremiumActualCost($contId, NULL, NULL, "100.00", "'civicrm_contribution'");
- $fValue2 = $this->_getPremiumActualCost($item2['id'], NULL, NULL, "100.00", "'civicrm_financial_item'");
- $this->assertEquals($cValue2, "100.00", "Verify Amount");
- $this->assertEquals($fValue2, "100.00", "Verify Amount");
- }
-
- /**
- * @param int $entityId
- * @param null $from
- * @param null $to
- * @param null $cost
- * @param null $entityTable
- * @param string $select
- *
- * @return null|string
- */
- public function _getPremiumActualCost($entityId, $from = NULL, $to = NULL, $cost = NULL, $entityTable = NULL, $select = "ft.total_amount AS amount") {
- $financialAccount = CRM_Contribute_PseudoConstant::financialAccount();
- $query = "SELECT
- {$select}
- FROM civicrm_financial_trxn ft
- INNER JOIN civicrm_entity_financial_trxn eft ON eft.financial_trxn_id = ft.id AND eft.entity_id = {$entityId}";
- if ($entityTable) {
- $query .= " AND eft.entity_table = {$entityTable}";
- }
- if (!empty($to)) {
- $to = array_search($to, $financialAccount);
- $query .= " AND ft.to_financial_account_id = {$to}";
- }
- if (!empty($from)) {
- $from = array_search($from, $financialAccount);
- $query .= " AND ft.from_financial_account_id = {$from}";
- }
- if (!empty($cost)) {
- $query .= " AND eft.amount = {$cost}";
- }
- $query .= " ORDER BY ft.id DESC LIMIT 1";
- $result = CRM_Core_DAO::singleValueQuery($query);
- return $result;
- }
-
- /**
- * @param int $contId
- *
- * @return null|string
- */
- public function _getFinancialTrxnAmount($contId) {
- $query = "SELECT
- SUM( ft.total_amount ) AS total
- FROM civicrm_financial_trxn AS ft
- LEFT JOIN civicrm_entity_financial_trxn AS ceft ON ft.id = ceft.financial_trxn_id
- WHERE ceft.entity_table = 'civicrm_contribution'
- AND ceft.entity_id = {$contId}";
- $result = CRM_Core_DAO::singleValueQuery($query);
- return $result;
- }
-
- /**
- * @param int $contId
- *
- * @return null|string
- */
- public function _getFinancialItemAmount($contId) {
- $lineItem = key(CRM_Price_BAO_LineItem::getLineItems($contId, 'contribution'));
- $query = "SELECT
- SUM(amount)
- FROM civicrm_financial_item
- WHERE entity_table = 'civicrm_line_item'
- AND entity_id = {$lineItem}";
- $result = CRM_Core_DAO::singleValueQuery($query);
- return $result;
- }
-
- /**
- * @param int $contId
- *
- * @return null|string
- */
- public function _getTotalContributedAmount($contId) {
- $query = "SELECT
- SUM(amount)
- FROM civicrm_entity_financial_trxn
- WHERE entity_table = 'civicrm_contribution'
- AND entity_id = {$contId}";
- $result = CRM_Core_DAO::singleValueQuery($query);
- return $result;
- }
-
- /**
- * @param $amount
- * @param string $status
- * @return array
- */
- public function _testOfflineContribution($amount, $status = "Completed") {
-
- $this->openCiviPage("contribute/add", "reset=1&context=standalone", "_qf_Contribution_upload");
-
- // create new contact using dialog
- $contact = $this->createDialogContact();
-
- // select financial type
- $this->select("financial_type_id", "value=1");
-
- //Contribution status
- $this->select("contribution_status_id", "label=$status");
-
- // total amount
- $this->type("total_amount", $amount);
-
- // select payment instrument type
- $this->select("payment_instrument_id", "label=Credit Card");
-
- $this->type("trxn_id", "P20901X1" . rand(100, 10000));
-
- //Custom Data
- //$this->click('CIVICRM_QFID_3_6');
-
- // Clicking save.
- $this->clickLink("_qf_Contribution_upload");
-
- // Is status message correct?
- $this->checkCRMAlert("The contribution record has been saved.");
-
- $this->waitForElementPresent("xpath=//form[@class='CRM_Contribute_Form_Search crm-search-form']/div[2]/table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span//a[text()='View']");
- // verify if Membership is created
-
- //click through to the Membership view screen
- $this->click("xpath=//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='View']");
-
- $expected = array(
- 'Financial Type' => 'Donation',
- 'Total Amount' => '100.00',
- 'Contribution Status' => $status,
- );
- $this->webtestVerifyTabularData($expected);
- $this->click("_qf_ContributionView_cancel-bottom");
-
- return $contact;
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Contribute_UpdatePendingContributionTest
- */
-class WebTest_Contribute_UpdatePendingContributionTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testPayNowLink() {
- $this->webtestLogin();
-
- //Offline Pay Later Contribution
- $contact = $this->_testOfflineContribution();
- $this->openCiviPage("contact/view", "reset=1&cid={$contact['id']}", "css=li#tab_contribute a");
- $this->click("css=li#tab_contribute a");
- $this->waitForElementPresent("xpath=//table[@class='selector row-highlight']/tbody//tr/td[8]/span/a");
-
- $this->clickPopupLink("xpath=//table[@class='selector row-highlight']/tbody//tr/td[8]/span/a[@title='Edit Contribution']");
- $this->waitForElementPresent('financial_type_id');
-
- $this->clickPopupLink("xpath=//a[contains(text(), 'Pay with Credit Card')]");
- $this->assertElementContainsText("xpath=//span[@class='ui-dialog-title']", "Pay with Credit Card");
- $this->assertElementNotPresent("xpath=//select[@id='currency']");
- $this->assertNotEditable('total_amount');
- $this->assertElementNotPresent("xpath=//select[@id='contribution_status_id']");
-
- $this->webtestAddCreditCardDetails();
- $this->webtestAddBillingDetails();
-
- //return to the edit contrib form
- $this->clickAjaxLink('_qf_Contribution_upload-bottom');
- $this->waitForText('crm-notification-container', "The contribution record has been saved.");
-
- //save the edit form
- $this->clickAjaxLink('_qf_Contribution_upload-bottom');
- $this->waitForText('crm-notification-container', "The contribution record has been saved.");
-
- $this->clickPopupLink("xpath=//table[@class='selector row-highlight']/tbody//tr/td[8]/span/a[@title='View Contribution']");
-
- // View Contribution Record and test for expected values
- $expected = array(
- 'From' => $contact['display_name'],
- 'Financial Type' => 'Donation',
- 'Total Amount' => '$ 100.00',
- 'Payment Method' => 'Credit Card (Test Processor)',
- 'Contribution Status' => 'Completed',
- 'Received Into' => 'Payment Processor Account',
- 'Net Amount' => '$ 98.50',
- 'Fee Amount' => '$ 1.50',
- );
- $this->webtestVerifyTabularData($expected);
- }
-
- public function testUpdatePendingContribution() {
- $this->webtestLogin();
-
- //Offline Pay Later Contribution
- $contact = $this->_testOfflineContribution();
-
- //Online Pay Later Contribution
- $this->_testOnlineContribution($contact);
- $this->openCiviPage("contribute/search", "reset=1", "contribution_date_low");
- $this->click("xpath=//tr/td[1]/label[contains(text(), 'Contribution is a Test?')]/../../td[2]/label[contains(text(), 'Yes')]/../a[1]");
- $this->type("sort_name", $contact['sort_name']);
- $this->click("_qf_Search_refresh");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->click('radio_ts', 'ts_all');
- $contriIDOff = explode('&', $this->getAttribute("xpath=//div[@id='contributionSearch']/table/tbody/tr[1]//td/span/a@href"));
- $contriIDOn = explode('&', $this->getAttribute("xpath=//div[@id='contributionSearch']/table/tbody/tr[1]//td/span/a@href"));
- if (!empty($contriIDOff)) {
- $contriIDOff = substr($contriIDOff[1], (strrpos($contriIDOff[1], '=') + 1));
- }
- if (!empty($contriIDOn)) {
- $contriIDOn = substr($contriIDOn[1], (strrpos($contriIDOn[1], '=') + 1));
- }
- $this->select('task', "label=Update pending contribution status");
- $this->click("_qf_Search_next_action");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->select('contribution_status_id', 'label=Completed');
- $this->type("trxn_id_{$contriIDOff}", substr(sha1(rand()), 0, 5));
- $this->type("trxn_id_{$contriIDOn}", substr(sha1(rand()), 0, 5));
- $this->click('_qf_Status_next');
- $this->waitForElementPresent("_qf_Result_done");
- $this->click("_qf_Result_done");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $status = 'Completed';
- $this->verifyText("xpath=id('contributionSearch')/table[1]/tbody/tr[1]//td[@class='crm-contribution-status']", preg_quote($status));
- $this->verifyText("xpath=id('contributionSearch')/table[1]/tbody/tr[2]//td[@class='crm-contribution-status']", preg_quote($status));
- }
-
- /**
- * @return array
- * Array of contact details
- */
- public function _testOfflineContribution() {
- // Create a contact to be used as soft creditor
- $softCreditFname = substr(sha1(rand()), 0, 7);
- $softCreditLname = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($softCreditFname, $softCreditLname, FALSE);
-
- $this->openCiviPage("contribute/add", "reset=1&context=standalone", "_qf_Contribution_upload");
-
- // create new contact using dialog
- $contact = $this->createDialogContact();
-
- // select financial type
- $this->select("financial_type_id", "value=1");
-
- // fill in Received Date
- $this->webtestFillDate('receive_date');
-
- //Contribution status
- $this->select("contribution_status_id", "label=Pending");
-
- // source
- $this->type("source", "Mailer 1");
-
- // total amount
- $this->type("total_amount", "100");
-
- // select payment instrument type = Check and enter chk number
- $this->select("payment_instrument_id", "value=4");
- $this->waitForElementPresent("check_number");
- $this->type("check_number", "check #1041");
-
- $this->type("trxn_id", "P20901X1" . rand(100, 10000));
-
- // soft credit
- $this->webtestFillAutocomplete("{$softCreditLname}, {$softCreditFname}", 'soft_credit_contact_id_1');
- $this->type("soft_credit_amount_1", "100");
- //Custom Data
- //$this->click('CIVICRM_QFID_3_6');
-
- //Additional Detail section
- $this->click("AdditionalDetail");
- $this->waitForElementPresent("thankyou_date");
-
- $this->type("note", "This is a test note.");
- $this->type("non_deductible_amount", "10");
- $this->type("invoice_id", time());
- $this->webtestFillDate('thankyou_date');
-
- //Premium section
- $this->click("Premium");
- $this->waitForElementPresent("fulfilled_date");
- $this->select("product_name[0]", "label=Coffee Mug ( MUG-101 )");
- $this->select("product_name[1]", "label=Black");
- $this->webtestFillDate('fulfilled_date');
-
- // Clicking save.
- $this->click("_qf_Contribution_upload");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Is status message correct?
- $this->assertTrue($this->isTextPresent("The contribution record has been saved."), "Status message didn't show up after saving!");
-
- // verify if Contribution is created
- $this->waitForElementPresent("xpath=//div[@class='view-content']//table[2]//tbody/tr[1]/td[8]/span/a[text()='View']");
-
- //click through to the Contribution view screen
- $this->click("xpath=//div[@class='view-content']//table[2]/tbody/tr[1]/td[8]/span/a[text()='View']");
- $this->waitForElementPresent("_qf_ContributionView_cancel-bottom");
-
- // View Contribution Record and test for expected values
- $expected = array(
- 'Financial Type' => 'Donation',
- 'Total Amount' => '$ 100.00',
- 'Contribution Status' => 'Pending',
- 'Payment Method' => 'Check',
- 'Check Number' => 'check #1041',
- );
- $this->webtestVerifyTabularData($expected);
-
- // go to soft creditor contact view page - this also does the soft credit check
- $this->click("xpath=id('ContributionView')/div[2]/div/div[1][contains(text(), 'Soft Credit')]/../div[2]/table[1]/tbody//tr/td[1]/a[contains(text(), '{$softCreditFname} {$softCreditLname}')]");
-
- $this->waitForPageToLoad($this->getTimeoutMsec());
- // go to contribution tab
- $this->waitForElementPresent("css=li#tab_contribute a");
- $this->click("css=li#tab_contribute a");
- $this->waitForElementPresent("link=Record Contribution (Check, Cash, EFT ...)");
-
- // verify soft credit details
- $expected = array(
- 4 => 'Donation',
- 2 => '$ 100.00',
- 6 => 'Pending',
- 1 => $contact['display_name'],
- );
- foreach ($expected as $value => $label) {
- $this->verifyText("xpath=id('Search')/div[2]/table[2]/tbody/tr[2]/td[$value]", preg_quote($label));
- }
- return $contact;
- }
-
- /**
- * @param array $contact
- */
- public function _testOnlineContribution($contact) {
-
- // Use default payment processor
- $processorName = 'Test Processor';
- $processorType = 'Dummy';
- $pageTitle = substr(sha1(rand()), 0, 7);
- $rand = 2 * rand(2, 50);
- $hash = substr(sha1(rand()), 0, 7);
- $amountSection = TRUE;
- $payLater = TRUE;
- $onBehalf = FALSE;
- $pledges = FALSE;
- $recurring = FALSE;
- $memberships = FALSE;
- $friend = FALSE;
- $profilePreId = 1;
- $profilePostId = NULL;
- $premiums = FALSE;
- $widget = FALSE;
- $pcp = FALSE;
- $memPriceSetId = NULL;
-
- // create a new online contribution page
- // create contribution page with randomized title and default params
- $pageId = $this->webtestAddContributionPage($hash,
- $rand,
- $pageTitle,
- array($processorName => $processorType),
- $amountSection,
- $payLater,
- $onBehalf,
- $pledges,
- $recurring,
- $memberships,
- $memPriceSetId,
- $friend,
- $profilePreId,
- $profilePostId,
- $premiums,
- $widget,
- $pcp
- );
-
- //logout
- $this->webtestLogout();
- $this->openCiviPage("contribute/transact", "reset=1&id=$pageId&action=preview", "_qf_Main_upload-bottom");
-
- $this->type("email-5", $contact['email']);
-
- $this->type("first_name", $contact['first_name']);
- $this->type("last_name", $contact['last_name']);
-
- $this->click("xpath=//div[@class='crm-section other_amount-section']//div[2]/input");
- $this->type("xpath=//div[@class='crm-section other_amount-section']//div[2]/input", 100);
- $this->click("xpath=//label[text()='Pay later label {$hash}']");
- $this->waitForAjaxContent();
- $streetAddress = "100 Main Street";
- $this->type("street_address-1", $streetAddress);
- $this->type("city-1", "San Francisco");
- $this->type("postal_code-1", "94117");
- $this->select("country-1", "value=1228");
- $this->select("state_province-1", "value=1001");
-
- $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
-
- $this->click("_qf_Confirm_next-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- //login to check contribution
- $this->webtestLogin();
-
- //Find Contribution
- $this->openCiviPage("contribute/search", "reset=1", "contribution_date_low");
- $this->click("xpath=//tr/td[1]/label[contains(text(), 'Contribution is a Test?')]/../../td[2]/label[contains(text(), 'Yes')]/preceding-sibling::input[1]");
- $this->type("sort_name", $contact['sort_name']);
- $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='contributionSearch']//table/tbody/tr[1]//td/span/a[text()='View']", FALSE);
- $this->click("xpath=//div[@id='contributionSearch']//table/tbody/tr[1]//td/span/a[text()='View']");
- // View Contribution Record and test for expected values
- $expected = array(
- 'From' => $contact['display_name'],
- 'Financial Type' => 'Donation',
- 'Total Amount' => '100.00',
- 'Contribution Status' => 'Pending : Pay Later',
- );
- $this->webtestVerifyTabularData($expected);
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Contribute_VerifySSLContributionTest
- */
-class WebTest_Contribute_VerifySSLContributionTest extends CiviSeleniumTestCase {
-
- protected $initialized = FALSE;
- protected $names = array();
- protected $pageId = 0;
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testPaymentProcessorsSSL() {
- $this->markTestSkipped('Skipping for now as it works fine locally.');
- $this->_initialize();
- $this->_tryPaymentProcessor($this->names['AuthNet']);
-
- // todo: write code to check other payment processors
- /*$this->_tryPaymentProcessor($this->names['Google_Checkout']);
- $this->_tryPaymentProcessor($this->names['PayPal']);
- $this->_tryPaymentProcessor($this->names['PayPal_Standard']);*/
- }
-
- public function _initialize() {
- if (!$this->initialized) {
- // log in
- $this->webtestLogin();
-
- // build names
- $hash = substr(sha1(rand()), 0, 7);
- $contributionPageTitle = "Verify SSL ($hash)";
- $this->names['PayPal'] = "PayPal Pro ($hash)";
- $this->names['AuthNet'] = "AuthNet ($hash)";
- //$this->names['PayPal_Standard'] = "PayPal Standard ($hash)";
-
- $processors = array();
- foreach ($this->names as $key => $val) {
- $processors[$val] = $key;
- }
-
- // create new contribution page
- $this->pageId = $this->webtestAddContributionPage(
- $hash,
- $rand = NULL,
- $pageTitle = $contributionPageTitle,
- $processor = $processors,
- $amountSection = TRUE,
- $payLater = FALSE,
- $onBehalf = FALSE,
- $pledges = FALSE,
- $recurring = FALSE,
- $membershipTypes = FALSE,
- $memPriceSetId = NULL,
- $friend = FALSE,
- $profilePreId = NULL,
- $profilePostId = NULL,
- $premiums = FALSE,
- $widget = FALSE,
- $pcp = FALSE,
- $isAddPaymentProcessor = TRUE,
- $isPcpApprovalNeeded = FALSE,
- $isSeparatePayment = FALSE,
- $honoreeSection = FALSE,
- $allowOtherAmount = TRUE
- );
-
- // enable verify ssl
- $this->openCiviPage("admin/setting/url", "reset=1");
- $this->click("id=CIVICRM_QFID_1_verifySSL");
- $this->click("id=_qf_Url_next-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->initialized = TRUE;
- }
- }
-
- /**
- * @param string $name
- */
- public function _tryPaymentProcessor($name) {
- // load contribution page
- $this->openCiviPage("contribute/transact", "reset=1&action=preview&id={$this->pageId}", "_qf_Main_upload-bottom");
-
- // fill out info
- $this->type("xpath=//div[@class='crm-section other_amount-section']//div[2]/input", "30");
- $this->type('email-5', "smith@example.com");
-
- // choose the payment processor
- $this->click("xpath=//label[text() = '{$name}']/preceding-sibling::input[1]");
-
- // do we need to add credit card details?
- if (strpos($name, "AuthNet") !== FALSE || strpos($name, "PayPal Pro") !== FALSE) {
- $this->webtestAddCreditCardDetails();
- list($firstName, $middleName, $lastName) = $this->webtestAddBillingDetails();
- }
-
- // submit contribution
- $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
-
- // confirm contribution
- $this->click("_qf_Confirm_next-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->assertStringsPresent("Payment Processor Error message");
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Event_AddEventTest
- */
-class WebTest_Event_AddEventTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testAddPaidEventNoTemplate() {
- // Log in using webtestLogin() method
- $this->webtestLogin();
-
- // Use default payment processor
- $processorName = 'Test Processor';
- $this->webtestAddPaymentProcessor($processorName);
-
- $this->openCiviPage("event/add", "reset=1&action=add");
-
- $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7);
- $eventDescription = "Here is a description for this conference.";
- $this->_testAddEventInfo($eventTitle, $eventDescription);
-
- $streetAddress = "100 Main Street";
- $this->_testAddLocation($streetAddress);
-
- $this->_testAddReminder($eventTitle);
-
- $this->_testAddFees(FALSE, FALSE, $processorName);
-
- // intro text for registration page
- $registerIntro = "Fill in all the fields below and click Continue.";
- $multipleRegistrations = TRUE;
- $this->_testAddOnlineRegistration($registerIntro, $multipleRegistrations);
-
- $eventInfoStrings = array($eventTitle, $eventDescription, $streetAddress);
- $eventId = $this->_testVerifyEventInfo($eventTitle, $eventInfoStrings);
-
- $registerStrings = array("225.00", "Member", "300.00", "Non-member", $registerIntro);
- $registerUrl = $this->_testVerifyRegisterPage($registerStrings);
-
- $numberRegistrations = 3;
- $anonymous = TRUE;
- $this->_testOnlineRegistration($registerUrl, $numberRegistrations, $anonymous);
-
- // Now test making a copy of the event
- $this->webtestLogin();
- $this->openCiviPage("event/manage", "reset=1&action=copy&id=$eventId");
- $this->_testVerifyEventInfo('Copy of ' . $eventTitle, $eventInfoStrings);
- $this->_testVerifyRegisterPage($registerStrings);
- }
-
- public function testAddPaidEventDiscount() {
-
- // Log in using webtestLogin() method
- $this->webtestLogin();
-
- // Use default payment processor
- $processorName = 'Test Processor';
- $this->webtestAddPaymentProcessor($processorName);
-
- $this->openCiviPage("event/add", "reset=1&action=add");
-
- $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7);
- $eventDescription = "Here is a description for this conference.";
- $this->_testAddEventInfo($eventTitle, $eventDescription);
-
- $streetAddress = "100 Main Street";
- $this->_testAddLocation($streetAddress);
-
- $this->_testAddReminder($eventTitle);
-
- $this->_testAddFees(TRUE, FALSE, $processorName);
-
- // intro text for registration page
- $registerIntro = "Fill in all the fields below and click Continue.";
- $multipleRegistrations = TRUE;
- $this->_testAddOnlineRegistration($registerIntro, $multipleRegistrations);
-
- $discountFees = array("225.00", "300.00");
-
- $eventInfoStrings = array($eventTitle, $eventDescription, $streetAddress);
- $this->_testVerifyEventInfo($eventTitle, $eventInfoStrings, $discountFees);
-
- $registerStrings = array_push($discountFees, "Member", "Non-member", $registerIntro);
- $registerUrl = $this->_testVerifyRegisterPage($registerStrings);
-
- $numberRegistrations = 3;
- $anonymous = TRUE;
- $this->_testOnlineRegistration($registerUrl, $numberRegistrations, $anonymous);
- }
-
- public function testDeletePriceSetDiscount() {
-
- // Log in using webtestLogin() method
- $this->webtestLogin();
-
- // Use default payment processor
- $processorName = 'Test Processor';
- $this->webtestAddPaymentProcessor($processorName);
-
- $this->openCiviPage("event/add", "reset=1&action=add");
-
- $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7);
- $eventDescription = "Here is a description for this conference.";
- $this->_testAddEventInfo($eventTitle, $eventDescription);
-
- $streetAddress = "100 Main Street";
- $this->_testAddLocation($streetAddress);
-
- //Add two discounts
- $discount = $this->_testAddFees(TRUE, FALSE, $processorName, TRUE);
-
- // intro text for registration page
- $registerIntro = "Fill in all the fields below and click Continue.";
- $multipleRegistrations = TRUE;
- $this->_testAddOnlineRegistration($registerIntro, $multipleRegistrations);
-
- $discountFees = array("225.00", "300.00");
-
- $eventInfoStrings = array($eventTitle, $eventDescription, $streetAddress);
- $id = $this->_testVerifyEventInfo($eventTitle, $eventInfoStrings, $discountFees);
-
- $registerStrings = array_push($discountFees, "Member", "Non-member", $registerIntro);
- $registerUrl = $this->_testVerifyRegisterPage($registerStrings);
-
- //Add Price Set now
- $this->openCiviPage("event/manage/fee", "reset=1&action=update&id=$id", "_qf_Fee_upload-bottom");
- $this->click("xpath=//a[@id='quickconfig']");
- $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']");
- $this->click("xpath=//div[@class='ui-dialog-buttonset']//button/span[text()='Continue']");
-
- //Assert quick config change and discount deletion
- $this->openCiviPage("admin/price", "reset=1");
- foreach ($discount as $key => $val) {
- $this->waitForTextPresent($val);
- }
- }
-
- public function testAddDeleteEventDiscount() {
-
- // Log in using webtestLogin() method
- $this->webtestLogin();
-
- // Use default payment processor
- $processorName = 'Test Processor';
- $this->webtestAddPaymentProcessor($processorName);
-
- $this->openCiviPage("event/add", "reset=1&action=add");
-
- $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7);
- $eventDescription = "Here is a description for this conference.";
- $this->_testAddEventInfo($eventTitle, $eventDescription);
-
- $streetAddress = "100 Main Street";
- $this->_testAddLocation($streetAddress);
-
- //Add two discounts
- $discount = $this->_testAddFees(TRUE, FALSE, $processorName, TRUE);
-
- // intro text for registration page
- $registerIntro = "Fill in all the fields below and click Continue.";
- $multipleRegistrations = TRUE;
- $this->_testAddOnlineRegistration($registerIntro, $multipleRegistrations);
-
- $discountFees = array("225.00", "300.00");
-
- $eventInfoStrings = array($eventTitle, $eventDescription, $streetAddress);
- $id = $this->_testVerifyEventInfo($eventTitle, $eventInfoStrings, $discountFees);
-
- $registerStrings = array_push($discountFees, "Member", "Non-member", $registerIntro);
- $registerUrl = $this->_testVerifyRegisterPage($registerStrings);
- //Delete the discount
- $this->_deleteDiscount($id, $eventTitle, $discount);
- }
-
- /**
- * @param int $id
- * @param $eventTitle
- * @param $discount
- */
- public function _deleteDiscount($id, $eventTitle, $discount) {
- $this->openCiviPage("event/manage/fee", "reset=1&action=update&id=$id", "_qf_Fee_upload-bottom");
- $this->type("discount_name_2", "");
- $this->click("xpath=//tr[@id='discount_2']/td[3]/a");
- $this->click("xpath=//tr[@id='discount_2']/td[4]/a");
- $this->type("discounted_value_1_2", "");
- $this->type("discounted_value_2_2", "");
- $this->click("_qf_Fee_upload-bottom");
- $this->waitForText('crm-notification-container', "'Fees' information has been saved.");
- //Assertions
- $this->openCiviPage("admin/price", "reset=1");
- $this->assertStringsPresent($discount[1]);
- }
-
- public function testAddPaidEventWithTemplate() {
-
- // Log in using webtestLogin() method
- $this->webtestLogin();
-
- // Use default payment processor
- $processorName = 'Test Processor';
- $this->webtestAddPaymentProcessor($processorName);
-
- $this->openCiviPage("event/add", "reset=1&action=add");
-
- $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7);
- $eventDescription = "Here is a description for this conference.";
- // Select paid online registration template.
- $templateID = 6;
- $eventTypeID = 1;
- $this->_testAddEventInfoFromTemplate($eventTitle, $eventDescription, $templateID, $eventTypeID);
-
- $streetAddress = "100 Main Street";
- $this->_testAddLocation($streetAddress);
-
- $this->_testAddFees(FALSE, FALSE, $processorName);
-
- // intro text for registration page
- $registerIntro = "Fill in all the fields below and click Continue.";
- $this->_testAddOnlineRegistration($registerIntro);
-
- // $eventInfoStrings = array( $eventTitle, $eventDescription, $streetAddress );
- $eventInfoStrings = array($eventTitle, $streetAddress);
- $this->_testVerifyEventInfo($eventTitle, $eventInfoStrings);
-
- $registerStrings = array("225.00", "Member", "300.00", "Non-member", $registerIntro);
- $this->_testVerifyRegisterPage($registerStrings);
- }
-
- public function testAddFreeEventWithTemplate() {
-
- // Log in using webtestLogin() method
- $this->webtestLogin();
-
- $this->openCiviPage("event/add", "reset=1&action=add");
-
- $eventTitle = 'My Free Meeting - ' . substr(sha1(rand()), 0, 7);
- $eventDescription = "Here is a description for this free meeting.";
- // Select "Free Meeting with Online Registration" template (id = 5).
- $templateID = 5;
- $eventTypeID = 4;
-
- $this->_testAddEventInfoFromTemplate($eventTitle, $eventDescription, $templateID, $eventTypeID);
-
- $streetAddress = "100 Main Street";
-
- $this->_testAddLocation($streetAddress);
-
- // Go to Fees tab and check that Paid Event is false (No)
- $this->click("link=Fees");
- $this->waitForElementPresent("_qf_Fee_upload-bottom");
- $this->verifyChecked("CIVICRM_QFID_0_is_monetary");
-
- // intro text for registration page
- $registerIntro = "Fill in all the fields below and click Continue.";
- $this->_testAddOnlineRegistration($registerIntro);
-
- // $eventInfoStrings = array( $eventTitle, $eventDescription, $streetAddress );
- $eventInfoStrings = array($eventTitle, $streetAddress);
- $this->_testVerifyEventInfo($eventTitle, $eventInfoStrings);
-
- $registerStrings = array($registerIntro);
- $this->_testVerifyRegisterPage($registerStrings);
- // make sure paid_event div is NOT present since this is a free event
- $this->verifyElementNotPresent("css=div.paid_event-section");
- }
-
- public function testUnpaidPaid() {
- $this->markTestSkipped('Skipping for now as it works fine locally.');
- // Log in using webtestLogin() method
- $this->webtestLogin();
-
- $this->openCiviPage("event/add", "reset=1&action=add");
- $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7);
- $eventDescription = "Here is a description for this conference.";
- $this->_testAddEventInfo($eventTitle, $eventDescription);
-
- //add fee section with pay later checked
- $this->_testAddFees(FALSE, FALSE, NULL, FALSE, TRUE);
-
- //make the event unpaid
- $this->waitForElementPresent("_qf_Fee_upload-bottom");
- $this->assertChecked('is_pay_later');
- $this->click("CIVICRM_QFID_0_is_monetary");
-
- $this->click("_qf_Fee_upload-bottom");
- $this->waitForText('crm-notification-container', "'Fees' information has been saved.");
- $this->waitForAjaxContent();
-
- //check if pay later option is disabled
- $this->click('CIVICRM_QFID_1_is_monetary');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForElementPresent('is_pay_later');
- $this->assertNotChecked('is_pay_later');
- }
-
- public function testAjaxCustomGroupLoad() {
- $this->webtestLogin();
-
- $triggerElement = array('name' => 'event_type_id', 'type' => 'select');
- $customSets = array(
- array('entity' => 'Event', 'subEntity' => 'Conference', 'triggerElement' => $triggerElement),
- );
-
- $pageUrl = array('url' => 'event/add', 'args' => "reset=1&action=add");
- $this->customFieldSetLoadOnTheFlyCheck($customSets, $pageUrl);
- }
-
- /**
- * @param $eventTitle
- * @param $eventDescription
- */
- public function _testAddEventInfo($eventTitle, $eventDescription) {
- $this->waitForElementPresent("_qf_EventInfo_upload-bottom");
-
- $this->select("event_type_id", "value=1");
-
- // Attendee role s/b selected now.
- $this->select("default_role_id", "value=1");
-
- // Enter Event Title, Summary and Description
- $this->type("title", $eventTitle);
- $this->type("summary", "This is a great conference. Sign up now!");
-
- // Type description in ckEditor (fieldname, text to type, editor)
- $this->fillRichTextField("description", $eventDescription, 'CKEditor');
-
- // Choose Start and End dates.
- // Using helper webtestFillDate function.
- $this->webtestFillDateTime("start_date", "+1 week");
- $this->webtestFillDateTime("end_date", "+1 week 1 day 8 hours ");
- $this->waitForElementPresent('max_participants');
- $this->type("max_participants", "50");
- $this->click("is_map");
- $this->click("is_public");
- $this->clickLink("_qf_EventInfo_upload-bottom");
- }
-
- /**
- * @param $eventTitle
- * @param $eventDescription
- * @param int $templateID
- * @param int $eventTypeID
- */
- public function _testAddEventInfoFromTemplate($eventTitle, $eventDescription, $templateID, $eventTypeID) {
- $this->waitForElementPresent("_qf_EventInfo_upload-bottom");
-
- // Select event template. Use option value, not label - since labels can be translated and test would fail
- $this->select("template_id", "value={$templateID}");
-
- // Wait for event type to be filled in (since page refreshes)
- $this->waitForAjaxContent();
- $this->verifySelectedValue("event_type_id", $eventTypeID);
-
- // Attendee role s/b selected now.
- $this->verifySelectedValue("default_role_id", "1");
-
- // Enter Event Title, Summary and Description
- $this->type("title", $eventTitle);
-
- $this->type("summary", "This is a great conference. Sign up now!");
-
- // Type description in ckEditor (fieldname, text to type, editor)
- $this->fillRichTextField("description", $eventDescription, 'CKEditor');
-
- // Choose Start and End dates.
- // Using helper webtestFillDate function.
- $this->webtestFillDateTime("start_date", "+1 week");
- $this->webtestFillDateTime("end_date", "+1 week 1 day 8 hours ");
-
- $this->type("max_participants", "50");
- $this->click("is_map");
- $this->clickLink("_qf_EventInfo_upload-bottom");
- }
-
- /**
- * @param $streetAddress
- */
- public function _testAddLocation($streetAddress) {
- // Wait for Location tab form to load
- $this->waitForAjaxContent();
- $this->waitForElementPresent("_qf_Location_upload-bottom");
-
- // Fill in address fields
- $streetAddress = "100 Main Street";
- $this->type("address_1_street_address", $streetAddress);
- $this->type("address_1_city", "San Francisco");
- $this->type("address_1_postal_code", "94117");
- $this->select('address_1_country_id', 'UNITED STATES');
- $this->select("address_1_state_province_id", "value=1004");
- $this->type("email_1_email", "info@civicrm.org");
-
- $this->click("_qf_Location_upload-bottom");
-
- // Wait for "saved" status msg
- $this->waitForText('crm-notification-container', "'Event Location' information has been saved.");
- }
-
- /**
- * @param bool $discount
- * @param bool $priceSet
- * @param string $processorName
- * @param bool $double
- * @param bool $payLater
- *
- * @return array
- */
- public function _testAddFees($discount = FALSE, $priceSet = FALSE, $processorName = "PP Pro", $double = FALSE, $payLater = FALSE) {
- $discount1 = "Early-bird" . substr(sha1(rand()), 0, 7);
- $discount2 = "";
- // Go to Fees tab
- $this->click("link=Fees");
- $this->waitForElementPresent("_qf_Fee_upload-bottom");
- $this->click("CIVICRM_QFID_1_is_monetary");
-
- if ($payLater) {
- $this->click('is_pay_later');
- $this->fillRichTextField('pay_later_receipt', 'testing later instructions');
- }
- else {
- $this->uncheck('is_pay_later');
- }
-
- if ($processorName) {
- $this->select2('payment_processor', $processorName, TRUE);
- }
- $this->select("financial_type_id", "value=4");
- if ($priceSet) {
- // get one - TBD
- }
- else {
- $this->type("label_1", "Member");
- $this->type("value_1", "225.00");
- $this->type("label_2", "Non-member");
- $this->type("value_2", "300.00");
- $this->click("CIVICRM_QFID_1_6");
- }
-
- if ($discount) {
- // enter early bird discount fees
- $this->click("is_discount");
- $this->waitForElementPresent("discount_name_1");
- $this->type("discount_name_1", $discount1);
- $this->webtestFillDate("discount_start_date_1", "-3 week");
- $this->webtestFillDate("discount_end_date_1", "-2 week");
- $this->clickLink("_qf_Fee_submit", "discounted_value_1_1");
-
- $this->type("discounted_value_1_1", "225.00");
- $this->type("discounted_value_2_1", "300.00");
-
- if ($double) {
- $discount2 = "Early-bird" . substr(sha1(rand()), 0, 7);
- // enter early bird discount fees
- $this->click("link=another discount set");
- $this->waitForElementPresent("discount_name_2");
- $this->type("discount_name_2", $discount2);
- $this->webtestFillDate("discount_start_date_2", "-1 week");
- $this->webtestFillDate("discount_end_date_2", "+1 week");
- $this->clickLink("_qf_Fee_submit", "discounted_value_2_1");
- $this->type("discounted_value_1_2", "225.00");
- $this->type("discounted_value_2_2", "300.00");
- }
- $this->click("xpath=//fieldset[@id='discount']/fieldset/table/tbody/tr[2]/td[3]/input");
- }
- $this->click("_qf_Fee_upload-bottom");
-
- // Wait for "saved" status msg
- $this->waitForText('crm-notification-container', "'Fees' information has been saved");
- return array($discount1, $discount2);
- }
-
- /**
- * @param $registerIntro
- * @param bool $multipleRegistrations
- */
- public function _testAddOnlineRegistration($registerIntro, $multipleRegistrations = FALSE, $allowSelfService = FALSE) {
- // Go to Online Registration tab
- $this->click("link=Online Registration");
- $this->waitForElementPresent("_qf_Registration_upload-bottom");
-
- $isChecked = $this->isChecked('is_online_registration');
- if (!$isChecked) {
- $this->click("is_online_registration");
- }
- $this->assertChecked("is_online_registration");
- if ($multipleRegistrations) {
- $isChecked = $this->isChecked('is_multiple_registrations');
- if (!$isChecked) {
- $this->click("is_multiple_registrations");
- }
- $this->assertChecked("is_multiple_registrations");
- }
-
- //enable 'Allow self-service'
- if ($allowSelfService) {
- $isChecked = $this->isChecked('allow_selfcancelxfer');
- if (!$isChecked) {
- $this->click("allow_selfcancelxfer");
- }
- $this->assertChecked("allow_selfcancelxfer");
- }
- $this->fillRichTextField("intro_text", $registerIntro, 'CKEditor', TRUE);
-
- // enable confirmation email
- $this->click("CIVICRM_QFID_1_is_email_confirm");
- $this->type("confirm_from_name", "Jane Doe");
-
- $this->type("confirm_from_email", "jane.doe@example.org");
-
- $this->click("_qf_Registration_upload-bottom");
- $this->waitForText('crm-notification-container', "'Online Registration' information has been saved.");
- }
-
- /**
- * @param $eventTitle
- * @param $eventInfoStrings
- * @param null $eventFees
- *
- * @return null
- */
- public function _testVerifyEventInfo($eventTitle, $eventInfoStrings, $eventFees = NULL) {
- // verify event input on info page
- // start at Manage Events listing
- $this->openCiviPage("event/manage", "reset=1");
- $this->click("link=$eventTitle");
-
- // Look for Register button
- $this->waitForElementPresent("link=Register Now");
-
- // Check for correct event info strings
- $this->assertStringsPresent($eventInfoStrings);
-
- // Optionally verify event fees (especially for discounts)
- if ($eventFees) {
- $this->assertStringsPresent($eventFees);
-
- }
- return $this->urlArg('id');
- }
-
- /**
- * @param $registerStrings
- *
- * @return string
- */
- public function _testVerifyRegisterPage($registerStrings) {
- // Go to Register page and check for intro text and fee levels
- $this->click("link=Register Now");
- $this->waitForElementPresent("_qf_Register_upload-bottom");
- $this->assertStringsPresent($registerStrings);
- return $this->getLocation();
- }
-
- /**
- * @param $registerUrl
- * @param int $numberRegistrations
- * @param bool $anonymous
- * @param bool $isPayLater
- * @param array $participantEmailInfo
- * @param null $paymentProcessor
- *
- * @return array
- */
- public function _testOnlineRegistration($registerUrl, $numberRegistrations = 1, $anonymous = TRUE, $isPayLater = FALSE, $participantEmailInfo = array(), $paymentProcessor = NULL) {
- $infoPassed = FALSE;
- if (!empty($participantEmailInfo)) {
- $infoPassed = TRUE;
- }
- if ($anonymous) {
- $this->webtestLogout();
- }
- $primaryParticipantInfo = array();
- $this->open($registerUrl);
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->waitForElementPresent('additional_participants');
-
- $this->select("additional_participants", "value=" . $numberRegistrations);
-
- if ($infoPassed) {
- $primaryParticipantInfo['first_name'] = $participantEmailInfo[0]['first_name'];
- $primaryParticipantInfo['last_name'] = $participantEmailInfo[0]['last_name'];
- $primaryParticipantInfo['email'] = $participantEmailInfo[0]['email'];
- }
- else {
- $primaryParticipantInfo['first_name'] = "Jane";
- $primaryParticipantInfo['last_name'] = "Smith" . substr(sha1(rand()), 0, 7);
- $primaryParticipantInfo['email'] = "smith" . substr(sha1(rand()), 0, 7) . "@example.org";
- }
-
- $this->type("first_name", $primaryParticipantInfo['first_name']);
- $this->type("last_name", $primaryParticipantInfo['last_name']);
- $this->type("email-Primary", $primaryParticipantInfo['email']);
-
- if (!$isPayLater) {
- if ($paymentProcessor) {
- $paymentProcessorEle = $this->getAttribute("xpath=//form[@id='Register']//label[contains(text(), '{$paymentProcessor}')]/@for");
- $this->click($paymentProcessorEle);
- }
- $this->select("credit_card_type", "value=Visa");
- $this->type("credit_card_number", "4111111111111111");
- $this->type("cvv2", "000");
- $this->select("credit_card_exp_date[M]", "value=1");
- $this->select("credit_card_exp_date[Y]", "value=2020");
- $this->type("billing_first_name", $primaryParticipantInfo['first_name']);
- $this->type("billing_last_name", $primaryParticipantInfo['last_name']);
- $this->type("billing_street_address-5", "15 Main St.");
- $this->type(" billing_city-5", "San Jose");
- $this->select("billing_country_id-5", "value=1228");
- $this->select("billing_state_province_id-5", "value=1004");
- $this->type("billing_postal_code-5", "94129");
- }
-
- $this->click("_qf_Register_upload-bottom");
-
- if ($numberRegistrations > 1) {
- for ($i = 1; $i <= $numberRegistrations; $i++) {
- $this->waitForPageToLoad($this->getTimeoutMsec());
- // Look for Skip button
- $this->waitForElementPresent("_qf_Participant_{$i}_next_skip-Array");
-
- if ($infoPassed) {
- $this->type("first_name", $participantEmailInfo[$i]['first_name']);
- $this->type("last_name", $participantEmailInfo[$i]['last_name']);
- $this->type("email-Primary", $participantEmailInfo[$i]['email']);
- }
- else {
- $this->type("first_name", "Jane Add $i");
- $this->type("last_name", "Smith" . substr(sha1(rand()), 0, 7));
- $this->type("email-Primary", "smith" . substr(sha1(rand()), 0, 7) . "@example.org");
- }
-
- $this->click("_qf_Participant_{$i}_next");
- }
- }
-
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForElementPresent("_qf_Confirm_next-bottom");
- $confirmStrings = array("Event Fee(s)");
- if (!$isPayLater) {
- $confirmStrings += array("Billing Name and Address", "Credit Card Information");
- }
- $this->assertStringsPresent($confirmStrings);
- $this->click("_qf_Confirm_next-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $thankStrings = array("Thank You for Registering", "Event Total");
- if (!$isPayLater) {
- $thankStrings = array("Transaction Date");
- }
- else {
- $thankStrings += array("testing later instructions");
- }
- $this->assertStringsPresent($thankStrings);
- return $primaryParticipantInfo;
- }
-
- /**
- * @param $eventTitle
- */
- public function _testAddReminder($eventTitle) {
- // Go to Schedule Reminders tab
- $this->click("link=Schedule Reminders");
- $this->waitForElementPresent("newScheduleReminder");
- $this->click("newScheduleReminder");
- $this->waitForElementPresent("_qf_ScheduleReminders_next-bottom");
- $this->type("title", "Event Reminder for " . $eventTitle);
- $this->select('entity', 'label=Registered');
-
- $this->select('start_action_offset', 'label=1');
- $this->select('start_action_condition', 'label=after');
- $this->click('is_repeat');
- $this->select('repetition_frequency_interval', 'label=2');
- $this->select('end_date', 'label=Event End Date');
- $this->click('recipient');
- $this->select('recipient', 'label=Participant Role');
- // $this->select( 'recipient_listing', 'value=1' );
-
- // Fill Subject
- $subject = 'subject' . substr(sha1(rand()), 0, 4);
- $this->type('subject', $subject);
- $this->fillRichTextField("html_message", "This is the test HTML version here!!!", 'CKEditor');
-
- $this->type("text_message", "This is the test text version here!!!");
- //click on save
- $this->click('_qf_ScheduleReminders_next-bottom');
- $this->waitForElementPresent("link=Add Reminder");
-
- $this->waitForElementPresent("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[7]/span/a[1]");
-
- $verifyText = array(
- 1 => 'Event Reminder for ' . $eventTitle,
- 3 => '1 hour after Event Start Date',
- 4 => 'Registered',
- 5 => 'Yes',
- 6 => 'Yes',
- );
-
- $this->waitForElementPresent("xpath=//form[@id='ScheduleReminders']//div[@id='option11_wrapper']");
- //verify the fields for Event Reminder selector
- foreach ($verifyText as $key => $value) {
- $this->verifyText("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody//tr/td[$key]", $value);
- }
- }
-
- public function testEventAddMultipleParticipant() {
- $this->markTestSkipped('Skipping for now as it works fine locally.');
- // Log in using webtestLogin() method
- $this->webtestLogin();
- $this->openCiviPage("event/add", "reset=1&action=add");
-
- $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7);
- $eventDescription = "Here is a description for this conference.";
- $this->_testAddEventInfo($eventTitle, $eventDescription);
- $streetAddress = "100 Main Street";
- $this->_testAddLocation($streetAddress);
-
- $this->_testAddFees(FALSE, FALSE, "Test Processor", FALSE, TRUE);
- $registerIntro = "Fill in all the fields below and click Continue.";
- $multipleRegistrations = TRUE;
- $this->_testAddOnlineRegistration($registerIntro, $multipleRegistrations);
- $eventInfoStrings = array($eventTitle, $eventDescription, $streetAddress);
- $eventId = $this->_testVerifyEventInfo($eventTitle, $eventInfoStrings);
-
- $registerStrings = array("225.00", "Member", "300.00", "Non-member", $registerIntro);
- $registerUrl = $this->_testVerifyRegisterPage($registerStrings);
- $numberRegistrations = 3;
- $anonymous = TRUE;
-
- // CRM-12615 add additional participants and check email, amount
- $primaryParticipant = array(
- 'email' => "smith" . substr(sha1(rand()), 0, 7) . "@example.org",
- 'first_name' => "Kate",
- 'last_name' => "Simth" . substr(sha1(rand()), 0, 7),
- );
- $secParticipant = array(
- 'email' => "smith" . substr(sha1(rand()), 0, 7) . "@example.org",
- 'first_name' => "Kate Add 1",
- 'last_name' => "Simth" . substr(sha1(rand()), 0, 7),
- );
- $thirdParticipant = array(
- 'email' => "smith" . substr(sha1(rand()), 0, 7) . "@example.org",
- 'first_name' => "Kate Add 2",
- 'last_name' => "Simth" . substr(sha1(rand()), 0, 7),
- );
-
- $participantEmails = array($primaryParticipant, $secParticipant, $thirdParticipant);
- $addtlPart = array($secParticipant, $thirdParticipant);
- $primaryParticipantInfo = $this->_testOnlineRegistration($registerUrl, 2, $anonymous, FALSE, $participantEmails, "Test Processor");
- $primaryDisplayName = "{$primaryParticipantInfo['first_name']} {$primaryParticipantInfo['last_name']}";
- $this->webtestLogin();
- $this->openCiviPage("event/search", "reset=1");
- $this->select2("event_id", $eventTitle, FALSE);
- $this->clickLink('_qf_Search_refresh');
- $this->waitForElementPresent("xpath=//div[@id='participantSearch']/table/tbody//tr/td[3]/a");
- $this->verifyText("xpath=//div[@id='participantSearch']/table/tbody//tr/td[@class='crm-participant-sort_name']/a[contains(text(),
- '{$secParticipant['last_name']}, {$secParticipant['first_name']}')]/../../td[6]", preg_quote('225.00'));
- $this->verifyText("xpath=//div[@id='participantSearch']/table/tbody//tr/td[@class='crm-participant-sort_name']/a[contains(text(),
- '{$thirdParticipant['last_name']}, {$thirdParticipant['first_name']}')]/../../td[6]", preg_quote('225.00'));
-
- //CRM-12618 check edit screen of additional participant and ensuring record_contribution not present
- foreach ($addtlPart as $value) {
- $this->clickAjaxLink("xpath=//div[@id='participantSearch']/table/tbody//tr/td[3]/a[contains(text(),
- '{$value['last_name']}, {$value['first_name']}')]/../../td[11]/span/a[2][contains(text(), 'Edit')]",
- '_qf_Participant_upload-bottom');
- $this->assertTrue(
- $this->isElementPresent("xpath=//tr[@class='crm-participant-form-block-registered-by']/td[2]/a[contains(text(),
- '$primaryDisplayName')]"), 'Registered By info is wrong on additional participant edit form');
- $this->assertTrue(
- $this->isElementPresent(
- "xpath=//table/tbody/tr[@class='crm-participant-form-block-displayName']/td[2][contains(text(),
- '{$value['first_name']} {$value['last_name']}')]"),
- 'Wrong Participant edit form'
- );
- $this->assertFalse($this->isElementPresent('record_contribution'),
- 'Record Payment checkbox showed up wrongly for additional participant edit screen');
- $this->click("_qf_Participant_cancel-top");
- }
-
- //unselect the payment processor configured
- $this->openCiviPage("event/manage/fee", "reset=1&action=update&id={$eventId}", '_qf_Fee_upload-bottom');
- $this->click("_qf_Fee_upload-bottom");
- $this->waitForText('crm-notification-container', "'Fees' information has been saved.");
-
- // add participant and 3 additional participant and change status of participant from edit participant
- $this->_testOnlineRegistration($registerUrl, $numberRegistrations, $anonymous, TRUE);
- $this->webtestLogin();
-
- $this->openCiviPage("event/search?reset=1", "reset=1");
- $this->select2("event_id", $eventTitle, FALSE);
- $this->multiselect2('participant_status_id', array('Pending (pay later)'));
- $this->clickLink('_qf_Search_refresh');
- $this->waitForElementPresent("xpath=//div[@id='participantSearch']/table/tbody//tr/td[11]/span/a[2][text()='Edit']");
-
- $uRL = $this->getAttribute("xpath=//div[@id='participantSearch']/table/tbody//tr/td[11]/span/a[2][text()='Edit']@href");
- $this->click("xpath=//div[@id='participantSearch']/table/tbody//tr/td[11]/span/a[2][text()='Edit']");
- $this->waitForElementPresent("status_id");
- $this->select('status_id', 'label=Registered');
- $this->waitForElementPresent("record_contribution");
- $this->click('record_contribution');
- $this->waitForElementPresent("contribution_status_id");
- $this->select('contribution_status_id', 'label=Completed');
- $pID = $this->urlArg('id', $uRL);
- $contributionID = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $pID, 'contribution_id', 'participant_id');
- $this->click('_qf_Participant_upload-top');
- $this->waitForElementPresent("xpath=//div[@id='participantSearch']/table/tbody//tr/td[11]/span/a[text()='Edit']");
- $this->waitForElementPresent("xpath=//div[@id='participantSearch']/table/tbody//tr/td[11]/span/a[text()='View']");
- $this->click("xpath=//div[@id='participantSearch']/table/tbody//tr/td[11]/span/a[text()='View']");
- $this->waitForElementPresent("css=.ui-dialog");
- $this->waitForAjaxContent();
- $this->verifyFinancialRecords($contributionID);
-
- // add participant and 3 additional participant and change status of participant from edit contribution
- $this->_testOnlineRegistration($registerUrl, $numberRegistrations, $anonymous, TRUE);
- $this->webtestLogin();
-
- $this->openCiviPage("event/search?reset=1", "reset=1");
- $this->select2("event_id", $eventTitle, FALSE);
- $this->multiselect2('participant_status_id', array('Pending (pay later)'));
- $this->clickLink('_qf_Search_refresh');
- $this->waitForElementPresent("xpath=//div[@id='participantSearch']/table/tbody//tr/td[11]/span/a[text()='View']");
- $uRL = $this->getAttribute("xpath=//div[@id='participantSearch']/table/tbody//tr/td[11]/span/a[text()='View']@href");
- $this->click("xpath=//div[@id='participantSearch']/table/tbody//tr/td[11]/span/a[text()='View']");
- $pID = $this->urlArg('id', $uRL);
- $contributionID = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $pID, 'contribution_id', 'participant_id');
- $this->waitForElementPresent("xpath=//tr[@id='rowid$contributionID']/td[8]/span//a[text()='Edit']");
- $this->click("xpath=//tr[@id='rowid$contributionID']/td[8]/span//a[text()='Edit']");
- $this->waitForElementPresent("_qf_Contribution_upload-bottom");
- $this->select('contribution_status_id', 'label=Completed');
- $this->clickLink('_qf_Contribution_upload-bottom', '_qf_ParticipantView_cancel-bottom', FALSE);
- $this->waitForAjaxContent();
- $this->verifyFinancialRecords($contributionID);
- }
-
- /**
- * @param int $contributionID
- */
- public function verifyFinancialRecords($contributionID) {
- // check count for civicrm_contribution and civicrm_financial_item in civicrm_entity_financial_trxn
- $query = "SELECT COUNT(DISTINCT(c1.id)) civicrm_contribution, COUNT(c2.id) civicrm_financial_item FROM civicrm_entity_financial_trxn c1
-LEFT JOIN civicrm_entity_financial_trxn c2 ON c1.financial_trxn_id = c2.financial_trxn_id AND c2.entity_table ='civicrm_financial_item'
-LEFT JOIN civicrm_financial_item cfi ON cfi.id = c2.entity_id
-WHERE c1.entity_table = 'civicrm_contribution' AND c1.entity_id = %1 AND cfi.status_id = 1";
- $params = array(1 => array($contributionID, 'Integer'));
- $dao = CRM_Core_DAO::executeQuery($query, $params);
- $dao->fetch();
- $this->assertEquals('2', $dao->civicrm_contribution, 'civicrm_financial_trxn count does not match');
- $this->assertEquals('8', $dao->civicrm_financial_item, 'civicrm_financial_item count does not match');
- $query = "SELECT COUNT(cft.id) civicrm_financial_trxn FROM civicrm_entity_financial_trxn ceft
-INNER JOIN civicrm_financial_trxn cft ON ceft.financial_trxn_id = cft.id
-WHERE ceft.entity_id = %1 AND ceft.entity_table = 'civicrm_contribution'";
- $dao = CRM_Core_DAO::executeQuery($query, $params);
- $dao->fetch();
- $this->assertEquals('2', $dao->civicrm_financial_trxn, 'civicrm_financial_trxn count does not match');
- }
-
- public function testEventApprovalRegistration() {
- $this->webtestLogin();
-
- //Participant Status
- $this->openCiviPage("admin/participant_status", "reset=1&action=browse");
- foreach (array('Awaiting approval', 'Pending from approval', 'Rejected') as $label) {
- $status = $this->webtest_civicrm_api("ParticipantStatusType", "getsingle", array('label' => $label));
- $this->_testEnableParticipantStatuses($status['id']);
- $this->isElementPresent("xpath=//tr[@id='participant_status_type-{$status['id']}']/td[9]/span/a[2][text()='Disable']");
- }
-
- //Create New Event
-
- $this->openCiviPage('event/add', 'reset=1&action=add', '_qf_EventInfo_upload-bottom');
- $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7);
- $email = 'Smith' . substr(sha1(rand()), 0, 7) . '@example.com';
- $eventDescription = 'Here is a description for this conference.';
- $this->select('event_type_id', 'value=1');
-
- // Attendee role s/b selected now.
- $this->select('default_role_id', 'value=1');
- // Enter Event Title, Summary and Description
- $this->type('title', $eventTitle);
- $this->type('summary', 'This is a great conference. Sign up now!');
-
- // Type description in ckEditor (fieldname, text to type, editor)
- $this->fillRichTextField('description', $eventDescription);
- $this->type('max_participants', '50');
- $this->click('is_map');
- $this->click('_qf_EventInfo_upload-bottom');
-
- // Wait for Location tab form to load
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Go to Fees tab
- $this->click('link=Fees');
- $id = $this->urlArg('id');
- $this->waitForElementPresent('_qf_Fee_upload-bottom');
- $this->click('CIVICRM_QFID_1_is_monetary');
- $processorName = 'Test Processor';
- $this->select2('payment_processor', $processorName, TRUE);
-
- $this->select('financial_type_id', 'label=Event Fee');
- $this->type("label[1]", 'Junior Stars');
- $this->type("value[1]", '500.00');
- $this->type("label[2]", 'Super Stars');
- $this->type("value[2]", '1000.00');
- $this->check('default');
- $this->click('_qf_Fee_upload-bottom');
- $this->waitForText('crm-notification-container', "'Fees' information has been saved.");
-
- // intro text for registration page
- $registerIntro = 'Fill in all the fields below and click Continue.';
-
- // Go to Online Registration tab
- $this->click('link=Online Registration');
- $this->waitForElementPresent('_qf_Registration_upload-bottom');
- $this->click('is_online_registration');
- $this->assertChecked('is_online_registration');
-
- //Requires Approvel
- $this->click('requires_approval');
- $this->assertChecked('requires_approval');
- $this->click('_qf_Registration_upload-bottom');
- $this->waitForText('crm-notification-container', "'Online Registration' information has been saved.");
-
- // verify event input on info page
- // start at Manage Events listing
- $this->openCiviPage('event/manage', 'reset=1');
- $this->click("link=$eventTitle");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $firstName = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName, 'Anderson', TRUE);
- $contactName = "Anderson, $firstName";
- $displayName = "$firstName Anderson";
- $this->openCiviPage("event/register", "reset=1&id=$id&action=preview", '_qf_Register_upload-bottom');
- $this->type('first_name', $firstName);
-
- //fill in last name
- $lastName = 'Recuron' . substr(sha1(rand()), 0, 7);
- $this->type('last_name', $contactName);
- $email = $firstName . '@example.com';
- $this->type('email-Primary', $email);
- $this->click('_qf_Register_upload');
- $this->waitForElementPresent("_qf_Confirm_next");
- $this->click('_qf_Confirm_next');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForElementPresent("xpath=//div[@class='crm-group participant_info-group']");
- $this->assertTextPresent("Thank You for Registering");
-
- }
-
- /**
- * Test enabling participant statuses.
- *
- * @param int $statusId
- */
- public function _testEnableParticipantStatuses($statusId) {
- // enable participant status
- if ($this->isElementPresent("xpath=//tr[@id='participant_status_type-{$statusId}']/td[9]/span/a[2][text()='Enable']")) {
- $this->click("xpath=//tr[@id='participant_status_type-{$statusId}']/td[9]/span/a[2][text()='Enable']");
- $this->waitForElementPresent("xpath=//tr[@id='participant_status_type-{$statusId}']/td[9]/span/a[2][text()='Disable']");
- }
- }
-
- /**
- * CRM-16777: Allow to add schedule reminder for event with 'edit all event' permission
- */
- public function testConfigureScheduleReminder() {
- // Log in using webtestLogin() method
- $this->webtestLogin('admin');
-
- //Details for TestUser1
- $role1 = 'role1' . substr(sha1(rand()), 0, 7);
- $TestUser1 = "TestUser1" . substr(sha1(rand()), 0, 4);
- $emailId1 = substr(sha1(rand()), 0, 7) . '@web.com';
-
- //create Role1 with permission 'Access CiviCRM', 'edit all events' and 'Access CiviEvent' permissions.
- $this->open($this->sboxPath . "admin/people/permissions/roles");
- $this->type("edit-name", $role1);
- $this->waitForElementPresent("edit-add");
- $this->click("edit-add");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->open($this->sboxPath . "admin/people/permissions/roles");
- $this->waitForElementPresent("xpath=//table[@id='user-roles']/tbody//tr/td[1][text()='{$role1}']");
- $roleId = explode('/', $this->getAttribute("xpath=//table[@id='user-roles']/tbody//tr/td[1][text()='{$role1}']/../td[4]/a[text()='edit permissions']/@href"));
- $permissions = array(
- "edit-{$roleId[5]}-access-civicrm",
- "edit-{$roleId[5]}-edit-all-events",
- "edit-{$roleId[5]}-access-civievent",
- );
- $this->changePermissions($permissions);
-
- //Create TestUser1
- $this->open($this->sboxPath . "admin/people/create");
- $this->waitForElementPresent("edit-submit");
- $this->type("edit-name", $TestUser1);
- $this->type("edit-mail", $emailId1);
- $this->type("edit-pass-pass1", "Test12345");
- $this->type("edit-pass-pass2", "Test12345");
- $this->click("xpath=//div[@class='form-item form-type-checkboxes form-item-roles']/div//div/label[contains(text(), '{$role1}')]");
- $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
- $lastName = 'An' . substr(sha1(rand()), 0, 7);
- $this->type("first_name", $firstName);
- $this->type("last_name", $lastName);
- $this->type("street_address-1", "902C El Camino Way SW");
- $this->type("city-1", "Dumfries");
- $this->type("postal_code-1", "1234");
- $this->select("state_province-1", "value=1019");
- $this->click("edit-submit");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- //Add event
- $this->openCiviPage("event/add", "reset=1&action=add");
- $this->waitForElementPresent("_qf_EventInfo_cancel-bottom");
- $eventName = 'My Event - ' . substr(sha1(rand()), 0, 7);
- $eventDescription = "Here is a description for this conference.";
- $this->_testAddEventInfo($eventName, $eventDescription);
-
- //Logging out
- $this->webtestLogout();
-
- //Login with TestUser1
- $this->webtestLogin($TestUser1, 'Test12345');
- $this->openCiviPage("event/manage", "reset=1");
- $this->type("title", $eventName);
- $this->click("_qf_SearchEvent_refresh");
- $this->waitForAjaxContent();
- $this->_testAddReminder($eventName);
- $this->webtestLogout();
-
- //Details for TestUser2
- $role2 = 'role2' . substr(sha1(rand()), 0, 5);
- $TestUser2 = "TestUser2" . substr(sha1(rand()), 0, 5);
- $emailId2 = substr(sha1(rand()), 0, 7) . '@web.com';
-
- //create Role2 with only 'Access CiviCRM' and 'Access CiviEvent' permissions
- $this->webtestLogin('admin');
- $this->open($this->sboxPath . "admin/people/permissions/roles");
- $this->type("edit-name", $role2);
- $this->waitForElementPresent("edit-add");
- $this->click("edit-add");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->open($this->sboxPath . "admin/people/permissions/roles");
- $this->waitForElementPresent("xpath=//table[@id='user-roles']/tbody//tr/td[1][text()='{$role2}']");
- $roleId = explode('/', $this->getAttribute("xpath=//table[@id='user-roles']/tbody//tr/td[1][text()='{$role2}']/../td[4]/a[text()='edit permissions']/@href"));
- $permissions = array(
- "edit-{$roleId[5]}-access-civicrm",
- "edit-{$roleId[5]}-access-civievent",
- );
- $this->changePermissions($permissions);
-
- //Create TestUser2
- $this->open($this->sboxPath . "admin/people/create");
- $this->waitForElementPresent("edit-submit");
- $this->type("edit-name", $TestUser2);
- $this->type("edit-mail", $emailId2);
- $this->type("edit-pass-pass1", "Test123");
- $this->type("edit-pass-pass2", "Test123");
- $this->click("xpath=//div[@class='form-item form-type-checkboxes form-item-roles']/div//div/label[contains(text(), '{$role2}')]");
- $firstName = 'Smith' . substr(sha1(rand()), 0, 4);
- $lastName = 'John' . substr(sha1(rand()), 0, 5);
- $this->type("first_name", $firstName);
- $this->type("last_name", $lastName);
- $this->type("street_address-1", "902C El Camino Way SW");
- $this->type("city-1", "Dumfries");
- $this->type("postal_code-1", "1234");
- $this->select("state_province-1", "value=1019");
- $this->click("edit-submit");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- //Logout
- $this->webtestLogout();
-
- //Login with TestUser2
- $this->webtestLogin($TestUser2, 'Test123');
- $this->openCiviPage("event/manage", "reset=1");
- $this->waitForElementPresent("xpath=//div[@id='event_status_id']/div[@class='dataTables_wrapper no-footer']");
- $this->verifyText("xpath=//div[@id='event_status_id']/div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td", "None found.");
- $this->webtestLogout();
- }
-
- /**
- * CRM-16761: Self service view, update and cancel for CiviEvent
- */
- public function testAllowSelfService() {
- $this->webtestLogin('admin');
-
- // Create Individual
- $contact1 = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($contact1, "Anderson", "{$contact1}@example.com");
-
- // Add event
- $this->openCiviPage("event/add", "reset=1&action=add");
- $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7);
- $eventDescription = "Here is a description for this conference.";
- $registerIntro = "Fill in all the fields below and click Continue.";
- $multipleRegistrations = TRUE;
- $allowSelfService = TRUE;
- $this->_testAddEventInfo($eventTitle, $eventDescription);
- $streetAddress = "100 Main Street";
- $this->_testAddLocation($streetAddress);
- $this->_testAddFees(FALSE, FALSE, "Test Processor", FALSE, TRUE);
- $this->_testAddOnlineRegistration($registerIntro, FALSE, $allowSelfService);
-
- // Register participant
- $id = $this->urlArg('id');
- $this->openCiviPage("event/register", "reset=1&id=$id&action=preview", '_qf_Register_upload-bottom');
- $this->waitForElementPresent("xpath=//div[@id='crm-event-register-different']/a");
- $this->click("xpath=//div[@id='crm-event-register-different']/a");
- $this->waitForAjaxcontent();
- $this->select2("select_contact_id", "$contact1");
-
- // Fill card details
- $this->select("credit_card_type", "value=Visa");
- $this->type("credit_card_number", "4111111111111111");
- $this->type("cvv2", "000");
- $this->select("credit_card_exp_date[M]", "value=1");
- $this->select("credit_card_exp_date[Y]", "value=2020");
-
- // Add billing Address
- $this->webtestAddBillingDetails($contact1, NULL, 'Anderson');
- $this->click("_qf_Register_upload-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForElementPresent("_qf_Confirm_next-top");
- $this->click("_qf_Confirm_next-top");
-
- // Find Participant.
- $this->openCiviPage("event/search", "reset=1");
- $this->waitForElementPresent("_qf_Search_refresh");
- $this->type('sort_name', "Anderson, $contact1");
- $this->click("_qf_Search_refresh");
- $this->waitForElementPresent("xpath=//div[@id='participantSearch']");
-
- // Get the id of primary participant
- $primaryParticipantId = $this->urlArg('id', $this->getAttribute("xpath=//div[@id='participantSearch']/table/tbody/tr/td[3]/a[text()='Anderson, $contact1']/../../td[11]/span/a[1][text()='View']@href"));
-
- // Get the contact id of primary participant
- $primaryParticipantContactid = $this->urlArg('cid', $this->getAttribute("xpath=//div[@id='participantSearch']/table/tbody/tr/td[3]/a[text()='Anderson, $contact1']/../../td[11]/span/a[1][text()='View']@href"));
-
- // Generate checksum for primary participant
- $checkSum = CRM_Contact_BAO_Contact_Utils::generateChecksum($primaryParticipantContactid);
- $this->open($this->sboxPath . "admin/people/permissions/roles");
- $permissions = array(
- "edit-1-access-civicrm",
- "edit-1-access-civievent",
- "edit-1-edit-all-events",
- );
- $this->webtestLogout();
-
- // Transfer event registration.
- $this->openCiviPage("event/selfsvcupdate", "reset=1&pid=$primaryParticipantId&cs=$checkSum");
- $this->waitForElementPresent("xpath=//table[@class='crm-selfsvcupdate-form-details']");
- $this->verifyText("xpath=//table[@class='crm-selfsvcupdate-form-details']/tbody/tr/td[1]", preg_quote("Anderson, $contact1"));
- $this->verifyText("xpath=//table[@class='crm-selfsvcupdate-form-details']/tbody/tr/td[2]", preg_quote("$eventTitle"));
- $this->select("action", "value=1");
- $this->click("_qf_SelfSvcUpdate_submit-bottom");
- $this->waitForElementPresent("_qf_SelfSvcTransfer_submit-bottom");
- $newParticipantFirstName = substr(sha1(rand()), 0, 5);
- $newParticipantLastName = "Smith";
- $newParticipantEmail = "{$newParticipantFirstName}@example.com";
- $this->type('email', $newParticipantEmail);
- $this->type('last_name', $newParticipantLastName);
- $this->type('first_name', $newParticipantFirstName);
- $this->click("_qf_SelfSvcTransfer_submit-bottom");
-
- // Cancel event registration.
- $this->webtestLogin('admin');
- $this->openCiviPage("event/search", "reset=1");
- $this->type('sort_name', "Smith, $newParticipantFirstName");
- $this->click("_qf_Search_refresh");
- $this->waitForElementPresent("xpath=//div[@id='participantSearch']/table/tbody/tr/td[3]/a[text()='Smith, $newParticipantFirstName']/../../td[11]/span/a[1][text()='View']");
-
- // Get the id of new participant
- $newParticipantId = $this->urlArg('id', $this->getAttribute("xpath=//div[@id='participantSearch']/table/tbody/tr/td[3]/a[text()='Smith, $newParticipantFirstName']/../../td[11]/span/a[1][text()='View']@href"));
-
- // Get the contact id of new participant
- $newParticipantContactId = $this->urlArg('cid', $this->getAttribute("xpath=//div[@id='participantSearch']/table/tbody/tr/td[3]/a[text()='Smith, $newParticipantFirstName']/../../td[11]/span/a[1][text()='View']@href"));
-
- // Generate checksum for new participant
- $newParticipantcheckSum = CRM_Contact_BAO_Contact_Utils::generateChecksum($newParticipantContactId);
- $this->webtestLogout();
- $this->openCiviPage("event/selfsvcupdate", "reset=1&pid=$newParticipantId&cs=$newParticipantcheckSum");
- $this->verifyText("xpath=//table[@class='crm-selfsvcupdate-form-details']/tbody/tr/td[1]", preg_quote("Smith, $newParticipantFirstName"));
- $this->verifyText("xpath=//table[@class='crm-selfsvcupdate-form-details']/tbody/tr/td[2]", preg_quote("$eventTitle"));
- $this->select("action", "value=2");
- $this->click("_qf_SelfSvcUpdate_submit-bottom");
-
- // Check the status of participant
- $this->webtestLogin('admin');
- $this->openCiviPage("event/search", "reset=1");
- $this->waitForElementPresent('_qf_Search_refresh');
- $this->select2("event_id", $eventTitle);
- $this->click("xpath=//div[@id='searchForm']/table/tbody/tr[9]/td[1]/label[text()='No']");
- $this->click("_qf_Search_refresh");
- $this->waitForElementPresent("xpath=//div[@id='participantSearch']/table/tbody");
- $this->assertElementContainsText("xpath=//div[@id='participantSearch']/table/tbody/tr[@id='rowid$primaryParticipantId']/td[9]", "Transferred");
- $this->assertElementContainsText("xpath=//div[@id='participantSearch']/table/tbody/tr[@id='rowid$newParticipantId']/td[9]", "Cancelled");
- }
-
- /**
- * CRM-17745: Make maximum number of participants configurable
- */
- public function testLimitMaximumParticipants() {
- $this->webtestLogin('admin');
-
- // Add event
- $this->openCiviPage("event/add", "reset=1&action=add");
- $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7);
- $eventDescription = "Here is a description for this conference.";
- $registerIntro = "Fill in all the fields below and click Continue.";
- $this->_testAddEventInfo($eventTitle, $eventDescription);
- $multipleRegistrations = TRUE;
- $this->_testAddOnlineRegistration($registerIntro, $multipleRegistrations);
- $id = $this->urlArg('id');
-
- // Limit additional participants
- $this->openCiviPage("event/manage/registration", "reset=1&action=update&id=$id", '_qf_Registration_upload-bottom');
- $this->select("max_additional_participants", "value=4");
- $this->click("_qf_Registration_upload-bottom");
- $this->waitForText('crm-notification-container', "'Online Registration' information has been saved.");
-
- // Open registration page and check maximum participants
- $this->openCiviPage("event/register", "reset=1&id=$id&action=preview", '_qf_Register_upload-bottom');
- $this->verifyText("xpath=//select[@id='additional_participants']/option[last()]", 5);
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Event_AddParticipationTest
- */
-class WebTest_Event_AddParticipationTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testEventParticipationAdd() {
- $this->webtestLogin();
-
- // Adding contact with randomized first name (so we can then select that contact when creating event registration)
- $firstName = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName, 'Anderson', TRUE);
- $displayName = "$firstName Anderson";
-
- $this->openCiviPage("participant/add", "reset=1&action=add&context=standalone", "_qf_Participant_upload-bottom");
-
- // Type contact last name in contact auto-complete, wait for dropdown and click first result
- $this->webtestFillAutocomplete($firstName);
-
- // Select event. Based on label for now.
- $this->select2('event_id', "Rain-forest Cup Youth Soccer Tournament");
-
- // Select role
- $this->multiselect2('role_id', array('Volunteer'));
-
- // Choose Registration Date.
- // Using helper webtestFillDate function.
- $this->webtestFillDate('register_date', 'now');
- $today = date('F jS, Y', strtotime('now'));
-
- // Select participant status
- $this->select('status_id', 'value=1');
-
- // Setting registration source
- $this->type('source', 'Event StandaloneAddTest Webtest');
-
- // Since we're here, let's check of screen help is being displayed properly
- $this->assertTrue($this->isTextPresent('Source for this registration (if applicable).'));
-
- // Select an event fee
- $this->waitForElementPresent('priceset');
-
- $this->click("xpath=//input[@class='crm-form-radio']");
-
- // Enter amount to be paid (note: this should default to selected fee level amount, s/b fixed during 3.2 cycle)
- $this->type('total_amount', '800');
-
- // Select payment method = Check and enter chk number
- $this->select('payment_instrument_id', 'value=4');
- $this->waitForElementPresent('check_number');
- $this->type('check_number', '1044');
-
- // go for the chicken combo (obviously)
- // $this->click('CIVICRM_QFID_chicken_Chicken');
-
- $this->waitForElementPresent('send_receipt');
- $this->assertTrue($this->isChecked("send_receipt"), 'Send Confirmation and Receipt checkbox should be checked by default but is not checked.');
-
- // Clicking save.
- $this->clickLink('_qf_Participant_upload-bottom');
-
- // Is status message correct?
- $this->checkCRMAlert("Event registration for $displayName has been added");
-
- $this->waitForElementPresent("xpath=//*[@id='Search']//table//tbody/tr[1]/td[8]/span/a[text()='View']");
- //click through to the participant view screen
- $this->clickAjaxLink("xpath=//*[@id='Search']/table/tbody/tr[1]/td[8]/span/a[text()='View']", '_qf_ParticipantView_cancel-bottom');
-
- $this->webtestVerifyTabularData(
- array(
- 'Event' => 'Rain-forest Cup Youth Soccer Tournament',
- 'Participant Role' => 'Attendee',
- 'Status' => 'Registered',
- 'Event Source' => 'Event StandaloneAddTest Webtest',
- 'Fees' => '$ 800.00',
- )
- );
- // check contribution record as well
- //click through to the contribution view screen
- $this->clickAjaxLink("xpath=id('ParticipantView')/div[2]/table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='View']", '_qf_ContributionView_cancel-bottom');
-
- $this->webtestVerifyTabularData(
- array(
- 'From' => $displayName,
- 'Financial Type' => 'Event Fee',
- 'Total Amount' => '$ 800.00',
- 'Contribution Status' => 'Completed',
- 'Payment Method' => 'Check',
- 'Check Number' => '1044',
- )
- );
- }
-
- public function testEventParticipationAddWithMultipleRoles() {
- $this->webtestLogin();
-
- // Adding contact with randomized first name (so we can then select that contact when creating event registration)
- $firstName = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName, 'Anderson', TRUE);
- $displayName = "$firstName Anderson";
-
- // add custom data for participant role
- $this->openCiviPage("admin/custom/group", "reset=1");
-
- //add new custom data
- $this->clickLink("//a[@id='newCustomDataGroup']/span");
-
- //fill custom group title
- $customGroupTitle = 'custom_' . substr(sha1(rand()), 0, 7);
- $this->click('title');
- $this->type('title', $customGroupTitle);
-
- //custom group extends
- $this->click('extends[0]');
- $this->select('extends[0]', 'value=ParticipantRole');
-
- $this->click('extends[1][]');
- $this->select('extends[1][]', 'value=2');
-
- $this->click("//option[@value='Contact']");
- $this->clickLink('_qf_Group_next');
-
- //Is custom group created?
- $this->checkCRMAlert("Your custom field set '$customGroupTitle' has been added. You can add custom fields now.");
-
- //add custom field - alphanumeric checkbox
- $this->waitForAjaxContent();
- $checkboxFieldLabel = 'custom_field' . substr(sha1(rand()), 0, 4);
- $this->click('label');
- $this->type('label', $checkboxFieldLabel);
- $this->click('data_type[1]');
- $this->select('data_type[1]', 'value=CheckBox');
- $this->click("//option[@value='CheckBox']");
- $checkboxOptionLabel1 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
- $this->type('option_label_1', $checkboxOptionLabel1);
- $this->type('option_value_1', '1');
- $checkboxOptionLabel2 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
- $this->type('option_label_2', $checkboxOptionLabel2);
- $this->type('option_value_2', '2');
- $this->click('link=another choice');
- $checkboxOptionLabel3 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
- $this->type('option_label_3', $checkboxOptionLabel3);
- $this->type('option_value_3', '3');
-
- //enter options per line
- $this->type('options_per_line', '2');
-
- //enter pre help message
- $this->type('help_pre', 'this is field pre help');
-
- //enter post help message
- $this->type('help_post', 'this field post help');
-
- //Is searchable?
- $this->click('is_searchable');
-
- //clicking save
- $this->click('_qf_Field_done-bottom');
-
- //Is custom field created?
- $this->checkCRMAlert("Custom field '$checkboxFieldLabel' has been saved.");
- $this->waitForAjaxContent();
-
- //create another custom field - Integer Radio
- $this->clickPopupLink('newCustomField', '_qf_Field_cancel');
- $this->click('data_type[0]');
- $this->select('data_type[0]', 'value=1');
- $this->click("//option[@value='1']");
- $this->click('data_type[1]');
- $this->select('data_type[1]', 'value=Radio');
- $this->click("//option[@value='Radio']");
-
- $radioFieldLabel = 'custom_field' . substr(sha1(rand()), 0, 4);
- $this->type('label', $radioFieldLabel);
- $radioOptionLabel1 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
- $this->type('option_label_1', $radioOptionLabel1);
- $this->type('option_value_1', '1');
- $radioOptionLabel2 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
- $this->type('option_label_2', $radioOptionLabel2);
- $this->type('option_value_2', '2');
- $this->click('link=another choice');
- $radioOptionLabel3 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
- $this->type('option_label_3', $radioOptionLabel3);
- $this->type('option_value_3', '3');
-
- //select options per line
- $this->type('options_per_line', '3');
-
- //enter pre help msg
- $this->type('help_pre', 'this is field pre help');
-
- //enter post help msg
- $this->type('help_post', 'this is field post help');
-
- //Is searchable?
- $this->click('is_searchable');
-
- //clicking save
- $this->clickAjaxLink('_qf_Field_done-bottom');
-
- $this->openCiviPage("participant/add", "reset=1&action=add&context=standalone", "_qf_Participant_upload-bottom");
-
- // Type contact last name in contact auto-complete, wait for dropdown and click first result
- $this->webtestFillAutocomplete($firstName);
-
- // Select event. Based on label for now.
- $this->select2('event_id', "Rain-forest Cup Youth Soccer Tournament");
-
- // Select roles
- $this->multiselect2('role_id', array('Volunteer', 'Host'));
-
- $this->waitForElementPresent("xpath=//div[@class='custom-group custom-group-$customGroupTitle crm-accordion-wrapper collapsed']");
- $this->click("xpath=//div[@class='custom-group custom-group-$customGroupTitle crm-accordion-wrapper collapsed']//div[1]");
- $this->click("xpath=//div[@class='custom-group custom-group-$customGroupTitle crm-accordion-wrapper']//div[2]//table//tbody//tr[2]//td[2]//table//tbody//tr[1]//td[1]//label");
- $this->click("xpath=//div[@class='custom-group custom-group-$customGroupTitle crm-accordion-wrapper']//div[2]//table//tbody//tr[4]//td[2]//table//tbody//tr[1]//td[1]//label");
-
- // Choose Registration Date.
- // Using helper webtestFillDate function.
- $this->webtestFillDate('register_date', 'now');
- $today = date('F jS, Y', strtotime('now'));
- // May 5th, 2010
-
- // Select participant status
- $this->select('status_id', 'value=1');
-
- // Setting registration source
- $this->type('source', 'Event StandaloneAddTest Webtest');
-
- // Since we're here, let's check of screen help is being displayed properly
- $this->assertTrue($this->isTextPresent('Source for this registration (if applicable).'));
-
- // Select an event fee
- $this->waitForElementPresent("xpath=//div[@class='crm-event-form-fee-block']");
-
- $this->click("xpath=//input[@class='crm-form-radio']");
-
- // Enter amount to be paid (note: this should default to selected fee level amount, s/b fixed during 3.2 cycle)
- $this->waitForElementPresent('total_amount');
- $this->type('total_amount', '800');
-
- // Select payment method = Check and enter chk number
- $this->select('payment_instrument_id', 'value=4');
- $this->waitForElementPresent('check_number');
- $this->type('check_number', '1044');
-
- // Clicking save.
- $this->clickLink('_qf_Participant_upload-bottom');
-
- // Is status message correct?
- $this->checkCRMAlert("Event registration for $displayName has been added");
-
- $this->waitForElementPresent("xpath=//form[@class='CRM_Event_Form_Search crm-search-form']/table/tbody/tr[1]/td[8]/span/a[text()='View']");
- //click through to the participant view screen
- $this->clickAjaxLink("xpath=//form[@class='CRM_Event_Form_Search crm-search-form']/table/tbody/tr[1]/td[8]/span/a[text()='View']", '_qf_ParticipantView_cancel-bottom');
-
- $this->webtestVerifyTabularData(
- array(
- 'Event' => 'Rain-forest Cup Youth Soccer Tournament',
- 'Participant Role' => 'Attendee, Volunteer, Host',
- 'Status' => 'Registered',
- 'Event Source' => 'Event StandaloneAddTest Webtest',
- 'Fees' => '$ 800.00',
- )
- );
-
- $this->assertTrue($this->isTextPresent("$customGroupTitle"));
- $this->assertTrue($this->isTextPresent("$checkboxOptionLabel1"));
- $this->assertTrue($this->isTextPresent("$radioOptionLabel1"));
-
- // check contribution record as well
- //click through to the contribution view screen
- $this->clickAjaxLink("xpath=id('ParticipantView')/div[2]/table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='View']", '_qf_ContributionView_cancel-bottom');
-
- $this->webtestVerifyTabularData(
- array(
- 'From' => $displayName,
- 'Financial Type' => 'Event Fee',
- 'Contribution Status' => 'Completed',
- 'Payment Method' => 'Check',
- 'Check Number' => '1044',
- )
- );
- $this->verifyText("xpath=//table/tbody/tr/td[text()='Total Amount']/following-sibling::td/strong", preg_quote('$ 800.00'));
- }
-
- public function testEventAddMultipleParticipants() {
- $this->webtestLogin();
-
- $processorId = $this->webtestAddPaymentProcessor();
-
- $this->openCiviPage("participant/add", "reset=1&action=add&context=standalone&mode=test&eid=3");
-
- $contacts = array();
-
- $this->assertTrue($this->isTextPresent("New Event Registration"), "Page title 'New Event Registration' missing");
- $this->assertTrue($this->isTextPresent("A TEST transaction will be submitted"), "test mode status 'A TEST transaction will be submitted' missing");
- $contacts[] = $this->_fillParticipantDetails($processorId);
- $this->clickLink('_qf_Participant_upload_new-bottom');
-
- $this->assertTrue($this->isTextPresent("New Event Registration"), "Page title 'New Event Registration' missing");
- $this->assertTrue($this->isTextPresent("A TEST transaction will be submitted"), "test mode status 'A TEST transaction will be submitted' missing");
- $contacts[] = $this->_fillParticipantDetails($processorId);
- $this->clickLink('_qf_Participant_upload_new-bottom');
-
- //searching the paricipants
- $this->openCiviPage("event/search", "reset=1");
- $this->type('sort_name', 'Individual');
- $eventName = "Rain-forest Cup Youth Soccer Tournament";
- $this->select2("event_id", $eventName, FALSE, FALSE);
- $this->check('participant_test');
- $this->clickLink("_qf_Search_refresh", "participantSearch");
-
- //verifying the registered participants
- $status = CRM_Core_TestEntity::appendTestText("Registered");
-
- foreach ($contacts as $contact) {
- $this->verifyText("xpath=//div[@id='participantSearch']//table//tbody//tr/td[@class='crm-participant-sort_name']/a[text()='{$contact['sort_name']}']/../../td[9]", preg_quote($status));
- $this->verifyText("xpath=//div[@id='participantSearch']//table//tbody//tr/td[@class='crm-participant-sort_name']/a[text()='{$contact['sort_name']}']/../../td[4]/a", preg_quote($eventName));
- }
- }
-
- public function testAjaxCustomGroupLoad() {
- $this->markTestSkipped('Skipping for now as it works fine locally.');
- $this->webtestLogin();
-
- $customSets = array(
- array(
- 'entity' => 'ParticipantEventName',
- 'subEntity' => 'Fall Fundraiser Dinner',
- 'triggerElement' => array(
- 'name' => "event_id",
- 'type' => "select2",
- ),
- ),
- array(
- 'entity' => 'ParticipantRole',
- 'subEntity' => 'Attendee',
- 'triggerElement' => array(
- 'name' => 'role_id',
- 'type' => "select",
- ),
- ),
- );
- $pageUrl = array('url' => "participant/add", 'args' => "reset=1&action=add&context=standalone");
- $this->customFieldSetLoadOnTheFlyCheck($customSets, $pageUrl, TRUE);
- }
-
- /**
- * Webtest for CRM-10983
- */
- public function testCheckDuplicateCustomDataLoad() {
- $this->webtestLogin();
-
- $customSets = array(
- array(
- 'entity' => 'ParticipantEventType',
- 'subEntity' => '- Any -',
- 'triggerElement' => array(
- 'name' => "event_id",
- 'type' => "select",
- ),
- ),
- array(
- 'entity' => 'ParticipantEventName',
- 'subEntity' => '- Any -',
- 'triggerElement' => array(
- 'name' => "event_id",
- 'type' => "select",
- ),
- ),
- array(
- 'entity' => 'ParticipantEventName',
- 'subEntity' => 'Rain-forest Cup Youth Soccer Tournament',
- 'triggerElement' => array(
- 'name' => "event_id",
- 'type' => "select",
- ),
- ),
- array(
- 'entity' => 'ParticipantRole',
- 'subEntity' => '- Any -',
- 'triggerElement' => array(
- 'type' => "checkbox",
- ),
- ),
- array(
- 'entity' => 'ParticipantRole',
- 'subEntity' => 'Volunteer',
- 'triggerElement' => array(
- 'type' => "checkbox",
- ),
- ),
- );
-
- $return = $this->addCustomGroupField($customSets);
-
- $this->openCiviPage("participant/add", "reset=1&action=add&context=standalone", "_qf_Participant_upload-bottom");
-
- // Select event.
- $this->select2('event_id', "Rain-forest Cup Youth Soccer Tournament");
-
- // Select role.
- $this->multiselect2('role_id', array('Volunteer'));
-
- foreach ($return as $values) {
- foreach ($values as $entityType => $customData) {
- //checking for duplicate custom data present or not
- $this->assertElementPresent("xpath=//div[@class='custom-group custom-group-{$customData['cgtitle']} crm-accordion-wrapper ']");
- $this->assertEquals(1, $this->getXpathCount("//div[@class='custom-group custom-group-{$customData['cgtitle']} crm-accordion-wrapper ']"));
- }
- }
- }
-
- /**
- * @param int $processorId
- */
- public function _fillParticipantDetails($processorId) {
- $contact = $this->createDialogContact();
-
- $event_id = $this->getAttribute("xpath=//*[@id='event_id']@value");
- //check if it is the selected event
- $this->assertEquals($event_id, 3);
- $this->select("role_id", "value=1");
- $this->webtestAddCreditCardDetails();
- $this->webtestAddBillingDetails();
- return $contact;
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Event_AddPricesetTest
- */
-class WebTest_Event_AddPricesetTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testAddPriceSet() {
-
- // Log in using webtestLogin() method
- $this->webtestLogin();
-
- $setTitle = 'Conference Fees - ' . substr(sha1(rand()), 0, 7);
- $usedFor = 'Event';
- $setHelp = 'Select your conference options.';
- $this->_testAddSet($setTitle, $usedFor, $setHelp);
-
- // Get the price set id ($sid) by retrieving and parsing the URL of the New Price Field form
- // which is where we are after adding Price Set.
- $sid = $this->urlArg('sid');
- $this->assertType('numeric', $sid);
-
- $validateStrings = array();
-
- $fields = array(
- 'Full Conference' => 'Text',
- 'Meal Choice' => 'Select',
- 'Pre-conference Meetup?' => 'Radio',
- 'Evening Sessions' => 'CheckBox',
- );
- $this->_testAddPriceFields($fields, $validateStrings);
-
- // load the Price Set Preview and check for expected values
- $this->_testVerifyPriceSet($validateStrings, $sid);
- }
-
- /**
- * @param $setTitle
- * @param $usedFor
- * @param $setHelp
- * @param string $financialType
- */
- public function _testAddSet($setTitle, $usedFor, $setHelp, $financialType = 'Event Fee') {
- $this->openCiviPage('admin/price', 'reset=1&action=add', '_qf_Set_next-bottom');
-
- // Enter Priceset fields (Title, Used For ...)
- $this->type('title', $setTitle);
- if ($usedFor == 'Event') {
- $this->check('extends[1]');
- }
- elseif ($usedFor == 'Contribution') {
- $this->check('extends[2]');
- }
-
- $this->select("financial_type_id", "label={$financialType}");
-
- $this->type('help_pre', $setHelp);
-
- $this->assertChecked('is_active', 'Verify that Is Active checkbox is set.');
- $this->clickLink('_qf_Set_next-bottom');
- }
-
- /**
- * @param $fields
- * @param $validateStrings
- * @param bool $dateSpecificFields
- */
- public function _testAddPriceFields(&$fields, &$validateStrings, $dateSpecificFields = FALSE) {
- $this->clickLinkSuppressPopup('newPriceField');
- foreach ($fields as $label => $type) {
- $validateStrings[] = $label;
-
- $this->type('label', $label);
- $this->select('html_type', "value={$type}");
-
- switch ($type) {
- case 'Text':
- $validateStrings[] = '525.00';
- $this->type('price', '525.00');
- $this->select('financial_type_id', 'Donation');
- if ($dateSpecificFields == TRUE) {
- $this->webtestFillDateTime('active_on', '+1 week');
- }
- else {
- $this->check('is_required');
- }
- break;
-
- case 'Select':
- $options = array(
- 1 => array(
- 'label' => 'Chicken',
- 'amount' => '30.00',
- 'financial_type_id' => 'Donation',
- ),
- 2 => array(
- 'label' => 'Vegetarian',
- 'amount' => '25.00',
- 'financial_type_id' => 'Donation',
- ),
- );
- $this->addMultipleChoiceOptions($options, $validateStrings);
- if ($dateSpecificFields == TRUE) {
- $this->webtestFillDateTime('expire_on', '-1 week');
- }
- break;
-
- case 'Radio':
- $options = array(
- 1 => array(
- 'label' => 'Yes',
- 'amount' => '50.00',
- 'financial_type_id' => 'Donation',
-
- ),
- 2 => array(
- 'label' => 'No',
- 'amount' => '0',
- 'financial_type_id' => 'Donation',
- ),
- );
- $this->addMultipleChoiceOptions($options, $validateStrings);
- $this->click('is_required');
- if ($dateSpecificFields == TRUE) {
- $this->webtestFillDateTime('active_on', '-1 week');
- }
- break;
-
- case 'CheckBox':
- $options = array(
- 1 => array(
- 'label' => 'First Night',
- 'amount' => '15.00',
- 'financial_type_id' => 'Donation',
- ),
- 2 => array(
- 'label' => 'Second Night',
- 'amount' => '15.00',
- 'financial_type_id' => 'Donation',
- ),
- );
- $this->addMultipleChoiceOptions($options, $validateStrings);
- if ($dateSpecificFields == TRUE) {
- $this->webtestFillDateTime('expire_on', '+1 week');
- }
- break;
-
- default:
- break;
- }
- $this->clickLink('_qf_Field_next_new-bottom', '_qf_Field_next-bottom', FALSE);
- $this->waitForText('crm-notification-container', "Price Field '" . $label . "' has been saved.");
- }
- }
-
- /**
- * @param $validateStrings
- * @param int $sid
- */
- public function _testVerifyPriceSet($validateStrings, $sid) {
- // verify Price Set at Preview page
- // start at Manage Price Sets listing
- $this->openCiviPage('admin/price', 'reset=1');
-
- // Use the price set id ($sid) to pick the correct row
- $this->clickLink("//*[@id='price_set-{$sid}']/td[4]/span[1]/a[2]", '_qf_Preview_cancel-bottom', FALSE);
-
- // Check for expected price set field strings
- if ($this->isElementPresent("xpath=//*[@class ='select2-chosen']")) {
- $this->clickAt("xpath=//*[@class ='select2-chosen']");
- }
- $this->assertStringsPresent($validateStrings);
- }
-
- public function testRegisterWithPriceSet() {
- // Log in using webtestLogin() method
- $this->webtestLogin();
-
- $setTitle = 'Conference Fees - ' . substr(sha1(rand()), 0, 7);
- $usedFor = 'Event';
- $setHelp = 'Select your conference options.';
- $this->_testAddSet($setTitle, $usedFor, $setHelp);
-
- // Get the price set id ($sid) by retrieving and parsing the URL of the New Price Field form
- // which is where we are after adding Price Set.
- $sid = $this->urlArg('sid');
- $this->assertType('numeric', $sid);
-
- $validStrings = array();
- $fields = array(
- 'Full Conference' => 'Text',
- 'Pre-conference Meetup?' => 'Radio',
- 'Evening Sessions' => 'CheckBox',
- );
- $this->_testAddPriceFields($fields, $validateStrings);
-
- // load the Price Set Preview and check for expected values
- $this->_testVerifyPriceSet($validateStrings, $sid);
-
- // Use default payment processor
- $processorName = 'Test Processor';
- $this->webtestAddPaymentProcessor($processorName);
-
- $this->openCiviPage('event/add', 'reset=1&action=add', '_qf_EventInfo_upload-bottom');
-
- $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7);
- $email = 'Smith' . substr(sha1(rand()), 0, 7) . '@example.com';
- $eventDescription = 'Here is a description for this conference.';
-
- $this->select('event_type_id', 'value=1');
-
- // Attendee role s/b selected now.
- $this->select('default_role_id', 'value=1');
-
- // Enter Event Title, Summary and Description
- $this->type('title', $eventTitle);
- $this->type('summary', 'This is a great conference. Sign up now!');
-
- // Type description in ckEditor (fieldname, text to type, editor)
- $this->fillRichTextField('description', $eventDescription);
-
- // Choose Start and End dates.
- // Using helper webtestFillDate function.
- $this->webtestFillDateTime("start_date", "+1 week");
- $this->webtestFillDateTime("end_date", "+1 week 1 day 8 hours ");
-
- $this->type('max_participants', '50');
- $this->click('is_map');
- $this->click('_qf_EventInfo_upload-bottom');
-
- // Wait for Location tab form to load
- $this->waitForElementPresent('_qf_Location_upload_done-bottom');
-
- // Go to Fees tab
- $this->click('link=Fees');
- $this->waitForElementPresent('_qf_Fee_upload_done-bottom');
- $this->click('CIVICRM_QFID_1_is_monetary');
- $this->select2('payment_processor', $processorName, TRUE);
- $this->select('financial_type_id', 'label=Event Fee');
- $this->select('price_set_id', 'label=' . $setTitle);
-
- // intro text for registration page
- $registerIntro = 'Fill in all the fields below and click Continue.';
- $this->clickLink('_qf_Fee_upload-bottom', 'link=Online Registration', FALSE);
-
- // Go to Online Registration tab
- $this->click('link=Online Registration');
- $this->waitForElementPresent('_qf_Registration_upload-bottom');
-
- $this->check('is_online_registration');
- $this->assertChecked('is_online_registration');
-
- $this->fillRichTextField('intro_text', $registerIntro, 'CKEditor', TRUE);
-
- // enable confirmation email
- $this->click('CIVICRM_QFID_1_is_email_confirm');
- $this->type('confirm_from_name', 'Jane Doe');
- $this->type('confirm_from_email', 'jane.doe@example.org');
-
- $this->click('_qf_Registration_upload-bottom');
- $this->waitForTextPresent("'Online Registration' information has been saved.");
-
- // verify event input on info page
- // start at Manage Events listing
- $this->openCiviPage('event/manage', 'reset=1');
- $this->click("link=$eventTitle");
-
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $eventInfoUrl = $this->getLocation();
-
- $permissions = array("edit-1-register-for-events");
- $this->changePermissions($permissions);
- $this->webtestLogout();
- $this->open($eventInfoUrl);
- $this->click('link=Register Now');
- $this->waitForElementPresent('_qf_Register_upload-bottom');
-
- $this->type("xpath=//input[@class='four crm-form-text required']", "1");
- $this->click("xpath=//input[@class='crm-form-radio']");
- $this->click("xpath=//input[@class='crm-form-checkbox']");
- $this->type("first_name", "Jane");
- $lastName = "Smith" . substr(sha1(rand()), 0, 7);
- $this->type("last_name", $lastName);
- $this->type('email-Primary', $email);
-
- $this->waitForElementPresent('credit_card_type');
- $this->select('credit_card_type', 'value=Visa');
- $this->type('credit_card_number', '4111111111111111');
- $this->type('cvv2', '000');
- $this->select('credit_card_exp_date[M]', 'value=1');
- $this->select('credit_card_exp_date[Y]', 'value=2020');
- $this->type('billing_first_name', 'Jane');
- $this->type('billing_last_name', $lastName);
- $this->type('billing_street_address-5', '15 Main St.');
- $this->type(' billing_city-5', 'San Jose');
- $this->select('billing_country_id-5', 'value=1228');
- $this->select('billing_state_province_id-5', 'value=1004');
- $this->type('billing_postal_code-5', '94129');
-
- $this->clickLink('_qf_Register_upload-bottom', '_qf_Confirm_next-bottom');
- $confirmStrings = array('Event Fee(s)', 'Billing Name and Address', 'Credit Card Information');
- $this->assertStringsPresent($confirmStrings);
- $this->click('_qf_Confirm_next-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $thankStrings = array('Thank You for Registering', 'Event Total', 'Transaction Date');
- $this->assertStringsPresent($thankStrings);
-
- // Log in using webtestLogin() method
- $this->webtestLogin();
-
- //Find Participant
- $this->openCiviPage('event/search', 'reset=1', '_qf_Search_refresh');
-
- $this->type('sort_name', "$email");
- $this->clickLink('_qf_Search_refresh', "xpath=id('participantSearch')/table/tbody/tr/td[11]/span/a[text()='View']");
- $this->click("xpath=id('participantSearch')/table/tbody/tr/td[11]/span/a[text()='View']");
- $this->waitForElementPresent('_qf_ParticipantView_cancel-bottom');
-
- $expected = array(
- 2 => 'Full Conference',
- 3 => 'Pre-conference Meetup? - Yes',
- 4 => 'Evening Sessions - First Night',
- );
- foreach ($expected as $value => $label) {
- $this->verifyText("xpath=id('ParticipantView')/div[2]/table[1]/tbody/tr[8]/td[2]/table/tbody/tr[$value]/td", $label);
- }
- // Fixme: We can't asset full string like - "Event Total: $ 590.00" as it has special char
- $this->assertStringsPresent(' 590.00');
- $this->click('_qf_ParticipantView_cancel-bottom');
- }
-
- public function testParticipantWithDateSpecificPriceSet() {
-
- // Log in using webtestLogin() method
- $this->webtestLogin();
-
- $setTitle = 'Conference Fees - ' . substr(sha1(rand()), 0, 7);
- $usedFor = 'Event';
- $setHelp = 'Select your conference options.';
- $this->_testAddSet($setTitle, $usedFor, $setHelp);
-
- // Get the price set id ($sid) by retrieving and parsing the URL of the New Price Field form
- // which is where we are after adding Price Set.
- $sid = $this->urlArg('sid');
- $this->assertType('numeric', $sid);
-
- $validStrings = array();
- $fields = array(
- 'Full Conference' => 'Text',
- 'Pre-conference Meetup?' => 'Radio',
- 'Evening Sessions' => 'CheckBox',
- );
- $this->_testAddPriceFields($fields, $validateStrings, TRUE);
-
- // load the Price Set Preview and check for expected values
- $this->_testVerifyPriceSet($validateStrings, $sid);
-
- // Use default payment processor
- $processorName = 'Test Processor';
- $this->webtestAddPaymentProcessor($processorName);
-
- $this->openCiviPage('event/add', 'reset=1&action=add', '_qf_EventInfo_upload-bottom');
-
- $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7);
- $email = 'Smith' . substr(sha1(rand()), 0, 7) . '@example.com';
- $eventDescription = 'Here is a description for this conference.';
-
- $this->select('event_type_id', 'value=1');
-
- // Attendee role s/b selected now.
- $this->select('default_role_id', 'value=1');
-
- // Enter Event Title, Summary and Description
- $this->type('title', $eventTitle);
- $this->type('summary', 'This is a great conference. Sign up now!');
-
- // Type description in ckEditor (fieldname, text to type, editor)
- $this->fillRichTextField('description', $eventDescription);
-
- // Choose Start and End dates.
- // Using helper webtestFillDate function.
- $this->webtestFillDateTime("start_date", "+1 week");
- $this->webtestFillDateTime("end_date", "+1 week 1 day 8 hours ");
-
- $this->type('max_participants', '50');
- $this->click('is_map');
- $this->click('_qf_EventInfo_upload-bottom');
-
- // Wait for Location tab form to load
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Go to Fees tab
- $this->click('link=Fees');
- $this->waitForElementPresent('_qf_Fee_upload-bottom');
- $this->click('CIVICRM_QFID_1_is_monetary');
- $this->select2('payment_processor', $processorName, TRUE);
- $this->select('financial_type_id', 'label=Event Fee');
- $this->select('price_set_id', 'label=' . $setTitle);
-
- $this->clickLink('_qf_Fee_upload-bottom', 'link=Online Registration', FALSE);
-
- // intro text for registration page
- $registerIntro = 'Fill in all the fields below and click Continue.';
-
- // Go to Online Registration tab
- $this->click('link=Online Registration');
- $this->waitForElementPresent('_qf_Registration_upload-bottom');
-
- $this->check('is_online_registration');
- $this->assertChecked('is_online_registration');
-
- $this->fillRichTextField('intro_text', $registerIntro, 'CKEditor', TRUE);
-
- // enable confirmation email
- $this->click('CIVICRM_QFID_1_is_email_confirm');
- $this->type('confirm_from_name', 'Jane Doe');
- $this->type('confirm_from_email', 'jane.doe@example.org');
-
- $this->click('_qf_Registration_upload-bottom');
- $this->waitForTextPresent("'Online Registration' information has been saved.");
-
- // verify event input on info page
- // start at Manage Events listing
- $this->openCiviPage('event/manage', 'reset=1');
- $this->click("link=$eventTitle");
-
- $this->waitForPageToLoad($this->getTimeoutMsec());
- // Adding contact with randomized first name (so we can then select that contact when creating event registration)
- // We're using Quick Add block on the main page for this.
- $firstName = substr(sha1(rand()), 0, 7);
- $lastName = 'Anderson' . substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName, $lastName, TRUE);
- $contactName = "$lastName, $firstName";
- $displayName = "$firstName $lastName";
-
- $this->openCiviPage('participant/add', 'reset=1&action=add&context=standalone', '_qf_Participant_upload-bottom');
-
- // Type contact last name in contact auto-complete, wait for dropdown and click first result
- $this->webtestFillAutocomplete($firstName);
-
- // Select event. Based on label for now.
- $this->select2('event_id', "$eventTitle");
- // Select role
- $this->multiselect2('role_id', array('Volunteer'));
-
- $this->waitForElementPresent("xpath=//input[@class='crm-form-radio']");
- $this->click("xpath=//input[@class='crm-form-radio']");
- $this->click("xpath=//input[@class='crm-form-checkbox']");
-
- // Choose Registration Date.
- // Using helper webtestFillDate function.
- $this->webtestFillDate('register_date', 'now');
- $today = date('F jS, Y', strtotime('now'));
-
- // Select participant status
- $this->select('status_id', 'value=1');
-
- // Clicking save.
- $this->click('_qf_Participant_upload-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- // Is status message correct?
- $this->waitForText("crm-notification-container", "Event registration for $displayName has been added", "Status message didn't show up after saving!");
-
- $this->waitForElementPresent("xpath=//form[@class='CRM_Event_Form_Search crm-search-form']/table//tbody/tr[1]/td[8]/span/a[text()='View']");
-
- //click through to the participant view screen
- $this->click("xpath=//form[@class='CRM_Event_Form_Search crm-search-form']/table/tbody/tr[1]/td[8]/span/a[text()='View']");
- $this->waitForElementPresent("xpath=//button//span[contains(text(),'Done')]");
- }
-
- /**
- * Test to regiter participant for event with
- * multiple price fields in price-set
- * CRM-11986
-
- */
- public function testEventWithPriceSet() {
- // Log in using webtestLogin() method
- $this->webtestLogin();
-
- // Adding contact with randomized first name (so we can then select that contact when creating event registration)
- // We're using Quick Add block on the main page for this.
- $firstName = substr(sha1(rand()), 0, 7);
- $lastName = 'Anderson' . substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName, $lastName, TRUE);
- $contactName = "$lastName, $firstName";
- $displayName = "$firstName $lastName";
-
- $setTitle = 'Conference Fees - ' . substr(sha1(rand()), 0, 7);
- $usedFor = 'Event';
- $setHelp = 'Select your conference options.';
- $this->_testAddSet($setTitle, $usedFor, $setHelp);
-
- // Get the price set id ($sid) by retrieving and parsing the URL of the New Price Field form
- // which is where we are after adding Price Set.
- $sid = $this->urlArg('sid');
- $this->assertType('numeric', $sid);
-
- $validStrings = array();
- $fields = array(
- 'Full Conference' => 'Text',
- 'Pre-conference Meetup?' => 'Radio',
- 'Evening Sessions' => 'CheckBox',
- );
- $this->_testAddPriceFields($fields, $validateStrings);
-
- // load the Price Set Preview and check for expected values
- $this->_testVerifyPriceSet($validateStrings, $sid);
-
- $this->openCiviPage('event/add', 'reset=1&action=add', '_qf_EventInfo_upload-bottom');
- $this->waitForElementPresent("_qf_EventInfo_upload-bottom");
- $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7);
- $email = 'Smith' . substr(sha1(rand()), 0, 7) . '@example.com';
- $eventDescription = 'Here is a description for this conference.';
-
- $this->select('event_type_id', 'value=1');
-
- // Attendee role s/b selected now.
- $this->select('default_role_id', 'value=1');
-
- // Enter Event Title, Summary and Description
- $this->type('title', $eventTitle);
- $this->type('summary', 'This is a great conference. Sign up now!');
-
- // Type description in ckEditor (fieldname, text to type, editor)
- $this->fillRichTextField('description', $eventDescription);
-
- // Choose Start and End dates.
- // Using helper webtestFillDate function.
- $this->webtestFillDateTime("start_date", "+1 week");
- $this->webtestFillDateTime("end_date", "+1 week 1 day 8 hours ");
-
- $this->type('max_participants', '50');
- $this->click('is_map');
- $this->click('_qf_EventInfo_upload-bottom');
-
- // Wait for Location tab form to load
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Go to Fees tab
- $this->click('link=Fees');
- $this->waitForElementPresent('_qf_Fee_upload-bottom');
- $this->click('CIVICRM_QFID_1_is_monetary');
- $this->select('financial_type_id', 'label=Event Fee');
- $this->select('price_set_id', 'label=' . $setTitle);
-
- $this->click('_qf_Fee_upload-bottom');
- $this->waitForText("crm-notification-container", "'Fees' information has been saved.");
- $this->waitForAjaxContent();
-
- $this->openCiviPage('participant/add', 'reset=1&action=add&context=standalone', '_qf_Participant_upload-bottom');
-
- // Type contact last name in contact auto-complete, wait for dropdown and click first result
- $this->webtestFillAutocomplete($firstName);
- $this->select2('event_id', $eventTitle);
- // Select role
- $this->multiselect2('role_id', array('Volunteer'));
-
- // Choose Registration Date.
- // Using helper webtestFillDate function.
- $this->webtestFillDate('register_date', 'now');
- $today = date('F jS, Y', strtotime('now'));
- // May 5th, 2010
-
- // Select participant status
- $this->select('status_id', 'value=1');
-
- // Setting registration source
- $this->type('source', 'Event StandaloneAddTest Webtest');
-
- // Select an event fee
- $this->waitForElementPresent("xpath=//div[@id='priceset']/div[2]/div[2]/input");
- $this->type("xpath=//div[@id='priceset']/div[2]/div[2]/input", '5');
- $this->fireEvent("xpath=//div[@id='priceset']/div[2]/div[2]/input", 'blur');
- $this->waitForElementPresent("xpath=//div[@id='priceset']/div[3]/div[2]/div[1]/span/input");
- $this->click("xpath=//div[@id='priceset']/div[3]/div[2]/div[1]/span/input");
- $this->click("xpath=//div[@id='priceset']/div[4]/div[2]/div[1]/span/input");
- $this->click("xpath=//div[@id='priceset']/div[4]/div[2]/div[2]/span/input");
-
- // Select payment method = Check and enter chk number
- $this->select('payment_instrument_id', 'value=4');
- $this->waitForElementPresent('check_number');
- $this->type('check_number', '1044');
-
- // Clicking save.
- $this->click('_qf_Participant_upload-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Is status message correct?
- $this->waitForText("crm-notification-container", "Event registration for $displayName has been added");
-
- $this->waitForElementPresent("xpath=//form[@id='Search']/table/tbody/tr[1]/td[8]/span//a[text()='View']");
- //click through to the participant view screen
- $this->click("xpath=//form[@id='Search']/table/tbody/tr[1]/td[8]/span//a[text()='View']");
- $this->waitForElementPresent('_qf_ParticipantView_cancel-bottom');
-
- $this->webtestVerifyTabularData(
- array(
- 'Event' => $eventTitle,
- 'Participant Role' => 'Attendee',
- 'Status' => 'Registered',
- 'Event Source' => 'Event StandaloneAddTest Webtest',
- )
- );
- $this->waitForElementPresent("xpath=//table/tbody/tr/td[text()='Fees']/following-sibling::td");
- $this->verifyText("xpath=//table/tbody/tr/td[text()='Fees']/following-sibling::td/table/tbody/tr[2]/td", preg_quote('$ 2,705.00'));
- $expectedLineItems = array(
- 2 => array(
- 1 => 'Full Conference ',
- 2 => '5',
- 3 => '$ 525.00',
- 4 => '$ 2,625.00',
- ),
- 3 => array(
- 2 => '1',
- 3 => '$ 50.00',
- 4 => '$ 50.00',
- ),
- 4 => array(
- 1 => 'Evening Sessions - First Night ',
- 2 => '1',
- 3 => '$ 15.00',
- 4 => '$ 15.00',
- ),
- 5 => array(
- 1 => 'Evening Sessions - Second Night ',
- 2 => '1',
- 3 => '$ 15.00',
- 4 => '$ 15.00',
- ),
- );
- $this->_checkLineItems($expectedLineItems);
- // check contribution record as well
- // click through to the contribution view screen
- $this->click("xpath=//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span//a[text()='View']");
- $this->waitForElementPresent('_qf_ContributionView_cancel-bottom');
-
- $this->webtestVerifyTabularData(
- array(
- 'From' => $displayName,
- 'Financial Type' => 'Event Fee',
- 'Contribution Status' => 'Completed',
- 'Payment Method' => 'Check',
- 'Check Number' => '1044',
- 'Received Into' => 'Deposit Bank Account',
- )
- );
- $this->verifyText("xpath=//td[text()='Contribution Amount']/following-sibling::td//div/div", preg_quote('Contribution Total: $ 2,705.00'));
-
- // CRM-17182 - Rename the price option and check the same in Find Participants
- $this->openCiviPage('admin/price/field', "reset=1&action=browse&sid={$sid}", 'newPriceField');
- $this->click("xpath=//table[@id='options']/tbody/tr[3]/td[8]/a[text()='Edit Price Options']");
- $this->waitForElementPresent("xpath=//span[contains(text(), 'Done')]");
- $this->click("xpath=//table[@id='options']/tbody/tr/td/div[text()='First Night']/../following-sibling::td[8]/span//a[text()='Edit Option']");
- $this->waitForElementPresent("_qf_Option_cancel");
- $this->type('label', 'First Night Edited');
- $this->click('_qf_Option_next');
- $this->waitForText('crm-notification-container', "The option 'First Night Edited' has been saved.");
-
- $this->openCiviPage('event/search', "reset=1", '_qf_Search_refresh');
- $this->select2('participant_fee_id', 'First Night Edited');
- $this->click('_qf_Search_refresh');
- $this->waitForAjaxContent();
- $this->clickLink("xpath=//form[@class='CRM_Event_Form_Search crm-search-form']//div[3]/div/div[2]//table//tbody/tr[1]/td[11]/span//a[text()='View']", "xpath=//span[contains(text(), 'Done')]", FALSE);
- $expectedLineItems[4][1] = 'Evening Sessions - First Night Edited';
- $this->_checkLineItems($expectedLineItems);
- }
-
-
- public function testDeletePriceSetforEventTemplate() {
- $this->markTestSkipped('Skipping for now as it works fine locally.');
- // Log in using webtestLogin() method
- $this->webtestLogin();
-
- $setTitle = 'Conference Fees - ' . substr(sha1(rand()), 0, 7);
- $usedFor = 'Event';
- $setHelp = 'Select your conference options.';
- $this->_testAddSet($setTitle, $usedFor, $setHelp);
-
- // Get the price set id ($sid) by retrieving and parsing the URL of the New Price Field form
- // which is where we are after adding Price Set.
- $sid = $this->urlArg('sid');
- $this->assertType('numeric', $sid);
-
- $validStrings = array();
- $fields = array(
- 'Test Field' => 'Text',
- );
- $this->_testAddPriceFields($fields, $validateStrings);
-
- // load the Price Set Preview and check for expected values
- $this->_testVerifyPriceSet($validateStrings, $sid);
- $this->openCiviPage('admin/eventTemplate', 'reset=1');
- $this->clickLink('newEventTemplate');
- $this->select("template_id", "value=6");
- // Wait for event type to be filled in (since page reloads)
- $this->waitForElementPresent("template_id");
- // Enter Event Title, Summary and Description
- $this->select("event_type_id", "value=4");
- $this->select("default_role_id", "value=1");
- $this->waitForAjaxContent();
- $this->type("title", "Test Event");
- $this->type("summary", "This is a great conference. Sign up now!");
-
- $this->click("_qf_EventInfo_upload-bottom");
- $this->waitForElementPresent('link=Fees');
- // Go to Fees tab
- $this->click('link=Fees');
- $this->waitForElementPresent('_qf_Fee_upload-bottom');
- $this->click('CIVICRM_QFID_1_is_monetary');
- $this->select('financial_type_id', 'label=Event Fee');
- $this->select('price_set_id', 'label=' . $setTitle);
- $templateId = $this->urlArg('id');
- $this->click('_qf_Fee_upload-bottom');
-
- //check the delete for price field
- $this->openCiviPage("admin/price/field", "reset=1&action=browse&sid={$sid}");
- $this->waitForElementPresent("xpath=//table[@id='options']/tbody/tr/td[9]/span[2]");
- $this->click("xpath=//table[@id='options']/tbody/tr/td[9]/span[2]/ul[@class='panel']/li[2]//a[text()='Delete']");
- //assert the message
- $this->waitForText('price_set_used_by', "it is currently in use by one or more active events or contribution pages or contributions or event templates. If you no longer want to use this price set, click the event title below, and modify the fees for that event.");
-
- //check the delete for priceset
- $this->openCiviPage("admin/price", "reset=1");
- $this->waitForElementPresent("xpath=//table[@class='display crm-price-set-listing dataTable no-footer']/tbody/tr/td[4]/span[2]");
- $this->click("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[4]/span[2]/ul/li[3]//a[text()='Delete']");
- // Check confirmation alert.
- $this->assertTrue((bool) preg_match("/^Are you sure you want to delete this price set?/",
- $this->getConfirmation()
- ));
- $this->chooseOkOnNextConfirmation();
- $this->waitForPageToLoad($this->getTimeoutMsec());
- //assert the message
- $this->waitForText('price_set_used_by',
- "it is currently in use by one or more active events or contribution pages or contributions or event templates.");
- }
-
- /**
- * @param array $expectedLineItems
- */
- public function _checkLineItems($expectedLineItems) {
- foreach ($expectedLineItems as $lineKey => $lineValue) {
- foreach ($lineValue as $key => $value) {
- $this->verifyText("xpath=//table/tbody//tr/td[text()='Selections']/following-sibling::td/table/tbody//tr[$lineKey]/td[$key]", preg_quote($value));
- }
- }
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-/**
- * Description of AddRecurringEventTest
- *
- * @author Priyanka
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Event_AddRecurringEventTest
- */
-class WebTest_Event_AddRecurringEventTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testRecurringEvent() {
- $this->webtestLogin();
-
- //Add repeat configuration for an event
- $this->openCiviPage("event/manage/repeat", "reset=1&action=update&id=1", '_qf_Repeat_cancel-bottom');
-
- $this->click('repetition_frequency_unit');
- $this->select('repetition_frequency_unit', 'label=week');
- $this->click('repetition_frequency_interval');
- $this->select('repetition_frequency_interval', 'label=1');
- $this->click('start_action_condition_monday');
- $this->click('start_action_condition_tuesday');
- $this->click('CIVICRM_QFID_1_ends');
-
- $occurrences = rand(3, 5);
- if (!$occurrences) {
- $occurrences = 3;
- }
- $this->select('start_action_offset', $occurrences);
- $this->multiselect2('exclude_date_list', array('05/11/2015', '05/12/2015'), TRUE);
- $this->click('_qf_Repeat_submit-bottom');
- $this->waitForTextPresent('A repeating set will be created with the following dates.');
- $this->click("xpath=//button//span[text()='Continue']");
- $this->waitForAjaxContent();
- $this->checkCRMAlert('Repeat Configuration has been saved');
-
- //Check if assertions are correct
- $this->waitForElementPresent("xpath=//div[@id='recurring-entity-block']/following-sibling::div//div[@class='crm-accordion-body']/div/table/tbody/tr");
- $count = $this->getXpathCount("xpath=//div[@id='recurring-entity-block']/following-sibling::div//div[@class='crm-accordion-body']/div/table/tbody/tr");
- $this->assertEquals($occurrences, $count);
-
- //Lets go to find participant page and see our repetitive events there
- $this->openCiviPage("event/manage", "reset=1");
- $eventTitle = "Fall Fundraiser Dinner";
- $this->type("title", $eventTitle);
- $this->click("_qf_SearchEvent_refresh");
- $this->assertTrue($this->isTextPresent("Repeating"));
-
- //Update Mode Cascade Changes
- $this->click('event-configure-1');
- $this->waitForElementPresent("xpath=//span[@id='event-configure-1']/ul[@class='panel']/li/a[text()='Info and Settings']");
- $this->click("xpath=//span[@id='event-configure-1']/ul[@class='panel']/li/a[text()='Info and Settings']");
- $this->waitForTextPresent("Event Title");
- $this->type('title', 'CiviCon');
- $this->click('_qf_EventInfo_upload_done-top');
- $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']/button/span[text()='Cancel']");
- $this->click("recur-all-entity");
- $this->click("xpath=//button//span[text()='Continue']");
- $this->waitForAjaxContent();
- $this->openCiviPage("event/manage", "reset=1");
- $newEventTitle = "CiviCon";
- $this->type("title", $newEventTitle);
- $this->click("_qf_SearchEvent_refresh");
- $this->waitForPageToLoad();
- $countOfEvents = $this->getXpathCount("xpath=//div[@id='option11_wrapper']/table[@id='option11']/tbody/tr");
- if ($countOfEvents) {
- for ($i = 0; $i <= $countOfEvents; $i++) {
- $this->verifyText("xpath=//div[@id='option11_wrapper']/table[@id='option11']/tbody/tr/td[1]/a", 'CiviCon');
- }
- }
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Event_AdditionalPaymentTest
- */
-class WebTest_Event_AdditionalPaymentTest extends CiviSeleniumTestCase {
- protected function setUp() {
- parent::setUp();
- }
-
- /**
- * CRM-13964 and CRM-13965
- */
- public function testParticipantPartialPaymentInitiation() {
- $this->markTestSkipped('Skipping for now as it works fine locally.');
- // Log in using webtestLogin() method
- $this->webtestLogin();
-
- $firstName = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName, 'Anderson', TRUE);
- $contactName = "Anderson, $firstName";
- $displayName = "$firstName Anderson";
-
- $this->openCiviPage("participant/add", "reset=1&action=add&context=standalone", "_qf_Participant_upload-bottom");
-
- $this->webtestFillAutocomplete($firstName);
-
- // Select event. Based on label for now.
- $this->select2('event_id', "Rain-forest Cup Youth Soccer Tournament");
-
- // Select role
- $this->multiselect2('role_id', array('Volunteer'));
-
- // Choose Registration Date.
- // Using helper webtestFillDate function.
- $this->webtestFillDate('register_date', 'now');
- $today = date('F jS, Y', strtotime('now'));
-
- // Select participant status
- $this->select('status_id', 'value=1');
-
- // Setting registration source
- $this->waitForElementPresent('source');
- $this->type('source', 'Event Partially Paid Webtest');
-
- // Since we're here, let's check of screen help is being displayed properly
- $this->assertTrue($this->isTextPresent('Source for this registration (if applicable).'));
-
- // Select an event fee
- $this->waitForElementPresent('priceset');
-
- $this->click("xpath=//input[@class='crm-form-radio']");
- $this->waitForAjaxContent();
- // record payment total amount
- // amount populated after fee selection
- $amtTotalOwed = (int) $this->getValue('id=total_amount');
- $this->assertEquals($amtTotalOwed, 800, 'The amount owed doesn\'t match to fee amount selected');
-
- // now change the amount to lesser amount value
- $this->type('total_amount', '400');
-
- // Select payment method = Check and enter chk number
- $this->select('payment_instrument_id', 'value=4');
- $this->waitForElementPresent('check_number');
- $this->type('check_number', '1044');
-
- // give some time for js to process
- $this->waitForAjaxContent();
- $this->verifySelectedLabel("status_id", 'Partially paid');
-
- // later on change the status
- $this->select('status_id', 'value=1');
-
- // Clicking save.
- // check for proper info message displayed regarding status
- $this->chooseCancelOnNextConfirmation();
- $this->click('_qf_Participant_upload-bottom');
- $this->assertTrue((bool) preg_match("/Payment amount is less than the amount owed. Expected participant status is 'Partially paid'. Are you sure you want to set the participant status to Registered/", $this->getConfirmation()));
-
- // select partially paid status again and click on save
- $this->select('status_id', 'label=Partially paid');
-
- // Clicking save.
- $this->clickLink('_qf_Participant_upload-bottom');
-
- // Is status message correct?
- $this->waitForText('crm-notification-container', "Event registration for $displayName has been added");
- $this->waitForElementPresent("xpath=//form[@class='CRM_Event_Form_Search crm-search-form']/table[@class='selector row-highlight']//tbody/tr[1]/td[8]/span//a[text()='View']");
- //click through to the participant view screen
- $this->click("xpath=//form[@class='CRM_Event_Form_Search crm-search-form']/table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span//a[text()='View']");
- $this->waitForElementPresent("xpath=//button//span[contains(text(),'Done')]");
-
- $this->webtestVerifyTabularData(
- array(
- 'Event' => 'Rain-forest Cup Youth Soccer Tournament',
- 'Participant Role' => 'Volunteer',
- 'Status' => 'Partially paid',
- 'Event Source' => 'Event Partially Paid Webtest',
- )
- );
-
- // check the fee amount and contribution amount
- $this->_checkPaymentInfoTable(800.00, 400.00);
- $balance = 800.00 - 400.00;
- //click through to the contribution view screen
- $this->waitForElementPresent("xpath=id('ParticipantView')/div[2]/table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='View']");
- $this->click("xpath=id('ParticipantView')/div[2]/table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='View']");
- $this->waitForElementPresent("xpath=//button//span[contains(text(),'Done')]");
-
- $this->webtestVerifyTabularData(
- array(
- 'From' => $displayName,
- 'Financial Type' => 'Event Fee',
- 'Total Amount' => '$ 800.00',
- 'Contribution Status' => 'Partially paid',
- 'Payment Method' => 'Check',
- 'Check Number' => '1044',
- )
- );
-
- $this->clickAjaxLink("xpath=//button//span[contains(text(),'Done')]");
- $this->waitForElementPresent("xpath=//form[@id='ParticipantView']//div/table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span//a[text()='View']");
- // make additional payment
- // 1 - check for links presence on participant view and edit page
- $this->waitForElementPresent("xpath=//form[@id='ParticipantView']//div//table//tbody//td[@id='payment-info']//a[contains(text(), 'Record Payment')]");
- $this->click("xpath=id('ParticipantView')//div[@class='action-link']/div/a/span[contains(text(), 'Edit')]");
- $this->waitForElementPresent("xpath=id('ParticipantView')//td[@id='payment-info']//a[contains(text(), 'Record Payment')]");
- $this->clickLinkSuppressPopup("xpath=id('ParticipantView')//td[@id='payment-info']//a[contains(text(), 'Record Payment')]", 'AdditionalPayment');
-
- // verify balance
- $text = $this->getText("xpath=id('AdditionalPayment')/div[2]//table/tbody/tr[3]/td[2]");
- $this->assertTrue((bool) preg_match("/{$balance}/", $text));
-
- // check form rule error
- $errorBalance = $balance + 1;
- $this->type('total_amount', $errorBalance);
- $this->select('payment_instrument_id', 'label=Cash');
- $this->click('_qf_AdditionalPayment_upload-bottom');
- $this->waitForText("xpath=//span[@id='totalAmount']/span", 'Payment amount cannot be greater than owed amount');
- $this->type('total_amount', $balance);
- $this->click('_qf_AdditionalPayment_upload-bottom');
- $this->checkCRMAlert('The payment record has been processed.');
- $this->waitForElementPresent("xpath=//*[contains(@class, 'CRM_Event_Form_Search')]//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='View']");
- $this->click("xpath=//*[contains(@class, 'CRM_Event_Form_Search')]//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='View']");
- $this->waitForElementPresent("xpath=//button//span[contains(text(),'Done')]");
- $this->webtestVerifyTabularData(
- array(
- 'Event' => 'Rain-forest Cup Youth Soccer Tournament',
- 'Participant Role' => 'Volunteer',
- 'Status' => 'Registered',
- 'Event Source' => 'Event Partially Paid Webtest',
- )
- );
- // check the fee amount and contribution amount
- $this->_checkPaymentInfoTable(800.00, 800.00);
-
- // check for absence of record payment button
- $this->assertFalse($this->isElementPresent("xpath=id('ParticipantView')//td[@id='payment-info']//a[contains(text(), 'Record Payment')]"));
-
- $this->clickAjaxLink("xpath=id('ParticipantView')/div[2]/table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='View']");
-
- $this->webtestVerifyTabularData(
- array(
- 'From' => $displayName,
- 'Financial Type' => 'Event Fee',
- 'Total Amount' => '$ 800.00',
- 'Contribution Status' => 'Completed',
- 'Payment Method' => 'Check',
- 'Check Number' => '1044',
- )
- );
- $this->click("xpath=//button//span[contains(text(),'Done')]");
-
- // view transaction popup info check
- $this->waitForElementPresent("xpath=//td[@id='payment-info']/table[@id='info']/tbody/tr[2]/td[2]/a");
- $this->clickAjaxLink("xpath=//td[@id='payment-info']/table[@id='info']/tbody/tr[2]/td[2]/a");
- $this->waitForElementPresent("xpath=//table[@id='info']/tbody/tr/th[contains(text(), 'Amount')]/../../tr[2]/td[contains(text(), '$ 400.00')]/../../tr[3]/td[contains(text(), '$ 400.00')]");
- $this->waitForElementPresent("xpath=//table[@id='info']/tbody/tr/th[3][contains(text(), 'Payment Method')]/../../tr[2]/td[3][contains(text(), 'Check')]/../../tr[3]/td[3][contains(text(), 'Cash')]");
- $this->waitForElementPresent("xpath=//table[@id='info']/tbody/tr/th[6][contains(text(), 'Status')]/../../tr[2]/td[6][contains(text(), 'Completed')]/../../tr[3]/td[6][contains(text(), 'Completed')]");
- }
-
- /**
- * @param $feeAmt
- * @param int $amtPaid
- */
- public function _checkPaymentInfoTable($feeAmt, $amtPaid) {
- $this->assertElementContainsText("xpath=//td[@id='payment-info']/table[@id='info']/tbody/tr[2]/td", "$ {$feeAmt}", 'Missing text: appropriate fee amount');
- $this->assertElementContainsText("xpath=//td[@id='payment-info']/table[@id='info']/tbody/tr[2]/td[2]", "$ {$amtPaid}", 'Missing text: appropriate fee amount');
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Event_ChangeParticipantStatus
- */
-class WebTest_Event_ChangeParticipantStatus extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testParticipationAdd() {
- // Log in using webtestLogin() method
- $this->webtestLogin();
-
- // Adding contact with randomized first name (so we can then select that contact when creating event registration)
- // We're using Quick Add block on the main page for this.
- $firstName1 = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName1, 'Anderson', TRUE);
- $sortName1 = "Anderson, $firstName1";
- $this->addParticipant($firstName1);
-
- $firstName2 = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName2, 'Anderson', TRUE);
- $sortName2 = "Anderson, $firstName2";
- $this->addParticipant($firstName2);
-
- // Search the participants
- $this->openCiviPage("event/search", "reset=1", '_qf_Search_refresh');
-
- $eventName = 'Rain-forest Cup Youth Soccer Tournament';
- $this->select2("event_id", $eventName);
- $this->click('_qf_Search_refresh');
-
- $this->waitForElementPresent("xpath=//div[@id='participantSearch']/table/tbody//tr/td[3]/a[text()='$sortName1']");
- $id1 = $this->getAttribute("xpath=//div[@id='participantSearch']/table/tbody//tr/td[3]/a[text()='$sortName1']/../../td[1]/input@id");
- $this->click("xpath=//div[@id='participantSearch']/table/tbody//tr/td[3]/a[text()='$sortName1']/../../td[1]/");
- $this->click($id1);
-
- $id2 = $this->getAttribute("xpath=//div[@id='participantSearch']/table/tbody//tr/td[3]/a[text()='$sortName2']/../../td[1]/input@id");
- $this->click("xpath=//div[@id='participantSearch']/table/tbody//tr/td[3]/a[text()='$sortName2']/../../td[1]/");
- $this->click($id2);
-
- // Change participant status for selected participants
- $this->select('task', "label=Participant status - change (emails sent)");
- $this->waitForElementPresent('_qf_ParticipantStatus_next');
-
- $this->select('status_change', "label=Attended");
- $this->clickLink('_qf_ParticipantStatus_next');
- $this->assertTrue($this->isTextPresent('The updates have been saved.'),
- "Status message didn't show up after saving!"
- );
-
- // Verify the changed status
- $this->openCiviPage("event/search", "reset=1", '_qf_Search_refresh');
- $this->type('sort_name', $firstName1);
- $this->click('_qf_Search_refresh');
- $this->waitForElementPresent("xpath=//div[@id='participantSearch']/table/tbody//tr/td[3]/a[text()='$sortName1']");
- $this->click("xpath=//div[@id='participantSearch']/table/tbody//tr/td[3]/a[text()='$sortName1']/../../td[11]/span/a[text()='View']");
- $this->waitForElementPresent('_qf_ParticipantView_cancel-bottom');
- $this->webtestVerifyTabularData(array('Status' => 'Attended'));
-
- $this->openCiviPage("event/search", "reset=1", '_qf_Search_refresh');
- $this->type('sort_name', $firstName2);
- $this->click('_qf_Search_refresh');
- $this->waitForElementPresent("xpath=//div[@id='participantSearch']/table/tbody//tr/td[3]/a[text()='$sortName2']");
- $this->click("xpath=//div[@id='participantSearch']/table/tbody//tr/td[3]/a[text()='$sortName2']/../../td[11]/span/a[text()='View']");
- $this->waitForElementPresent('_qf_ParticipantView_cancel-bottom');
- $this->webtestVerifyTabularData(array('Status' => 'Attended'));
- }
-
- /**
- * @param string $firstName
- */
- public function addParticipant($firstName) {
- $this->openCiviPage("participant/add", "reset=1&action=add&context=standalone", '_qf_Participant_upload-bottom');
-
- // Type contact last name in contact auto-complete, wait for dropdown and click first result
- $this->webtestFillAutocomplete($firstName);
-
- // Select event. Based on label for now.
- $this->select2('event_id', "Rain-forest Cup Youth Soccer Tournament");
-
- // Select role
- $this->multiselect2('role_id', array('Volunteer'));
-
- // Choose Registration Date.
- // Using helper webtestFillDate function.
- $this->webtestFillDate('register_date', 'now');
- $today = date('F jS, Y', strtotime('now'));
-
- // Select participant status
- $this->select('status_id', 'value=1');
-
- // Setting registration source
- $this->type('source', 'Event StandaloneAddTest Webtest');
-
- // Since we're here, let's check of screen help is being displayed properly
- $this->assertTrue($this->isTextPresent('Source for this registration (if applicable).'));
-
- // Select an event fee
- $this->waitForElementPresent('priceset');
-
- $this->click("xpath=//input[@class='crm-form-radio']");
- // Select 'Record Payment'
- $this->click('record_contribution');
-
- // Enter amount to be paid (note: this should default to selected fee level amount, s/b fixed during 3.2 cycle)
- $this->type('total_amount', '800');
-
- // Select payment method = Check and enter chk number
- $this->select('payment_instrument_id', 'value=4');
- $this->waitForElementPresent('check_number');
- $this->type('check_number', '1044');
-
- // Clicking save.
- $this->click('_qf_Participant_upload-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Is status message correct?
- $this->assertTrue($this->isTextPresent("Event registration for $firstName Anderson has been added"),
- "Status message didn't show up after saving!"
- );
-
- $this->waitForElementPresent("xpath=//*[@id='Search']//table//tbody/tr[1]/td[8]/span/a[text()='View']");
- //click through to the participant view screen
- $this->click("xpath=//*[@id='Search']//table//tbody/tr[1]/td[8]/span/a[text()='View']");
- $this->waitForElementPresent('_qf_ParticipantView_cancel-bottom');
-
- $this->webtestVerifyTabularData(
- array(
- 'Event' => 'Rain-forest Cup Youth Soccer Tournament',
- 'Participant Role' => 'Attendee',
- 'Status' => 'Registered',
- 'Event Source' => 'Event StandaloneAddTest Webtest',
- )
- );
- $this->verifyText("xpath=//td[text()='Selections']/following-sibling::td//div", preg_quote('Event Total: $ 800.00'));
- }
-
-}
+++ /dev/null
-<?php
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Event_EventListingTest
- */
-class WebTest_Event_EventListingTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testEventListing() {
- // Log in using webtestLogin() method
- $this->webtestLogin('admin');
-
- //Closed Event
- $eventTitle1 = 'My Conference - ' . substr(sha1(rand()), 0, 7);
- $this->_testCreateEvent($eventTitle1, '-12 months', '-3 months');
-
- //Closed Event with current date as end date
- $eventTitle2 = 'My Conference - ' . substr(sha1(rand()), 0, 7);
- $this->_testCreateEvent($eventTitle2, '-12 months', 'now');
-
- //Ongoing Event with start date as yesterday
- $eventTitle3 = 'My Conference - ' . substr(sha1(rand()), 0, 7);
- $this->_testCreateEvent($eventTitle3, '-1 day', '+12 months');
-
- //Upcoming Event
- $eventTitle4 = 'My Conference - ' . substr(sha1(rand()), 0, 7);
- $this->_testCreateEvent($eventTitle4, '+6 months', '+12 months');
-
- //Upcoming Event
- $eventTitle5 = 'My Conference - ' . substr(sha1(rand()), 0, 7);
- $this->_testCreateEvent($eventTitle5, '+3 months', '+6 months');
-
- //go to manage event and check for presence of ongoing and
- //upcoming events
- $this->openCiviPage("event/manage", "reset=1");
- $this->type("xpath=//div[@class='crm-block crm-form-block crm-event-searchevent-form-block']/table/tbody/tr/td/input", $eventTitle1);
- $this->click("_qf_SearchEvent_refresh");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->assertFalse($this->isTextPresent("{$eventTitle1}"));
- $this->type("xpath=//div[@class='crm-block crm-form-block crm-event-searchevent-form-block']/table/tbody/tr/td/input", $eventTitle2);
- $this->click("_qf_SearchEvent_refresh");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->assertFalse($this->isTextPresent("{$eventTitle2}"));
- $this->type("xpath=//div[@class='crm-block crm-form-block crm-event-searchevent-form-block']/table/tbody/tr/td/input", $eventTitle3);
- $this->click("_qf_SearchEvent_refresh");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForText("SearchEvent", "{$eventTitle3}");
- $this->type("xpath=//div[@class='crm-block crm-form-block crm-event-searchevent-form-block']/table/tbody/tr/td/input", $eventTitle4);
- $this->click("_qf_SearchEvent_refresh");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForText("SearchEvent", "{$eventTitle4}");
- $this->type("xpath=//div[@class='crm-block crm-form-block crm-event-searchevent-form-block']/table/tbody/tr/td/input", $eventTitle5);
- $this->click("_qf_SearchEvent_refresh");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForText("SearchEvent", "{$eventTitle5}");
- $this->type("xpath=//div[@class='crm-block crm-form-block crm-event-searchevent-form-block']/table/tbody/tr/td/input", "");
-
- //check if closed Event is present
- $this->waitForElementPresent('CIVICRM_QFID_1_eventsByDates');
- $this->click('CIVICRM_QFID_1_eventsByDates');
- $this->webtestFillDate("end_date", "now");
- $this->waitForElementPresent('_qf_SearchEvent_refresh');
- $this->click('_qf_SearchEvent_refresh');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->waitForText("option11", "{$eventTitle1}");
- $this->waitForText("option11", "{$eventTitle2}");
- $this->assertFalse($this->isTextPresent("{$eventTitle3}"));
- $this->assertFalse($this->isTextPresent("{$eventTitle4}"));
- $this->assertFalse($this->isTextPresent("{$eventTitle5}"));
-
- //go to ical and check for presence of ongoing and upcoming events
- $this->openCiviPage("event/ical", "reset=1&page=1&html=1", NULL);
- $this->assertFalse($this->isTextPresent("{$eventTitle1}"));
- $this->assertFalse($this->isTextPresent("{$eventTitle2}"));
- $this->waitForText("option11", "{$eventTitle3}");
- $this->waitForText("option11", "{$eventTitle4}");
- $this->waitForText("option11", "{$eventTitle5}");
-
- //go to block listing to enable Upcoming Events Block
- // you need to be admin user for below operation
- $this->webtestLogout();
- $this->webtestLogin('admin');
-
- $this->open($this->sboxPath . 'admin/structure/block/manage/civicrm/6/configure');
- $this->waitForElementPresent('edit-submit');
- $this->type('edit-pages', 'civicrm/dashboard');
- $this->click('edit-submit');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->open($this->sboxPath . 'admin/structure/block');
- $this->select('edit-blocks-civicrm-6-region', 'value=sidebar_second');
- $this->click('edit-submit');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForTextPresent("The block settings have been updated.");
-
- //go to civicrm home and check for presence of upcoming events
- $this->openCiviPage("dashboard", "reset=1");
- $this->assertFalse($this->isTextPresent("{$eventTitle1}"));
- $this->assertFalse($this->isTextPresent("{$eventTitle2}"));
- $this->assertFalse($this->isTextPresent("{$eventTitle3}"));
- $this->waitForText("block-civicrm-6", "{$eventTitle4}");
- $this->waitForText("block-civicrm-6", "{$eventTitle5}");
-
- //go to block listing to disable Upcoming Events Block
- $this->open($this->sboxPath . 'admin/structure/block');
- $this->select('edit-blocks-civicrm-6-region', 'value=-1');
- $this->click('edit-submit');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForTextPresent("The block settings have been updated.");
- }
-
- /**
- * @param $eventTitle
- * @param $startdate
- * @param $enddate
- */
- public function _testCreateEvent($eventTitle, $startdate, $enddate) {
-
- $this->openCiviPage("event/add", "reset=1&action=add");
-
- // $eventTitle = 'My Conference - '.substr(sha1(rand()), 0, 7);
- $eventDescription = "Here is a description for this conference.";
- $this->waitForElementPresent("_qf_EventInfo_upload-bottom");
-
- $this->select("event_type_id", "value=1");
-
- // Attendee role s/b selected now.
- $this->select("default_role_id", "value=1");
-
- // Enter Event Title, Summary and Description
- $this->type("title", $eventTitle);
- $this->type("summary", "This is a great conference. Sign up now!");
-
- // Type description in ckEditor (fieldname, text to type, editor)
- $this->fillRichTextField("description", $eventDescription, 'CKEditor');
-
- // Choose Start and End dates.
- // Using helper webtestFillDate function.
- if ($startdate) {
- $this->webtestFillDateTime("start_date", $startdate);
- }
-
- if ($enddate == 'now') {
- // to avoid time zone difference problem between selenium-test & drupal
- $this->webtestFillDate("end_date", $enddate);
- }
- elseif ($enddate) {
- $this->webtestFillDateTime("end_date", $enddate);
- }
-
- $this->type("max_participants", "6");
- $this->click("is_public");
- $this->clickLink("_qf_EventInfo_upload-bottom", "_qf_Location_upload_done-bottom");
-
- $this->click("_qf_Location_upload_done-bottom");
-
- // Wait for "saved" status msg
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForText("crm-notification-container", "'Event Location' information has been saved.");
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Event_EventWaitListTest
- */
-class WebTest_Event_EventWaitListTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testEventWaitList() {
- // Log in using webtestLogin() method
- $this->webtestLogin();
-
- // Use default payment processor
- $processorName = 'Test Processor';
- $this->webtestAddPaymentProcessor($processorName);
-
- $this->openCiviPage("event/add", "reset=1&action=add");
-
- $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7);
- $eventDescription = "Here is a description for this conference.";
- $this->waitForElementPresent("_qf_EventInfo_upload-bottom");
-
- $this->select("event_type_id", "value=1");
-
- // Attendee role s/b selected now.
- $this->select("default_role_id", "value=1");
-
- // Enter Event Title, Summary and Description
- $this->type("title", $eventTitle);
- $this->type("summary", "This is a great conference. Sign up now!");
-
- // Type description in ckEditor (fieldname, text to type, editor)
- $this->fillRichTextField("description", $eventDescription, 'CKEditor');
-
- // Choose Start and End dates.
- // Using helper webtestFillDate function.
- $this->webtestFillDateTime("start_date", "+1 week");
- $this->webtestFillDateTime("end_date", "+1 week 1 day 8 hours ");
-
- $this->type("max_participants", "6");
- $this->click("is_map");
- $this->click("_qf_EventInfo_upload-bottom");
-
- $streetAddress = "100 Main Street";
-
- // Wait for Location tab form to load
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForElementPresent("_qf_Location_upload-bottom");
-
- // Fill in address fields
- $streetAddress = "100 Main Street";
- $this->type("address_1_street_address", $streetAddress);
- $this->type("address_1_city", "San Francisco");
- $this->type("address_1_postal_code", "94117");
- $this->select('address_1_country_id', 'UNITED STATES');
- $this->select("address_1_state_province_id", "value=1004");
- $this->type("email_1_email", "info@civicrm.org");
-
- $this->click("_qf_Location_upload-bottom");
-
- // Wait for "saved" status msg
- $this->waitForElementPresent("_qf_Location_upload-bottom");
- $this->waitForTextPresent("'Event Location' information has been saved.");
-
- // Go to Fees tab
- $this->click("link=Fees");
- $this->waitForElementPresent("_qf_Fee_upload-bottom");
- $this->click("CIVICRM_QFID_1_is_monetary");
- $this->select2('payment_processor', $processorName, TRUE);
- $this->select("financial_type_id", "Donation");
- $this->type("label_1", "Member");
- $this->type("value_1", "250.00");
- $this->type("label_2", "Non-member");
- $this->type("value_2", "325.00");
- //set default
- $this->click("xpath=//table[@id='map-field-table']/tbody/tr[2]/td[3]/input");
-
- $this->click("_qf_Fee_upload-bottom");
-
- // Wait for "saved" status msg
- $this->waitForElementPresent("_qf_Fee_upload-bottom");
- $this->waitForTextPresent("'Fees' information has been saved.");
-
- // intro text for registration page
- $registerIntro = "Fill in all the fields below and click Continue.";
- $multipleRegistrations = TRUE;
-
- // Go to Online Registration tab
- $this->click("link=Online Registration");
- $this->waitForElementPresent("_qf_Registration_upload-bottom");
- $this->isTextPresent("BCC Confirmation To");
- $this->check("is_online_registration");
- $this->assertChecked("is_online_registration");
- if ($multipleRegistrations) {
- $this->check("is_multiple_registrations");
- $this->assertChecked("is_multiple_registrations");
- }
-
- $this->fillRichTextField('intro_text', $registerIntro, 'CKEditor', TRUE);
-
- // enable confirmation email
- $this->click("CIVICRM_QFID_1_is_email_confirm");
- $this->type("confirm_from_name", "Jane Doe");
- $this->type("confirm_from_email", "jane.doe@example.org");
-
- $this->click("_qf_Registration_upload-bottom");
- $this->waitForElementPresent("_qf_Registration_upload-bottom");
- $this->waitForTextPresent("'Online Registration' information has been saved.");
-
- $eventInfoStrings = array($eventTitle, $eventDescription, $streetAddress);
- $this->_testVerifyEventInfo($eventTitle, $eventInfoStrings);
-
- $registerStrings = array("250.00", "Member", "325.00", "Non-member");
- $registerUrl = $this->_testVerifyRegisterPage($registerStrings);
-
- $numberRegistrations = 2;
- $anonymous = TRUE;
- $this->_testOnlineRegistration($registerUrl, $numberRegistrations, $anonymous);
-
- $numberRegistrations = 2;
- $anonymous = TRUE;
- $this->_testOnlineRegistration($registerUrl, $numberRegistrations, $anonymous);
-
- //check whether event is full
- $this->open($registerUrl);
- $this->assertStringsPresent("This event is currently full.");
- }
-
- /**
- * @param $eventTitle
- * @param $eventInfoStrings
- */
- public function _testVerifyEventInfo($eventTitle, $eventInfoStrings) {
- // verify event input on info page
- // start at Manage Events listing
- $this->openCiviPage("event/manage", "reset=1");
- $this->clickLink("link=$eventTitle", "link=Register Now");
-
- // Check for correct event info strings
- $this->assertStringsPresent($eventInfoStrings);
- }
-
- /**
- * @param $registerStrings
- *
- * @return string
- */
- public function _testVerifyRegisterPage($registerStrings) {
- // Go to Register page and check for intro text and fee levels
- $this->click("link=Register Now");
- $this->waitForElementPresent("_qf_Register_upload-bottom");
- $this->assertStringsPresent($registerStrings);
- return $this->getLocation();
- }
-
- /**
- * @param $registerUrl
- * @param int $numberRegistrations
- * @param bool $anonymous
- */
- public function _testOnlineRegistration($registerUrl, $numberRegistrations = 1, $anonymous = TRUE) {
- if ($anonymous) {
- $this->webtestLogout();
- }
- $this->open($registerUrl);
-
- $this->select("additional_participants", "value=" . $numberRegistrations);
- $this->type("first_name", "Jane");
- $lastName = "Smith" . substr(sha1(rand()), 0, 7);
- $this->type("last_name", $lastName);
- $this->type("email-Primary", "smith" . substr(sha1(rand()), 0, 7) . "@example.org");
-
- $this->select("credit_card_type", "value=Visa");
- $this->type("credit_card_number", "4111111111111111");
- $this->type("cvv2", "000");
- $this->select("credit_card_exp_date[M]", "value=1");
- $this->select("credit_card_exp_date[Y]", "value=2020");
- $this->type("billing_first_name", "Jane");
- $this->type("billing_last_name", $lastName);
- $this->type("billing_street_address-5", "15 Main St.");
- $this->type(" billing_city-5", "San Jose");
- $this->select("billing_country_id-5", "value=1228");
- $this->select("billing_state_province_id-5", "value=1004");
- $this->type("billing_postal_code-5", "94129");
-
- $this->click("_qf_Register_upload-bottom");
-
- if ($numberRegistrations > 1) {
- for ($i = 1; $i <= $numberRegistrations; $i++) {
- $this->waitForPageToLoad($this->getTimeoutMsec());
- // Look for continue button
- $this->waitForElementPresent("_qf_Participant_{$i}_next");
- $this->type("first_name", "Jane Add {$i}");
- $lastName = "Smith" . substr(sha1(rand()), 0, 7);
- $this->type("last_name", $lastName);
- $this->type("email-Primary", "smith" . substr(sha1(rand()), 0, 7) . "@example.org");
- $this->click("_qf_Participant_{$i}_next");
- }
- }
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForElementPresent("_qf_Confirm_next-bottom");
- $confirmStrings = array("Event Fee(s)", "Billing Name and Address", "Credit Card Information");
- $this->assertStringsPresent($confirmStrings);
- $this->click("_qf_Confirm_next-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $thankStrings = array("Thank You for Registering", "Event Total", "Transaction Date");
- $this->assertStringsPresent($thankStrings);
-
- if ($anonymous) {
- // log back in so we're in the same state
- $this->webtestLogin();
- }
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Event_MultipleEventRegistrationbyCartTest
- */
-class WebTest_Event_MultipleEventRegistrationbyCartTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- /**
- * this functionality is broken hence skipping the test.
- */
- public function skiptestAuthenticatedMultipleEvent() {
-
- // Log in using webtestLogin() method
- $this->webtestLogin();
-
- //Enable shopping cart style
- $this->openCiviPage("admin/setting/preferences/event", "reset=1");
- $this->check("enable_cart");
- $this->click("_qf_Event_next-top");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Use default payment processor
- $processorName = 'Test Processor';
- $this->webtestAddPaymentProcessor($processorName);
-
- //event 1
-
- $this->openCiviPage("event/add", "reset=1&action=add");
-
- $eventTitle1 = 'My Conference1 - ' . substr(sha1(rand()), 0, 7);
- $eventDescription1 = "Here is a description for this conference 1.";
- $this->_testAddEventInfo($eventTitle1, $eventDescription1);
-
- $streetAddress1 = "100 Main Street";
- $this->_testAddLocation($streetAddress1);
-
- $this->_testAddFees(FALSE, FALSE, $processorName);
-
- // intro text for registration page
- $registerIntro = "Fill in all the fields below and click Continue.";
- $multipleRegistrations = TRUE;
- $this->_testAddOnlineRegistration($registerIntro, $multipleRegistrations);
-
- $eventInfoStrings1 = array($eventTitle1, $eventDescription1, $streetAddress1);
- $this->_AddEventToCart($eventTitle1, $eventInfoStrings1);
-
- //event 2
-
- $this->openCiviPage("event/add", "reset=1&action=add");
-
- $eventTitle2 = 'My Conference2 - ' . substr(sha1(rand()), 0, 7);
- $eventDescription2 = "Here is a description for this conference 2.";
- $this->_testAddEventInfo($eventTitle2, $eventDescription2);
-
- $streetAddress2 = "101 Main Street";
- $this->_testAddLocation($streetAddress2);
-
- $this->_testAddFees(FALSE, FALSE, $processorName);
-
- // intro text for registration page
- $registerIntro = "Fill in all the fields below and click Continue.";
- $multipleRegistrations = TRUE;
- $this->_testAddOnlineRegistration($registerIntro, $multipleRegistrations);
-
- $eventInfoStrings2 = array($eventTitle2, $eventDescription2, $streetAddress2);
- $this->_AddEventToCart($eventTitle2, $eventInfoStrings2);
-
- //event 3
-
- $this->openCiviPage("event/add", "reset=1&action=add");
-
- $eventTitle3 = 'My Conference3 - ' . substr(sha1(rand()), 0, 7);
- $eventDescription3 = "Here is a description for this conference 3.";
- $this->_testAddEventInfo($eventTitle3, $eventDescription3);
-
- $streetAddress3 = "102 Main Street";
- $this->_testAddLocation($streetAddress3);
-
- $this->_testAddFees(FALSE, FALSE, $processorName);
-
- // intro text for registration page
- $registerIntro = "Fill in all the fields below and click Continue.";
- $multipleRegistrations = TRUE;
- $this->_testAddOnlineRegistration($registerIntro, $multipleRegistrations);
-
- $eventInfoStrings3 = array($eventTitle3, $eventDescription3, $streetAddress3);
- $this->_AddEventToCart($eventTitle3, $eventInfoStrings3);
-
- //Checkout
- $value = $this->_testCheckOut();
-
- //three event names
- $events = array(
- 1 => $eventTitle1,
- 2 => $eventTitle2,
- 3 => $eventTitle3,
- );
- //check the existence of the contacts who were registered and the one who did the contribution
-
- $this->_checkContributionsandEventRegistration($value[0], $value[1], $events);
- }
-
- /**
- * this functionality is broken hence skipping the test.
- */
- public function skiptestAnonymousMultipleEvent() {
- // This is the path where our testing install resides.
- // The rest of URL is defined in CiviSeleniumTestCase base class, in
- // class attributes.
-
- // Log in using webtestLogin() method
- $this->webtestLogin();
-
- // Use default payment processor
- $processorName = 'Test Processor';
- $this->webtestAddPaymentProcessor($processorName);
-
- //event 1
-
- $this->openCiviPage("event/add", "reset=1&action=add");
-
- $eventTitle1 = 'My Conference1 - ' . substr(sha1(rand()), 0, 7);
- $eventDescription1 = "Here is a description for this conference 1.";
- $this->_testAddEventInfo($eventTitle1, $eventDescription1);
-
- $streetAddress1 = "100 Main Street";
- $this->_testAddLocation($streetAddress1);
-
- $this->_testAddFees(FALSE, FALSE, $processorName);
-
- // intro text for registration page
- $registerIntro = "Fill in all the fields below and click Continue.";
- $multipleRegistrations = TRUE;
- $this->_testAddOnlineRegistration($registerIntro, $multipleRegistrations);
-
- $eventInfoStrings1 = array($eventTitle1, $eventDescription1, $streetAddress1);
- $registerUrl1 = $this->_testVerifyEventInfo($eventTitle1, $eventInfoStrings1);
-
- //event 2
-
- $this->openCiviPage("event/add", "reset=1&action=add");
-
- $eventTitle2 = 'My Conference2 - ' . substr(sha1(rand()), 0, 7);
- $eventDescription2 = "Here is a description for this conference 2.";
- $this->_testAddEventInfo($eventTitle2, $eventDescription2);
-
- $streetAddress2 = "101 Main Street";
- $this->_testAddLocation($streetAddress2);
-
- $this->_testAddFees(FALSE, FALSE, $processorName);
-
- // intro text for registration page
- $registerIntro = "Fill in all the fields below and click Continue.";
- $multipleRegistrations = TRUE;
- $this->_testAddOnlineRegistration($registerIntro, $multipleRegistrations);
-
- $eventInfoStrings2 = array($eventTitle2, $eventDescription2, $streetAddress2);
- $registerUrl2 = $this->_testVerifyEventInfo($eventTitle2, $eventInfoStrings2);
-
- //event 3
-
- $this->openCiviPage("event/add", "reset=1&action=add");
-
- $eventTitle3 = 'My Conference3 - ' . substr(sha1(rand()), 0, 7);
- $eventDescription3 = "Here is a description for this conference 3.";
- $this->_testAddEventInfo($eventTitle3, $eventDescription3);
-
- $streetAddress3 = "102 Main Street";
- $this->_testAddLocation($streetAddress3);
-
- $this->_testAddFees(FALSE, FALSE, $processorName);
-
- // intro text for registration page
- $registerIntro = "Fill in all the fields below and click Continue.";
- $multipleRegistrations = TRUE;
- $this->_testAddOnlineRegistration($registerIntro, $multipleRegistrations);
-
- $eventInfoStrings3 = array($eventTitle3, $eventDescription3, $streetAddress3);
- $registerUrl3 = $this->_testVerifyEventInfo($eventTitle3, $eventInfoStrings3);
-
- //Enable shopping cart style
- $this->openCiviPage("admin/setting/preferences/event", "reset=1");
- $this->check("enable_cart");
- $this->click("_qf_Event_next-top");
-
- $numberRegistrations = 1;
- $anonymous = TRUE;
- $this->_testOnlineRegistration($registerUrl1, $numberRegistrations, $anonymous);
- $this->_testOnlineRegistration($registerUrl2, $numberRegistrations, $anonymous);
- $this->_testOnlineRegistration($registerUrl3, $numberRegistrations, $anonymous);
- //Checkout
- $value = $this->_testCheckOut();
- // Log in using webtestLogin() method
- $this->webtestLogin();
-
- $this->openCiviPage("dashboard", "reset=1");
-
- //three event names
- $events = array(
- 1 => $eventTitle1,
- 2 => $eventTitle2,
- 3 => $eventTitle3,
- );
- //check the existence of the contacts who were registered and the one who did the contribution
-
- $this->_checkContributionsandEventRegistration($value[0], $value[1], $events);
- }
-
- /**
- * @param $eventTitle
- * @param $eventDescription
- */
- public function _testAddEventInfo($eventTitle, $eventDescription) {
- $this->waitForElementPresent("_qf_EventInfo_upload-bottom");
-
- $this->select("event_type_id", "value=1");
-
- // Attendee role s/b selected now.
- $this->select("default_role_id", "value=1");
-
- // Enter Event Title, Summary and Description
- $this->type("title", $eventTitle);
- $this->type("summary", "This is a great conference. Sign up now!");
-
- // Type description in ckEditor (fieldname, text to type, editor)
- $this->fillRichTextField("description", $eventDescription, 'CKEditor');
-
- // Choose Start and End dates.
- // Using helper webtestFillDate function.
- $this->webtestFillDateTime("start_date", "+1 week");
- $this->webtestFillDateTime("end_date", "+1 week 1 day 8 hours ");
-
- $this->type("max_participants", "50");
- $this->click("is_map");
- $this->click("_qf_EventInfo_upload-bottom");
- }
-
- /**
- * @param $streetAddress
- */
- public function _testAddLocation($streetAddress) {
- // Wait for Location tab form to load
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForElementPresent("_qf_Location_upload-bottom");
-
- $this->type("address_1_street_address", $streetAddress);
- $this->type("address_1_city", "San Francisco");
- $this->type("address_1_postal_code", "94117");
- $this->select("address_1_state_province_id", "value=1004");
- $this->type("email_1_email", "info@civicrm.org");
-
- $this->click("_qf_Location_upload-bottom");
-
- // Wait for "saved" status msg
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForTextPresent("'Location' information has been saved.");
- }
-
- /**
- * @param bool $discount
- * @param bool $priceSet
- * @param string $processorName
- */
- public function _testAddFees($discount = FALSE, $priceSet = FALSE, $processorName = "PP Pro") {
- // Go to Fees tab
- $this->click("link=Fees");
- $this->waitForElementPresent("_qf_Fee_upload-bottom");
- $this->click("CIVICRM_QFID_1_is_monetary");
- $this->click("xpath=//tr[@class='crm-event-manage-fee-form-block-payment_processor']/td[2]/label[text()='$processorName']");
- $this->select('financial_type_id', 'Event Fee');
- if ($priceSet) {
- // get one - TBD
- }
- else {
- $this->type("label_1", "Member");
- $this->type("value_1", "250.00");
- $this->type("label_2", "Non-member");
- $this->type("value_2", "325.00");
- $this->click("CIVICRM_QFID_2_6");
- }
-
- if ($discount) {
- // enter early bird discount fees
- $this->click("is_discount");
- $this->waitForElementPresent("discount_name_1");
- $this->type("discount_name_1", "Early-bird" . substr(sha1(rand()), 0, 7));
- $this->webtestFillDate("discount_start_date_1", "-1 week");
- $this->webtestFillDate("discount_end_date_1", "+2 week");
- $this->clickLink("_qf_Fee_submit", "discounted_value_2_1");
- $this->type("discounted_value_1_1", "225.00");
- $this->type("discounted_value_2_1", "300.00");
- $this->click("xpath=//fieldset[@id='discount']/fieldset/table/tbody/tr[2]/td[3]/input");
- }
-
- $this->click("_qf_Fee_upload-bottom");
-
- // Wait for "saved" status msg
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForTextPresent("'Fee' information has been saved.");
- }
-
- /**
- * @param $registerIntro
- * @param bool $multipleRegistrations
- */
- public function _testAddOnlineRegistration($registerIntro, $multipleRegistrations = FALSE) {
- // Go to Online Registration tab
- $this->click("link=Online Registration");
- $this->waitForElementPresent("_qf_Registration_upload-bottom");
-
- $this->check("is_online_registration");
- $this->assertChecked("is_online_registration");
- if ($multipleRegistrations) {
- $this->check("is_multiple_registrations");
- $this->assertChecked("is_multiple_registrations");
- }
-
- $this->fillRichTextField("intro_text", $registerIntro);
-
- // enable confirmation email
- $this->click("CIVICRM_QFID_1_is_email_confirm");
- $this->type("confirm_from_name", "Jane Doe");
- $this->type("confirm_from_email", "jane.doe@example.org");
-
- $this->click("_qf_Registration_upload-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForTextPresent("'Registration' information has been saved.");
- }
-
- /**
- * @param $eventTitle
- * @param $eventInfoStrings
- * @param null $eventFees
- */
- public function _AddEventToCart($eventTitle, $eventInfoStrings, $eventFees = NULL) {
- // verify event input on info page
- // start at Manage Events listing
- $this->openCiviPage("event/manage", "reset=1");
- $this->clickLink("link=$eventTitle", "link=Add to Cart");
- $this->click("link=Add to Cart");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->assertTrue($this->isTextPresent("$eventTitle has been added to your cart"));
- }
-
- /**
- * @param $eventTitle
- * @param $eventInfoStrings
- * @param null $eventFees
- *
- * @return string
- */
- public function _testVerifyEventInfo($eventTitle, $eventInfoStrings, $eventFees = NULL) {
- // verify event input on info page
- // start at Manage Events listing
- $this->openCiviPage("event/manage", "reset=1");
- $this->click("link=$eventTitle");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Check for correct event info strings
- $this->assertStringsPresent($eventInfoStrings);
-
- // Optionally verify event fees (especially for discounts)
- if ($eventFees) {
- $this->assertStringsPresent($eventFees);
-
- }
- return $this->getLocation();
- }
-
- /**
- * @param $registerUrl
- * @param int $numberRegistrations
- * @param bool $anonymous
- */
- public function _testOnlineRegistration($registerUrl, $numberRegistrations = 1, $anonymous = TRUE) {
- if ($anonymous) {
- $this->webtestLogout();
- }
- $this->open($registerUrl);
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForElementPresent("link=Add to Cart");
- $this->click("link=Add to Cart");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- }
-
- /**
- * @return array
- */
- public function _testCheckOut() {
- //View the Cart
- $this->click("xpath=//div[@id='messages']/div/div/a[text()='View your cart.']");
-
- //Click on Checkout
- $this->waitForElementPresent("xpath=//a[@class='button crm-check-out-button']/span");
- $this->click("xpath=//a[@class='button crm-check-out-button']/span");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $firstName = "AB" . substr(sha1(rand()), 0, 7);
- $lastName = "XY" . substr(sha1(rand()), 0, 7);
- for ($i = 1; $i <= 3; $i++) {
- $this->type("xpath=//form[@id='ParticipantsAndPrices']/fieldset[$i]/div/fieldset/div/div/fieldset/div/div[2]/input", "{$firstName}.{$lastName}@home.com");
- $this->type("xpath=//form[@id='ParticipantsAndPrices']/fieldset[$i]/div/fieldset/div/div[2]/div[2]/input", "{$firstName}.{$lastName}@example.com");
- $this->click("xpath=//form[@id='ParticipantsAndPrices']/fieldset[$i]/div[2]/div[2]/input[2]");
- }
- $this->click("_qf_ParticipantsAndPrices_upload-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->select("credit_card_type", "value=Visa");
- $this->type("credit_card_number", "4111111111111111");
- $this->type("cvv2", "000");
- $this->select("credit_card_exp_date[M]", "value=1");
- $this->select("credit_card_exp_date[Y]", "value=2020");
- $this->type("billing_first_name", $firstName);
- $this->type("billing_last_name", $lastName);
- $this->type("billing_street_address-5", "15 Main St.");
- $this->type(" billing_city-5", "San Jose");
- $this->select("billing_country_id-5", "value=1228");
- $this->select("billing_state_province_id-5", "value=1004");
- $this->type("billing_postal_code-5", "94129");
- $this->type("billing_contact_email", "{$firstName}.{$lastName}@example.com");
-
- $this->click("_qf_Payment_next-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->assertTrue($this->isTextPresent("This is your receipt of payment made for the following event registration."));
- return array($firstName, $lastName);
- }
-
- /**
- * @param string $firstName
- * @param string $lastName
- * @param $events
- */
- public function _checkContributionsandEventRegistration($firstName, $lastName, $events) {
- //Type the registered participant's email in autocomplete.
- $this->click('sort_name_navigation');
- $this->type('css=input#sort_name_navigation', "{$firstName}.{$lastName}@home.com");
- $this->typeKeys('css=input#sort_name_navigation', "{$firstName}.{$lastName}@home.com");
-
- // Wait for result list.
- $this->waitForElementPresent("css=div.ac_results-inner li");
-
- // Visit contact summary page.
- $this->click("css=div.ac_results-inner li");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- //click on Events Tab
- $this->click("xpath=//li[@id='tab_participant']/a");
- //check if the participant is registered for all the three events
- foreach ($events as $key => $value) {
- $this->waitForElementPresent("link=$value");
- $this->assertTrue($this->isElementPresent("link=$value"));
- }
- for ($i = 1; $i <= 3; $i++) {
- $this->waitForElementPresent("xpath=//table[@class='selector']/tbody/tr[$i]/td[6][text()='Registered']");
- $this->assertTrue($this->isElementPresent("xpath=//table[@class='selector']/tbody/tr[$i]/td[6][text()='Registered']"));
- }
-
- //Type the billing email in autocomplete.
- $this->click('sort_name_navigation');
- $this->type('css=input#sort_name_navigation', "{$firstName}.{$lastName}@example.com");
- $this->typeKeys('css=input#sort_name_navigation', "{$firstName}.{$lastName}@example.com");
-
- // Wait for result list.
- $this->waitForElementPresent("css=div.ac_results-inner li");
-
- // Visit contact summary page.
- $this->click("css=div.ac_results-inner li");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- //click on Contributions Tab
- $this->click("xpath=//li[@id='tab_contribute']/a");
- //check for the three contributions
- foreach ($events as $key => $value) {
- $this->waitForElementPresent("xpath=//table[@class='selector']/tbody/tr/td[3][contains(text(),'$value')]");
- $this->assertTrue($this->isElementPresent("xpath=//table[@class='selector']/tbody/tr/td[3][contains(text(),'$value')]"));
- }
-
- //Disable shopping cart style
- $this->openCiviPage("admin/setting/preferences/event", "reset=1");
- $this->click("enable_cart");
- $this->click("_qf_Event_next-top");
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Event_MultiprofileEventTest
- */
-class WebTest_Event_MultiprofileEventTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testCreateEventRegisterPage() {
- // Log in using webtestLogin() method
- $this->webtestLogin();
-
- $customGrp1 = "Custom Data1_" . substr(sha1(rand()), 0, 7);
- $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
- $lastName = 'An' . substr(sha1(rand()), 0, 7);
- $participantfname = 'Dany' . substr(sha1(rand()), 0, 4);
- $participantlname = 'Dan' . substr(sha1(rand()), 0, 4);
- $email1 = $firstName . "@test.com";
- $email2 = $participantfname . "@test.com";
-
- // Use default payment processor
- $processorName = 'Test Processor';
- $this->webtestAddPaymentProcessor($processorName);
-
- //add email to name and address profile
- $cfId = $this->_addEmailField();
-
- // create custom group1
- $this->openCiviPage("admin/custom/group", "reset=1");
- $this->click("newCustomDataGroup");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->type("title", $customGrp1);
- $this->select("extends[0]", "value=Contact");
- $this->click("_qf_Group_next-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // get custom group id
- $customGrpId1 = $this->urlArg('gid');
-
- $customId = $this->_testGetCustomFieldId($customGrpId1);
-
- $profileId = $this->_testGetProfileId($customId);
-
- $this->openCiviPage("event/add", "reset=1&action=add");
-
- $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7);
- $eventDescription = "Here is a description for this conference.";
- $this->_testAddEventInfo($eventTitle, $eventDescription);
-
- $streetAddress = "100 Main Street";
- $this->_testAddLocation($streetAddress);
-
- $this->_testAddFees(FALSE, FALSE, $processorName);
-
- $eventPageId = $this->_testAddMultipleProfile($profileId);
-
- $this->_testEventRegistration($eventPageId, $customId, $firstName, $lastName,
- $participantfname, $participantlname, $email1, $email2
- );
- $this->waitForAjaxContent();
-
- // Find Main Participant
- $this->openCiviPage("event/search", "reset=1");
- $this->type("sort_name", $firstName);
- $this->click("xpath=//tr/td[1]/label[contains(text(), 'Participant is a Test?')]/../label[contains(text(), 'Yes')]/preceding-sibling::input[1]");
- $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='participantSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']");
- $this->clickLink("xpath=//div[@id='participantSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']", "_qf_ParticipantView_cancel-top", FALSE);
-
- $name = $firstName . " " . $lastName;
- $status = 'Registered';
-
- $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table[1]/tbody/tr[1]/td[2]/strong/a", preg_quote($name));
- $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table[1]/tbody/tr[3]/td[2]/a", preg_quote($eventTitle));
- $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table/tbody/tr[6]/td[2]", preg_quote($status));
-
- // Find additional Participant
- $this->openCiviPage("event/search", "reset=1");
- $this->type("sort_name", $participantfname);
- $this->click("xpath=//tr/td[1]/label[contains(text(), 'Participant is a Test?')]/../label[contains(text(), 'Yes')]/preceding-sibling::input[1]");
- $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='participantSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']");
- $this->clickLink("xpath=//div[@id='participantSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']", "_qf_ParticipantView_cancel-top", FALSE);
-
- $name = $participantfname . " " . $participantlname;
- $status = 'Registered';
-
- $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table[1]/tbody/tr[1]/td[2]/strong/a", preg_quote($name));
- $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table[1]/tbody/tr[3]/td[2]/a", preg_quote($eventTitle));
- $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table[1]/tbody/tr[6]/td[2]", preg_quote($status));
-
- // delete all custom data
- if (isset($cfId)) {
- $this->_removeEmailField($cfId);
- }
- foreach ($customId as $cid) {
- $this->openCiviPage("admin/custom/group/field", "action=delete&reset=1&gid={$customGrpId1}&id=$cid");
- $this->click("_qf_DeleteField_next-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- }
- $this->openCiviPage("admin/custom/group", "action=delete&reset=1&id=$customGrpId1");
- $this->click("_qf_DeleteGroup_next-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- }
-
- public function testAnoumyousRegisterPage() {
- // add the required Drupal permission
- $permission = array('edit-1-access-all-custom-data');
- $this->changePermissions($permission);
-
- $customGrp1 = "Custom Data1_" . substr(sha1(rand()), 0, 7);
- $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
- $lastName = 'An' . substr(sha1(rand()), 0, 7);
- $participantfname = 'Dany' . substr(sha1(rand()), 0, 4);
- $participantlname = 'Dan' . substr(sha1(rand()), 0, 4);
- $email1 = $firstName . "@test.com";
- $email2 = $participantfname . "@test.com";
- $firstName2 = 'Man' . substr(sha1(rand()), 0, 4);
- $lastName2 = 'Ann' . substr(sha1(rand()), 0, 7);
- $participantfname2 = 'Adam' . substr(sha1(rand()), 0, 4);
- $participantlname2 = 'Gil' . substr(sha1(rand()), 0, 4);
- $email3 = $participantfname2 . "@test.com";
- $email4 = $firstName2 . "@test.com";
-
- // Use default payment processor
- $processorName = 'Test Processor';
- $this->webtestAddPaymentProcessor($processorName);
-
- //add email field to name and address profile
- $cfId = $this->_addEmailField();
-
- // create custom group1
- $this->openCiviPage("admin/custom/group", "reset=1");
- $this->click("newCustomDataGroup");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->type("title", $customGrp1);
- $this->select("extends[0]", "value=Contact");
- $this->click("_qf_Group_next-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // get custom group id
- $customGrpId1 = $this->urlArg('gid');
-
- $customId = $this->_testGetCustomFieldId($customGrpId1);
-
- $profileId = $this->_testGetProfileId($customId);
-
- $this->openCiviPage('event/add', "reset=1&action=add");
-
- $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7);
- $eventDescription = "Here is a description for this conference.";
- $this->_testAddEventInfo($eventTitle, $eventDescription);
-
- $streetAddress = "100 Main Street";
- $this->_testAddLocation($streetAddress);
-
- $this->_testAddFees(FALSE, FALSE, $processorName);
-
- $eventPageId = $this->_testAddMultipleProfile($profileId);
-
- // logout
- $this->webtestLogout();
-
- $this->_testEventRegistration($eventPageId, $customId, $firstName, $lastName, $participantfname, $participantlname, $email1, $email2);
- $this->waitForPageToLoad($this->getTimeoutMsec());
- // Log in using webtestLogin() method
- $this->webtestLogin();
-
- // Find Main Participant
- $this->openCiviPage("event/search", "reset=1");
- $this->type("sort_name", $firstName);
- $this->click("xpath=//tr/td[1]/label[contains(text(), 'Participant is a Test?')]/../label[contains(text(), 'Yes')]/preceding-sibling::input[1]");
- $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='participantSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']");
- $this->clickLink("xpath=//div[@id='participantSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']", "_qf_ParticipantView_cancel-top", FALSE);
-
- $name = $firstName . " " . $lastName;
- $status = 'Registered';
-
- $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table/tbody/tr[1]/td[2]/strong/a", preg_quote($name));
- $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table/tbody/tr[3]/td[2]/a", preg_quote($eventTitle));
- $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table/tbody/tr[6]/td[2]", preg_quote($status));
-
- // Find additional Participant
- $this->openCiviPage("event/search", "reset=1");
- $this->type("sort_name", $participantfname);
- $this->click("xpath=//tr/td[1]/label[contains(text(), 'Participant is a Test?')]/../label[contains(text(), 'Yes')]/preceding-sibling::input[1]");
- $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='participantSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']");
- $this->clickLink("xpath=//div[@id='participantSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']", "_qf_ParticipantView_cancel-top", FALSE);
-
- $name = $participantfname . " " . $participantlname;
- $status = 'Registered';
-
- $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table/tbody/tr[1]/td[2]/strong/a", preg_quote($name));
- $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table/tbody/tr[3]/td[2]/a", preg_quote($eventTitle));
- $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table/tbody/tr[6]/td[2]", preg_quote($status));
-
- // Edit page and remove some profile
- $this->_testRemoveProfile($eventPageId);
-
- // logout
- $this->webtestLogout();
-
- $this->_testEventRegistrationAfterRemoving($eventPageId, $customId, $firstName2, $lastName2, $participantfname2, $participantlname2, $email3, $email4);
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Log in using webtestLogin() method
- $this->webtestLogin();
-
- // Find Main Participant
- $this->openCiviPage('event/search', "reset=1");
- $this->type("sort_name", $firstName2);
- $this->click("xpath=//tr/td[1]/label[contains(text(), 'Participant is a Test?')]/../label[contains(text(), 'Yes')]/preceding-sibling::input[1]");
- $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='participantSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']");
- $this->clickLink("xpath=//div[@id='participantSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']", "_qf_ParticipantView_cancel-top", FALSE);
-
- $name = $firstName2 . " " . $lastName2;
- $status = 'Registered';
-
- $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table/tbody/tr[1]/td[2]/strong/a", preg_quote($name));
- $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table/tbody/tr[3]/td[2]/a", preg_quote($eventTitle));
- $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table/tbody/tr[6]/td[2]", preg_quote($status));
-
- // Find additional Participant
- $this->openCiviPage("event/search", "reset=1");
- $this->type("sort_name", $participantfname2);
- $this->click("xpath=//tr/td[1]/label[contains(text(), 'Participant is a Test?')]/../label[contains(text(), 'Yes')]/preceding-sibling::input[1]");
- $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='participantSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']");
- $this->clickLink("xpath=//div[@id='participantSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']", "_qf_ParticipantView_cancel-top", FALSE);
-
- $name = $participantfname2 . " " . $participantlname2;
- $status = 'Registered';
-
- $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table/tbody/tr[1]/td[2]/strong/a", preg_quote($name));
- $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table/tbody/tr[3]/td[2]/a", preg_quote($eventTitle));
- $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table/tbody/tr[6]/td[2]", preg_quote($status));
-
- // delete all custom data
- if (isset($cfId)) {
- $this->_removeEmailField($cfId);
- }
- foreach ($customId as $cid) {
- $this->openCiviPage("admin/custom/group/field", "action=delete&reset=1&gid={$customGrpId1}&id=$cid");
- $this->click("_qf_DeleteField_next-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- }
- $this->openCiviPage("admin/custom/group", "action=delete&reset=1&id=$customGrpId1");
- $this->click("_qf_DeleteGroup_next-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- }
-
- /**
- * Get custom field ID.
- *
- * @param int $customGrpId1
- *
- * @return array
- */
- public function _testGetCustomFieldId($customGrpId1) {
- $customId = array();
-
- // Create a custom data to add in profile
-
- $field1 = "Fname" . substr(sha1(rand()), 0, 7);
- $field2 = "Mname" . substr(sha1(rand()), 0, 7);
- $field3 = "Lname" . substr(sha1(rand()), 0, 7);
-
- // add custom fields for group 1
- $this->openCiviPage("admin/custom/group/field/add", "reset=1&action=add&gid=$customGrpId1");
- $this->type("label", $field1);
- $this->check("is_searchable");
- $this->click("_qf_Field_next_new-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->type("label", $field2);
- $this->check("is_searchable");
- $this->click("_qf_Field_next_new-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->type("label", $field3);
- $this->check("is_searchable");
- $this->click("_qf_Field_done-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // get id of custom fields
- $this->openCiviPage("admin/custom/group/field", "reset=1&action=browse&gid=$customGrpId1");
- $custom1 = explode('&id=', $this->getAttribute("xpath=//div[@id='field_page']//table/tbody//tr[1]/td[8]/span/a[text()='Edit Field']/@href"));
- $custom1 = $custom1[1];
- array_push($customId, $custom1);
- $custom2 = explode('&id=', $this->getAttribute("xpath=//div[@id='field_page']//table/tbody//tr[2]/td[8]/span/a[text()='Edit Field']/@href"));
- $custom2 = $custom2[1];
- array_push($customId, $custom2);
- $custom3 = explode('&id=', $this->getAttribute("xpath=//div[@id='field_page']//table/tbody//tr[3]/td[8]/span/a[text()='Edit Field']/@href"));
- $custom3 = $custom3[1];
- array_push($customId, $custom3);
-
- return $customId;
- }
-
- /**
- * @param int $eventPageId
- */
- public function _testRemoveProfile($eventPageId) {
- $this->openCiviPage("event/manage/settings", "reset=1&action=update&id=$eventPageId");
-
- // Go to Online Contribution tab
- $this->click("link=Online Registration");
- $this->waitForElementPresent("_qf_Registration_upload-bottom");
- $this->click("xpath=//*[@id='additional_custom_post_id_multiple_1']/parent::td/span[1]/a");
- $this->click("xpath=//*[@id='additional_custom_post_id_multiple_2']/parent::td/span[1]/a");
- $this->click("xpath=//*[@id='additional_custom_post_id_multiple_3']/parent::td/span[1]/a");
- $this->click("xpath=//*[@id='additional_custom_post_id_multiple_4']/parent::td/span[1]/a");
- $this->click("_qf_Registration_upload-bottom");
- $this->waitForElementPresent("_qf_Registration_upload-bottom");
- }
-
- /**
- * @param int $customId
- *
- * @return array
- */
- public function _testGetProfileId($customId) {
- // create profiles
- $profileId = array();
- $profilefield = array(
- 'street_address' => 'street_address',
- 'supplemental_address_1' => 'supplemental_address_1',
- 'city' => 'city',
- );
- $location = 1;
- $type = "Contact";
- $profileId1 = $this->_testCreateProfile($profilefield, $location, $type);
- array_push($profileId, $profileId1);
-
- $profilefield = array(
- 'street_address' => 'street_address',
- 'city' => 'city',
- 'phone' => 'phone',
- 'postal_code' => 'postal_code',
- );
- $location = 0;
- $type = "Contact";
- $profileId2 = $this->_testCreateProfile($profilefield, $location, $type);
- array_push($profileId, $profileId2);
-
- $profilefield = array(
- 'nick_name' => 'nick_name',
- 'url' => 'url',
- );
- $location = 0;
- $type = "Contact";
- $profileId3 = $this->_testCreateProfile($profilefield, $location, $type);
- array_push($profileId, $profileId3);
-
- $profilefield = array(
- 'current_employer' => 'current_employer',
- 'job_title' => 'job_title',
- );
- $location = 0;
- $type = "Individual";
- $profileId4 = $this->_testCreateProfile($profilefield, $location, $type);
- array_push($profileId, $profileId4);
-
- $profilefield = array(
- 'middle_name' => 'middle_name',
- 'gender_id' => 'gender_id',
- );
- $location = 0;
- $type = "Individual";
- $profileId5 = $this->_testCreateProfile($profilefield, $location, $type);
- array_push($profileId, $profileId5);
-
- $profilefield = array(
- 'custom_' . $customId[0] => 'custom_' . $customId[0],
- 'custom_' . $customId[1] => 'custom_' . $customId[1],
- 'custom_' . $customId[2] => 'custom_' . $customId[2],
- );
- $location = 0;
- $type = "Contact";
- $profileId6 = $this->_testCreateProfile($profilefield, $location, $type);
- array_push($profileId, $profileId6);
-
- $profilefield = array(
- 'participant_role' => 'participant_role',
- );
- $location = 0;
- $type = "Participant";
- $profileId7 = $this->_testCreateProfile($profilefield, $location, $type);
- array_push($profileId, $profileId7);
-
- return $profileId;
- }
-
- /**
- * Test profile creation.
- *
- * @param array $profileField
- * @param int $location
- * @param $type
- *
- * @return null
- */
- public function _testCreateProfile($profileField, $location = 0, $type) {
- $locationFields = array(
- 'supplemental_address_1',
- 'supplemental_address_2',
- 'supplemental_address_3',
- 'city',
- 'country',
- 'email',
- 'state',
- 'street_address',
- 'postal_code',
- );
-
- // Add new profile.
- $profileName = "Profile_" . substr(sha1(rand()), 0, 7);
- $this->openCiviPage("admin/uf/group", "reset=1");
- $this->click('newCiviCRMProfile-top');
- $this->waitForElementPresent('_qf_Group_next-top');
-
- //Name of profile
- $this->type('title', $profileName);
- $this->click('uf_group_type_Profile');
- $this->click('_qf_Group_next-top');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $profileId = $this->urlArg('gid');
-
- //Add field to profile_testCreateProfile
- foreach ($profileField as $key => $value) {
- $this->openCiviPage("admin/uf/group/field/add", "reset=1&action=add&gid=$profileId");
- if (in_array($value, $locationFields)) {
- $this->select("field_name[0]", "value={$type}");
- $this->select("field_name[1]", "value={$value}");
- $this->select("field_name[2]", "value={$location}");
- $this->type("label", $value);
- }
- else {
- $this->select("field_name[0]", "value={$type}");
- $this->select("field_name[1]", "value={$value}");
- $this->type("label", $value);
- }
- $this->click('_qf_Field_next-top');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- }
- return $profileId;
- }
-
- /**
- * @param $eventTitle
- * @param $eventDescription
- */
- public function _testAddEventInfo($eventTitle, $eventDescription) {
- $this->waitForElementPresent("_qf_EventInfo_upload-bottom");
-
- $this->select("event_type_id", "value=1");
-
- // Attendee role s/b selected now.
- $this->select("default_role_id", "value=1");
-
- // Enter Event Title, Summary and Description
- $this->type("title", $eventTitle);
- $this->type("summary", "This is a great conference. Sign up now!");
-
- // Type description in ckEditor (fieldname, text to type, editor)
- $this->fillRichTextField("description", $eventDescription, 'CKEditor');
-
- // Choose Start and End dates.
- // Using helper webtestFillDate function.
- $this->webtestFillDateTime("start_date", "+1 week");
- $this->webtestFillDateTime("end_date", "+1 week 1 day 8 hours ");
-
- $this->type("max_participants", "50");
- $this->click("is_map");
- $this->click("_qf_EventInfo_upload-bottom");
- }
-
- /**
- * @param $streetAddress
- */
- public function _testAddLocation($streetAddress) {
- // Wait for Location tab form to load
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForElementPresent("_qf_Location_upload-bottom");
-
- // Fill in address fields
- //$streetAddress = "100 Main Street";
- $this->type("address_1_street_address", $streetAddress);
- $this->type("address_1_city", "San Francisco");
- $this->waitForElementPresent('address_1_country_id');
- $this->select("address_1_country_id", "value=1228");
- $this->type("address_1_postal_code", "94117");
- $this->select("address_1_state_province_id", "value=1004");
- $this->type("email_1_email", "info@civicrm.org");
-
- $this->click("_qf_Location_upload-bottom");
-
- // Wait for "saved" status msg
- $this->waitForElementPresent("_qf_Location_upload-bottom");
- $this->waitForText('crm-notification-container', "'Event Location' information has been saved.");
- }
-
- /**
- * @param bool $discount
- * @param bool $priceSet
- * @param string $processorName
- */
- public function _testAddFees($discount = FALSE, $priceSet = FALSE, $processorName = "PP Pro") {
- // Go to Fees tab
- $this->click("link=Fees");
- $this->waitForElementPresent("_qf_Fee_upload-bottom");
- $this->click("CIVICRM_QFID_1_is_monetary");
-
- // select newly created processor
- $this->select2('payment_processor', $processorName, TRUE);
- $this->select("financial_type_id", "label=Event Fee");
- if ($priceSet) {
- // get one - TBD
- }
- else {
- $this->type("label_1", "Member");
- $this->type("value_1", "250.00");
- $this->type("label_2", "Non-member");
- $this->type("value_2", "325.00");
- //set default
- $this->click("xpath=//table[@id='map-field-table']/tbody/tr[2]/td[3]/input");
- }
-
- if ($discount) {
- // enter early bird discounts TBD
- }
-
- $this->click("_qf_Fee_upload-bottom");
-
- // Wait for "saved" status msg
- $this->waitForElementPresent("_qf_Fee_upload-bottom");
- $this->waitForTextPresent("'Fees' information has been saved.");
- }
-
- /**
- * Test adding multiple profiles.
- *
- * @param int $profileId
- *
- * @return null
- */
- public function _testAddMultipleProfile($profileId) {
- // Go to Online Contribution tab
- $this->click("link=Online Registration");
- $this->waitForElementPresent("_qf_Registration_upload-bottom");
- $this->click("is_online_registration");
- $this->check("is_multiple_registrations");
- $this->select("xpath=//*[@id='custom_pre_id']/parent::td/div[1]/div/span/select", "value=1");
- $this->select("xpath=//*[@id='custom_post_id']/parent::td/div[1]/div/span/select", "value=" . $profileId[3]);
- $this->select("xpath=//*[@id='additional_custom_post_id']/parent::td/div[1]/div/span/select", "- same as for main contact -");
- //Click 'add another profile (bottom of page)'
- $this->waitForElementPresent("xpath=//div[@id='registration_screen']/table[2]//tbody/tr[2]/td[2]/span/a");
- $this->click("xpath=//div[@id='registration_screen']/table[2]//tbody/tr[2]/td[2]/span/a");
- $this->waitForElementPresent("custom_post_id_multiple_1");
- $this->select("xpath=//*[@id='custom_post_id_multiple_1']/parent::td/div[1]/div/span/select", "value=" . $profileId[2]);
-
- $this->waitForElementPresent("xpath=//div[@id='registration_screen']/table[2]//tbody/tr[2]/td[2]/span/a");
- $this->click("xpath=//div[@id='registration_screen']/table[2]//tbody/tr[2]/td[2]/span/a");
- $this->waitForElementPresent("custom_post_id_multiple_2");
- $this->select("xpath=//*[@id='custom_post_id_multiple_2']/parent::td/div[1]/div/span/select", "value=" . $profileId[1]);
-
- $this->waitForElementPresent("xpath=//div[@id='registration_screen']/table[2]//tbody/tr[2]/td[2]/span/a");
- $this->click("xpath=//div[@id='registration_screen']/table[2]//tbody/tr[2]/td[2]/span/a");
- $this->waitForElementPresent("custom_post_id_multiple_3");
- $this->select("xpath=//*[@id='custom_post_id_multiple_3']/parent::td/div[1]/div/span/select", "value=" . $profileId[4]);
-
- $this->waitForElementPresent("xpath=//div[@id='registration_screen']/table[2]//tbody/tr[2]/td[2]/span/a");
- $this->click("xpath=//div[@id='registration_screen']/table[2]//tbody/tr[2]/td[2]/span/a");
- $this->waitForElementPresent("custom_post_id_multiple_4");
- $this->select("xpath=//*[@id='custom_post_id_multiple_4']/parent::td/div[1]/div/span/select", "value=" . $profileId[5]);
-
- $this->waitForElementPresent("xpath=//div[@id='registration_screen']/table[2]//tbody/tr[2]/td[2]/span/a");
- $this->click("xpath=//div[@id='registration_screen']/table[2]//tbody/tr[2]/td[2]/span/a");
- $this->waitForElementPresent("custom_post_id_multiple_5");
- $this->select("xpath=//*[@id='custom_post_id_multiple_5']/parent::td/div[1]/div/span/select", "value=" . $profileId[6]);
-
- $this->waitForElementPresent("xpath=//div[@id='registration_screen']/table[3]//tbody/tr[2]/td[2]/span/a");
- $this->click("xpath=//div[@id='registration_screen']/table[3]//tbody/tr[2]/td[2]/span/a");
- $this->waitForElementPresent("additional_custom_post_id_multiple_1");
- $this->select("xpath=//*[@id='additional_custom_post_id_multiple_1']/parent::td/div[1]/div/span/select", "value=" . $profileId[5]);
-
- $this->waitForElementPresent("xpath=//div[@id='registration_screen']/table[3]//tbody/tr[2]/td[2]/span/a");
- $this->click("xpath=//div[@id='registration_screen']/table[3]//tbody/tr[2]/td[2]/span/a");
- $this->waitForElementPresent("additional_custom_post_id_multiple_2");
- $this->select("xpath=//*[@id='additional_custom_post_id_multiple_2']/parent::td/div[1]/div/span/select", "value=" . $profileId[1]);
-
- $this->waitForElementPresent("xpath=//div[@id='registration_screen']/table[3]//tbody/tr[2]/td[2]/span/a");
- $this->click("xpath=//div[@id='registration_screen']/table[3]//tbody/tr[2]/td[2]/span/a");
- $this->waitForElementPresent("additional_custom_post_id_multiple_3");
- $this->select("xpath=//*[@id='additional_custom_post_id_multiple_3']/parent::td/div[1]/div/span/select", "value=" . $profileId[2]);
-
- $this->waitForElementPresent("xpath=//div[@id='registration_screen']/table[3]//tbody/tr[2]/td[2]/span/a");
- $this->click("xpath=//div[@id='registration_screen']/table[3]//tbody/tr[2]/td[2]/span/a");
- $this->waitForElementPresent("additional_custom_post_id_multiple_4");
- $this->select("xpath=//*[@id='additional_custom_post_id_multiple_4']/parent::td/div[1]/div/span/select", "value=" . $profileId[3]);
-
- $this->click("CIVICRM_QFID_1_is_email_confirm");
- $this->type("confirm_from_name", "TestEvent");
- $this->type("confirm_from_email", "testevent@test.com");
- $this->click("_qf_Registration_upload-bottom");
-
- // Wait for "saved" status msg
- $this->waitForElementPresent("_qf_Registration_upload-bottom");
- $this->waitForText('crm-notification-container', "'Online Registration' information has been saved.");
-
- return $this->urlArg('id');
- }
-
- /**
- * @param int $eventPageId
- * @param int $customId
- * @param string $firstName
- * @param string $lastName
- * @param string $participantfname
- * @param string $participantlname
- * @param $email1
- * @param $email2
- */
- public function _testEventRegistration(
- $eventPageId, $customId, $firstName, $lastName,
- $participantfname, $participantlname, $email1, $email2
- ) {
- $this->openCiviPage("event/register", "id={$eventPageId}&reset=1&action=preview", "_qf_Register_upload-bottom");
- $this->waitForElementPresent("_qf_Register_upload-bottom");
- $this->select("additional_participants", "value=1");
-
- $this->type("email-Primary", $email1);
- $this->type("first_name", $firstName);
- $this->type("last_name", $lastName);
- $this->type("street_address-1", "Test street address");
- $this->type("city-1", "Mumbai");
- $this->type("postal_code-1", "2354");
- $this->select("state_province-1", "value=1001");
-
- // Credit Card Info
- $this->select("credit_card_type", "value=Visa");
- $this->type("credit_card_number", "4111111111111111");
- $this->type("cvv2", "000");
- $this->select("credit_card_exp_date[M]", "value=1");
- $this->select("credit_card_exp_date[Y]", "value=2020");
-
- //Billing Info
- $this->type("billing_first_name", $firstName . 'billing');
- $this->type("billing_last_name", $lastName . 'billing');
- $this->type("billing_street_address-5", "0121 Mount Highschool.");
- $this->type(" billing_city-5", "Shangai");
- $this->select("billing_country_id-5", "value=1228");
- $this->select("billing_state_province_id-5", "value=1004");
- $this->type("billing_postal_code-5", "94129");
-
- $this->waitForElementPresent("current_employer");
- $this->type("current_employer", "ABCD");
- $this->type("job_title", "Painter");
- $this->waitForElementPresent('nick_name');
- $this->type("nick_name", "Nick");
- $this->type("url-1", "http://www.test.com");
-
- $this->waitForElementPresent('street_address-Primary');
- $this->type("street_address-Primary", "Primary street address");
- $this->type("city-Primary", "primecity");
- $this->type("phone-Primary-1", "98667764");
- $this->type("postal_code-Primary", "6548");
-
- $this->type("custom_" . $customId[0], "fname_custom1");
- $this->type("custom_" . $customId[1], "mname_custom1");
- $this->type("custom_" . $customId[2], "lname_custom1");
-
- $this->type("middle_name", "xyz");
- $this->click("name=gender_id value=2");
- $this->waitForElementPresent('participant_role');
- $this->select("participant_role", "value=2");
-
- $this->click("_qf_Register_upload-bottom");
- $this->waitForElementPresent("_qf_Participant_1_next-Array");
- $this->type("email-Primary", $email2);
- $this->type("first_name", $participantfname);
- $this->type("last_name", $participantlname);
- $this->type("street_address-1", "participant street address");
- $this->type("city-1", "pune");
- $this->type("postal_code-1", "2354");
- $this->select("state_province-1", "value=1001");
-
- $this->waitForElementPresent("current_employer");
- $this->type("current_employer", "ABCD");
- $this->type("job_title", "Potato picker");
-
- $this->type("custom_" . $customId[0], "participant_custom1");
- $this->type("custom_" . $customId[1], "participant_custom1");
- $this->type("custom_" . $customId[2], "participant_custom1");
-
- $this->waitForElementPresent('street_address-Primary');
- $this->type("street_address-Primary", "Primary street address");
- $this->type("city-Primary", "primecity");
- $this->type("phone-Primary-1", "98667764");
- $this->type("postal_code-Primary", "6548");
- $this->waitForElementPresent('nick_name');
- $this->type("nick_name", "Nick1");
- $this->type("url-1", "http://www.part.com");
-
- $this->clickLink("_qf_Participant_1_next-Array", "_qf_Confirm_next-bottom");
- $this->click("_qf_Confirm_next-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- }
-
- /**
- * @param int $eventPageId
- * @param int $customId
- * @param string $firstName2
- * @param string $lastName2
- * @param string $participantfname2
- * @param $participantlname2
- * @param $email3
- * @param $email4
- */
- public function _testEventRegistrationAfterRemoving($eventPageId, $customId, $firstName2, $lastName2, $participantfname2, $participantlname2, $email3, $email4) {
- $this->openCiviPage("event/register", "id={$eventPageId}&reset=1&action=preview", "_qf_Register_upload-bottom");
- $this->select("additional_participants", "value=1");
-
- $this->type("email-Primary", $email4);
- $this->type("first_name", $firstName2);
- $this->type("last_name", $lastName2);
- $this->type("street_address-1", "Test street address");
- $this->type("city-1", "Mumbai");
- $this->type("postal_code-1", "2354");
- $this->select("state_province-1", "value=1001");
-
- // Credit Card Info
- $this->select("credit_card_type", "value=Visa");
- $this->type("credit_card_number", "4111111111111111");
- $this->type("cvv2", "000");
- $this->select("credit_card_exp_date[M]", "value=1");
- $this->select("credit_card_exp_date[Y]", "value=2020");
-
- //Billing Info
- $this->type("billing_first_name", $firstName2 . 'billing');
- $this->type("billing_last_name", $lastName2 . 'billing');
- $this->type("billing_street_address-5", "0121 Mount Highschool.");
- $this->type(" billing_city-5", "Shangai");
- $this->select("billing_country_id-5", "value=1228");
- $this->select("billing_state_province_id-5", "value=1004");
- $this->type("billing_postal_code-5", "94129");
-
- $this->type("current_employer", "ABCD");
- $this->type("job_title", "Painter");
-
- $this->type("nick_name", "Nickkk");
- $this->type("url-1", "http://www.testweb.com");
-
- $this->type("street_address-Primary", "Primary street address");
- $this->type("city-Primary", "primecity");
- $this->type("phone-Primary-1", "9866776422");
- $this->type("postal_code-Primary", "6534");
-
- $this->type("custom_" . $customId[0], "fname_custom1");
- $this->type("custom_" . $customId[1], "mname_custom1");
- $this->type("custom_" . $customId[2], "lname_custom1");
-
- $this->type("middle_name", "xyz");
- $this->click("name=gender_id value=2");
- $this->select("participant_role", "value=2");
-
- $this->click("_qf_Register_upload-bottom");
- $this->waitForElementPresent("_qf_Participant_1_next-Array");
-
- $this->type("email-Primary", $email3);
- $this->type("first_name", $participantfname2);
- $this->type("last_name", $participantlname2);
- $this->type("street_address-1", "participant street address");
- $this->type("city-1", "pune");
- $this->type("postal_code-1", "2354");
- $this->select("state_province-1", "value=1001");
-
- $this->type("current_employer", "ABCD");
- $this->type("job_title", "BATCHER");
-
- $this->clickLink("_qf_Participant_1_next-Array", "_qf_Confirm_next-bottom");
- $this->click("_qf_Confirm_next-bottom");
- }
-
- /**
- * @return array|string
- */
- public function _addEmailField() {
- //add email field in name and address profile
- $this->openCiviPage('admin/uf/group/field/add', 'reset=1&action=add&gid=1', "_qf_Field_next-bottom");
- $this->select("field_name[0]", "value=Contact");
- $this->select("field_name[1]", "value=email");
- $this->select("field_name[2]", "value=0");
- $this->click('_qf_Field_next-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $cfId = "";
- //check wheather webtest has created the field
- if ($this->assertElementNotContainsText('crm-notification-container', "The selected field was not added. It already exists in this profile")) {
- $this->waitForElementPresent("xpath=//div[@id='field_page']//table/tbody//tr[8]/td[9]/span/a[text()='Edit']");
- $cfId = explode('&id=', $this->getAttribute("xpath=//div[@id='field_page']//table/tbody//tr[8]/td[9]/span/a[text()='Edit']/@href"));
- $cfId = $cfId[1];
- }
- return $cfId;
- }
-
- /**
- * @param int $cfId
- */
- public function _removeEmailField($cfId) {
- $this->openCiviPage("admin/uf/group/field", "action=delete&id={$cfId}");
- $this->click("_qf_Field_next-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Event_PCPAddTest
- */
-class WebTest_Event_PCPAddTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testPCPAdd() {
- $this->markTestSkipped('Skipping for now as it works fine locally.');
- //give permissions to anonymous user
- $permission = array(
- 'edit-1-profile-listings-and-forms',
- 'edit-1-access-all-custom-data',
- 'edit-1-register-for-events',
- 'edit-1-make-online-contributions',
- );
- $this->changePermissions($permission);
-
- // Log in as normal user
- $this->webtestLogin();
-
- // set domain values
- $domainNameValue = 'civicrm organization ';
- $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
- $lastName = 'An' . substr(sha1(rand()), 0, 7);
- $middleName = 'Mid' . substr(sha1(rand()), 0, 7);
- $email = substr(sha1(rand()), 0, 7) . '@example.org';
- $this->openCiviPage("admin/domain", "action=update&reset=1", '_qf_Domain_cancel-bottom');
- $this->type('name', $domainNameValue);
- $this->type('email_name', $firstName);
- $this->type('email_address', $email);
-
- $this->click('_qf_Domain_next_view-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // a random 7-char string and an even number to make this pass unique
- $conHash = substr(sha1(rand()), 0, 7);
- $conRand = $contributionAmount = 1000;
- $contributionPageTitle = 'Contribution page for pcp' . $conHash;
- $conProcessorType = 'Dummy';
- $conAmountSection = TRUE;
- $conPayLater = TRUE;
- $conOnBehalf = FALSE;
- $conPledges = FALSE;
- $conRecurring = FALSE;
- $conMemberships = FALSE;
- $conMemPriceSetId = NULL;
- $conFriend = FALSE;
- $conProfilePreId = NULL;
- $conProfilePostId = NULL;
- $conPremiums = FALSE;
- $conWidget = FALSE;
- $conPcp = FALSE;
- $conIsAprovalNeeded = TRUE;
-
- // Use default payment processor
- $processorName = 'Test Processor';
-
- //create contribution page for event pcp with campaign type as contribution
- $contributionPageId = $this->webtestAddContributionPage($conHash,
- $conRand,
- $contributionPageTitle,
- array($processorName => $conProcessorType),
- $conAmountSection,
- $conPayLater,
- $conOnBehalf,
- $conPledges,
- $conRecurring,
- $conMemberships,
- $conMemPriceSetId,
- $conFriend,
- $conProfilePreId,
- $conProfilePostId,
- $conPremiums,
- $conWidget,
- $conPcp,
- TRUE,
- $conIsAprovalNeeded
- );
-
- //event add for contribute campaign type
- $campaignType = 'contribute';
- $this->_testAddEventForPCP($processorName, $campaignType, $contributionPageId, $firstName, $lastName, $middleName, $email);
-
- //event add for contribute campaign type
- $campaignType = 'event';
- $firstName = 'Pa' . substr(sha1(rand()), 0, 4);
- $lastName = 'Cn' . substr(sha1(rand()), 0, 7);
- $middleName = 'PCid' . substr(sha1(rand()), 0, 7);
- $email = substr(sha1(rand()), 0, 7) . '@example.org';
- $this->_testAddEventForPCP($processorName, $campaignType, NULL, $firstName, $lastName, $middleName, $email);
- }
-
- /**
- * @param string $processorName
- * @param $campaignType
- * @param int $contributionPageId
- * @param string $firstName
- * @param string $lastName
- * @param string $middleName
- * @param $email
- */
- public function _testAddEventForPCP($processorName, $campaignType, $contributionPageId = NULL, $firstName, $lastName, $middleName, $email) {
-
- $this->openCiviPage("event/add", "reset=1&action=add");
-
- $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7);
- $eventDescription = "Here is a description for this conference.";
- $this->_testAddEventInfo($eventTitle, $eventDescription);
-
- $streetAddress = "100 Main Street";
- $this->_testAddLocation($streetAddress);
-
- $this->_testAddFees(FALSE, FALSE, $processorName);
-
- // intro text for registration page
- $registerIntro = "Fill in all the fields below and click Continue.";
- $multipleRegistrations = TRUE;
- $this->_testAddOnlineRegistration($registerIntro, $multipleRegistrations);
-
- $pageId = $this->_testEventPcpAdd($campaignType, $contributionPageId);
- $this->_testOnlineRegistration($eventTitle, $pageId, $firstName, $lastName, $middleName, $email, '', $campaignType, TRUE);
- }
-
- /**
- * @param $eventTitle
- * @param $eventDescription
- */
- public function _testAddEventInfo($eventTitle, $eventDescription) {
- $this->waitForElementPresent("_qf_EventInfo_upload-bottom");
-
- $this->select("event_type_id", "value=1");
-
- // Attendee role s/b selected now.
- $this->select("default_role_id", "value=1");
-
- // Enter Event Title, Summary and Description
- $this->type("title", $eventTitle);
- $this->type("summary", "This is a great conference. Sign up now!");
-
- // Type description in ckEditor (fieldname, text to type, editor)
- $this->fillRichTextField("description", $eventDescription, 'CKEditor');
-
- // Choose Start and End dates.
- // Using helper webtestFillDate function.
- $this->webtestFillDateTime("start_date", "+1 week");
- $this->webtestFillDateTime("end_date", "+1 week 1 day 8 hours ");
-
- $this->type("max_participants", "50");
- $this->click("is_map");
- $this->click("_qf_EventInfo_upload-bottom");
- }
-
- /**
- * @param $streetAddress
- */
- public function _testAddLocation($streetAddress) {
- // Wait for Location tab form to load
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForElementPresent("_qf_Location_upload-bottom");
-
- // Fill in address fields
- $streetAddress = "100 Main Street";
- $this->type("address_1_street_address", $streetAddress);
- $this->type("address_1_city", "San Francisco");
- $this->type("address_1_postal_code", "94117");
- $this->select("address_1_state_province_id", "value=1004");
- $this->type("email_1_email", "info@civicrm.org");
-
- $this->click("_qf_Location_upload-bottom");
-
- // Wait for "saved" status msg
- $this->waitForElementPresent("_qf_Location_upload-bottom");
- $this->waitForTextPresent("'Event Location' information has been saved.");
- }
-
- /**
- * @param bool $discount
- * @param bool $priceSet
- * @param string $processorName
- */
- public function _testAddFees($discount = FALSE, $priceSet = FALSE, $processorName = "PP Pro") {
- // Go to Fees tab
- $this->click("link=Fees");
- $this->waitForElementPresent("_qf_Fee_upload-bottom");
- $this->click("CIVICRM_QFID_1_is_monetary");
- $this->select2('payment_processor', $processorName, TRUE);
- if ($priceSet) {
- // get one - TBD
- }
- else {
- $this->select("financial_type_id", "label=Donation");
- $this->type("label_1", "Member");
- $this->type("value_1", "250.00");
- $this->type("label_2", "Non-member");
- $this->type("value_2", "325.00");
- //set default
- $this->click("xpath=//table[@id='map-field-table']/tbody/tr[2]/td[3]/input");
- }
-
- if ($discount) {
- // enter early bird discounts TBD
- }
-
- $this->click("_qf_Fee_upload-bottom");
-
- // Wait for "saved" status msg
- $this->waitForElementPresent("_qf_Fee_upload-bottom");
- $this->waitForTextPresent("'Fees' information has been saved.");
- }
-
- /**
- * @param $registerIntro
- * @param bool $multipleRegistrations
- */
- public function _testAddOnlineRegistration($registerIntro, $multipleRegistrations = FALSE) {
- // Go to Online Registration tab
- $this->click("link=Online Registration");
- $this->waitForElementPresent("_qf_Registration_upload-bottom");
-
- $this->check("is_online_registration");
-
- $this->assertChecked("is_online_registration");
- if ($multipleRegistrations) {
- $this->check("is_multiple_registrations");
- $this->assertChecked("is_multiple_registrations");
- }
-
- $this->click('intro_text');
- $this->fillRichTextField('intro_text', $registerIntro, 'CKEditor', TRUE);
-
- // enable confirmation email
- $this->click("CIVICRM_QFID_1_is_email_confirm");
- $this->type("confirm_from_name", "Jane Doe");
- $this->type("confirm_from_email", "jane.doe@example.org");
-
- $this->click("_qf_Registration_upload-bottom");
- $this->waitForElementPresent("_qf_Registration_upload-bottom");
- $this->waitForTextPresent("'Online Registration' information has been saved.");
- }
-
- /**
- * @param $eventTitle
- * @param int $pageId
- * @param string $firstName
- * @param string $lastName
- * @param string $middleName
- * @param $email
- * @param int $numberRegistrations
- * @param $campaignType
- * @param bool $anonymous
- */
- public function _testOnlineRegistration($eventTitle, $pageId, $firstName, $lastName, $middleName, $email, $numberRegistrations = 1, $campaignType, $anonymous = TRUE) {
- $hash = substr(sha1(rand()), 0, 7);
- $contributionAmount = 600;
-
- // registering online
- if ($anonymous) {
- $this->webtestLogout();
- }
-
- //participant registeration
- $firstNameParticipants = 'Jane' . substr(sha1(rand()), 0, 7);
- $lastNameParticipants = 'Smith' . substr(sha1(rand()), 0, 7);
- $emailParticipants = 'jane' . substr(sha1(rand()), 0, 7) . "@example.org";
-
- $registerUrl = "civicrm/event/register?id={$pageId}&reset=1";
- $this->open($this->sboxPath . $registerUrl);
-
- $this->type("first_name", "{$firstNameParticipants}");
- $this->type("last_name", "{$lastNameParticipants}");
- $this->select("additional_participants", "value=" . $numberRegistrations);
- $this->type("email-Primary", $emailParticipants);
- $this->select("credit_card_type", "value=Visa");
- $this->type("credit_card_number", "4111111111111111");
- $this->type("cvv2", "000");
- $this->select("credit_card_exp_date[M]", "value=1");
- $this->select("credit_card_exp_date[Y]", "value=2020");
- $this->type("billing_first_name", "{$firstNameParticipants}");
- $this->type("billing_last_name", "{$lastNameParticipants}");
- $this->type("billing_street_address-5", "15 Main St.");
- $this->type(" billing_city-5", "San Jose");
- $this->select("billing_country_id-5", "value=1228");
- $this->select("billing_state_province_id-5", "value=1004");
- $this->type("billing_postal_code-5", "94129");
-
- $this->click("_qf_Register_upload-bottom");
-
- if ($numberRegistrations > 1) {
- for ($i = 1; $i <= $numberRegistrations; $i++) {
- $this->waitForPageToLoad($this->getTimeoutMsec());
- // Look for Skip button
- $this->waitForElementPresent("_qf_Participant_{$i}_next_skip-Array");
- $this->type("email-Primary", "{$firstName}" . substr(sha1(rand()), 0, 7) . "@example.org");
- $this->click("_qf_Participant_{$i}_next");
- }
- }
-
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForElementPresent("_qf_Confirm_next-bottom");
- $confirmStrings = array("Event Fee(s)", "Billing Name and Address", "Credit Card Information");
- $this->assertStringsPresent($confirmStrings);
- $this->click("_qf_Confirm_next-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $thankStrings = array("Thank You for Registering", "Event Total", "Transaction Date");
- $this->assertStringsPresent($thankStrings);
-
- //pcp creation via different user
- $this->openCiviPage('contribute/campaign', "action=add&reset=1&pageId={$pageId}&component=event", "_qf_PCPAccount_next-bottom");
-
- $cmsUserName = 'CmsUser' . substr(sha1(rand()), 0, 7);
-
- $this->type("cms_name", $cmsUserName);
- $this->click("checkavailability");
- $this->waitForTextPresent('This username is currently available');
- $this->type("first_name", $firstName);
- $this->type("last_name", $lastName);
- $this->type("email-Primary", $email);
- $this->click("_qf_PCPAccount_next-bottom");
- $this->waitForElementPresent("_qf_Campaign_upload-bottom");
-
- $pcpTitle = 'PCPTitle' . substr(sha1(rand()), 0, 7);
- $this->type("pcp_title", $pcpTitle);
- $this->type("pcp_intro_text", "Welcome Text $hash");
- $this->type("goal_amount", $contributionAmount);
- $this->click("_qf_Campaign_upload-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- //admin pcp approval
- //login to check contribution
-
- // Log in using webtestLogin() method
- $this->webtestLogin();
-
- $this->openCiviPage('admin/pcp', 'reset=1&page_type=event', "_qf_PCP_refresh");
- $this->select('status_id', 'value=1');
- $this->click("_qf_PCP_refresh");
- $this->waitForElementPresent("_qf_PCP_refresh");
- $id = explode('id=', $this->getAttribute("xpath=//div[@id='option11_wrapper']/table[@id='option11']/tbody//tr/td/a[text()='$pcpTitle']@href"));
- $pcpUrl = "civicrm/pcp/info?reset=1&id=$id[1]";
- $this->click("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody//tr/td/a[text()='$pcpTitle']/../../td[7]/span[1]/a[2][text()='Approve']");
-
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->webtestLogout();
-
- $this->open($this->sboxPath . $pcpUrl);
- $this->waitForElementPresent("xpath=//div[@class='pcp-donate']/a");
- $this->click("xpath=//div[@class='pcp-donate']/a");
- $emailElement = "";
- if ($campaignType == 'contribute') {
- $this->waitForElementPresent("_qf_Main_upload-bottom");
- $emailElement = "email-5";
- }
- elseif ($campaignType == 'event') {
- $this->waitForElementPresent('_qf_Register_upload-bottom');
- $emailElement = "email-Primary";
- }
-
- if ($campaignType == 'contribute') {
- $this->type("xpath=//div[@class='crm-section other_amount-section']//div[2]/input", "$contributionAmount");
- $feeLevel = NULL;
- }
- elseif ($campaignType == 'event') {
- $contributionAmount = '250.00';
- }
-
- $firstNameDonar = 'Andrew' . substr(sha1(rand()), 0, 7);
- $lastNameDonar = 'Roger' . substr(sha1(rand()), 0, 7);
- $middleNameDonar = 'Nicholas' . substr(sha1(rand()), 0, 7);
-
- if ($this->isElementPresent("first_name")) {
- $this->type('first_name', $firstNameDonar);
- }
-
- if ($this->isElementPresent("last_name")) {
- $this->type('last_name', $lastNameDonar);
- }
- $this->type("{$emailElement}", $firstNameDonar . "@example.com");
- $this->webtestAddCreditCardDetails();
- $this->webtestAddBillingDetails($firstNameDonar, $middleNameDonar, $lastNameDonar);
-
- if ($campaignType == 'contribute') {
- $this->click("_qf_Main_upload-bottom");
- }
- elseif ($campaignType == 'event') {
- $this->click('_qf_Register_upload-bottom');
- }
-
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForElementPresent("_qf_Confirm_next-bottom");
- $this->click("_qf_Confirm_next-bottom");
-
- if ($campaignType == 'contribute') {
- $this->waitForTextPresent("Your transaction has been processed successfully");
- }
- elseif ($campaignType == 'event') {
- $this->waitForTextPresent("Thank You for Registering");
- }
-
- //login to check contribution
- $this->webtestLogin();
-
- if ($campaignType == 'event') {
- $this->_testParticipantSearchEventName($eventTitle, $lastNameDonar, $firstNameDonar, $firstName, $lastName, $contributionAmount);
- }
- elseif ($campaignType == 'contribute') {
- $this->_testSearchTest($firstNameDonar, $lastNameDonar, $firstName, $lastName, $contributionAmount);
- }
- }
-
- /**
- * @param $campaignType
- * @param int $contributionPageId
- *
- * @return null
- */
- public function _testEventPcpAdd($campaignType, $contributionPageId) {
- $hash = substr(sha1(rand()), 0, 7);
- $isPcpApprovalNeeded = TRUE;
-
- // fill in step 9 (Enable Personal Campaign Pages)
- $this->click('link=Personal Campaigns');
- $this->waitForElementPresent('pcp_active');
- $this->click('pcp_active');
- $this->waitForElementPresent('_qf_Event_upload-bottom');
-
- $this->select('target_entity_type', "value={$campaignType}");
-
- if ($campaignType == 'contribute' && !empty($contributionPageId)) {
-
- $this->select('target_entity_id', "value={$contributionPageId}");
-
- }
-
- if (!$isPcpApprovalNeeded) {
-
- $this->click('is_approval_needed');
-
- }
- $this->type('notify_email', "$hash@example.name");
- $this->select('supporter_profile_id', 'value=2');
- $this->type('tellfriend_limit', 7);
- $this->type('link_text', "'Create Personal Campaign Page' link text $hash");
-
- $this->click('_qf_Event_upload-bottom');
- $this->waitForElementPresent('_qf_Event_upload-bottom');
- $text = "'Personal Campaigns' information has been saved.";
- $this->waitForText('crm-notification-container', $text);
-
- // parse URL to grab the contribution page id
- return $this->urlArg('id');
- }
-
- /**
- * @param string $eventName
- * @param string $lastNameDonar
- * @param string $firstNameDonar
- * @param string $firstNameCreator
- * @param string $lastNameCreator
- * @param $amount
- */
- public function _testParticipantSearchEventName($eventName, $lastNameDonar, $firstNameDonar, $firstNameCreator, $lastNameCreator, $amount) {
- $sortName = $lastNameDonar . ', ' . $firstNameDonar;
- $this->openCiviPage("event/search", "reset=1");
-
- $this->select2("event_id", $eventName);
-
- $this->clickLink("_qf_Search_refresh");
-
- $this->clickLink("xpath=//div[@id='participantSearch']/table/tbody/tr[1]/td[@class='crm-participant-sort_name']/a[text()='{$sortName}']/../../td[11]/span/a[text()='View']", "xpath=//table[@class='selector row-highlight']/tbody/tr/td[8]/span/a[text()='View']", FALSE);
- $this->clickLink("xpath=//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='View']", "_qf_ParticipantView_cancel-bottom", FALSE);
-
- $this->webtestVerifyTabularData(
- array(
- 'From' => "{$firstNameDonar} {$lastNameDonar}",
- 'Total Amount' => $amount,
- 'Contribution Status' => 'Completed',
- )
- );
- $softCreditor = "{$firstNameCreator} {$lastNameCreator}";
- $this->verifyText("xpath=//div[@id='PCPView']/div[2]//table[@class='crm-info-panel']/tbody/tr[2]/td[2]", preg_quote($softCreditor));
- }
-
- /**
- * @param string $firstName
- * @param $lastName
- * @param $pcpCreatorFirstName
- * @param $pcpCreatorLastName
- * @param $amount
- */
- public function _testSearchTest($firstName, $lastName, $pcpCreatorFirstName, $pcpCreatorLastName, $amount) {
- $sortName = "$pcpCreatorLastName, $pcpCreatorFirstName";
- $displayName = "$firstName $lastName";
-
- // visit contact search page
- $this->openCiviPage("contact/search", "reset=1");
-
- // fill name as first_name
- $this->type("css=.crm-basic-criteria-form-block input#sort_name", $pcpCreatorFirstName);
-
- // click to search
- $this->clickLink("_qf_Basic_refresh");
-
- $this->click("xpath=//div[@class='crm-search-results']//table/tbody//tr/td[3]/a[text()='{$sortName}']");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->click("css=li#tab_contribute a");
- $this->waitForElementPresent("xpath=//form[@id='Search']/div[@class='view-content']/table[2]/tbody/tr[@id='rowid']/td/a[text()='$displayName']");
- $this->click("xpath=//form[@id='Search']/div[@class='view-content']/table[2]/tbody/tr[@id='rowid']/td[8]/a[text()='View']");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- // as per changes made in CRM-15407
- $feeAmount = 1.50;
- $amount = $amount - $feeAmount;
-
- $this->webtestVerifyTabularData(
- array(
- 'From' => "{$firstName} {$lastName}",
- 'Net Amount' => $amount,
- 'Contribution Status' => 'Completed',
- )
- );
- $softCreditor = "{$pcpCreatorFirstName} {$pcpCreatorLastName}";
- $this->verifyText("xpath=//div[@id='PCPView']/div[2]//table[@class='crm-info-panel']/tbody/tr[2]/td[2]", preg_quote($softCreditor));
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Event_ParticipantCountTest
- */
-class WebTest_Event_ParticipantCountTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testParticipantCountWithFeelevel() {
- $this->markTestSkipped('Skipping for now as it works fine locally.');
- // Log in using webtestLogin() method
- $this->webtestLogin();
-
- // Use default payment processor
- $processorName = 'Test Processor';
- $this->webtestAddPaymentProcessor($processorName);
-
- // create an event
- $eventTitle = 'A Conference - ' . substr(sha1(rand()), 0, 7);
- $paramsEvent = array(
- 'title' => $eventTitle,
- 'template_id' => 6,
- 'event_type_id' => 4,
- 'payment_processor' => $processorName,
- 'fee_level' => array(
- 'Member' => '250.00',
- 'Non-Member' => '325.00',
- ),
- );
-
- $infoEvent = $this->_testAddEvent($paramsEvent);
-
- // logout to register for event.
- $this->webtestLogout();
-
- // Register Participant 1
- // visit event info page
- $this->open($infoEvent);
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // register for event
- $this->click('link=Register Now');
- $this->waitForElementPresent('_qf_Register_upload-bottom');
- $this->click("xpath=//input[@class='crm-form-radio']");
-
- $email = 'jane_' . substr(sha1(rand()), 0, 5) . '@example.org';
- $this->type('first_name', 'Mary');
- $this->type('last_name', 'Jones' . substr(sha1(rand()), 0, 5));
- $this->type('email-Primary', $email);
-
- // fill billing details and register
- $this->_testRegisterWithBillingInfo();
-
- // Register Participant 2
- // visit event info page
- $this->open($infoEvent);
-
- // register for event
- $this->click('link=Register Now');
- $this->waitForElementPresent('_qf_Register_upload-bottom');
-
- $this->click("xpath=//input[@class='crm-form-radio']");
- $email = 'jane_' . substr(sha1(rand()), 0, 5) . '@example.org';
- $this->type('first_name', 'Mary');
- $this->type('last_name', 'Jones' . substr(sha1(rand()), 0, 5));
- $this->type('email-Primary', $email);
-
- // fill billing details and register
- $this->_testRegisterWithBillingInfo();
-
- // login to check participant count
- $this->webtestLogin();
-
- // Find Participant
- $this->openCiviPage("event/search", "reset=1", 'participant_fee_amount_low');
- $this->select2("event_id", $eventTitle);
- $this->click('_qf_Search_refresh');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // verify number of registered participants
- $this->assertElementContainsText("xpath=//div[@class='crm-results-block']//div/table/tbody/tr/td", '2 Results');
- }
-
- public function testParticipantCountWithPriceset() {
- // Log in using webtestLogin() method
- $this->webtestLogin();
-
- // Use default payment processor
- $processorName = 'Test Processor';
- $this->webtestAddPaymentProcessor($processorName);
-
- // create priceset
- $priceset = 'Price - ' . substr(sha1(rand()), 0, 7);
- $this->_testAddSet($priceset);
-
- // create price fields
- $fields = array(
- 'Full Conference' => array(
- 'type' => 'Text',
- 'amount' => '525.00',
- 'count' => '2',
- ),
- 'Meal Choice' => array(
- 'type' => 'Select',
- 'options' => array(
- 1 => array(
- 'label' => 'Chicken',
- 'amount' => '525.00',
- 'count' => '2',
- ),
- 2 => array(
- 'label' => 'Vegetarian',
- 'amount' => '200.00',
- 'count' => '2',
- ),
- ),
- ),
- 'Pre-conference Meetup?' => array(
- 'type' => 'Radio',
- 'options' => array(
- 1 => array(
- 'label' => 'Yes',
- 'amount' => '50.00',
- 'count' => '2',
- ),
- 2 => array(
- 'label' => 'No',
- 'amount' => '0',
- ),
- ),
- ),
- 'Evening Sessions' => array(
- 'type' => 'CheckBox',
- 'options' => array(
- 1 => array(
- 'label' => 'First Five',
- 'amount' => '100.00',
- 'count' => '5',
- ),
- 2 => array(
- 'label' => 'Second Four',
- 'amount' => '50.00',
- 'count' => '4',
- ),
- ),
- ),
- );
-
- foreach ($fields as $label => $field) {
- $this->waitForAjaxContent();
- $this->select('html_type', "value={$field['type']}");
- if ($field['type'] == 'Text') {
- $this->type('price', $field['amount']);
- //yash
- $this->waitForElementPresent('count');
- $this->type('count', $field['count']);
- $this->check('is_required');
- }
- else {
- $this->_testAddMultipleChoiceOptions($field['options']);
- }
- $this->type('label', $label);
- $this->clickLink('_qf_Field_next_new-bottom', '_qf_Field_next-bottom', FALSE);
- $this->waitForText("crm-notification-container", "Price Field '$label' has been saved.");
- }
-
- // create event.
- $eventTitle = 'Meeting - ' . substr(sha1(rand()), 0, 7);
- $paramsEvent = array(
- 'title' => $eventTitle,
- 'template_id' => 6,
- 'event_type_id' => 4,
- 'payment_processor' => $processorName,
- 'price_set' => $priceset,
- );
-
- $infoEvent = $this->_testAddEvent($paramsEvent);
-
- // logout to register for event.
- $this->webtestLogout();
-
- $priceFieldOptionCounts = $participants = array();
-
- // Register Participant 1
- // visit event info page
- $this->open($infoEvent);
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // register for event
- $this->click('link=Register Now');
- $this->waitForElementPresent('_qf_Register_upload-bottom');
-
- $this->type("xpath=//div[@id='priceset']/div[@class='crm-section full_conference-section']//div/input[@class='four crm-form-text required']", '1');
-
- $email = 'jane_' . substr(sha1(rand()), 0, 5) . '@example.org';
- $participants[1] = array(
- 'email' => $email,
- 'first_name' => 'Jane_' . substr(sha1(rand()), 0, 5),
- 'last_name' => 'San_' . substr(sha1(rand()), 0, 5),
- );
-
- $this->type('first_name', $participants[1]['first_name']);
- $this->type('last_name', $participants[1]['last_name']);
- $this->type('email-Primary', $email);
-
- // fill billing related info and register
- $this->_testRegisterWithBillingInfo($participants[1]);
-
- // Options filled by 1st participants.
- $priceFieldOptionCounts[1] = array(
- 'Full Conference' => 1,
- 'Meal Choice - Chicken' => 1,
- 'Meal Choice - Vegetarian' => 0,
- 'Pre-conference Meetup? - Yes' => 1,
- 'Pre-conference Meetup? - No' => 0,
- 'Evening Sessions - First Five' => 1,
- 'Evening Sessions - Second Four' => 0,
- );
-
- // Register Participant 1
- // visit event info page
- $this->open($infoEvent);
-
- // register for event
- $this->click('link=Register Now');
- $this->waitForElementPresent('_qf_Register_upload-bottom');
- $this->type("xpath=//div[@id='priceset']/div[@class='crm-section full_conference-section']//div/input[@class='four crm-form-text required']", '2');
- $email = 'jane_' . substr(sha1(rand()), 0, 5) . '@example.org';
-
- $participants[2] = array(
- 'email' => $email,
- 'first_name' => 'Jane_' . substr(sha1(rand()), 0, 5),
- 'last_name' => 'San_' . substr(sha1(rand()), 0, 5),
- );
-
- $this->type('first_name', $participants[2]['first_name']);
- $this->type('last_name', $participants[2]['last_name']);
- $this->type('email-Primary', $email);
-
- // fill billing related info and register
- $this->_testRegisterWithBillingInfo($participants[2]);
-
- // Options filled by 2nd participants.
- $priceFieldOptionCounts[2] = array(
- 'Full Conference' => 2,
- 'Meal Choice - Chicken' => 1,
- 'Meal Choice - Vegetarian' => 0,
- 'Pre-conference Meetup? - Yes' => 1,
- 'Pre-conference Meetup? - No' => 0,
- 'Evening Sessions - First Five' => 1,
- 'Evening Sessions - Second Four' => 0,
- );
-
- // login to check participant count
- $this->webtestLogin();
-
- // Find Participant
- $this->openCiviPage('event/search', 'reset=1', 'participant_fee_amount_low');
- $this->waitForElementPresent('event_id');
- $this->select2("event_id", $eventTitle);
- $this->click('_qf_Search_refresh');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // verify number of participants records and total participant count
- $this->waitForAjaxContent();
- $this->assertStringsPresent(array('2 Results', 'Actual participant count : 24'));
-
- // CRM-7953, check custom search Price Set Details for Event
- // Participants
- $this->_testPricesetDetailsCustomSearch($paramsEvent, $participants, $priceFieldOptionCounts);
- }
-
- /**
- * @param $setTitle
- * @param string $financialType
- */
- public function _testAddSet($setTitle, $financialType = 'Event Fee') {
- $this->openCiviPage('admin/price', 'reset=1&action=add', '_qf_Set_next-bottom');
-
- // Enter Priceset fields (Title, Used For ...)
- $this->waitForElementPresent("title");
- $this->type('title', $setTitle);
- $this->check('extends[1]');
- $this->select("css=select.crm-form-select", "label={$financialType}");
- $this->waitForElementPresent("help_pre");
- $this->type('help_pre', 'This is test priceset.');
-
- $this->assertChecked('is_active', 'Verify that Is Active checkbox is set.');
- $this->clickLink('_qf_Set_next-bottom', '_qf_Field_next-bottom');
- }
-
- /**
- * @param $options
- */
- public function _testAddMultipleChoiceOptions($options) {
- foreach ($options as $oIndex => $oValue) {
- $this->type("option_label_{$oIndex}", $oValue['label']);
- $this->type("option_amount_{$oIndex}", $oValue['amount']);
- if (array_key_exists('count', $oValue)) {
- $this->waitForElementPresent("option_count_{$oIndex}");
- $this->type("option_count_{$oIndex}", $oValue['count']);
- }
- $this->click('link=another choice');
- }
- $this->click('CIVICRM_QFID_1_2');
- }
-
- /**
- * @param array $params
- *
- * @return string
- */
- public function _testAddEvent($params) {
- $this->openCiviPage('event/add', 'reset=1&action=add', '_qf_EventInfo_upload-bottom');
-
- $this->select('event_type_id', "value={$params['event_type_id']}");
-
- // Attendee role s/b selected now.
- $this->select('default_role_id', 'value=1');
-
- // Enter Event Title, Summary and Description
- $this->type('title', $params['title']);
- $this->type('summary', 'This is a great conference. Sign up now!');
- $this->fillRichTextField('description', 'Here is a description for this event.', 'CKEditor');
-
- // Choose Start and End dates.
- // Using helper webtestFillDate function.
- $this->webtestFillDateTime('start_date', '+1 week');
- $this->webtestFillDateTime('end_date', '+1 week 1 day 8 hours ');
-
- $this->type('max_participants', '50');
- $this->click('is_map');
- $this->click('_qf_EventInfo_upload-bottom');
-
- // Wait for Location tab form to load
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Go to Fees tab
- $this->click('link=Fees');
- $this->waitForElementPresent('_qf_Fee_upload-bottom');
- $this->click('CIVICRM_QFID_1_is_monetary');
- $this->select2('payment_processor', $params['payment_processor'], TRUE);
-
- $this->select('financial_type_id', 'Event Fee');
- if (array_key_exists('price_set', $params)) {
- $this->select('price_set_id', 'label=' . $params['price_set']);
- }
- if (array_key_exists('fee_level', $params)) {
- $counter = 1;
- foreach ($params['fee_level'] as $label => $amount) {
- $this->type("label_{$counter}", $label);
- $this->type("value_{$counter}", $amount);
- $counter++;
- }
- }
-
- $this->click('_qf_Fee_upload-bottom');
- $this->waitForElementPresent('_qf_Fee_cancel-top');
-
- // Go to Online Registration tab
- $this->click('link=Online Registration');
- $this->waitForElementPresent('_qf_Registration_upload-bottom');
-
- $this->check('is_online_registration');
- $this->assertChecked('is_online_registration');
-
- $this->click('intro_text');
- $this->fillRichTextField('intro_text', 'Fill in all the fields below and click Continue.', 'CKEditor', TRUE);
-
- // enable confirmation email
- $this->click('CIVICRM_QFID_1_is_email_confirm');
- $this->type('confirm_from_name', 'Jane Doe');
- $this->type('confirm_from_email', 'jane.doe@example.org');
-
- $this->click('_qf_Registration_upload-bottom');
- $this->waitForElementPresent('_qf_Registration_upload-bottom');
- $this->waitForTextPresent("'Online Registration' information has been saved.");
-
- // verify event input on info page
- // start at Manage Events listing
- $this->openCiviPage('event/manage', 'reset=1');
- $this->click('link=' . $params['title']);
-
- $this->waitForPageToLoad($this->getTimeoutMsec());
- return $this->getLocation();
- }
-
- /**
- * @param array $participant
- */
- public function _testRegisterWithBillingInfo($participant = array()) {
- $this->waitForElementPresent("credit_card_type");
- $this->select('credit_card_type', 'value=Visa');
- $this->type('credit_card_number', '4111111111111111');
- $this->type('cvv2', '000');
- $this->select('credit_card_exp_date[M]', 'value=1');
- $this->select('credit_card_exp_date[Y]', 'value=2020');
- $this->type('billing_first_name', isset($participant['first_name']) ? $participant['first_name'] : 'Jane_' . substr(sha1(rand()), 0, 5));
- $this->type('billing_last_name', isset($participant['last_name']) ? $participant['last_name'] : 'San_' . substr(sha1(rand()), 0, 5));
- $this->type('billing_street_address-5', '15 Main St.');
- $this->type(' billing_city-5', 'San Jose');
- $this->select('billing_country_id-5', 'value=1228');
- $this->select('billing_state_province_id-5', 'value=1004');
- $this->type('billing_postal_code-5', '94129');
-
- $this->clickLink('_qf_Register_upload-bottom', '_qf_Confirm_next-bottom', FALSE);
- $confirmStrings = array('Event Fee(s)', 'Billing Name and Address', 'Credit Card Information');
- $this->assertStringsPresent($confirmStrings);
- $this->click('_qf_Confirm_next-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $thankStrings = array('Thank You for Registering', 'Event Total', 'Transaction Date');
- $this->assertStringsPresent($thankStrings);
- }
-
- /**
- * @param array $eventParams
- * @param $participants
- * @param $priceFieldOptionCounts
- */
- public function _testPricesetDetailsCustomSearch($eventParams, $participants, $priceFieldOptionCounts) {
- $this->openCiviPage('contact/search/custom', 'csid=9&reset=1');
-
- $this->select('event_id', 'label=' . $eventParams['title']);
- $this->click('_qf_Custom_refresh-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $tableHeaders = array('Contact ID', 'Participant ID', 'Name');
- $tableHeaders = array_merge($tableHeaders, array_keys(current($priceFieldOptionCounts)));
-
- $tdnum = 2;
- foreach ($tableHeaders as $header) {
- $this->verifyText("xpath=//form[@id='Custom']//div[@class='crm-search-results']//table[@class='selector row-highlight']/thead/tr[1]/th[$tdnum]", $header);
- $tdnum++;
- }
-
- foreach ($participants as $participantNum => $participant) {
- $tdnum = 4;
- $this->verifyText("xpath=//form[@id='Custom']//div[@class='crm-search-results']//table[@class='selector row-highlight']/tbody/tr[{$participantNum}]/td[{$tdnum}]", preg_quote("{$participant['first_name']} {$participant['last_name']}"));
- foreach ($priceFieldOptionCounts[$participantNum] as $priceFieldOptionCount) {
- $tdnum++;
- $this->verifyText("xpath=//form[@id='Custom']//div[@class='crm-search-results']//table[@class='selector row-highlight']/tbody/tr[{$participantNum}]/td[{$tdnum}]", preg_quote($priceFieldOptionCount));
- }
- }
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Event_ParticipantSearchTest
- */
-class WebTest_Event_ParticipantSearchTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- /**
- * @param $strings
- */
- public function _checkStrings(&$strings) {
- // search for elements
- foreach ($strings as $string) {
- $this->assertTrue($this->isTextPresent($string), "Could not find $string on page");
- }
- }
-
- public function testParticipantSearchForm() {
- $this->webtestLogin();
-
- // visit event search page
- $this->openCiviPage("event/search", "reset=1");
-
- $stringsToCheck = array(
- 'Participant Name',
- 'Event Name',
- 'Event Dates',
- 'Participant Status',
- 'Participant Role',
- 'Participant is a Test?',
- 'Participant is Pay Later?',
- 'Fee Level',
- 'Fee Amount',
- // check that the custom data is also there
- 'Food Preference',
- 'Soup Selection',
- );
- $this->_checkStrings($stringsToCheck);
- }
-
- public function testParticipantSearchForce() {
- $this->webtestLogin();
-
- // visit event search page
- $this->openCiviPage("event/search", "reset=1&force=1");
-
- // assume generated DB
- // there are participants
- $this->assertTrue($this->isTextPresent("Select Records"), "A forced event search did not return any results");
- }
-
- public function testParticipantSearchEmpty() {
- $this->webtestLogin();
-
- // visit event search page
- $this->openCiviPage("event/search", "reset=1");
-
- $crypticName = "foobardoogoo_" . md5(time());
- $this->type("sort_name", $crypticName);
-
- $this->clickLink("_qf_Search_refresh");
-
- $stringsToCheck = array(
- 'No matches found for',
- 'Name or Email LIKE',
- $crypticName,
- );
-
- $this->_checkStrings($stringsToCheck);
- }
-
- public function testParticipantSearchEventName() {
- $this->webtestLogin();
-
- // visit event search page
- $this->openCiviPage("event/search", "reset=1");
- $this->waitForElementPresent('_qf_Search_refresh');
-
- $eventName = "Rain-forest Cup Youth Soccer Tournament";
- $this->waitForElementPresent("event_id");
- $this->select2("event_id", $eventName);
-
- $this->click("_qf_Search_refresh");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $stringsToCheck = array(
- "Event = $eventName",
- 'Select Records:',
- 'Edit Search Criteria',
- );
- $this->_checkStrings($stringsToCheck);
- }
-
- public function testParticipantSearchEventDate() {
-
- $this->webtestLogin();
-
- // visit event search page
- $this->openCiviPage("event/search", "reset=1");
-
- $this->select('event_relative', "label=Choose Date Range");
- $this->webtestFillDate('event_start_date_low', '-2 year');
- $this->webtestFillDate('event_end_date_high', '+1 year');
-
- $this->clickLink("_qf_Search_refresh");
-
- $stringsToCheck = array(
- "Start Date - greater than or equal to",
- '...AND...',
- "End Date - less than or equal to",
- 'Select Records:',
- 'Edit Search Criteria',
- );
-
- $this->_checkStrings($stringsToCheck);
- }
-
- public function testParticipantSearchEventDateAndType() {
- $this->markTestSkipped('Skipping for now as it works fine locally.');
- $this->webtestLogin();
-
- // visit event search page
- $this->openCiviPage("event/search", "reset=1");
-
- $eventTypeName = 'Fundraiser';
- $this->waitForElementPresent('event_type_id');
- $this->select2("event_type_id", $eventTypeName);
- $this->waitForElementPresent('event_relative');
- $this->select('event_relative', "label=Choose Date Range");
- $this->webtestFillDate('event_start_date_low', '-2 year');
- $this->webtestFillDate('event_end_date_high', '+1 year');
-
- $this->click("_qf_Search_refresh");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForElementPresent("xpath=//form[@id='Search']/div[3]/div/div[1]/div");
-
- $stringsToCheck = array(
- "Start Date - greater than or equal to",
- '...AND...',
- "End Date - less than or equal to",
- "Event Type = $eventTypeName",
- 'Select Records:',
- 'Edit Search Criteria',
- );
-
- $this->_checkStrings($stringsToCheck);
- }
-
- public function testParticipantSearchCustomField() {
- $this->markTestSkipped('Skipping for now as it works fine locally.');
- $this->webtestLogin();
-
- // visit event search page
- $this->openCiviPage("event/search", "reset=1");
-
- $this->select("css=select[data-crm-custom='Food_Preference:Soup_Selection']", 'Chicken Combo');
-
- $this->clickLink("_qf_Search_refresh");
-
- // note since this is generated data
- // we are not sure if someone has this selection, so
- // we are not testing for an empty record set
- $stringsToCheck = array("Soup Selection In Chicken Combo");
-
- $this->_checkStrings($stringsToCheck);
-
- $this->select("css=select[data-crm-custom='Food_Preference:Soup_Selection']", 'Salmon Stew');
- $this->clickLink("_qf_Search_refresh");
-
- $stringsToCheck = array("Soup Selection In Salmon Stew");
-
- $this->_checkStrings($stringsToCheck);
- }
-
- public function testParticipantSearchForceAndView() {
-
- $this->webtestLogin();
-
- // visit event search page
- $this->openCiviPage("event/search", "reset=1&force=1");
-
- // assume generated DB
- // there are participants
- $this->assertTrue($this->isTextPresent("Select Records"), "A forced event search did not return any results");
-
- $this->waitForElementPresent("xpath=id('participantSearch')/table/tbody/tr/td[11]/span/a[text()='View']");
- $this->click("xpath=id('participantSearch')/table/tbody/tr/td[11]/span/a[text()='View']");
- $this->waitForTextPresent("View Event Registration");
-
- // ensure we get to particpant view
- $stringsToCheck = array(
- "Name",
- "Event",
- "Participant Role",
- );
-
- $this->_checkStrings($stringsToCheck);
- }
-
- public function testParticipantSearchForceAndEdit() {
-
- $this->webtestLogin();
-
- // visit event search page
- $this->openCiviPage("event/search", "reset=1&force=1");
-
- // assume generated DB
- // there are participants
- $this->assertTrue($this->isTextPresent("Select Records"), "A forced event search did not return any results");
-
- $this->waitForElementPresent("xpath=id('participantSearch')/table/tbody/tr/td[11]/span/a[text()='Edit']");
- $this->click("xpath=id('participantSearch')/table/tbody/tr/td[11]/span/a[text()='Edit']");
- $this->waitForElementPresent("xpath=//button//span[contains(text(),'Save')]");
-
- // ensure we get to particpant view
- $stringsToCheck = array(
- "Participant",
- "Event",
- "Participant Role",
- );
-
- $this->_checkStrings($stringsToCheck);
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Event_PricesetMaxCountTest
- */
-class WebTest_Event_PricesetMaxCountTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testWithoutFieldCount() {
- // Log in using webtestLogin() method
- $this->webtestLogin();
-
- // Use default payment processor
- $processorName = 'Test Processor';
- $this->webtestAddPaymentProcessor($processorName);
-
- // create priceset
- $priceset = 'Price - ' . substr(sha1(rand()), 0, 7);
- $financialType = 'Donation';
- $this->_testAddSet($priceset, $financialType);
-
- // create price fields
- $fields = array(
- 'Full Conference' => array(
- 'type' => 'Text',
- 'amount' => '525.00',
- 'max_count' => 2,
- 'is_required' => TRUE,
- 'financial_type_id' => 1,
- ),
- 'Meal Choice' => array(
- 'type' => 'Select',
- 'options' => array(
- 1 => array(
- 'label' => 'Chicken',
- 'amount' => '525.00',
- 'max_count' => 1,
- 'financial_type_id' => 1,
- ),
- 2 => array(
- 'label' => 'Vegetarian',
- 'amount' => '200.00',
- 'max_count' => 5,
- 'financial_type_id' => 1,
- ),
- ),
- ),
- 'Pre-conference Meetup?' => array(
- 'type' => 'Radio',
- 'options' => array(
- 1 => array(
- 'label' => 'Yes',
- 'amount' => '50.00',
- 'max_count' => 1,
- 'financial_type_id' => 1,
- ),
- 2 => array(
- 'label' => 'No',
- 'amount' => '10',
- 'max_count' => 5,
- 'financial_type_id' => 1,
- ),
- ),
- ),
- 'Evening Sessions' => array(
- 'type' => 'CheckBox',
- 'options' => array(
- 1 => array(
- 'label' => 'First Five',
- 'amount' => '100.00',
- 'max_count' => 2,
- 'financial_type_id' => 1,
- ),
- 2 => array(
- 'label' => 'Second Four',
- 'amount' => '50.00',
- 'max_count' => 4,
- 'financial_type_id' => 1,
- ),
- ),
- ),
- );
-
- // add price fields
- $this->_testAddPriceFields($fields);
-
- // get price set url.
- $pricesetLoc = $this->getLocation();
-
- // get text field Id.
- $this->waitForElementPresent("xpath=//div[@id='crm-main-content-wrapper']/div/a[1]");
- $textFieldIdURL = $this->getAttribute("xpath=//div[@id='field_page']/table/tbody/tr[1]/td[9]/span[1]/a[2]@href");
- $textFieldId = $this->urlArg('fid', $textFieldIdURL);
-
- $this->open($pricesetLoc);
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // get select field id
- $this->click("xpath=//div[@id='field_page']//table/tbody/tr[2]/td[8]/a");
- $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']/button[2]/span[2]");
- $selectFieldLoc = $this->getLocation();
- $selectFieldURL = $this->getAttribute("xpath=//div[@id='field_page']//table/tbody/tr[2]/td[9]/span[1]/a[2]@href");
- $selectFieldId = $this->urlArg('fid', $selectFieldURL);
-
- // get select field ids
- // get select field option1
- $selectFieldOp1URL = $this->getAttribute("xpath=//div[@id='field_page']//table/tbody/tr[1]/td/span/a[text()='Edit Option']@href");
- $selectFieldOp1 = $this->urlArg('oid', $selectFieldOp1URL);
-
- // get select field option2
- $selectFieldOp2URL = $this->getAttribute("xpath=//div[@id='field_page']//table/tbody/tr[2]/td/span/a[text()='Edit Option']@href");
- $selectFieldOp2 = $this->urlArg('oid', $selectFieldOp2URL);
-
- // create event.
- $eventTitle = 'Meeting - ' . substr(sha1(rand()), 0, 7);
- $paramsEvent = array(
- 'title' => $eventTitle,
- 'template_id' => 6,
- 'event_type_id' => 4,
- 'payment_processor' => $processorName,
- 'price_set' => $priceset,
- );
-
- $infoEvent = $this->_testAddEvent($paramsEvent);
-
- // logout to register for event.
- $this->webtestLogout();
-
- // Register Participant 1
- // visit event info page
- $this->open($infoEvent);
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // register for event
- $this->click('link=Register Now');
- $this->waitForElementPresent('_qf_Register_upload-bottom');
-
- // exceed maximun count for text field, check for form rule
- $this->type("xpath=//input[@id='price_{$textFieldId}']", '3');
-
- $this->select("price_{$selectFieldId}", "value={$selectFieldOp1}");
-
- $this->type('first_name', 'Mary');
- $this->type('last_name', 'Jones' . substr(sha1(rand()), 0, 5));
- $email = 'jane_' . substr(sha1(rand()), 0, 5) . '@example.org';
- $this->type('email-Primary', $email);
-
- // fill billing related info
- $this->_fillRegisterWithBillingInfo();
-
- $this->assertStringsPresent(array('Sorry, currently only 2 spaces are available for this option.'));
-
- // fill correct value for text field
- $this->type("xpath=//input[@id='price_{$textFieldId}']", '1');
-
- $this->click('_qf_Register_upload-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->_checkConfirmationAndRegister();
-
- // Register Participant 2
- // visit event info page
- $this->open($infoEvent);
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->click('link=Register Now');
- $this->waitForElementPresent('_qf_Register_upload-bottom');
-
- // exceed maximun count for text field, check for form rule
- $this->type("xpath=//input[@id='price_{$textFieldId}']", '2');
- $this->type('first_name', 'Mary');
- $this->type('last_name', 'Jane' . substr(sha1(rand()), 0, 5));
- $email = 'jane_' . substr(sha1(rand()), 0, 5) . '@example.org';
- $this->type('email-Primary', $email);
-
- // fill billing related info and register
- $this->_fillRegisterWithBillingInfo();
-
- $this->assertStringsPresent(array('Sorry, currently only a single space is available for this option.'));
-
- // fill correct value for test field
- $this->type("xpath=//input[@id='price_{$textFieldId}']", '1');
-
- // select sold option for select field, check for form rule
- $this->assertElementContainsText("xpath=//select[@id='price_{$selectFieldId}']//option[@value='crm_disabled_opt-{$selectFieldOp1}']", "(Sold out)");
-
- // fill correct available option for select field
- $this->select("price_{$selectFieldId}", "value={$selectFieldOp2}");
-
- $this->click("css=input[data-amount=10]");
- $this->click('_qf_Register_upload-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->_checkConfirmationAndRegister();
- }
-
- public function testWithFieldCount() {
- // Log in using webtestLogin() method
- $this->webtestLogin();
-
- // Use default payment processor
- $processorName = 'Test Processor';
- $this->webtestAddPaymentProcessor($processorName);
-
- // create priceset
- $priceset = 'Price - ' . substr(sha1(rand()), 0, 7);
- $financialType = 'Donation';
- $this->_testAddSet($priceset, $financialType);
-
- // create price fields
- $fields = array(
- 'Full Conference' => array(
- 'type' => 'Text',
- 'amount' => '525.00',
- 'max_count' => 4,
- 'count' => 2,
- 'is_required' => TRUE,
- 'financial_type_id' => 1,
- ),
- 'Meal Choice' => array(
- 'type' => 'Select',
- 'options' => array(
- 1 => array(
- 'label' => 'Chicken',
- 'amount' => '525.00',
- 'max_count' => 2,
- 'count' => 2,
- 'financial_type_id' => 1,
- ),
- 2 => array(
- 'label' => 'Vegetarian',
- 'amount' => '200.00',
- 'max_count' => 10,
- 'count' => 5,
- 'financial_type_id' => 1,
- ),
- ),
- ),
- 'Pre-conference Meetup?' => array(
- 'type' => 'Radio',
- 'options' => array(
- 1 => array(
- 'label' => 'Yes',
- 'amount' => '50.00',
- 'max_count' => 2,
- 'count' => 1,
- 'financial_type_id' => 1,
- ),
- 2 => array(
- 'label' => 'No',
- 'amount' => '10',
- 'max_count' => 10,
- 'count' => 5,
- 'financial_type_id' => 1,
- ),
- ),
- ),
- 'Evening Sessions' => array(
- 'type' => 'CheckBox',
- 'options' => array(
- 1 => array(
- 'label' => 'First Five',
- 'amount' => '100.00',
- 'max_count' => 4,
- 'count' => 2,
- 'financial_type_id' => 1,
- ),
- 2 => array(
- 'label' => 'Second Four',
- 'amount' => '50.00',
- 'max_count' => 8,
- 'count' => 4,
- 'financial_type_id' => 1,
- ),
- ),
- ),
- );
-
- // add price fields
- $this->_testAddPriceFields($fields);
-
- // get price set url.
- $pricesetLoc = $this->getLocation();
-
- // get text field Id.
- $this->waitForElementPresent("xpath=//div[@id='crm-main-content-wrapper']/div/a[1]");
- $textFieldIdURL = $this->getAttribute("xpath=//div[@id='field_page']//table/tbody/tr[1]/td[9]/span[1]/a[2]@href");
- $textFieldId = $this->urlArg('fid', $textFieldIdURL);
-
- $this->open($pricesetLoc);
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // get select field id
- $this->click("xpath=//div[@id='field_page']//table/tbody/tr[2]/td[8]/a");
- $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']/button[2]/span[2]");
- $selectFieldLoc = $this->getLocation();
- $selectFieldURL = $this->getAttribute("xpath=//div[@id='field_page']//table/tbody/tr[2]/td[9]/span[1]/a[2]@href");
- $selectFieldId = $this->urlArg('fid', $selectFieldURL);
-
- // get select field ids
- // get select field option1
- $selectFieldOp1URL = $this->getAttribute("xpath=//div[@id='field_page']//table/tbody/tr[1]/td/span/a[text()='Edit Option']@href");
- $selectFieldOp1 = $this->urlArg('oid', $selectFieldOp1URL);
-
- // get select field option2
- $selectFieldOp2URL = $this->getAttribute("xpath=//div[@id='field_page']//table/tbody/tr[2]/td/span/a[text()='Edit Option']@href");
- $selectFieldOp2 = $this->urlArg('oid', $selectFieldOp2URL);
-
- // create event.
- $eventTitle = 'Meeting - ' . substr(sha1(rand()), 0, 7);
- $paramsEvent = array(
- 'title' => $eventTitle,
- 'template_id' => 6,
- 'event_type_id' => 4,
- 'payment_processor' => $processorName,
- 'price_set' => $priceset,
- );
-
- $infoEvent = $this->_testAddEvent($paramsEvent);
-
- // logout to register for event.
- $this->webtestLogout();
-
- // Register Participant 1
- // visit event info page
- $this->open($infoEvent);
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // register for event
- $this->click('link=Register Now');
- $this->waitForElementPresent('_qf_Register_upload-bottom');
-
- // check for form rule
- $this->type("xpath=//input[@id='price_{$textFieldId}']", '3');
-
- $this->type('first_name', 'Mary');
- $this->type('last_name', 'Jane' . substr(sha1(rand()), 0, 5));
- $email = 'jane_' . substr(sha1(rand()), 0, 5) . '@example.org';
- $this->type('email-Primary', $email);
-
- // fill billing related info
- $this->_fillRegisterWithBillingInfo();
-
- $this->assertStringsPresent(array('Sorry, currently only 4 spaces are available for this option.'));
-
- $this->select("price_{$selectFieldId}", "value={$selectFieldOp1}");
-
- // fill correct value and register
- $this->type("xpath=//input[@id='price_{$textFieldId}']", '1');
-
- $this->click('_qf_Register_upload-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->_checkConfirmationAndRegister();
-
- // Register Participant 2
- // visit event info page
- $this->open($infoEvent);
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->click('link=Register Now');
- $this->waitForElementPresent('_qf_Register_upload-bottom');
-
- // check for form rule
- $this->type("xpath=//input[@id='price_{$textFieldId}']", '2');
- $this->type('first_name', 'Mary');
- $this->type('last_name', 'Jane' . substr(sha1(rand()), 0, 5));
- $email = 'jane_' . substr(sha1(rand()), 0, 5) . '@example.org';
- $this->type('email-Primary', $email);
-
- // fill billing related info and register
- $this->_fillRegisterWithBillingInfo();
-
- $this->assertStringsPresent(array('Sorry, currently only 2 spaces are available for this option.'));
-
- // fill correct value and register
- $this->type("xpath=//input[@id='price_{$textFieldId}']", '1');
-
- // check for sold option for select field
- $this->assertElementContainsText("xpath=//select[@id='price_{$selectFieldId}']//option[@value='crm_disabled_opt-{$selectFieldOp1}']", "(Sold out)");
-
- // check for sold option for select field
- $this->select("price_{$selectFieldId}", "value={$selectFieldOp2}");
-
- $this->click('_qf_Register_upload-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->_checkConfirmationAndRegister();
- }
-
- public function testAdditionalParticipantWithoutFieldCount() {
- // Log in using webtestLogin() method
- $this->webtestLogin();
-
- // Use default payment processor
- $processorName = 'Test Processor';
- $this->webtestAddPaymentProcessor($processorName);
-
- // create priceset
- $priceset = 'Price - ' . substr(sha1(rand()), 0, 7);
- $financialType = 'Donation';
- $this->_testAddSet($priceset, $financialType);
-
- // create price fields
- $fields = array(
- 'Full Conference' => array(
- 'type' => 'Text',
- 'amount' => '525.00',
- 'max_count' => 6,
- 'is_required' => TRUE,
- 'financial_type_id' => 1,
- ),
- 'Meal Choice' => array(
- 'type' => 'Select',
- 'options' => array(
- 1 => array(
- 'label' => 'Chicken',
- 'amount' => '525.00',
- 'max_count' => 3,
- 'financial_type_id' => 1,
- ),
- 2 => array(
- 'label' => 'Vegetarian',
- 'amount' => '200.00',
- 'max_count' => 2,
- 'financial_type_id' => 1,
- ),
- ),
- ),
- 'Pre-conference Meetup?' => array(
- 'type' => 'Radio',
- 'options' => array(
- 1 => array(
- 'label' => 'Yes',
- 'amount' => '50.00',
- 'max_count' => 4,
- 'financial_type_id' => 1,
- ),
- 2 => array(
- 'label' => 'No',
- 'amount' => '10',
- 'max_count' => 5,
- 'financial_type_id' => 1,
- ),
- ),
- ),
- 'Evening Sessions' => array(
- 'type' => 'CheckBox',
- 'options' => array(
- 1 => array(
- 'label' => 'First Five',
- 'amount' => '100.00',
- 'max_count' => 6,
- 'financial_type_id' => 1,
- ),
- 2 => array(
- 'label' => 'Second Four',
- 'amount' => '50.00',
- 'max_count' => 4,
- 'financial_type_id' => 1,
- ),
- ),
- ),
- );
-
- // add price fields
- $this->_testAddPriceFields($fields);
-
- // get price set url.
- $pricesetLoc = $this->getLocation();
-
- // get text field Id.
- $this->waitForElementPresent("xpath=//div[@id='crm-main-content-wrapper']/div/a[1]");
- $textFieldURL = $this->getAttribute("xpath=//div[@id='field_page']/table/tbody/tr[1]/td[9]/span[1]/a[2]@href");
- $textFieldId = $this->urlArg('fid', $textFieldURL);
-
- $this->open($pricesetLoc);
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // get select field id
- $this->click("xpath=//div[@id='field_page']//table/tbody/tr[2]/td[8]/a");
- $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']/button[2]/span[2]");
- $selectFieldLoc = $this->getLocation();
- $selectFieldURL = $this->getAttribute("xpath=//div[@id='field_page']//table/tbody/tr[2]/td[9]/span[1]/a[2]@href");
- $selectFieldId = $this->urlArg('fid', $selectFieldURL);
-
- // get select field ids
- // get select field option1
- $selectFieldOp1URL = $this->getAttribute("xpath=//div[@id='field_page']//table/tbody/tr[1]/td/span/a[text()='Edit Option']@href");
- $selectFieldOp1 = $this->urlArg('oid', $selectFieldOp1URL);
-
- // get select field option2
- $selectFieldOp2URL = $this->getAttribute("xpath=//div[@id='field_page']//table/tbody/tr[2]/td/span/a[text()='Edit Option']@href");
- $selectFieldOp2 = $this->urlArg('oid', $selectFieldOp2URL);
-
- // create event.
- $eventTitle = 'Meeting - ' . substr(sha1(rand()), 0, 7);
- $paramsEvent = array(
- 'title' => $eventTitle,
- 'template_id' => 6,
- 'event_type_id' => 4,
- 'payment_processor' => $processorName,
- 'price_set' => $priceset,
- 'is_multiple_registrations' => TRUE,
- );
-
- $infoEvent = $this->_testAddEvent($paramsEvent);
-
- // logout to register for event.
- $this->webtestLogout();
-
- // 1'st registration
- // Register Participant 1
- // visit event info page
- $this->open($infoEvent);
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // register for event
- $this->click('link=Register Now');
- $this->waitForElementPresent('_qf_Register_upload-bottom');
-
- // select 3 participants ( including current )
- $this->select('additional_participants', 'value=2');
-
- // Check for Participant1
- // exceed maximun count for text field, check for form rule
- $this->type("xpath=//input[@id='price_{$textFieldId}']", '7');
-
- $this->type('first_name', 'Mary');
- $this->type('last_name', 'Jane' . substr(sha1(rand()), 0, 5));
- $email = 'jane_' . substr(sha1(rand()), 0, 5) . '@example.org';
- $this->type('email-Primary', $email);
-
- // fill billing related info
- $this->_fillRegisterWithBillingInfo();
-
- $this->assertStringsPresent(array('Sorry, currently only 6 spaces are available for this option.'));
-
- // fill correct value for text field
- $this->type("xpath=//input[@id='price_{$textFieldId}']", '1');
- $this->select("price_{$selectFieldId}", "value={$selectFieldOp2}");
-
- $this->click('_qf_Register_upload-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Check for Participant2
- // exceed maximun count for text field, check for form rule
- $this->type("xpath=//input[@id='price_{$textFieldId}']", '6');
-
- $this->type('first_name', 'Mary Add 2');
- $this->type('last_name', 'Jane' . substr(sha1(rand()), 0, 5));
- $email = 'jane_' . substr(sha1(rand()), 0, 5) . '@example.org';
- $this->type('email-Primary', $email);
-
- $this->click('_qf_Participant_1_next-Array');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->assertStringsPresent(array('Sorry, currently only 6 spaces are available for this option.'));
-
- // fill correct value for text field
- $this->type("xpath=//input[@id='price_{$textFieldId}']", '3');
- $this->select("price_{$selectFieldId}", "value={$selectFieldOp2}");
-
- $this->click('_qf_Participant_1_next-Array');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Check for Participant3, check and skip
- // exceed maximun count for text field, check for form rule
- $this->type("xpath=//input[@id='price_{$textFieldId}']", '3');
-
- $this->type('first_name', 'Mary Add 2');
- $this->type('last_name', 'Jane' . substr(sha1(rand()), 0, 5));
- $email = 'jane_' . substr(sha1(rand()), 0, 5) . '@example.org';
- $this->type('email-Primary', $email);
-
- $this->click('_qf_Participant_2_next-Array');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->assertStringsPresent(array('Sorry, currently only 6 spaces are available for this option.'));
-
- // fill correct value for text field
- $this->type("xpath=//input[@id='price_{$textFieldId}']", '1');
-
- // check for select
- $this->assertElementContainsText("xpath=//select[@id='price_{$selectFieldId}']//option[@value='crm_disabled_opt-{$selectFieldOp2}']", "(Sold out)");
-
- // Skip participant3 and register
- $this->click('_qf_Participant_2_next_skip-Array');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->_checkConfirmationAndRegister();
-
- // 2'st registration
- // Register Participant 1
- // visit event info page
- $this->open($infoEvent);
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // register for event
- $this->click('link=Register Now');
- $this->waitForElementPresent('_qf_Register_upload-bottom');
-
- // select 2 participants ( including current )
- $this->select('additional_participants', 'value=1');
-
- // Check for Participant1
- // exceed maximun count for text field, check for form rule
- $this->type("xpath=//input[@id='price_{$textFieldId}']", '3');
-
- $this->type('first_name', 'Mary');
- $this->type('last_name', 'Jane' . substr(sha1(rand()), 0, 5));
- $email = 'jane_' . substr(sha1(rand()), 0, 5) . '@example.org';
- $this->type('email-Primary', $email);
-
- // fill billing related info
- $this->_fillRegisterWithBillingInfo();
-
- $this->assertStringsPresent(array('Sorry, currently only 2 spaces are available for this option.'));
-
- // fill correct value for text field
- $this->type("xpath=//input[@id='price_{$textFieldId}']", '1');
-
- // check for select field
- $this->assertElementContainsText("xpath=//select[@id='price_{$selectFieldId}']//option[@value='crm_disabled_opt-{$selectFieldOp2}']", "(Sold out)");
-
- // fill available value for select
- $this->select("price_{$selectFieldId}", "value={$selectFieldOp1}");
-
- $this->click('_qf_Register_upload-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Check for Participant2
- // exceed maximun count for text field, check for form rule
- $this->type("xpath=//input[@id='price_{$textFieldId}']", '2');
-
- $this->type('first_name', 'Mary Add 1');
- $this->type('last_name', 'Jane' . substr(sha1(rand()), 0, 5));
- $email = 'jane_' . substr(sha1(rand()), 0, 5) . '@example.org';
- $this->type('email-Primary', $email);
-
- $this->click('_qf_Participant_1_next-Array');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->assertStringsPresent(array('Sorry, currently only 2 spaces are available for this option.'));
-
- // fill correct value for text field
- $this->type("xpath=//input[@id='price_{$textFieldId}']", '1');
-
- // check for select field
- $this->assertElementContainsText("xpath=//select[@id='price_{$selectFieldId}']//option[@value='crm_disabled_opt-{$selectFieldOp2}']", "(Sold out)");
-
- // fill available value for select
- $this->select("price_{$selectFieldId}", "value={$selectFieldOp1}");
-
- $this->click('_qf_Participant_1_next-Array');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->_checkConfirmationAndRegister();
- }
-
- public function testAdditionalParticipantWithFieldCount() {
- // Log in using webtestLogin() method
- $this->webtestLogin();
-
- // Use default payment processor
- $processorName = 'Test Processor';
- $this->webtestAddPaymentProcessor($processorName);
-
- // create priceset
- $priceset = 'Price - ' . substr(sha1(rand()), 0, 7);
- $financialType = 'Donation';
- $this->_testAddSet($priceset, $financialType);
-
- // create price fields
- $fields = array(
- 'Full Conference' => array(
- 'type' => 'Text',
- 'amount' => '525.00',
- 'count' => 2,
- 'max_count' => 12,
- 'is_required' => TRUE,
- 'financial_type_id' => 1,
- ),
- 'Meal Choice' => array(
- 'type' => 'Select',
- 'options' => array(
- 1 => array(
- 'label' => 'Chicken',
- 'amount' => '525.00',
- 'count' => 1,
- 'max_count' => 3,
- 'financial_type_id' => 1,
- ),
- 2 => array(
- 'label' => 'Vegetarian',
- 'amount' => '200.00',
- 'count' => 2,
- 'max_count' => 4,
- 'financial_type_id' => 1,
- ),
- ),
- ),
- 'Pre-conference Meetup?' => array(
- 'type' => 'Radio',
- 'options' => array(
- 1 => array(
- 'label' => 'Yes',
- 'amount' => '50.00',
- 'count' => 2,
- 'max_count' => 8,
- 'financial_type_id' => 1,
- ),
- 2 => array(
- 'label' => 'No',
- 'amount' => '10',
- 'count' => 5,
- 'max_count' => 25,
- 'financial_type_id' => 1,
- ),
- ),
- ),
- 'Evening Sessions' => array(
- 'type' => 'CheckBox',
- 'options' => array(
- 1 => array(
- 'label' => 'First Five',
- 'amount' => '100.00',
- 'count' => 2,
- 'max_count' => 16,
- 'financial_type_id' => 1,
- ),
- 2 => array(
- 'label' => 'Second Four',
- 'amount' => '50.00',
- 'count' => 1,
- 'max_count' => 4,
- 'financial_type_id' => 1,
- ),
- ),
- ),
- );
-
- // add price fields
- $this->_testAddPriceFields($fields);
-
- // get price set url.
- $pricesetLoc = $this->getLocation();
-
- // get text field Id.
- $this->waitForElementPresent("xpath=//div[@id='crm-main-content-wrapper']/div/a[1]");
- $textFieldIdURL = $this->getAttribute("xpath=//div[@id='field_page']//table/tbody/tr[1]/td[9]/span[1]/a[2]@href");
- $textFieldId = $this->urlArg('fid', $textFieldIdURL);
-
- $this->open($pricesetLoc);
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // get select field id
- $this->click("xpath=//div[@id='field_page']//table/tbody/tr[2]/td[8]/a");
- $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']/button[2]/span[2]");
- $selectFieldLoc = $this->getLocation();
- $selectFieldURL = $this->getAttribute("xpath=//div[@id='field_page']//table/tbody/tr[2]/td[9]/span[1]/a[2]@href");
- $selectFieldId = $this->urlArg('fid', $selectFieldURL);
-
- // get select field ids
- // get select field option1
- $selectFieldOp1URL = $this->getAttribute("xpath=//div[@id='field_page']//table/tbody/tr[1]/td/span/a[text()='Edit Option']@href");
- $selectFieldOp1 = $this->urlArg('oid', $selectFieldOp1URL);
-
- // get select field option2
- $selectFieldOp2URL = $this->getAttribute("xpath=//div[@id='field_page']//table/tbody/tr[2]/td/span/a[text()='Edit Option']@href");
- $selectFieldOp2 = $this->urlArg('oid', $selectFieldOp2URL);
-
- // create event.
- $eventTitle = 'Meeting - ' . substr(sha1(rand()), 0, 7);
- $paramsEvent = array(
- 'title' => $eventTitle,
- 'template_id' => 6,
- 'event_type_id' => 4,
- 'payment_processor' => $processorName,
- 'price_set' => $priceset,
- 'is_multiple_registrations' => TRUE,
- );
-
- $infoEvent = $this->_testAddEvent($paramsEvent);
-
- // logout to register for event.
- $this->webtestLogout();
-
- // 1'st registration
- // Register Participant 1
- // visit event info page
- $this->open($infoEvent);
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // register for event
- $this->click('link=Register Now');
- $this->waitForElementPresent('_qf_Register_upload-bottom');
-
- // select 3 participants ( including current )
- $this->select('additional_participants', 'value=2');
-
- // Check for Participant1
- // exceed maximun count for text field, check for form rule
- $this->type("xpath=//input[@id='price_{$textFieldId}']", '7');
-
- $this->type('first_name', 'Mary');
- $this->type('last_name', 'Jane' . substr(sha1(rand()), 0, 5));
- $email = 'jane_' . substr(sha1(rand()), 0, 5) . '@example.org';
- $this->type('email-Primary', $email);
-
- // fill billing related info
- $this->_fillRegisterWithBillingInfo();
-
- $this->assertStringsPresent(array('Sorry, currently only 12 spaces are available for this option.'));
-
- // fill correct value for text field
- $this->type("xpath=//input[@id='price_{$textFieldId}']", '1');
- $this->select("price_{$selectFieldId}", "value={$selectFieldOp2}");
-
- $this->click('_qf_Register_upload-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Check for Participant2
- // exceed maximun count for text field, check for form rule
- $this->type("xpath=//input[@id='price_{$textFieldId}']", '6');
-
- $this->type('first_name', 'Mary Add 1');
- $this->type('last_name', 'Jane' . substr(sha1(rand()), 0, 5));
- $email = 'jane_' . substr(sha1(rand()), 0, 5) . '@example.org';
- $this->type('email-Primary', $email);
-
- $this->click('_qf_Participant_1_next-Array');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->assertStringsPresent(array('Sorry, currently only 12 spaces are available for this option.'));
-
- // fill correct value for text field
- $this->type("xpath=//input[@id='price_{$textFieldId}']", '3');
- $this->select("price_{$selectFieldId}", "value={$selectFieldOp2}");
-
- $this->click('_qf_Participant_1_next-Array');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Check for Participant3, check and skip
- // exceed maximun count for text field, check for form rule
- $this->type("xpath=//input[@id='price_{$textFieldId}']", '3');
-
- $this->type('first_name', 'Mary Add 2');
- $this->type('last_name', 'Jane' . substr(sha1(rand()), 0, 5));
- $email = 'jane_' . substr(sha1(rand()), 0, 5) . '@example.org';
- $this->type('email-Primary', $email);
-
- $this->click('_qf_Participant_2_next-Array');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->assertStringsPresent(array('Sorry, currently only 12 spaces are available for this option.'));
-
- // fill correct value for text field
- $this->type("xpath=//input[@id='price_{$textFieldId}']", '1');
-
- // check for select
- $this->assertElementContainsText("xpath=//select[@id='price_{$selectFieldId}']//option[@value='crm_disabled_opt-{$selectFieldOp2}']", "(Sold out)");
-
- // Skip participant3 and register
- $this->click('_qf_Participant_2_next_skip-Array');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->_checkConfirmationAndRegister();
-
- // 2'st registration
- // Register Participant 1
- // visit event info page
- $this->open($infoEvent);
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // register for event
- $this->click('link=Register Now');
- $this->waitForElementPresent('_qf_Register_upload-bottom');
-
- // select 2 participants ( including current )
- $this->select('additional_participants', 'value=1');
-
- // Check for Participant1
- // exceed maximun count for text field, check for form rule
- $this->type("xpath=//input[@id='price_{$textFieldId}']", '3');
-
- $this->type('first_name', 'Mary');
- $this->type('last_name', 'Jane' . substr(sha1(rand()), 0, 5));
- $email = 'jane_' . substr(sha1(rand()), 0, 5) . '@example.org';
- $this->type('email-Primary', $email);
-
- // fill billing related info
- $this->_fillRegisterWithBillingInfo();
-
- $this->assertStringsPresent(array('Sorry, currently only 4 spaces are available for this option.'));
-
- // fill correct value for text field
- $this->type("xpath=//input[@id='price_{$textFieldId}']", '1');
-
- // check for select field
- $this->assertElementContainsText("xpath=//select[@id='price_{$selectFieldId}']//option[@value='crm_disabled_opt-{$selectFieldOp2}']", "(Sold out)");
-
- // fill available value for select
- $this->select("price_{$selectFieldId}", "value={$selectFieldOp1}");
-
- $this->click('_qf_Register_upload-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Check for Participant2
- // exceed maximun count for text field, check for form rule
- $this->type("xpath=//input[@id='price_{$textFieldId}']", '2');
-
- $this->type('first_name', 'Mary Add 1');
- $this->type('last_name', 'Jane' . substr(sha1(rand()), 0, 5));
- $email = 'jane_' . substr(sha1(rand()), 0, 5) . '@example.org';
- $this->type('email-Primary', $email);
-
- $this->click('_qf_Participant_1_next-Array');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->assertStringsPresent(array('Sorry, currently only 4 spaces are available for this option.'));
-
- // fill correct value for text field
- $this->type("xpath=//input[@id='price_{$textFieldId}']", '1');
-
- // check for select field
- $this->assertElementContainsText("xpath=//select[@id='price_{$selectFieldId}']//option[@value='crm_disabled_opt-{$selectFieldOp2}']", "(Sold out)");
-
- // fill available value for select
- $this->select("price_{$selectFieldId}", "value={$selectFieldOp1}");
-
- $this->click('_qf_Participant_1_next-Array');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->_checkConfirmationAndRegister();
- }
-
- /**
- * @param $setTitle
- * @param null $financialType
- */
- public function _testAddSet($setTitle, $financialType = NULL) {
- $this->openCiviPage('admin/price', 'reset=1&action=add', '_qf_Set_next-bottom');
-
- // Enter Priceset fields (Title, Used For ...)
- $this->type('title', $setTitle);
- $this->check('extends_1');
-
- if ($financialType) {
- $this->select("css=select.crm-form-select", "label={$financialType}");
- }
-
- $this->click("xpath=//form[@id='Set']/div[3]/table/tbody/tr[4]/td[2]/select");
- $this->type('help_pre', 'This is test priceset.');
-
- $this->assertChecked('is_active', 'Verify that Is Active checkbox is set.');
- $this->clickLink('_qf_Set_next-bottom');
- }
-
- /**
- * @param $fields
- */
- public function _testAddPriceFields($fields) {
- $fieldCount = count($fields);
- $count = 1;
- $this->waitForElementPresent('label');
- foreach ($fields as $label => $field) {
- $this->waitForElementPresent('label');
- $this->type('label', $label);
- $this->select('html_type', "value={$field['type']}");
-
- if ($field['type'] == 'Text') {
- $this->type('price', $field['amount']);
-
- if (isset($field['count'])) {
- $this->waitForElementPresent('count');
- $this->type('count', $field['count']);
- }
-
- if (isset($field['count'])) {
- $this->waitForElementPresent('count');
- $this->type('count', $field['count']);
- }
-
- if (isset($field['max_count'])) {
- $this->waitForElementPresent('max_value');
- $this->type('max_value', $field['max_count']);
- }
-
- if (isset($field['financial_type_id'])) {
- $this->waitForElementPresent('financial_type_id');
- $this->select('financial_type_id', "value={$field['financial_type_id']}");
- }
-
- }
- else {
- $this->_testAddMultipleChoiceOptions($field['options'], $field['type']);
- }
-
- if (isset($field['is_required']) && $field['is_required']) {
- $this->check('is_required');
- }
-
- if ($count < $fieldCount) {
- $this->click('_qf_Field_next_new-bottom');
- }
- else {
- $this->click('_qf_Field_next-bottom');
- }
- $this->waitForAjaxContent();
- $this->waitForText('crm-notification-container', "Price Field '$label' has been saved.");
-
- $count++;
- }
- }
-
- /**
- * @param $options
- * @param $fieldType
- */
- public function _testAddMultipleChoiceOptions($options, $fieldType) {
- foreach ($options as $oIndex => $oValue) {
- $this->type("option_label_{$oIndex}", $oValue['label']);
- $this->type("option_amount_{$oIndex}", $oValue['amount']);
-
- if (isset($oValue['count'])) {
- $this->waitForElementPresent("option_count_{$oIndex}");
- $this->type("option_count_{$oIndex}", $oValue['count']);
- }
-
- if (isset($oValue['max_count'])) {
- $this->waitForElementPresent("option_max_value_{$oIndex}");
- $this->type("option_max_value_{$oIndex}", $oValue['max_count']);
- }
-
- if (!empty($oValue['financial_type_id'])) {
- $this->select("option_financial_type_id_{$oIndex}", "value={$oValue['financial_type_id']}");
- }
-
- $this->click('link=another choice');
- }
-
- // select first element as default
- if ($fieldType == 'CheckBox') {
- $this->click('default_checkbox_option[1]');
- }
- else {
- $this->click('CIVICRM_QFID_1_2');
- }
- }
-
- /**
- * @param array $params
- *
- * @return string
- */
- public function _testAddEvent($params) {
- $this->openCiviPage('event/add', 'reset=1&action=add', '_qf_EventInfo_upload-bottom');
-
- $this->select('event_type_id', "value={$params['event_type_id']}");
-
- // Attendee role s/b selected now.
- $this->select('default_role_id', 'value=1');
-
- // Enter Event Title, Summary and Description
- $this->type('title', $params['title']);
- $this->type('summary', 'This is a great conference. Sign up now!');
- $this->fillRichTextField('description', 'Here is a description for this event.', 'CKEditor');
-
- // Choose Start and End dates.
- // Using helper webtestFillDate function.
- $this->webtestFillDateTime('start_date', '+1 week');
- $this->webtestFillDateTime('end_date', '+1 week 1 day 8 hours ');
-
- $this->type('max_participants', '50');
- $this->click('is_map');
- $this->click('_qf_EventInfo_upload-bottom');
-
- // Wait for Location tab form to load
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Go to Fees tab
- $this->click('link=Fees');
- $this->waitForElementPresent('_qf_Fee_upload-bottom');
- $this->click('xpath=//form[@id="Fee"]//div/table/tbody//tr//td/label[contains(text(), "Yes")]');
- $processorName = $params['payment_processor'];
- $this->select2('payment_processor', $processorName, TRUE);
- $this->select('financial_type_id', 'value=4');
-
- if (array_key_exists('price_set', $params)) {
- $this->select('price_set_id', 'label=' . $params['price_set']);
- }
- if (array_key_exists('fee_level', $params)) {
- $counter = 1;
- foreach ($params['fee_level'] as $label => $amount) {
- $this->type("label_{$counter}", $label);
- $this->type("value_{$counter}", $amount);
- $counter++;
- }
- }
-
- $this->clickLink('_qf_Fee_upload-bottom', 'link=Online Registration', FALSE);
-
- // Go to Online Registration tab
- $this->click('link=Online Registration');
- $this->waitForElementPresent('_qf_Registration_upload-bottom');
-
- $this->check('is_online_registration');
- $this->assertChecked('is_online_registration');
-
- if (isset($params['is_multiple_registrations']) && $params['is_multiple_registrations']) {
- $this->click('is_multiple_registrations');
- }
-
- $this->fillRichTextField('intro_text', 'Fill in all the fields below and click Continue.', 'CKEditor', TRUE);
-
- // enable confirmation email
- $this->click('CIVICRM_QFID_1_is_email_confirm');
- $this->type('confirm_from_name', 'Jane Doe');
- $this->type('confirm_from_email', 'jane.doe@example.org');
-
- $this->click('_qf_Registration_upload-bottom');
- $this->waitForTextPresent("'Fees' information has been saved.");
-
- // verify event input on info page
- // start at Manage Events listing
- $this->openCiviPage('event/manage', 'reset=1');
- $this->click('link=' . $params['title']);
-
- $this->waitForPageToLoad($this->getTimeoutMsec());
- return $this->getLocation();
- }
-
- public function _fillRegisterWithBillingInfo() {
- $this->waitForElementPresent('credit_card_type');
- $this->select('credit_card_type', 'value=Visa');
- $this->type('credit_card_number', '4111111111111111');
- $this->type('cvv2', '000');
- $this->select('credit_card_exp_date[M]', 'value=1');
- $this->select('credit_card_exp_date[Y]', 'value=2020');
- $this->type('billing_first_name', 'Jane_' . substr(sha1(rand()), 0, 5));
- $this->type('billing_last_name', 'San_' . substr(sha1(rand()), 0, 5));
- $this->type('billing_street_address-5', '15 Main St.');
- $this->type(' billing_city-5', 'San Jose');
- $this->select('billing_country_id-5', 'value=1228');
- $this->select('billing_state_province_id-5', 'value=1004');
- $this->type('billing_postal_code-5', '94129');
-
- $this->click('_qf_Register_upload-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- }
-
- public function _checkConfirmationAndRegister() {
- $confirmStrings = array('Event Fee(s)', 'Billing Name and Address', 'Credit Card Information');
- $this->assertStringsPresent($confirmStrings);
- $this->waitForElementPresent("_qf_Confirm_next-bottom");
- $this->click('_qf_Confirm_next-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $thankStrings = array('Thank You for Registering', 'Event Total', 'Transaction Date');
- $this->assertStringsPresent($thankStrings);
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Event_TellAFriendTest
- */
-class WebTest_Event_TellAFriendTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testAddEvent() {
- // Log in using webtestLogin() method
- $this->webtestLogin('admin');
-
- $this->openCiviPage("event/add", "reset=1&action=add");
-
- $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7);
- $eventDescription = "Here is a description for this conference.";
- $this->_testAddEventInfo($eventTitle, $eventDescription);
-
- $streetAddress = "100 Main Street";
- $this->_testAddLocation($streetAddress);
-
- // intro text for registration page
- $registerIntro = "Fill in all the fields below and click Continue.";
- $multipleRegistrations = TRUE;
- $this->_testAddOnlineRegistration($registerIntro, $multipleRegistrations);
-
- // enable tell a friend
- $subject = "$eventTitle Tell A Friend";
- $thankYouMsg = "$eventTitle Tell A Friend Test Thankyou Message";
- $this->_testAddTellAFriend($subject, $thankYouMsg, $eventTitle);
-
- // get the url for registration
- $this->waitForElementPresent("xpath=//div[@id='event_status_id']//div[@id='option11_wrapper']/table/tbody//tr/td[1]/a[text()='$eventTitle']");
- $this->click("link=$eventTitle");
- $this->waitForElementPresent("link=Register Now");
- $this->click("link=Register Now");
- $this->waitForElementPresent("_qf_Register_upload-bottom");
- $registerUrl = $this->getLocation();
-
- // give permissions for event registration
- $permission = array('edit-1-register-for-events');
- $this->changePermissions($permission);
-
- // register as an anonymous user
- $this->webtestLogout();
- $this->open($registerUrl);
- $this->waitForElementPresent('_qf_Register_upload-bottom');
-
- $firstName = 'Jane' . substr(sha1(rand()), 0, 7);
- $lastName = 'Doe' . substr(sha1(rand()), 0, 7);
- $this->type('first_name', "$firstName");
- $this->type('last_name', "$lastName");
- $this->type('email-Primary', "$firstName@$lastName.com");
- $this->click('_qf_Register_upload-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->click('_qf_Confirm_next-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->click("css=div.crm-event-thankyou-form-block div#tell-a-friend a");
- $this->waitForElementPresent('_qf_Form_cancel');
-
- $this->type('suggested_message', '$subject Test Message for the recipients');
-
- // fill the recipients
- $firstName1 = 'John' . substr(sha1(rand()), 0, 7);
- $lastName1 = substr(sha1(rand()), 0, 7);
- $this->type('friend_1_first_name', "$firstName1");
- $this->type('friend_1_last_name', "$lastName1");
- $this->type('friend_1_email', "$firstName1@$lastName1.com");
-
- $firstName2 = 'Smith' . substr(sha1(rand()), 0, 7);
- $lastName2 = substr(sha1(rand()), 0, 7);
- $this->type('friend_2_first_name', "$firstName2");
- $this->type('friend_2_last_name', "$lastName2");
- $this->type('friend_2_email', "$firstName2@$lastName2.com");
-
- $firstName3 = 'James' . substr(sha1(rand()), 0, 7);
- $lastName3 = substr(sha1(rand()), 0, 7);
- $this->type('friend_3_first_name', "$firstName3");
- $this->type('friend_3_last_name', "$lastName3");
- $this->type('friend_3_email', "$firstName3@$lastName3.com");
-
- $this->click('_qf_Form_submit');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->waitForTextPresent($thankYouMsg);
-
- // Log in using webtestLogin() method
- $this->webtestLogin();
-
- // get all friends contact id
- $this->openCiviPage("contact/search", "reset=1", '_qf_Basic_refresh');
- $this->type('sort_name', $firstName1);
- $this->click('_qf_Basic_refresh ');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->click("xpath=//div[@class='crm-search-results']/table/tbody/tr/td[11]/span/a[text()='View']");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->openCiviPage("contact/search", "reset=1", '_qf_Basic_refresh');
- $this->type('sort_name', $firstName2);
- $this->click('_qf_Basic_refresh ');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->click("xpath=//div[@class='crm-search-results']/table/tbody/tr/td[11]/span/a[text()='View']");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->openCiviPage("contact/search", "reset=1", '_qf_Basic_refresh');
- $this->type('sort_name', $firstName3);
- $this->click('_qf_Basic_refresh ');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->click("xpath=//div[@class='crm-search-results']/table/tbody/tr/td[11]/span/a[text()='View']");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->openCiviPage("contact/search", "reset=1", '_qf_Basic_refresh');
- $this->type('sort_name', $firstName);
- $this->click('_qf_Basic_refresh ');
- $this->waitForTextPresent('1 Contact');
-
- // Verify Activity created
- $this->openCiviPage("activity/search", "reset=1", '_qf_Search_refresh');
- $this->type('sort_name', $firstName1);
- $this->click('_qf_Search_refresh');
- $this->waitForElementPresent("xpath=//div[@class='crm-search-results']//table[@class='selector row-highlight']/tbody/tr[2]/td[9]/span/a[text()='View']");
- $this->click("xpath=//div[@class='crm-search-results']//table[@class='selector row-highlight']/tbody/tr[2]/td[9]/span/a[text()='View']");
- $this->waitForElementPresent('_qf_Activity_cancel-bottom');
- $this->verifyText("xpath=//table[@class='crm-info-panel']/tbody/tr[1]/td[2]/span/a[1]",
- preg_quote("$lastName, $firstName")
- );
-
- $this->verifyText("xpath=//table[@class='crm-info-panel']/tbody/tr[2]/td[2]/span",
- preg_quote("$lastName1, $firstName1")
- );
- $this->verifyText("xpath=//table[@class='crm-info-panel']/tbody/tr[2]/td[2]/span",
- preg_quote("$lastName2, $firstName2")
- );
- $this->verifyText("xpath=//table[@class='crm-info-panel']/tbody/tr[2]/td[2]/span",
- preg_quote("$lastName3, $firstName3")
- );
-
- $this->verifyText("xpath=//table[@class='crm-info-panel']/tbody/tr[4]/td[2]/span",
- preg_quote("Tell a Friend:")
- );
- }
-
- /**
- * @param $eventTitle
- * @param $eventDescription
- */
- public function _testAddEventInfo($eventTitle, $eventDescription) {
- $this->waitForElementPresent("_qf_EventInfo_upload-bottom");
-
- $this->select("event_type_id", "value=1");
-
- // Attendee role s/b selected now.
- $this->select("default_role_id", "value=1");
-
- // Enter Event Title, Summary and Description
- $this->type("title", $eventTitle);
- $this->type("summary", "This is a great conference. Sign up now!");
-
- // Type description in ckEditor (fieldname, text to type, editor)
- $this->fillRichTextField("description", $eventDescription, 'CKEditor');
-
- // Choose Start and End dates.
- // Using helper webtestFillDate function.
- $this->webtestFillDateTime("start_date", "+1 week");
- $this->webtestFillDateTime("end_date", "+1 week 1 day 8 hours ");
-
- $this->type("max_participants", "50");
- $this->click("is_map");
- $this->click("_qf_EventInfo_upload-bottom");
- }
-
- /**
- * @param $streetAddress
- */
- public function _testAddLocation($streetAddress) {
- // Wait for Location tab form to load
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForElementPresent("_qf_Location_upload-bottom");
-
- // Fill in address fields
- $streetAddress = "100 Main Street";
- $this->type("address_1_street_address", $streetAddress);
- $this->type("address_1_city", "San Francisco");
- $this->type("address_1_postal_code", "94117");
- $this->select('address_1_country_id', 'UNITED STATES');
- $this->select("address_1_state_province_id", "value=1004");
- $this->type("email_1_email", "info@civicrm.org");
-
- $this->click("_qf_Location_upload-bottom");
-
- // Wait for "saved" status msg
- $this->waitForElementPresent("_qf_Location_upload-bottom");
- $this->waitForTextPresent("'Event Location' information has been saved.");
- }
-
- /**
- * @param $registerIntro
- * @param bool $multipleRegistrations
- */
- public function _testAddOnlineRegistration($registerIntro, $multipleRegistrations = FALSE) {
- // Go to Online Registration tab
- $this->click("link=Online Registration");
- $this->waitForElementPresent("_qf_Registration_upload-bottom");
-
- $this->check("is_online_registration");
- $this->assertChecked("is_online_registration");
- if ($multipleRegistrations) {
- $this->check("is_multiple_registrations");
- $this->assertChecked("is_multiple_registrations");
- }
-
- $this->click("xpath=//div[@id='registration_screen']/table/tbody/tr[1]/td[2]/div[@class='replace-plain']");
- $this->fillRichTextField("intro_text", $registerIntro);
-
- // enable confirmation email
- $this->click('xpath=//fieldset[@id="mail"]/div/table/tbody/tr/td[2]/label[contains(text(), "Yes")]');
- $this->type("confirm_from_name", "Jane Doe");
- $this->type("confirm_from_email", "jane.doe@example.org");
-
- $this->click("_qf_Registration_upload-bottom");
- $this->waitForElementPresent("_qf_Registration_upload-bottom");
- $this->waitForTextPresent("'Online Registration' information has been saved.");
- }
-
- /**
- * @param $subject
- * @param $thankYouMsg
- * @param $eventTitle
- */
- public function _testAddTellAFriend($subject, $thankYouMsg, $eventTitle) {
- // Go to Tell A Friend Tab
- $this->click('link=Tell a Friend');
- $this->waitForElementPresent('_qf_Event_cancel-bottom');
-
- // Enable tell a friend feature
- $this->check('tf_is_active');
- $this->waitForElementPresent('tf_thankyou_text');
-
- // Modify the messages
- $this->type('intro', "This is $subject Test intro text");
- $this->type('suggested_message', "$subject Test Message. This is amazing!");
-
- $this->type('tf_thankyou_title', 'Test thank you title');
- $this->type('tf_thankyou_text', $thankYouMsg);
-
- $this->click('_qf_Event_upload_done-bottom');
- $this->waitForElementPresent("xpath=//div[@id='event_status_id']//div[@id='option11_wrapper']/table/tbody//tr/td[1]/a[text()='$eventTitle']");
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'WebTest/Export/ExportCiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Export_ContactTest
- */
-class WebTest_Export_ContactTest extends ExportCiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testPrefixGenderSuffix() {
- $this->markTestSkipped('Skipping for now as it works fine locally.');
- $this->webtestLogin();
-
- // Create new group
- $parentGroupName = 'TestSuffixPrefixGender_' . substr(sha1(rand()), 0, 7);
- $this->WebtestAddGroup($parentGroupName);
-
- // Adding Parent group contact
- // We're using Quick Add block on the main page for this.
- $firstContactName = 'TestExport' . substr(sha1(rand()), 0, 7);
-
- list($emailContactFirst, $prefixLabelContactFrst, $suffixLabelContactFrst, $genderLabelContactFrst) = WebTest_Export_ContactTest::webtestAddContactWithGenderPrefixSuffix($firstContactName, "Smith", "$firstContactName.smith@example.org", NULL);
-
- $sortFirstName = "Smith, $firstContactName";
- $displayFirstName = "$firstContactName Smith";
-
- // Add contact to parent group
- // visit group tab.
- $this->click("css=li#tab_group a");
- $this->waitForElementPresent("group_id");
-
- // Add to group.
- $this->select("group_id", "label=$parentGroupName");
- $this->click("_qf_GroupContact_next");
- $this->waitForAjaxContent();
-
- $secondContactName = 'TestExport2' . substr(sha1(rand()), 0, 7);
- list($emailContactSecond, $prefixLabelContactScnd, $suffixLabelContactScnd, $genderLabelContactScnd) = WebTest_Export_ContactTest::webtestAddContactWithGenderPrefixSuffix($secondContactName, "John", "$secondContactName.john@example.org", NULL);
-
- $sortSecondName = "John, $secondContactName";
- $displaySecondName = "$secondContactName John";
-
- // Add contact to parent group
- // visit group tab.
- $this->click("css=li#tab_group a");
- $this->waitForElementPresent("group_id");
-
- // Add to group.
- $this->select("group_id", "label=$parentGroupName");
- $this->click("_qf_GroupContact_next");
- $this->waitForAjaxContent();
-
- $this->openCiviPage("contact/search", "reset=1");
-
- // Select contact type as Indiividual.
- $this->select("contact_type", "value=Individual");
-
- // Select group.
- $this->select("group", "label=$parentGroupName");
-
- // Click to search.
- $this->clickLink("_qf_Basic_refresh");
-
- // Is contact present in search result?
- $this->assertElementContainsText('css=div.crm-search-results', $sortFirstName, "Contact did not found in search result!");
-
- // Is contact present in search result?
- $this->assertElementContainsText('css=div.crm-search-results', $sortSecondName, "Contact did not found in search result!");
-
- // select to export all the contasct from search result.
- $this->click("CIVICRM_QFID_ts_all_4");
-
- // Select the task action to export.
- $this->click("task");
- $this->select("task", "label=Export contacts");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $csvFile = $this->downloadCSV("_qf_Select_next-bottom");
-
- // Build header row for assertion.
- require_once 'CRM/Contact/BAO/Contact.php';
- $expotableFields = CRM_Contact_BAO_Contact::exportableFields('All', FALSE, TRUE);
-
- $checkHeaders = array();
- foreach ($expotableFields as $key => $field) {
- // Exclude custom fields.
- if ($key && (substr($key, 0, 6) == 'custom')) {
- continue;
- }
- $checkHeaders[] = $field['title'];
- }
-
- // All other rows to be check.
- $checkRows = array(
- 1 => array(
- 'First Name' => $secondContactName,
- 'Last Name' => 'John',
- 'Email' => '' . strtolower($emailContactSecond) . '',
- 'Individual Suffix' => $suffixLabelContactScnd,
- 'Gender' => $genderLabelContactScnd,
- ),
- 2 => array(
- 'First Name' => $firstContactName,
- 'Last Name' => 'Smith',
- 'Email' => '' . strtolower($emailContactFirst) . '',
- 'Sort Name' => $sortFirstName,
- 'Display Name' => $prefixLabelContactFrst . ' ' . $displayFirstName . ' ' . $suffixLabelContactFrst,
- 'Individual Prefix' => $prefixLabelContactFrst,
- 'Individual Suffix' => $suffixLabelContactFrst,
- 'Gender' => $genderLabelContactFrst,
- ),
- );
-
- // Read CSV and fire assertions.
- $this->reviewCSV($csvFile, $checkHeaders, $checkRows, 2);
- }
-
- /**
- * Test Contact Export.
- */
- public function testContactExport() {
- $this->markTestSkipped('Skipping for now as it works fine locally.');
- $this->webtestLogin();
-
- // Create new group
- $parentGroupName = 'Parentgroup_' . substr(sha1(rand()), 0, 7);
- $this->WebtestAddGroup($parentGroupName);
-
- // Create new group and select the previously selected group as parent group for this new group.
- $childGroupName = 'Childgroup_' . substr(sha1(rand()), 0, 7);
- $this->WebtestAddGroup($childGroupName, $parentGroupName);
-
- // Adding Parent group contact
- // We're using Quick Add block on the main page for this.
- $firstName = 'a' . substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName, "Smith", "$firstName.smith@example.org");
-
- $sortName = "Smith, $firstName";
- $displayName = "$firstName Smith";
-
- // Add contact to parent group
- // visit group tab.
- $this->click("css=li#tab_group a");
- $this->waitForElementPresent("group_id");
-
- // Add to group.
- $this->select("group_id", "label=$parentGroupName");
- $this->click("_qf_GroupContact_next");
- $this->waitForAjaxContent();
-
- // Adding child group contact
- // We're using Quick Add block on the main page for this.
- $childName = 'b' . substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($childName, "John", "$childName.john@example.org");
-
- $childSortName = "John, $childName";
- $childDisplayName = "$childName John";
-
- // Add contact to child group
- // visit group tab.
- $this->click("css=li#tab_group a");
- $this->waitForElementPresent("group_id");
-
- // Add to child group.
- $this->select("group_id", "label=regexp:$childGroupName");
- $this->click("_qf_GroupContact_next");
- $this->waitForAjaxContent();
-
- // Visit contact search page.
- $this->openCiviPage("contact/search", "reset=1");
-
- // Select contact type as Indiividual.
- $this->select("contact_type", "value=Individual");
-
- // Select group.
- $this->select("group", "label=$parentGroupName");
-
- // Click to search.
- $this->clickLink("_qf_Basic_refresh");
-
- // Is contact present in search result?
- $this->assertElementContainsText('css=div.crm-search-results', $sortName, "Contact did not found in search result!");
-
- // Is contact present in search result?
- $this->assertElementContainsText('css=div.crm-search-results', $childSortName, "Contact did not found in search result!");
-
- // select to export all the contacts from search result.
- $this->click("CIVICRM_QFID_ts_all_4");
-
- // Select the task action to export.
- $this->click("task");
- $this->select("task", "label=Export contacts");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $csvFile = $this->downloadCSV("_qf_Select_next-bottom");
-
- // Build header row for assertion.
- require_once 'CRM/Contact/BAO/Contact.php';
- $expotableFields = CRM_Contact_BAO_Contact::exportableFields('All', FALSE, TRUE);
-
- $checkHeaders = array();
- foreach ($expotableFields as $key => $field) {
- // Exclude custom fields.
- if ($key && (substr($key, 0, 6) == 'custom')) {
- continue;
- }
- $checkHeaders[] = $field['title'];
- }
-
- // All other rows to be check.
- $checkRows = array(
- 1 => array(
- 'First Name' => $childName,
- 'Last Name' => 'John',
- 'Email' => "$childName.john@example.org",
- 'Sort Name' => $childSortName,
- 'Display Name' => $childDisplayName,
- ),
- 2 => array(
- 'First Name' => $firstName,
- 'Last Name' => 'Smith',
- 'Email' => "$firstName.smith@example.org",
- 'Sort Name' => $sortName,
- 'Display Name' => $displayName,
- ),
- );
-
- // Read CSV and fire assertions.
- $this->reviewCSV($csvFile, $checkHeaders, $checkRows, 2);
- }
-
- public function testMergeHousehold() {
- $this->markTestSkipped('Skipping for now as it works fine locally.');
- $this->webtestLogin();
-
- // Create new group
- $groupName = 'TestGroup_' . substr(sha1(rand()), 0, 7);
- $this->WebtestAddGroup($groupName);
-
- // Adding Parent group contact
- // We're using Quick Add block on the main page for this.
- $houseHold = 'H' . substr(sha1(rand()), 0, 5) . ' House';
-
- $this->openCiviPage("contact/add", "reset=1&ct=Household");
- $this->click('household_name');
- $this->type('household_name', $houseHold);
-
- //address section
- $this->click("addressBlock");
- $this->waitForElementPresent("address_1_street_address");
-
- // fill in address
- $this->click("//div[@id='addressBlockId']/div[1]");
- $this->type("address_1_street_address", "121A Sherman St. Apt. 12");
- $this->type("address_1_city", "Dumfries");
- $this->type("address_1_postal_code", "1234");
- $this->select("address_1_country_id", "UNITED STATES");
- $this->select("address_1_state_province_id", "value=1019");
-
- $this->click('_qf_Contact_upload_view');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Add contact to group
- // visit group tab.
- $this->click("css=li#tab_group a");
- $this->waitForElementPresent("group_id");
-
- // Add to group.
- $this->select("group_id", "label=$groupName");
- $this->click("_qf_GroupContact_next");
- $this->waitForAjaxContent();
-
- $firstName1 = 'aa' . substr(sha1(rand()), 0, 5);
- $this->webtestAddContact($firstName1, "Smith", "{$firstName1}.smith@example.org");
-
- $sortName1 = "Smith, {$firstName1}";
- $displayName1 = "{$firstName1} Smith";
-
- // Add contact to parent group
- // visit group tab.
- $this->click("css=li#tab_group a");
- $this->waitForElementPresent("group_id");
-
- // Add to group.
- $this->select("group_id", "label=$groupName");
- $this->click("_qf_GroupContact_next");
- $this->waitForAjaxContent();
-
- $firstName2 = 'bb' . substr(sha1(rand()), 0, 5);
-
- $this->openCiviPage("contact/add", "reset=1&ct=Individual", "_qf_Contact_upload_view-bottom");
- $this->type('first_name', $firstName2);
- $this->type('last_name', "Smith");
- $this->type('email_1_email', "{$firstName2}.smith@example.org");
-
- //address section
- $this->click("addressBlock");
- $this->waitForElementPresent("address_1_street_address");
-
- $this->click("//div[@id='addressBlockId']/div[1]");
-
- $this->click("address[1][use_shared_address]");
- $this->waitForElementPresent("address_1_master_contact_id");
- $this->select2('address_1_master_contact_id', $houseHold);
- $this->waitForTextPresent("121A Sherman");
-
- $this->click('_qf_Contact_upload_view-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $sortName2 = "Smith, {$firstName2}";
- $displayName2 = "{$firstName2} Smith";
-
- // Add contact to parent group
- // visit group tab.
- $this->click("css=li#tab_group a");
- $this->waitForElementPresent("group_id");
-
- // Add to group.
- $this->select("group_id", "label=$groupName");
- $this->click("_qf_GroupContact_next");
- $this->waitForAjaxContent();
-
- $this->openCiviPage("contact/search", "reset=1", NULL);
-
- // Select group.
- $this->select("group", "label=$groupName");
-
- // Click to search.
- $this->clickLink("_qf_Basic_refresh");
-
- // Is contact present in search result?
- $this->assertElementContainsText('css=div.crm-search-results', $sortName1, "Contact did not found in search result!");
-
- // Is contact present in search result?
- $this->assertElementContainsText('css=div.crm-search-results', $sortName2, "Contact did not found in search result!");
-
- // Is contact present in search result?
- $this->assertElementContainsText('css=div.crm-search-results', $houseHold, "Contact did not found in search result!");
-
- // select to export all the contasct from search result.
- $this->click("CIVICRM_QFID_ts_all_4");
-
- // Select the task action to export.
- $this->click("task");
- $this->select("task", "label=Export contacts");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->click("CIVICRM_QFID_2_10");
-
- $csvFile = $this->downloadCSV("_qf_Select_next-bottom");
-
- // Build header row for assertion.
- require_once 'CRM/Contact/BAO/Contact.php';
- $expotableFields = CRM_Contact_BAO_Contact::exportableFields('All', FALSE, TRUE);
-
- $checkHeaders = array();
- foreach ($expotableFields as $key => $field) {
- // Exclude custom fields.
- if ($key && (substr($key, 0, 6) == 'custom')) {
- continue;
- }
- $checkHeaders[] = $field['title'];
- }
-
- // All other rows to be check.
- $checkRows = array(
- 1 => array(
- 'Contact Type' => 'Household',
- 'Household Name' => $houseHold,
- ),
- 2 => array(
- 'Contact Type' => 'Individual',
- 'First Name' => $firstName1,
- 'Email' => "{$firstName1}.smith@example.org",
- 'Sort Name' => $sortName1,
- 'Display Name' => $displayName1,
- ),
- );
-
- // Read CSV and fire assertions.
- $this->reviewCSV($csvFile, $checkHeaders, $checkRows, 2);
- }
-
- /**
- * @param string $fname
- * @param string $lname
- * @param null $email
- * @param null $contactSubtype
- *
- * @return array
- */
- public function webtestAddContactWithGenderPrefixSuffix($fname = 'Anthony', $lname = 'Anderson', $email = NULL, $contactSubtype = NULL) {
- $url = $this->sboxPath . 'civicrm/contact/add?reset=1&ct=Individual';
- if ($contactSubtype) {
- $url = $url . "&cst={$contactSubtype}";
- }
- $this->open($url);
- $this->waitForElementPresent('_qf_Contact_upload_view-bottom');
-
- $this->type('first_name', $fname);
- $this->type('last_name', $lname);
- if ($email === TRUE) {
- $email = substr(sha1(rand()), 0, 7) . '@example.org';
- }
- if ($email) {
- $this->type('email_1_email', $email);
- }
- $genderLabelArray = array(
- 1 => 'Female',
- 2 => 'Male',
- 3 => 'Other',
- );
- $prefix = rand(1, 4);
- $suffix = rand(1, 8);
- $gender = rand(1, 3);
- $genderLabel = "civicrm_gender_" . $genderLabelArray[$gender] . "_$gender";
- $this->select("prefix_id", "value=$prefix");
- $this->select("suffix_id", "value=$suffix");
- $this->click("demographics");
- $this->waitForElementPresent("civicrm_gender_Female_1");
- $this->click($genderLabel, "value=$gender");
- $this->waitForElementPresent('_qf_Contact_upload_view-bottom');
- $this->click('_qf_Contact_upload_view-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $prefixLabel = WebTest_Export_ContactTest::getOptionLabel('individual_prefix', $prefix);
- $suffixLabel = WebTest_Export_ContactTest::getOptionLabel('individual_suffix', $suffix);
- $genderLabel = WebTest_Export_ContactTest::getOptionLabel('gender', $gender);
- return array($email, $prefixLabel, $suffixLabel, $genderLabel);
- }
-
- /**
- * @param string $optionGroupName
- * @param $optionValue
- *
- * @return array|int
- */
- public function getOptionLabel($optionGroupName, $optionValue) {
- $params = array(
- 'version' => 3,
- 'sequential' => 1,
- 'option_group_name' => $optionGroupName,
- 'value' => $optionValue,
- 'return' => 'label',
- );
- $optionLabel = $this->webtest_civicrm_api("OptionValue", "getvalue", $params);
- return $optionLabel;
- }
-
- /**
- * CRM-17286 - Test Contribution Export for Soft Credit fields.
- */
- public function testContributionExport() {
- $this->markTestSkipped('Skipping for now as it works fine locally.');
- $this->webtestLogin();
-
- // Create a contact to be used as soft creditor
- $firstName = 'a' . substr(sha1(rand()), 0, 7);
- $softCreditLname = substr(sha1(rand()), 0, 7);
- $lastName = 'Anderson';
- $this->webtestAddContact($firstName, $softCreditLname, FALSE);
- $this->webtestAddContact($firstName, $lastName, FALSE);
- $contactId = $this->urlArg('cid');
-
- $this->openCiviPage('contribute/add', 'reset=1&action=add&context=standalone', '_qf_Contribution_upload-bottom');
- $this->webtestFillAutocomplete("{$lastName}, {$firstName}");
- // select financial type
- $this->select("financial_type_id", "value=1");
-
- // fill in Received Date
- $this->webtestFillDate('receive_date');
-
- // source
- $this->type("source", "Mailer 1");
-
- // total amount
- $this->type("total_amount", "100");
-
- // create first soft credit
- $this->click("softCredit");
- $this->waitForElementPresent("soft_credit_amount_1");
- $this->webtestFillAutocomplete("{$softCreditLname}, {$firstName}", 's2id_soft_credit_contact_id_1');
- $this->type("soft_credit_amount_1", "50");
-
- // Clicking save.
- $this->clickLink("_qf_Contribution_upload");
-
- $this->openCiviPage("contribute/search", "reset=1", "_qf_Search_refresh");
- $this->type("sort_name", $firstName);
- $this->select('contribution_or_softcredits', 'Both');
- $this->clickLink("_qf_Search_refresh");
- // Is contact present in search result?
- $this->assertElementContainsText('css=div.crm-search-results', $firstName, "Contact did not found in search result!");
- $contributionID = $this->urlArg('id', $this->getAttribute("xpath=//div[@id='contributionSearch']/table/tbody/tr//td//span//a[text()='Edit']@href"));
- // select to export all the contacts from search result.
- $this->click("toggleSelect");
-
- // Select the task action to export.
- $this->click("task");
- $this->select("task", "label=Export contributions");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->click('CIVICRM_QFID_2_4');
- $this->clickLink('_qf_Select_next-bottom');
-
- $this->select("mapper_1_0_0", 'Contribution');
- $this->select("mapper_1_0_1", 'Soft Credit Amount');
-
- $this->select("mapper_1_1_0", 'Contribution');
- $this->select("mapper_1_1_1", 'Soft Credit For');
-
- $this->select("mapper_1_2_0", 'Contribution');
- $this->select("mapper_1_2_1", 'Soft Credit For Contribution ID');
-
- $this->select("mapper_1_3_0", 'Contribution');
- $this->select("mapper_1_3_1", 'Soft Credit Type');
-
- $this->select("mapper_1_4_0", 'Contribution');
- $this->select("mapper_1_4_1", 'Soft Credit For Contact ID');
-
- $csvFile = $this->downloadCSV("_qf_Map_next-bottom", 'CiviCRM_Contribution_Search.csv');
-
- // All other rows to be check.
- $checkRows = array(
- 1 => array(
- 'Soft Credit Amount' => '',
- 'Soft Credit For' => '',
- 'Soft Credit For Contribution ID' => '',
- 'Soft Credit Type' => '',
- 'Soft Credit For Contact ID' => '',
- ),
- 2 => array(
- 'Soft Credit Amount' => 50.00,
- 'Soft Credit For' => "{$lastName}, {$firstName}",
- 'Soft Credit For Contribution ID' => $contributionID,
- 'Soft Credit Type' => 'Solicited',
- 'Soft Credit For Contact ID' => $contactId,
- ),
- );
-
- // Read CSV and fire assertions.
- $this->reviewCSV($csvFile, array(), $checkRows, 2);
-
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class ExportCiviSeleniumTestCase
- */
-class ExportCiviSeleniumTestCase extends CiviSeleniumTestCase {
-
- /**
- * Download CSV file.
- *
- * @param string $selector
- * Element selector(download button in most of the cases).
- * @param string $fileName
- * File name to be download.
- * @param string $downloadDir
- * Download dir.
- *
- * @return string
- * downloaded file path.
- */
- public function downloadCSV($selector, $fileName = 'CiviCRM_Contact_Search.csv', $downloadDir = '/tmp') {
- // File download path.
- $file = "{$downloadDir}/{$fileName}";
-
- // Delete file if already exists.
- if (file_exists($file)) {
- @unlink($file);
- }
-
- $this->click($selector);
-
- // Wait for file to be downloaded
- for ($i = 1; $i < 15; ++$i) {
- sleep(2);
- if (file_exists($file)) {
- return $file;
- }
- }
- // Timeout
- $this->fail("CSV {$file} was not downloaded.");
- }
-
- /**
- * Read CSV file and fire provided assertions.
- *
- * @param string $file
- * File path of CSV file.
- * @param array $checkColumns
- * Check first row of csv.
- * independent of index.
- * @param array $checkRows
- * Array of header and rows according to row index.
- * eg: array(
- * 1 => array(
- * // Row index 1
- * // column name 'First Name', value 'Jones'
- * 'First Name' => 'Jones',
- * 'Last Name' => 'Franklin'
- * ),
- * 2 => array(
- * // Row index 2
- * 'First Name' => 'Rajan',
- * 'Last Name' => 'mayekar'
- * ),
- * );
- * @param int $rowCount
- * Count rows (excluding header row).
- * @param array $settings
- * Used for override settings.
- */
- public function reviewCSV($file, $checkColumns = array(), $checkRows = array(), $rowCount = 0, $settings = array()) {
- // Check file exists before proceed.
- $this->assertTrue(($file && file_exists($file)), "Not able to locate {$file}.");
-
- // We are going to read downloaded file.
- $fd = fopen($file, 'r');
- if (!$fd) {
- $this->fail("Could not read {$file}.");
- }
-
- // Default seperator ','.
- $fieldSeparator = !empty($settings['fieldSeparator']) ? $settings['fieldSeparator'] : ',';
-
- $allRows = array();
-
- // Read header row.
- $headerRow = fgetcsv($fd, 0, $fieldSeparator);
- $allRows[] = $headerRow;
-
- // Read all other rows.
- while ($row = fgetcsv($fd, 0, $fieldSeparator)) {
- $allRows[] = $row;
- }
-
- // We have done with the CSV reading.
- fclose($fd);
-
- // Check header columns.
- if (!empty($checkColumns)) {
- foreach ($checkColumns as $column) {
- if (!in_array($column, $headerRow)) {
- $this->fail("Missing column {$column}.");
- }
- }
- }
-
- // Check row count, excluding header row.
- if ($rowCount && !($rowCount == (count($allRows) - 1))) {
- $this->fail("Mismatching row count");
- }
-
- // Check all other rows.
- if (!empty($checkRows)) {
- foreach ($checkRows as $rowIndex => $row) {
- if ($rowIndex == 0) {
- // Skip checking header row, since we are already doing it above.
- continue;
- }
-
- foreach ($row as $column => $value) {
- $headerIndex = array_search($column, $headerRow);
- if ($headerIndex === FALSE) {
- $this->fail("Not able to locate column {$column} for row index {$rowIndex}.");
- }
-
- if (!isset($allRows[$rowIndex][$headerIndex]) || !($value == $allRows[$rowIndex][$headerIndex])) {
- $this->fail("Expected: {$value}, Got: {$allRows[$rowIndex][$headerIndex]}, for column {$column} for row index {$rowIndex}.");
- }
- }
- }
- }
-
- // Delete file, since we no longer need it.
- if (empty($settings['skipDeleteFile'])) {
- @unlink($file);
- }
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Financial_FinancialAccountTest
- */
-class WebTest_Financial_FinancialAccountTest extends CiviSeleniumTestCase {
-
- /**
- * Test To Add Financial Account class attributes.
- */
- public function testFinancialAccount() {
- $this->webtestLogin();
-
- // Add new Financial Account
- $orgName = 'Alberta ' . substr(sha1(rand()), 0, 7);
- $uniqueName = explode(" ", $orgName);
- $financialAccountTitle = 'Financial Account ' . substr(sha1(rand()), 0, 4);
- $financialAccountDescription = "{$financialAccountTitle} Description";
- $accountingCode = 1033;
- $financialAccountType = 'Liability';
- $taxDeductible = FALSE;
- $isActive = TRUE;
- $isTax = TRUE;
- $taxRate = 9.99999999;
- $isDefault = FALSE;
-
- //Add new organisation
- if ($orgName) {
- $this->webtestAddOrganization($orgName);
- }
-
- $this->_testAddFinancialAccount($financialAccountTitle,
- $financialAccountDescription,
- $accountingCode,
- $uniqueName[1],
- $financialAccountType,
- $taxDeductible,
- $isActive,
- $isTax,
- $taxRate,
- $isDefault
- );
-
- $this->waitForElementPresent("xpath=//table/tbody//tr/td[1]/div[text()='{$financialAccountTitle}']/../../td[9]/span/a[text()='Edit']");
-
- $this->clickLink("xpath=//table/tbody//tr/td[1]/div[text()='{$financialAccountTitle}']/../../td[9]/span/a[text()='Edit']", '_qf_FinancialAccount_cancel-botttom', FALSE);
- //Varify Data after Adding new Financial Account
- $verifyData = array(
- 'name' => $financialAccountTitle,
- 'description' => $financialAccountDescription,
- 'accounting_code' => $accountingCode,
- 'tax_rate' => $taxRate,
- 'is_tax' => 'on',
- 'is_deductible' => 'off',
- 'is_default' => 'off',
- );
-
- $this->assertEquals($orgName, $this->getText("xpath=//*[@id='s2id_contact_id']/a/span[1]"));
-
- $this->_assertFinancialAccount($verifyData);
- $verifySelectFieldData = array('financial_account_type_id' => $financialAccountType);
- $this->_assertSelectVerify($verifySelectFieldData);
- $this->click('_qf_FinancialAccount_cancel-botttom');
-
- //Edit Financial Account
- $editfinancialAccount = $financialAccountTitle;
- $financialAccountTitle .= ' Edited';
- $orgNameEdit = FALSE;
- $financialAccountType = 'Liability';
-
- if ($orgNameEdit) {
- $orgNameEdit = 'NGO ' . substr(sha1(rand()), 0, 7);
- $this->webtestAddOrganization($orgNameEdit);
- $uniqueName = explode(" ", $orgNameEdit);
- }
-
- $this->_testEditFinancialAccount($editfinancialAccount,
- $financialAccountTitle,
- $financialAccountDescription,
- $accountingCode,
- $uniqueName[1],
- $financialAccountType,
- $taxDeductible,
- $isActive,
- $isTax,
- $taxRate,
- $isDefault
- );
-
- if ($orgNameEdit) {
- $orgName = $orgNameEdit;
- }
- $this->waitForElementPresent("xpath=//table/tbody//tr/td[1]/div[text()='{$financialAccountTitle}']/../../td[9]/span/a[text()='Edit']");
- $this->clickLink("xpath=//table/tbody//tr/td[1]/div[text()='{$financialAccountTitle}']/../../td[9]/span/a[text()='Edit']", '_qf_FinancialAccount_cancel-botttom', FALSE);
-
- $verifyData = array(
- 'name' => $financialAccountTitle,
- 'description' => $financialAccountDescription,
- 'accounting_code' => $accountingCode,
- 'tax_rate' => $taxRate,
- 'is_tax' => 'on',
- 'is_deductible' => 'off',
- 'is_default' => 'off',
- );
-
- $this->assertEquals($orgName, $this->getText("xpath=//*[@id='s2id_contact_id']/a/span[1]"));
-
- $this->_assertFinancialAccount($verifyData);
- $verifySelectFieldData = array('financial_account_type_id' => $financialAccountType);
- $this->_assertSelectVerify($verifySelectFieldData);
- $this->click('_qf_FinancialAccount_cancel-botttom');
- $this->waitForElementPresent("xpath=//table/tbody//tr/td[1]/div[text()='{$financialAccountTitle}']/../../td[9]/span/a[text()='Delete']");
-
- //Delete Financial Account
- $this->_testDeleteFinancialAccount($financialAccountTitle);
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Financial_FinancialAccountTypeTest
- */
-class WebTest_Financial_FinancialAccountTypeTest extends CiviSeleniumTestCase {
-
- public function testFinancialAccount() {
- // To Add Financial Account
-
- // class attributes.
-
- // Log in using webtestLogin() method
- $this->webtestLogin();
-
- //Add new Financial Type
- $financialType['name'] = 'FinancialType ' . substr(sha1(rand()), 0, 4);
- $financialType['is_deductible'] = TRUE;
- $financialType['is_reserved'] = FALSE;
- $this->addeditFinancialType($financialType);
- $expected = array(
- array(
- 'financial_account' => $financialType['name'],
- 'account_relationship' => "Income Account is",
- ),
- array(
- 'financial_account' => 'Banking Fees',
- 'account_relationship' => 'Expense Account is',
- ),
- array(
- 'financial_account' => 'Accounts Receivable',
- 'account_relationship' => 'Accounts Receivable Account is',
- ),
- array(
- 'financial_account' => 'Premiums',
- 'account_relationship' => 'Cost of Sales Account is',
- ),
- );
-
- $this->waitForElementPresent('newFinancialType');
- $this->click("xpath=id('ltype')/div/table/tbody//tr/td[1]/div[text()='$financialType[name]']/../../td[7]/span/a[text()='Accounts']");
- $this->waitForElementPresent('newfinancialTypeAccount');
-
- foreach ($expected as $value => $label) {
- $this->verifyText("xpath=//div[@id='ltype']/div/table/tbody/tr/td[2][text()='$label[financial_account]']/../td[1]", preg_quote($label['account_relationship']));
- }
-
- $this->openCiviPage('admin/financial/financialType', 'reset=1', 'newFinancialType');
- $this->verifyText("xpath=id('ltype')/div/table/tbody//tr/td[1]/div[text()='$financialType[name]']/../../td[3]", 'Accounts Receivable,Banking Fees,Premiums,' . $financialType['name']);
- $this->click("xpath=id('ltype')/div/table/tbody//tr/td[1]/div[text()='$financialType[name]']/../../td[7]/span/a[text()='Accounts']");
- $this->waitForElementPresent('newfinancialTypeAccount');
- $this->click("xpath=//div[@id='ltype']/div/table/tbody//tr/td[2][text()='Banking Fees']/../td[7]/span/a[text()='Edit']");
- $this->waitForElementPresent('_qf_FinancialTypeAccount_next');
- $this->select('account_relationship', "value=select");
- $this->waitForElementPresent("xpath=//select[@id='account_relationship']/option[text()='- Select Financial Account Relationship -']");
- $this->select('account_relationship', "label=Premiums Inventory Account is");
- $this->waitForElementPresent("xpath=//select[@id='financial_account_id']/option[3][text()='Deposit Bank Account']");
- $this->select('financial_account_id', "label=Premiums inventory");
- $this->click('_qf_FinancialTypeAccount_next');
- $this->waitForElementPresent("xpath=//div[@id='ltype']/div/table/tbody//tr/td[2][text()='Premiums inventory']/../td[7]/span/a[text()='Edit']");
- $this->verifyText("xpath=//div[@id='ltype']/div/table/tbody//tr/td[2][text()='Premiums inventory']/../td[1]", preg_quote('Premiums Inventory Account is'));
- $this->clickLink("xpath=//div[@id='ltype']/div/table/tbody//tr/td[2][text()='Premiums inventory']/../td[7]/span/a[text()='Delete']", '_qf_FinancialTypeAccount_next-botttom', FALSE);
- $this->click('_qf_FinancialTypeAccount_next-botttom');
- $this->waitForText('crm-notification-container', 'Selected financial type account has been deleted.');
-
- //edit financial type
- $financialType['oldname'] = $financialType['name'];
- $financialType['name'] = 'Edited FinancialType ' . substr(sha1(rand()), 0, 4);
- $financialType['is_deductible'] = TRUE;
- $financialType['is_reserved'] = FALSE;
- $this->addeditFinancialType($financialType, 'Edit');
- //delete financialtype
- $this->addeditFinancialType($financialType, 'Delete');
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Financial_FinancialBatchExport
- */
-class WebTest_Financial_FinancialBatchExport extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testAddFinancialBatch() {
- // Log in using webtestLogin() method
- $this->webtestLogin('admin');
- $this->openCiviPage("financial/batch", "reset=1&action=add", '_qf_FinancialBatch_next-botttom');
- $setTitle = 'Batch ' . substr(sha1(rand()), 0, 7) . date('Y-m-d');
- $setDescription = 'Test Batch Creation';
- $setPaymentInstrument = 'Credit Card';
- $numberOfTrxn = '10'; // can be 10, 25, 50, 100
- $totalAmt = '1000';
- $exportFormat = 'CSV';
- $batchId = $this->_testAddBatch(
- $setTitle,
- $setDescription,
- $setPaymentInstrument,
- $numberOfTrxn,
- $totalAmt
- );
- $this->_testAssignBatch($numberOfTrxn);
- $this->_testExportBatch($setTitle, $batchId, $exportFormat);
- }
-
- /**
- * @param $setTitle
- * @param $setDescription
- * @param $setPaymentInstrument
- * @param $numberOfTrxn
- * @param $totalAmt
- *
- * @return null
- */
- public function _testAddBatch($setTitle, $setDescription, $setPaymentInstrument, $numberOfTrxn, $totalAmt) {
- // Enter Optional Constraints
- $this->type('title', $setTitle);
- $this->type('description', $setDescription);
- if ($setPaymentInstrument == 'Credit Card') {
- $this->select("payment_instrument_id", "value=1");
- }
- elseif ($setPaymentInstrument == 'Debit Card') {
- $this->select("payment_instrument_id", "value=2");
- }
- elseif ($setPaymentInstrument == 'Cash') {
- $this->select("payment_instrument_id", "value=3");
- }
- elseif ($setPaymentInstrument == 'Check') {
- $this->select("payment_instrument_id", "value=4");
- }
- elseif ($setPaymentInstrument == 'EFT') {
- $this->select("payment_instrument_id", "value=5");
- }
- $this->type('item_count', $numberOfTrxn);
- $this->type('total', $totalAmt);
-
- $this->click('_qf_FinancialBatch_next-botttom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // parse URL to grab the batch ID
- $batchId = $this->urlArg('bid');
- return $batchId;
- }
-
- /**
- * @param $numberOfTrxn
- */
- public function _testAssignBatch($numberOfTrxn) {
- $this->waitForAjaxContent();
- $this->select("xpath=//div[@class='dataTables_length']/label/select", "value={$numberOfTrxn}");
- // Because it tends to cause problems, all uses of sleep() must be justified in comments
- // Sleep should never be used for wait for anything to load from the server
- // Justification for this instance: FIXME
- $this->waitForAjaxContent();
- $this->click('toggleSelect');
- $this->select('trans_assign', 'value=Assign');
- $this->click('Go');
- }
-
- /**
- * @param $setTitle
- * @param int $batchId
- * @param $exportFormat
- */
- public function _testExportBatch($setTitle, $batchId, $exportFormat) {
- $this->openCiviPage("financial/batch", "reset=1&action=export&id=$batchId");
- if ($exportFormat == 'CSV') {
- $this->click("xpath=//form[@id='FinancialBatch']/div[2]/table[@class='form-layout']/tbody/tr/td/input[1]");
- $this->click('_qf_FinancialBatch_next-botttom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- }
- else {
- $this->click("xpath=//form[@id='FinancialBatch']/div[2]/table[@class='form-layout']/tbody/tr/td/input[1]");
- $this->click('_qf_FinancialBatch_next-botttom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- }
- $this->openCiviPage("dashboard", "reset=1");
- $this->clickLink("xpath=//div[@id='crm-recently-viewed']/ul/li[1]/a", "_qf_Activity_cancel-bottom");
- $this->webtestVerifyTabularData(
- array(
- 'Current Attachment(s)' => 'Financial_Transactions_',
- )
- );
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Generic_CheckActivityTest
- */
-class WebTest_Generic_CheckActivityTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testCheckDashboardElements() {
- // Log in using webtestLogin() method
- $this->webtestLogin();
-
- // Adding contact with randomized first name
- // We're using Quick Add block on the main page for this.
- $contactFirstName1 = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($contactFirstName1, "Devis", TRUE);
-
- // Adding another contact with randomized first name
- // We're using Quick Add block on the main page for this.
- $contactFirstName2 = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($contactFirstName2, "Anderson", TRUE);
- $this->openCiviPage("activity", "reset=1&action=add&context=standalone", "_qf_Activity_upload");
-
- $this->select("activity_type_id", "label=Meeting");
-
- $this->click("xpath=//div[@id='s2id_target_contact_id']/ul/li/input");
- $this->keyDown("xpath=//div[@id='s2id_target_contact_id']/ul/li/input", " ");
- $this->type("xpath=//div[@id='s2id_target_contact_id']/ul/li/input", $contactFirstName1);
- $this->typeKeys("xpath=//div[@id='s2id_target_contact_id']/ul/li/input", $contactFirstName1);
-
- // ...waiting for drop down with results to show up...
- $this->waitForElementPresent("xpath=//div[@class='select2-result-label']");
-
- // ...need to use mouseDownAt on first result (which is a li element), click does not work
- $this->clickAt("xpath=//div[@class='select2-result-label']");
-
- // ...again, waiting for the box with contact name to show up (span with delete token class indicates that it's present)...
- $this->waitForText("xpath=//div[@id='s2id_target_contact_id']", "$contactFirstName1");
-
- // Now we're doing the same for "Assigned To" field.
- // Typing contact's name into the field (using typeKeys(), not type()!)...
- $this->click("xpath=//div[@id='s2id_assignee_contact_id']/ul/li/input");
- $this->keyDown("xpath=//div[@id='s2id_assignee_contact_id']/ul/li/input", " ");
- $this->type("xpath=//div[@id='s2id_assignee_contact_id']/ul/li/input", $contactFirstName2);
- $this->typeKeys("xpath=//div[@id='s2id_assignee_contact_id']/ul/li/input", $contactFirstName2);
-
- // ...waiting for drop down with results to show up...
- $this->waitForElementPresent("xpath=//div[@class='select2-result-label']");
-
- //..need to use mouseDownAt on first result (which is a li element), click does not work
- $this->clickAt("xpath=//div[@class='select2-result-label']");
-
- // ...again, waiting for the box with contact name to show up...
- $this->waitForText("xpath=//div[@id='s2id_assignee_contact_id']", "$contactFirstName2");
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License and the CiviCRM Licensing Exception along |
- | with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Generic_CheckDashboardTest
- */
-class WebTest_Generic_CheckDashboardTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testCheckDashboardElements() {
- $this->markTestSkipped('Skipping for now as it works fine locally.');
- $this->webtestLogin();
-
- $this->open($this->sboxPath . "civicrm");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->assertTrue($this->isElementPresent("link=Configure Your Dashboard"));
-
- // Test Activities widget enable and full screen.
- $this->_testActivityDashlet();
-
- // More dashlet tests can be added here using the functions modeled below
- }
-
- /**
- * @param int $widgetConfigureID
- * @param $widgetEnabledSelector
- * @param $widgetTitle
- */
- public function _testAddDashboardElement($widgetConfigureID, $widgetEnabledSelector, $widgetTitle) {
- // Check if desired widget is already loaded on dashboard and remove it if it is so we can test adding it.
- // Because it tends to cause problems, all uses of sleep() must be justified in comments
- // Sleep should never be used for wait for anything to load from the server
- // Justification for this instance: FIXME
- sleep(10);
- if ($this->isElementPresent($widgetEnabledSelector)) {
- $this->_testRemoveDashboardElement($widgetConfigureID, $widgetEnabledSelector, $widgetTitle);
- };
- $this->click("link=Configure Your Dashboard");
- $this->waitForElementPresent("dashlets-header-col-0");
- $this->mouseDownAt($widgetConfigureID, "");
- // Because it tends to cause problems, all uses of sleep() must be justified in comments
- // Sleep should never be used for wait for anything to load from the server
- // Justification for this instance: FIXME
- sleep(3);
- $this->mouseMoveAt("existing-dashlets-col-1", "");
- // Because it tends to cause problems, all uses of sleep() must be justified in comments
- // Sleep should never be used for wait for anything to load from the server
- // Justification for this instance: FIXME
- sleep(3);
- $this->mouseUpAt("existing-dashlets-col-1", "");
- // Because it tends to cause problems, all uses of sleep() must be justified in comments
- // Sleep should never be used for wait for anything to load from the server
- // Justification for this instance: FIXME
- sleep(3);
- $this->click("link=Done");
- $this->waitForElementPresent("link=Configure Your Dashboard");
- $this->waitForTextPresent("$widgetTitle");
-
- // click Full Screen icon and test full screen container
- $this->waitForElementPresent("css=li#widget-3 a.fa-expand");
- $this->click("css=li#widget-3 a.fa-expand");
- $this->waitForElementPresent("ui-id-1");
- $this->waitForTextPresent("$widgetTitle");
- // Because it tends to cause problems, all uses of sleep() must be justified in comments
- // Sleep should never be used for wait for anything to load from the server
- // Justification for this instance: FIXME
- sleep(5);
- $this->click("xpath=//button[@title='Close']");
- }
-
- /**
- * @param int $widgetConfigureID
- * @param $widgetEnabledSelector
- */
- public function _testRemoveDashboardElement($widgetConfigureID, $widgetEnabledSelector) {
- $this->click("link=Configure Your Dashboard");
- $this->waitForElementPresent("dashlets-header-col-0");
- $this->mouseDownAt("{$widgetConfigureID}", "");
- // Because it tends to cause problems, all uses of sleep() must be justified in comments
- // Sleep should never be used for wait for anything to load from the server
- // Justification for this instance: FIXME
- sleep(1);
- $this->mouseMoveAt("available-dashlets", "");
- // Because it tends to cause problems, all uses of sleep() must be justified in comments
- // Sleep should never be used for wait for anything to load from the server
- // Justification for this instance: FIXME
- sleep(1);
- $this->mouseUpAt("available-dashlets", "");
- // Because it tends to cause problems, all uses of sleep() must be justified in comments
- // Sleep should never be used for wait for anything to load from the server
- // Justification for this instance: FIXME
- sleep(1);
- $this->click("link=Done");
- $this->waitForElementPresent("link=Configure Your Dashboard");
- // giving time for activity widget to load (and make sure it did NOT)
- // Because it tends to cause problems, all uses of sleep() must be justified in comments
- // Sleep should never be used for wait for anything to load from the server
- // Justification for this instance: FIXME
- sleep(10);
- $this->assertFalse($this->isElementPresent($widgetEnabledSelector));
- }
-
- public function _testActivityDashlet() {
- // Add an activity that will show up in the widget
- $this->WebtestAddActivity();
- $widgetTitle = "Activities";
- $widgetEnabledSelector = "contact-activity-selector-dashlet_wrapper";
- $widgetConfigureID = "3-0";
-
- // now add the widget
- $this->open($this->sboxPath . "civicrm");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForTextPresent("Configure Your Dashboard");
- $this->_testAddDashboardElement($widgetConfigureID, $widgetEnabledSelector, $widgetTitle);
-
- // If CiviCase enabled, click 'more' link for context menu pop-up in the widget selector
- if ($this->isElementPresent("//table[@id='contact-activity-selector-dashlet']/tbody/tr[1]/td[8]/span[text()='more ']")) {
- // click 'Delete Activity' link
- $this->click("//table[@class='contact-activity-selector-dashlet dataTable no-footer']/tbody/tr[1]/td[8]/span[text()='more ']/ul/li[2]/a[text()='Delete']");
- }
- else {
- // click 'Delete Activity' link
- $this->click("//table[@class='contact-activity-selector-dashlet crm-ajax-table dataTable no-footer']/tbody/tr[1]/td[8]/span//a[text()='Delete']");
- }
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForElementPresent("_qf_Activity_next-bottom");
- $this->assertTrue($this->isTextPresent("Are you sure you want to delete"));
- $this->click("_qf_Activity_next-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->assertTrue($this->isTextPresent("Selected Activity has been deleted successfully."));
- // FIXMED: Currently there's a bug, dashboard context is ignored after delete so we should already be back on home dash.
- // Issue filed: CRM-
- // $this->assertTrue($this->isTextPresent("Configure Your Dashboard");
- $this->open($this->sboxPath . "civicrm");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForTextPresent("Configure Your Dashboard");
-
- // cleanup by removing the widget
- $this->_testRemoveDashboardElement($widgetConfigureID, $widgetEnabledSelector);
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Generic_CheckFindTest
- */
-class WebTest_Generic_CheckFindTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testCheckDashboardElements() {
- $this->webtestLogin();
-
- $this->openCiviPage("contact/search", "reset=1", "_qf_Basic_refresh");
- $this->click("//input[@name='_qf_Basic_refresh' and @value='Search']");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->assertTrue($this->isElementPresent("search-status"));
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Generic_GeneralClickAroundTest
- */
-class WebTest_Generic_GeneralClickAroundTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function login() {
- $this->webtestLogin();
- $this->openCiviPage('');
- }
-
- public function testSearchMenu() {
- $this->login();
- // click Search -> Find Contacts
- // Use class names for menu items since li array can change based on which components are enabled
- $this->click("css=ul#civicrm-menu li.crm-Search");
- $this->click("css=ul#civicrm-menu li.crm-Find_Contacts a");
- $this->waitForElementPresent('tag');
-
- $this->click('contact_type');
- $this->select('contact_type', 'label=Individual');
- $this->select('tag', 'label=Major Donor');
- $this->click('_qf_Basic_refresh');
- $this->waitForElementPresent('search-status');
- $this->assertText('search-status', "Contact Type In Individual");
- $this->assertText('search-status', 'Tagged = Major Donor');
-
- // Advanced Search by Tag
- $this->click("css=ul#civicrm-menu li.crm-Search");
- $this->click("css=ul#civicrm-menu li.crm-Advanced_Search a");
- $this->waitForElementPresent('contact_tags');
- $this->select('contact_tags', 'label=Major Donor');
- $this->click('_qf_Advanced_refresh');
- $this->waitForElementPresent('search-status');
- $this->assertText('search-status', 'Tagged In Major Donor');
- }
-
- public function testNewIndividual() {
- $this->login();
-
- // Create New → Individual
- $this->click("crm-create-new-link");
- $this->click("link=Individual");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->assertElementPresent("first_name");
- $this->assertElementPresent("email_1_email");
- $this->assertElementPresent("phone_1_phone");
- $this->assertElementPresent("contact_source");
- $this->assertTextPresent("Constituent Information");
- $this->click("//form[@id='Contact']/div[2]/div[4]/div[1]");
- $this->click("//div[@id='customData1']/table/tbody/tr[1]/td[1]/label");
- $this->assertTextPresent("Most Important Issue");
- $this->click("//form[@id='Contact']/div[2]/div[6]/div[1]");
- $this->assertTextPresent("Communication Preferences");
- $this->assertTextPresent("Do not phone");
- }
-
- public function testManageGroups() {
- $this->login();
-
- // Contacts → Manage Groups
- $this->click("//ul[@id='civicrm-menu']/li[4]");
- $this->clickLink("xpath=//div[@id='root-menu-div']//div/ul//li/div/a[text()='Manage Groups']");
-
- $this->assertTextPresent("Find Groups");
- $this->assertElementPresent("title");
- $this->assertTextPresent("Access Control");
- $this->waitForElementPresent('link=Settings');
- $this->assertTextPresent("Administrators");
- $this->assertTextPresent("Add Group");
- }
-
- public function testContributionDashboard() {
- $this->webtestLogin();
- // Enable CiviContribute module if necessary
- $this->enableComponents("CiviContribute");
-
- // Contributions → Dashboard
- $this->click("css=ul#civicrm-menu li.crm-Contributions");
- $this->clickLink("css=ul#civicrm-menu li.crm-Contributions li.crm-Dashboard a");
-
- $this->waitForElementPresent("xpath=//*[@id='chart_view']/a");
- $this->waitForElementPresent("xpath=//*[@id='ContributionCharts']/div[4]/div[3]");
- $this->assertTextPresent("Contribution Summary");
- $this->assertTextPresent("Recent Contributions");
- }
-
- public function testEventDashboard() {
- $this->webtestLogin();
-
- // Enable CiviEvent module if necessary
- $this->enableComponents("CiviEvent");
-
- // Events → Dashboard
- $this->click("css=ul#civicrm-menu li.crm-Events");
- $this->clickLink("css=ul#civicrm-menu li.crm-Events li.crm-Dashboard a");
-
- $this->assertTextPresent("Event Summary");
- $this->assertTextPresent("Counted:");
- $this->assertTextPresent("Not Counted:");
- $this->assertTextPresent("Not Counted Due To Status:");
- $this->assertTextPresent("Not Counted Due To Role:");
- $this->assertTextPresent("Registered:");
- $this->assertTextPresent("Attended:");
- $this->assertTextPresent("No-show:");
- $this->assertTextPresent("Cancelled:");
- $this->assertTextPresent("Recent Registrations");
- $this->assertTextPresent("Find more event participants...");
- $this->assertTextPresent("Configure");
- }
-
- public function testMembershipsDashboard() {
- $this->webtestLogin();
-
- // Enable CiviMember module if necessary
- $this->enableComponents("CiviMember");
-
- // Memberships → Dashboard
- $this->click("css=ul#civicrm-menu li.crm-Memberships");
- $this->click("css=ul#civicrm-menu li.crm-Memberships li.crm-Dashboard a");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->assertTextPresent("Membership Summary");
- $this->assertTextPresent("Members by Type");
- $this->assertTextPresent("Recent Memberships");
- $this->assertTextPresent("Find more members...");
- }
-
- public function testFindContributions() {
- $this->webtestLogin();
-
- // Enable CiviContribute module if necessary
- $this->enableComponents("CiviContribute");
-
- // Search → Find Contributions
- // Use class names for menu items since li array can change based on which components are enabled
- $this->click("css=ul#civicrm-menu li.crm-Search");
- $this->clickLink("css=ul#civicrm-menu li.crm-Find_Contributions a");
-
- $this->assertTextPresent("Edit Search Criteria");
- $this->assertElementPresent("sort_name");
- $this->assertElementPresent("contribution_date_low");
- $this->assertElementPresent("contribution_amount_low");
- $this->assertElementPresent("contribution_check_number");
- $this->assertTextPresent("Financial Type");
- $this->assertTextPresent("Contribution Page");
- $this->assertElementPresent("s2id_contribution_or_softcredits");
- $this->assertElementPresent("contribution_source");
- $this->assertTextPresent("Personal Campaign Page");
- $this->assertTextPresent("Personal Campaign Page Honor Roll");
- $this->assertTextPresent("Currency");
- }
-
- public function testNewMailing() {
- $this->webtestLogin();
-
- // Enable CiviMail module if necessary
- $this->enableComponents("CiviMail");
-
- // configure default mail-box
- $this->setupDefaultMailbox();
-
- // New Mailing Form
- // Use class names for menu items since li array can change based on which components are enabled
- $this->click("css=ul#civicrm-menu li.crm-Mailings");
- $this->clickLink("css=ul#civicrm-menu li.crm-New_Mailing a");
-
- $this->assertTextPresent("Mailing");
- }
-
- public function testConstituentReportSummary() {
- $this->login();
-
- // Constituent Report Summary
- $this->click("css=ul#civicrm-menu li.crm-Reports");
- $this->clickLink("css=ul#civicrm-menu li.crm-Contact_Reports a");
-
- $this->clickLink("xpath=//div[@id='Contact']/table/tbody/tr/td[1]/a");
-
- $this->assertTextPresent("Constituent Summary");
- $this->click("xpath=//div[@id='mainTabContainer']/ul/li[3]/a");
- $this->waitForElementPresent("xpath=//div[@id='report-tab-set-filters']");
- $this->assertTextPresent("Contact Name");
- $this->assertTextPresent("Contact Source");
- $this->assertTextPresent("Country");
- $this->assertTextPresent("State/Province");
- $this->assertTextPresent("Group");
- $this->assertTextPresent("Tag");
- $this->clickLink("_qf_Summary_submit");
-
- $this->assertTextPresent("Row(s) Listed");
- $this->assertTextPresent("Total Row(s)");
- }
-
- public function testCustomData() {
- $this->login();
-
- // Use class names for menu items since li array can change based on which components are enabled
- $this->click("css=ul#civicrm-menu li.crm-Administer");
- $this->clickLink("xpath=//div[@id='root-menu-div']//a[text()='Custom Fields']");
-
- $this->assertTextPresent("Custom Data");
- $this->assertTextPresent("Constituent Information");
- $this->assertTextPresent("Donor Information");
- $this->assertTextPresent("Food Preference");
-
- // Verify create form
- $this->clickLink("//span[contains(text(), 'Add Set of Custom Fields')]");
-
- $this->assertElementPresent("title");
- $this->assertElementPresent("extends[0]");
- $this->assertElementPresent("weight");
- $this->assertTextPresent("Pre-form Help");
- $this->assertTextPresent("Post-form Help");
- }
-
- public function testProfile() {
- $this->login();
-
- // Use class names for menu items since li array can change based on which components are enabled
- $this->click("css=ul#civicrm-menu li.crm-Administer");
- $this->click("css=ul#civicrm-menu li.crm-Customize_Data_and_Screens");
- $this->clickLink("xpath=//div[@id='root-menu-div']//a[text()='Profiles']");
-
- $this->assertTextPresent("CiviCRM Profile");
- // Verify Reserved Profiles
-
- $this->click("xpath=//div[@id='mainTabContainer']/ul/li[2]/a");
- $this->waitForElementPresent("newCiviCRMProfile-bottom");
- $this->assertTextPresent("New Household");
- $this->assertTextPresent("New Individual");
- $this->assertTextPresent("New Organization");
- $this->assertTextPresent("Participant Status");
- $this->assertTextPresent("Shared Address");
- $this->assertTextPresent("Summary Overlay");
-
- // Verify profiles that are not reserved
- $this->click("xpath=//div[@id='mainTabContainer']/ul/li[1]/a");
- $this->assertTextPresent("Name and Address");
- $this->assertTextPresent("Supporter Profile");
-
- // Verify create form
- $this->click("//span[contains(text(), 'Add Profile')]");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->assertElementPresent("title");
- $this->assertElementPresent("uf_group_type[Profile]");
- $this->assertElementPresent("weight");
- $this->assertTextPresent("Pre-form Help");
- $this->assertTextPresent("Post-form Help");
- $this->click("//form[@id='Group']/div[2]/div[2]/div/div");
- $this->assertElementPresent("group");
- $this->assertElementPresent("post_URL");
- $this->assertTextPresent("Drupal user account registration option?");
- $this->assertTextPresent("What to do upon duplicate match");
- $this->assertTextPresent("Proximity Search");
- }
-
- public function testTags() {
- $this->login();
-
- // Use class names for menu items since li array can change based on which components are enabled
- $this->click("css=ul#civicrm-menu li.crm-Administer");
- $this->click("css=ul#civicrm-menu li.crm-Customize_Data_and_Screens");
- $this->clickLink("xpath=//div[@id='root-menu-div']//a[text()='Tags (Categories)']");
-
- // Verify tags
- $this->assertTextPresent("Non-profit");
- $this->assertTextPresent("Company");
- $this->assertTextPresent("Government Entity");
- $this->assertTextPresent("Major Donor");
- $this->assertTextPresent("Volunteer");
- }
-
- public function testActivityTypes() {
- $this->login();
-
- // Use class names for menu items since li array can change based on which components are enabled
- $this->click("css=ul#civicrm-menu li.crm-Administer");
- $this->click("css=ul#civicrm-menu li.crm-Customize_Data_and_Screens");
- $this->clickLink("xpath=//div[@id='root-menu-div']//a[text()='Activity Types']");
-
- // Verify activity types
- $this->assertTextPresent("Meeting");
- $this->assertTextPresent("Print/Merge Document");
- $this->assertTextPresent("Event Registration");
- $this->assertTextPresent("Contribution");
- $this->assertTextPresent("Membership Signup");
- }
-
- public function testRelationshipTypes() {
- $this->login();
-
- // Use class names for menu items since li array can change based on which components are enabled
- $this->click("css=ul#civicrm-menu li.crm-Administer");
- $this->click("css=ul#civicrm-menu li.crm-Customize_Data_and_Screens");
-
- $this->clickLink("xpath=//div[@id='root-menu-div']//a[text()='Relationship Types']");
-
- // Verify relationship types
- $this->assertTextPresent("Child of");
- $this->assertTextPresent("Head of Household for");
- $this->assertTextPresent("Sibling of");
- $this->assertTextPresent("Spouse of");
- $this->assertTextPresent("Supervised by");
- $this->assertTextPresent("Volunteer for");
- }
-
- public function testMessageTemplates() {
- $this->markTestSkipped('Skipping for now as it works fine locally.');
- $this->login();
-
- // Use class names for menu items since li array can change based on which components are enabled
- $this->click("css=ul#civicrm-menu li.crm-Administer");
- $this->click("css=ul#civicrm-menu li.crm-Communications");
- $this->clickLink("xpath=//div[@id='root-menu-div']//a[text()='Message Templates']");
-
- // Verify message templates
- $this->click("xpath=//div[@id='mainTabContainer']/ul//li/a[contains(text(),'System Workflow Messages')]");
- $this->assertTextPresent("Contributions - Receipt (on-line)");
- $this->assertTextPresent("Events - Registration Confirmation and Receipt (off-line)");
- $this->assertTextPresent("Memberships - Signup and Renewal Receipts (off-line)");
- $this->assertTextPresent("Personal Campaign Pages - Supporter Status Change Notification");
- $this->assertTextPresent("Profiles - Admin Notification");
- $this->assertTextPresent("Tell-a-Friend Email");
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Grant_ContactContextAddTest
- */
-class WebTest_Grant_ContactContextAddTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testContactContextAddTest() {
- // Log in as admin first to verify permissions for CiviGrant
- $this->webtestLogin('admin');
-
- // Enable CiviGrant module if necessary
- $this->enableComponents("CiviGrant");
-
- // let's give full CiviGrant permissions to demo user (registered user).
- $permission = array('edit-2-access-civigrant', 'edit-2-edit-grants', 'edit-2-delete-in-civigrant');
- $this->changePermissions($permission);
-
- // Log in as normal user
- $this->webtestLogin();
-
- // create unique name
- $name = substr(sha1(rand()), 0, 7);
- $firstName = 'Grant' . $name;
- $lastName = 'L' . $name;
-
- // create new contact
- $this->webtestAddContact($firstName, $lastName);
-
- // wait for action element
- $this->waitForElementPresent('crm-contact-actions-link');
-
- // now add grant from contact summary
- $this->click("xpath=//div[@class='crm-actions-ribbon']/ul[@id='actions']/li[@class='crm-contact-activity crm-summary-block']/div/a[@id='crm-contact-actions-link']");
- $this->waitForElementPresent('crm-contact-actions-list');
-
- // wait for add Grant link
- $this->waitForElementPresent('link=Add Grant');
-
- $this->click('link=Add Grant');
-
- // wait for grant form to load completely
- $this->waitForText('css=span.ui-dialog-title', "New Grant");
- $this->waitForElementPresent('status_id');
-
- // check contact name on Grant form
-
- // select grant Status
- $this->select('status_id', 'value=1');
-
- // select grant type
- $this->select('grant_type_id', 'value=1');
-
- // total amount
- $this->type('amount_total', '200');
-
- // amount requested
- $this->type('amount_requested', '200');
-
- // amount granted
- $this->type('amount_granted', '190');
-
- // fill in application received Date
- $this->webtestFillDate('application_received_date', 'now');
-
- // fill in decision Date
- $this->webtestFillDate('decision_date', 'now');
-
- // fill in money transferred date
- $this->webtestFillDate('money_transfer_date', 'now');
-
- // fill in grant due Date
- $this->webtestFillDate('grant_due_date', 'now');
-
- // check grant report received.
- $this->check('grant_report_received');
-
- // grant rationale
- $this->type('rationale', 'Grant Rationale for webtest');
-
- // grant note
- $this->type('note', "Grant Note for $firstName");
-
- // Clicking save.
- $this->clickLink('_qf_Grant_upload', "xpath=//div[@class='view-content']//table/tbody/tr[1]/td[8]/span/a[text()='View']", FALSE);
-
- // click through to the Grant view screen
- $this->clickLink("xpath=//div[@class='view-content']//table/tbody/tr[1]/td[8]/span/a[text()='View']", '_qf_GrantView_cancel-bottom', FALSE);
-
- $gDate = date('F jS, Y', strtotime('now'));
-
- // verify tabular data for grant view
- $this->webtestVerifyTabularData(array(
- 'Name' => "$firstName $lastName",
- 'Grant Status' => 'Submitted',
- 'Grant Type' => 'Emergency',
- 'Application Received' => $gDate,
- 'Grant Decision' => $gDate,
- 'Money Transferred' => $gDate,
- 'Grant Report Due' => $gDate,
- 'Amount Requested' => '$ 200.00',
- 'Amount Granted' => '$ 190.00',
- 'Grant Report Received?' => 'Yes',
- 'Rationale' => 'Grant Rationale for webtest',
- 'Notes' => "Grant Note for $firstName",
- )
- );
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Grant_CustomFieldsetTest
- */
-class WebTest_Grant_CustomFieldsetTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testCustomFieldsetTest() {
- // Log in as admin first to verify permissions for CiviGrant
- $this->webtestLogin('admin');
-
- // Enable CiviGrant module if necessary
- $this->enableComponents("CiviGrant");
-
- // let's give full CiviGrant permissions to demo user (registered user).
- $permission = array('edit-2-access-civigrant', 'edit-2-edit-grants', 'edit-2-delete-in-civigrant');
- $this->changePermissions($permission);
-
- // Log in as normal user
- $this->webtestLogin();
-
- // Create unique identifier for names
- $rand = substr(sha1(rand()), 0, 7);
-
- // Add new Grant Type
- $this->openCiviPage('admin/options/grant_type', 'reset=1');
- $this->click("xpath=//*[@id='crm-main-content-wrapper']/div[2]/div[1]/a");
- $this->waitForElementPresent('_qf_Options_cancel-bottom');
- $grantType = 'GrantType' . $rand;
- $this->type('id=label', $grantType);
- $this->click('id=_qf_Options_next-top');
- $this->waitForText('crm-notification-container', "The Grant Type '$grantType' has been saved.");
-
- // Create new Custom Field Set that extends the grant type
- $this->openCiviPage('admin/custom/group', 'reset=1');
- $this->click("css=#newCustomDataGroup > span");
- $this->waitForElementPresent('_qf_Group_next-bottom');
- $grantFieldSet = 'Fieldset' . $rand;
- $this->type('id=title', $grantFieldSet);
- $this->select('id=extends_0', 'label=Grants');
- $this->addSelection('id=extends_1', "label=$grantType");
- $this->click('id=collapse_display');
- $this->clickLink('id=_qf_Group_next-bottom');
- $this->waitForText('crm-notification-container', "Your custom field set '$grantFieldSet' has been added.");
- $this->waitForElementPresent('_qf_Field_done-bottom');
-
- // Add field to fieldset
- $grantField = 'GrantField' . $rand;
- $this->type('id=label', $grantField);
- $this->select('id=data_type_0', 'label=Money');
- $this->click('id=_qf_Field_done-bottom');
- $this->waitForText('crm-notification-container', "Custom field '$grantField' has been saved.");
-
- // Create new Grant
- $this->openCiviPage('grant/add', 'reset=1&action=add&context=standalone', '_qf_Grant_upload-bottom');
- $contact = $this->createDialogContact();
- $this->select('id=status_id', 'label=Approved for Payment');
- $this->select('id=grant_type_id', "label=$grantType");
- $this->waitForTextPresent($grantField);
- $this->assertElementContainsText("xpath=//div[@id='customData']/div[@class='custom-group custom-group-$grantFieldSet crm-accordion-wrapper ']", $grantField);
- $this->type('id=amount_total', '100.00');
- $this->type("xpath=//div[@id='customData']/div[@class='custom-group custom-group-$grantFieldSet crm-accordion-wrapper ']/div[@class='crm-accordion-body']/table/tbody/tr/td[2]/input[@class='crm-form-text']", '99.99');
- $this->clickLink('id=_qf_Grant_upload-bottom', "xpath=//div[@class='view-content']//table/tbody/tr[1]/td[8]/span/a[text()='View']");
-
- // Click through to the Grant view screen
- $this->click("xpath=//div[@class='view-content']//table/tbody/tr[1]/td[8]/span/a[text()='View']");
- $this->waitForElementPresent('_qf_GrantView_cancel-bottom');
-
- // verify tabular data for grant view
- $this->webtestVerifyTabularData(array(
- 'Name' => $contact['display_name'],
- 'Grant Status' => 'Approved',
- 'Grant Type' => $grantType,
- $grantField => '$ 99.99',
- )
- );
- }
-
- public function testAjaxCustomGroupLoad() {
- $this->webtestLogin();
-
- // Enable CiviGrant module if necessary
- $this->enableComponents("CiviGrant");
-
- $triggerElement = array('name' => 'grant_type_id', 'type' => 'select');
- $customSets = array(
- array('entity' => 'Grant', 'subEntity' => 'Emergency', 'triggerElement' => $triggerElement),
- array('entity' => 'Grant', 'subEntity' => 'Family Support', 'triggerElement' => $triggerElement),
- );
-
- $pageUrl = array('url' => 'grant/add', 'args' => 'reset=1&action=add&context=standalone');
- $this->customFieldSetLoadOnTheFlyCheck($customSets, $pageUrl);
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Grant_StandaloneAddTest
- */
-class WebTest_Grant_StandaloneAddTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testStandaloneGrantAdd() {
- // Log in as admin first to verify permissions for CiviGrant
- $this->webtestLogin('admin');
-
- // Enable CiviGrant module if necessary
- $this->enableComponents("CiviGrant");
-
- // let's give full CiviGrant permissions to demo user (registered user).
- $permission = array('edit-2-access-civigrant', 'edit-2-edit-grants', 'edit-2-delete-in-civigrant');
- $this->changePermissions($permission);
-
- // Log in as normal user
- $this->webtestLogin();
-
- $this->openCiviPage('grant/add', 'reset=1&context=standalone', '_qf_Grant_upload');
-
- // create new contact using dialog
- $contact = $this->createDialogContact();
-
- // select grant Status
- $this->select("status_id", "value=1");
-
- // select grant type
- $this->select("grant_type_id", "value=1");
-
- // total amount
- $this->type("amount_total", "100");
-
- // amount requested
- $this->type("amount_requested", "100");
-
- // amount granted
- $this->type("amount_granted", "90");
-
- // fill in application received Date
- $this->webtestFillDate('application_received_date');
-
- // fill in decision Date
- $this->webtestFillDate('decision_date');
-
- // fill in money transferred date
- $this->webtestFillDate('money_transfer_date');
-
- // fill in grant due Date
- $this->webtestFillDate('grant_due_date');
-
- // check grant report received.
- $this->check("grant_report_received");
-
- // grant note
- $this->type("note", "Grant Note");
-
- // Clicking save.
- $this->clickLink("_qf_Grant_upload", "xpath=//div[@class='view-content']//table//tbody/tr[1]/td[8]/span/a[text()='View']", FALSE);
-
- //click through to the Grant view screen
- $this->click("xpath=//div[@class='view-content']//table/tbody/tr[1]/td[8]/span/a[text()='View']");
-
- $this->waitForElementPresent("_qf_GrantView_cancel-bottom");
-
- $expected = array(
- 'Grant Status' => 'Submitted',
- 'Grant Type' => 'Emergency',
- 'Amount Requested' => '$ 100.00',
- 'Amount Granted' => '$ 90.00',
- 'Notes' => 'Grant Note',
- );
-
- $this->webtestVerifyTabularData($expected);
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'WebTest/Import/ImportCiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Import_ActivityTest
- */
-class WebTest_Import_ActivityTest extends ImportCiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testActivityImport() {
-
- $this->webtestLogin();
-
- // Get sample import data.
- list($headers, $rows) = $this->_activityCSVData();
- $fieldMapper = array(
- 'mapper[0][0]' => 'target_contact_id',
- 'mapper[1][0]' => 'activity_label',
- 'mapper[2][0]' => 'activity_subject',
- 'mapper[3][0]' => 'activity_date_time',
- );
- $this->importCSVComponent('Activity', $headers, $rows, NULL, NULL, $fieldMapper);
- }
-
- /**
- * @return array
- */
- public function _activityCSVData() {
-
- $firstName1 = substr(sha1(rand()), 0, 7);
- $email1 = 'mail_' . substr(sha1(rand()), 0, 7) . '@example.com';
- $this->webtestAddContact($firstName1, 'Anderson', $email1);
- $id1 = $this->urlArg('cid');
-
- $firstName2 = substr(sha1(rand()), 0, 7);
- $email2 = 'mail_' . substr(sha1(rand()), 0, 7) . '@example.com';
- $this->webtestAddContact($firstName2, 'Anderson', $email2);
- $id2 = $this->urlArg('cid');
-
- $headers = array(
- 'target_contact_id' => 'Contact ID',
- 'activity_type_label' => 'Activity Type Label',
- 'subject' => 'Subject',
- 'activity_date' => 'Activity Date',
- 'activity_status_id' => 'Activity Status Id',
- 'duration' => 'Duration',
- 'location' => 'Location',
- );
-
- $rows = array(
- array(
- 'target_contact_id' => $id1,
- 'activity_type_label' => 'Meeting',
- 'subject' => 'Test Meeting',
- 'activity_date' => '2009-10-01',
- 'activity_status_id' => 'Completed',
- 'duration' => '20',
- 'location' => 'UK',
- ),
- array(
- 'target_contact_id' => $id2,
- 'activity_type_label' => 'Phone Call',
- 'subject' => 'Test Phone Call',
- 'activity_date' => '2010-10-15',
- 'activity_status_id' => 'Completed',
- 'duration' => '20',
- 'location' => 'USA',
- ),
- );
-
- return array($headers, $rows);
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'WebTest/Import/ImportCiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Import_AddressImportTest
- */
-class WebTest_Import_AddressImportTest extends ImportCiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testCustomAddressDataImport() {
- $this->webtestLogin();
-
- $firstName1 = 'Ma_' . substr(sha1(rand()), 0, 7);
- // Add a custom group and custom field
- $customDataParams = $this->_addCustomData();
-
- // Get sample import data.
- list($headers, $rows) = $this->_individualCustomCSVData($customDataParams, $firstName1);
-
- $this->importContacts($headers, $rows, 'Individual', 'Skip', array());
-
- // Type search name in autocomplete.
- $this->click('sort_name_navigation');
- $this->type('css=input#sort_name_navigation', $firstName1);
- $this->typeKeys('css=input#sort_name_navigation', $firstName1);
-
- // Wait for result list.
- $this->waitForElementPresent("css=ul.ui-autocomplete li");
-
- // Visit contact summary page.
- $this->click("css=ul.ui-autocomplete li");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- foreach ($customDataParams['customFields'] as $key => $value) {
- $this->assertTrue($this->isElementPresent("xpath=//div[@class='crm-summary-row']/div[@class='crm-label'][contains(text(), '$key')]"));
- $this->assertElementContainsText('address-block-1', "$value");
- }
- }
-
- /**
- * Helper function to provide data for custom data import.
- *
- * @param array $customDataParams
- * @param string $firstName1
- *
- * @return array
- */
- public function _individualCustomCSVData($customDataParams, $firstName1) {
-
- $headers = array(
- 'first_name' => 'First Name',
- 'last_name' => 'Last Name',
- 'address_1' => 'Additional Address 1',
- 'address_2' => 'Additional Address 2',
- 'city' => 'City',
- 'state' => 'State',
- 'country' => 'Country',
- );
- foreach ($customDataParams['headers'] as $key => $value) {
- $headers[$key] = $value;
- }
-
- $rows = array(
- 0 => array(
- 'first_name' => $firstName1,
- 'last_name' => 'Anderson',
- 'address_1' => 'Add 1',
- 'address_2' => 'Add 2',
- 'city' => 'Watson',
- 'state' => 'NY',
- 'country' => 'UNITED STATES',
- ),
- );
- foreach ($customDataParams['rows'][0] as $key => $values) {
- $rows[0][$key] = $values;
- }
- return array($headers, $rows);
- }
-
- /**
- * @return array
- */
- public function _addCustomData() {
-
- $this->openCiviPage('admin/custom/group', 'reset=1');
-
- //add new custom data
- $this->click("//a[@id='newCustomDataGroup']/span");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- //fill custom group title
- $customGroupTitle = 'Custom ' . substr(sha1(rand()), 0, 7);
- $this->click('title');
- $this->type('title', $customGroupTitle);
-
- //custom group extends
- $this->click('extends[0]');
- $this->select('extends[0]', "value=Address");
- $this->click("//option[@value='Address']");
- $this->clickLink('_qf_Group_next-bottom');
-
- //Is custom group created?
- $this->waitForText('crm-notification-container', "Your custom field set '{$customGroupTitle}' has been added. You can add custom fields now.");
- $gid = $this->urlArg('gid');
- $this->waitForElementPresent('_qf_Field_cancel-bottom');
-
- // create custom field "alphanumeric text"
- $customField = 'Custom field ' . substr(sha1(rand()), 0, 4);
- $this->type('label', $customField);
-
- // clicking save
- $this->click('_qf_Field_done-bottom');
-
- $this->waitForText('crm-notification-container', "Custom field '{$customField}' has been saved.");
- $this->assertTrue($this->isTextPresent($customField), 'Missing text: ' . $customField);
- $this->waitForAjaxContent();
- $customFieldId = explode('&id=', $this->getAttribute("xpath=//div[@id='field_page']//table/tbody//tr/td/div[text()='$customField']/../../td[8]/span/a@href"));
- $customFieldId = $customFieldId[1];
-
- // create custom field - Integer
- $this->click("newCustomField");
- $this->waitForElementPresent('_qf_Field_done-bottom');
- $customField1 = 'Customfield_int ' . substr(sha1(rand()), 0, 4);
- $this->type('label', $customField1);
- $this->select("data_type[0]", "value=1");
-
- // clicking save
- $this->click('_qf_Field_done-bottom');
- $this->waitForElementPresent('newCustomField');
- $this->waitForText('crm-notification-container', "Custom field '{$customField1}' has been saved.");
- $this->assertTrue($this->isTextPresent($customField1), 'Missing text: ' . $customField1);
- $this->waitForAjaxContent();
- $customFieldId1 = explode('&id=', $this->getAttribute("xpath=//div[@id='field_page']//table/tbody//tr/td/div[text()='$customField1']/../../td[8]/span/a@href"));
- $customFieldId1 = $customFieldId1[1];
-
- // create custom field - Number
- $this->click("newCustomField");
- $this->waitForElementPresent('_qf_Field_done-bottom');
- $customField2 = 'Customfield_Number ' . substr(sha1(rand()), 0, 4);
- $this->type('label', $customField2);
- $this->select("data_type[0]", "value=2");
-
- // clicking save
- $this->click('_qf_Field_done-bottom');
- $this->waitForElementPresent('newCustomField');
- $this->waitForText('crm-notification-container', "Custom field '{$customField2}' has been saved.");
- $this->assertTrue($this->isTextPresent($customField2), 'Missing text: ' . $customField2);
- $this->waitForAjaxContent();
- $customFieldId2 = explode('&id=', $this->getAttribute("xpath=//div[@id='field_page']//table/tbody//tr/td/div[text()='$customField2']/../../td[8]/span/a@href"));
- $customFieldId2 = $customFieldId2[1];
-
- // create custom field - "alphanumeric select"
- $this->click("newCustomField");
- $this->waitForElementPresent('_qf_Field_done-bottom');
- $customField3 = 'Customfield_alp_select' . substr(sha1(rand()), 0, 4);
- $customFieldId3 = $this->_createMultipleValueCustomField($customField3, 'Select');
-
- // create custom field - "alphanumeric radio"
- $this->click("newCustomField");
- $this->waitForElementPresent('_qf_Field_done-bottom');
- $customField4 = 'Customfield_alp_radio' . substr(sha1(rand()), 0, 4);
- $customFieldId4 = $this->_createMultipleValueCustomField($customField4, 'Radio');
-
- // create custom field - "alphanumeric checkbox"
- $this->click("newCustomField");
- $this->waitForElementPresent('_qf_Field_done-bottom');
- $customField5 = 'Customfield_alp_checkbox' . substr(sha1(rand()), 0, 4);
- $customFieldId5 = $this->_createMultipleValueCustomField($customField5, 'CheckBox');
-
- // create custom field - "alphanumeric multiselect"
- $this->click("newCustomField");
- $this->waitForElementPresent('_qf_Field_done-bottom');
- $customField6 = 'Customfield_alp_multiselect' . substr(sha1(rand()), 0, 4);
- $customFieldId6 = $this->_createMultipleValueCustomField($customField6, 'Multi-Select');
-
- // create custom field - "alphanumeric autocompleteselect"
- $this->click("newCustomField");
- $this->waitForElementPresent('_qf_Field_done-bottom');
- $customField8 = 'Customfield_alp_autocompleteselect' . substr(sha1(rand()), 0, 4);
- $customFieldId8 = $this->_createMultipleValueCustomField($customField8, 'Autocomplete-Select');
-
- // create custom field - Money
- $this->click("newCustomField");
- $this->waitForElementPresent('_qf_Field_done-bottom');
- $customField9 = 'Customfield_Money' . substr(sha1(rand()), 0, 4);
- $this->type('label', $customField9);
- $this->select("data_type[0]", "value=3");
-
- // clicking save
- $this->click('_qf_Field_done-bottom');
- $this->waitForElementPresent('newCustomField');
- $this->waitForText('crm-notification-container', "Custom field '{$customField9}' has been saved.");
- $this->assertTrue($this->isTextPresent($customField9), 'Missing text: ' . $customField9);
- $this->waitForAjaxContent();
- $customFieldId9 = explode('&id=', $this->getAttribute("xpath=//div[@id='field_page']//table/tbody//tr/td/div[text()='$customField9']/../../td[8]/span/a@href"));
- $customFieldId9 = $customFieldId9[1];
-
- // create custom field - Date
- $this->click("newCustomField");
- $this->waitForElementPresent('_qf_Field_done-bottom');
- $customField10 = 'Customfield_Date' . substr(sha1(rand()), 0, 4);
- $this->type('label', $customField10);
- $this->select("data_type[0]", "value=5");
- $this->select("date_format", "value=yy-mm-dd");
-
- // clicking save
- $this->click('_qf_Field_done-bottom');
- $this->waitForElementPresent('newCustomField');
- $this->waitForText('crm-notification-container', "Custom field '{$customField10}' has been saved.");
- $this->assertTrue($this->isTextPresent($customField9), 'Missing text: ' . $customField9);
- $this->waitForAjaxContent();
- $customFieldId10 = explode('&id=', $this->getAttribute("xpath=//div[@id='field_page']//table/tbody//tr/td/div[text()='$customField10']/../../td[8]/span/a@href"));
- $customFieldId10 = $customFieldId10[1];
-
- return array(
- 'headers' => array(
- "custom_{$customFieldId}" => "$customField :: $customGroupTitle",
- "custom_{$customFieldId3}" => "$customField3 :: $customGroupTitle",
- "custom_{$customFieldId4}" => "$customField4 :: $customGroupTitle",
- "custom_{$customFieldId5}" => "$customField5 :: $customGroupTitle",
- "custom_{$customFieldId6}" => "$customField6 :: $customGroupTitle",
- "custom_{$customFieldId8}" => "$customField8 :: $customGroupTitle",
- "custom_{$customFieldId1}" => "$customField1 :: $customGroupTitle",
- "custom_{$customFieldId2}" => "$customField2 :: $customGroupTitle",
- "custom_{$customFieldId9}" => "$customField9 :: $customGroupTitle",
- "custom_{$customFieldId10}" => "$customField10 :: $customGroupTitle",
- ),
- 'rows' => array(
- 0 => array(
- "custom_{$customFieldId}" => "This is a test field",
- "custom_{$customFieldId3}" => "label1",
- "custom_{$customFieldId4}" => "label1",
- "custom_{$customFieldId5}" => "label1",
- "custom_{$customFieldId6}" => "label1",
- "custom_{$customFieldId8}" => "label1",
- "custom_{$customFieldId1}" => 1,
- "custom_{$customFieldId2}" => 12345,
- "custom_{$customFieldId9}" => 123456,
- "custom_{$customFieldId10}" => "2009-12-31",
- ),
- ),
- 'customFields' => array(
- $customField => 'This is a test field',
- $customField3 => 'label1',
- $customField4 => 'label1',
- $customField5 => 'label1',
- $customField6 => 'label1',
- $customField8 => 'label1',
- $customField1 => '1',
- $customField2 => '12345',
- $customField9 => '123,456.00',
- //CRM-16068 -- changing assertion to match the date format selected during custom field creation.
- $customField10 => '2009-12-31',
- ),
- );
- }
-
- /**
- * @param string $customFieldName
- * @param $type
- *
- * @return array
- */
- public function _createMultipleValueCustomField($customFieldName, $type) {
- $this->type('label', $customFieldName);
- $this->select("data_type[0]", "value=0");
- $this->select("data_type[1]", "value=" . $type);
- $this->type("option_label_1", "label1");
- $this->type("option_value_1", "label1");
- $this->type("option_label_2", "label2");
- $this->type("option_value_2", "label2");
-
- // clicking save
- $this->click('_qf_Field_done-bottom');
- $this->waitForElementPresent('newCustomField');
- $this->waitForText('crm-notification-container', "Custom field '{$customFieldName}' has been saved.");
- $this->assertTrue($this->isTextPresent($customFieldName), 'Missing text: ' . $customFieldName);
- $this->waitForAjaxContent();
- $customFieldId = explode('&id=', $this->getAttribute("xpath=//div[@id='field_page']//table/tbody//tr/td/div[text()='$customFieldName']/../../td[8]/span/a@href"));
- $customFieldId = $customFieldId[1];
- return $customFieldId;
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'WebTest/Import/ImportCiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Import_AddressParsingTest
- */
-class WebTest_Import_AddressParsingTest extends ImportCiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- /**
- * Check for Valid Street Address.
- */
- public function testValidStreetAddressParsing() {
- $this->webtestLogin();
-
- //Go to the URL of Address Setting to enable street address parsing option
- $this->openCiviPage("admin/setting/preferences/address", "reset=1");
-
- //check the street address parsing is already enabled
- if (!$this->isChecked("address_options[13]")) {
- $this->click("address_options[13]");
- $this->click("_qf_Address_next");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- }
-
- // Get sample import data.
- list($headers, $rows) = $this->_validStreetAddressCSVData();
-
- $this->importContacts($headers, $rows);
-
- // Get imported contact Ids
- $importedContactIds = $this->_getImportedContactIds($rows);
-
- //Go to the url of edit contact
- $this->openCiviPage("contact/add", "reset=1&action=update&cid={$importedContactIds[1]}");
- $this->click("addressBlock");
- $this->click("//div[@id='addressBlockId']/div[1]");
- $this->waitForElementPresent("address_1_street_address");
-
- //Edit Address Elements
- $this->click("link=Edit Address Elements");
- $this->waitForElementPresent("address_1_street_unit");
-
- //verify all the address fields whether parsed correctly
- $verifyData = array(
- 'address_1_street_number' => '22',
- 'address_1_street_name' => 'Adams Avenue',
- 'address_1_street_unit' => 'Unit 3c',
- );
- foreach ($verifyData as $key => $expectedvalue) {
- $actualvalue = $this->getValue($key);
- $this->assertEquals($expectedvalue, $actualvalue);
- }
- $this->clickLink('_qf_Contact_upload_view-top');
-
- //Go to the URL of Address Setting to disable street address parsing option
- $this->openCiviPage("admin/setting/preferences/address", "reset=1");
-
- //Disable street address parsing
- $this->click("address_options[13]");
- $this->click("_qf_Address_next");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- }
-
- /**
- * Check for Invalid Street Address.
- */
- public function testInvalidStreetAddressParsing() {
- $this->webtestLogin();
-
- //Go to the URL of Address Setting to enable street address parsing option
- $this->openCiviPage("admin/setting/preferences/address", "reset=1");
-
- //check the street address parsing is already enabled
- if (!$this->isChecked("address_options[13]")) {
- $this->click("address_options[13]");
- $this->click("_qf_Address_next");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- }
-
- // Get sample import data.
- list($headers, $rows) = $this->_invalidStreetAddressCSVData();
-
- $this->importContacts($headers, $rows);
- $this->assertTrue($this->isTextPresent("Records imported successfully but unable to parse some of the street addresses"));
- $this->assertTrue($this->isTextPresent("You can Download Street Address Records . You may then edit those contact records and update the street address accordingly."));
-
- // Get imported contact Ids
- $importedContactIds = $this->_getImportedContactIds($rows);
-
- //Go to the url of edit contact
- $this->openCiviPage("contact/add", "reset=1&action=update&cid={$importedContactIds[1]}");
- $this->click("addressBlock");
- $this->click("//div[@id='addressBlockId']/div[1]");
- $this->waitForElementPresent("address_1_street_address");
-
- //Edit Address Elements
- $this->click("link=Edit Address Elements");
- $this->waitForElementPresent("address_1_street_unit");
-
- //verify all the address fields whether parsed correctly
- $verifyData = array(
- 'address_1_street_number' => '',
- 'address_1_street_name' => '',
- 'address_1_street_unit' => '',
- );
- foreach ($verifyData as $key => $expectedvalue) {
- $actualvalue = $this->getValue($key);
- $this->assertEquals($expectedvalue, $actualvalue);
- }
-
- //Go to the URL of Address Setting to disable street address parsing option
- $this->openCiviPage("admin/setting/preferences/address", "reset=1");
-
- //Disable street address parsing
- $this->click("address_options[13]");
- $this->click("_qf_Address_next");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- }
-
- /**
- * Check Street Address when Address Parsing is Disabled.
- */
- public function testStreetAddress() {
- $this->webtestLogin();
-
- //Go to the URL of Address Setting to enable street address parsing option
- $this->openCiviPage("admin/setting/preferences/address", "reset=1");
-
- //check the street address parsing is already disabled
- if ($this->isChecked("address_options[13]")) {
- $this->click("address_options[13]");
- $this->click("_qf_Address_next");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- }
-
- // Get sample import data.
- list($headers, $rows) = $this->_validStreetAddressCSVData();
-
- $this->importContacts($headers, $rows);
-
- // Get imported contact Ids
- $importedContactIds = $this->_getImportedContactIds($rows);
-
- //Go to the url of edit contact
- $this->openCiviPage("contact/add", "reset=1&action=update&cid={$importedContactIds[1]}");
- $this->click("addressBlock");
- $this->click("//div[@id='addressBlockId']/div[1]");
- $this->waitForElementPresent("address_1_street_address");
-
- //verify the address field
- $verifyData = array('address_1_street_address' => '22 Adams Avenue Unit 3c');
- $actualvalue = $this->getValue('address_1_street_address');
- $this->assertEquals('22 Adams Avenue Unit 3c', $actualvalue);
- }
-
- /**
- * Helper function to provide csv data with Valid Street Address.
- *
- * @return array
- */
- public function _validStreetAddressCSVData() {
- $headers = array(
- 'first_name' => 'First Name',
- 'middle_name' => 'Middle Name',
- 'last_name' => 'Last Name',
- 'email' => 'Email',
- 'phone' => 'Phone',
- 'street_address' => 'Street Address',
- 'address_1' => 'Supplemental Address 1',
- 'address_2' => 'Supplemental Address 2',
- 'city' => 'City',
- 'state' => 'State',
- 'country' => 'Country',
- );
-
- $rows = array(
- array(
- 'first_name' => 'A' . substr(sha1(rand()), 0, 7),
- 'middle_name' => substr(sha1(rand()), 0, 7),
- 'last_name' => substr(sha1(rand()), 0, 7) . 'and',
- 'email' => substr(sha1(rand()), 0, 7) . '@example.com',
- 'phone' => '6949912154',
- 'street_address' => '54A Excelsior Ave. Apt 1C',
- 'address_1' => 'Add 1',
- 'address_2' => 'Add 2',
- 'city' => 'Watson',
- 'state' => 'NY',
- 'country' => 'UNITED STATES',
- ),
- array(
- 'first_name' => 'S' . substr(sha1(rand()), 0, 7),
- 'middle_name' => substr(sha1(rand()), 0, 7),
- 'last_name' => substr(sha1(rand()), 0, 7) . 'sum',
- 'email' => substr(sha1(rand()), 0, 7) . '@example.com',
- 'phone' => '6944412154',
- 'street_address' => '22 Adams Avenue Unit 3c',
- 'address_1' => 'Add 1',
- 'address_2' => 'Add 2',
- 'city' => 'Watson',
- 'state' => 'NY',
- 'country' => 'UNITED STATES',
- ),
- );
-
- return array($headers, $rows);
- }
-
- /**
- * Helper function to provide csv data with Invalid Street Address.
- *
- * @return array
- */
- public function _invalidStreetAddressCSVData() {
- $headers = array(
- 'first_name' => 'First Name',
- 'middle_name' => 'Middle Name',
- 'last_name' => 'Last Name',
- 'email' => 'Email',
- 'phone' => 'Phone',
- 'street_address' => 'Street Address',
- 'address_1' => 'Supplemental Address 1',
- 'address_2' => 'Supplemental Address 2',
- 'city' => 'City',
- 'state' => 'State',
- 'country' => 'Country',
- );
-
- $rows = array(
- array(
- 'first_name' => 'A' . substr(sha1(rand()), 0, 7),
- 'middle_name' => substr(sha1(rand()), 0, 7),
- 'last_name' => substr(sha1(rand()), 0, 7) . 'and',
- 'email' => substr(sha1(rand()), 0, 7) . '@example.com',
- 'phone' => '6949912154',
- 'street_address' => 'West St. Apt 1',
- 'address_1' => 'Add 1',
- 'address_2' => 'Add 2',
- 'city' => 'Watson',
- 'state' => 'NY',
- 'country' => 'UNITED STATES',
- ),
- array(
- 'first_name' => 'S' . substr(sha1(rand()), 0, 7),
- 'middle_name' => substr(sha1(rand()), 0, 7),
- 'last_name' => substr(sha1(rand()), 0, 7) . 'sum',
- 'email' => substr(sha1(rand()), 0, 7) . '@example.com',
- 'phone' => '6944412154',
- 'street_address' => 'SW 440N Lincoln Dr S',
- 'address_1' => 'Add 1',
- 'address_2' => 'Add 2',
- 'city' => 'Watson',
- 'state' => 'NY',
- 'country' => 'UNITED STATES',
- ),
- );
-
- return array($headers, $rows);
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'WebTest/Import/ImportCiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Import_ContactCustomDataTest
- */
-class WebTest_Import_ContactCustomDataTest extends ImportCiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testCustomDataImport() {
- $this->webtestLogin();
-
- $firstName1 = 'Ma_' . substr(sha1(rand()), 0, 7);
- // Add a custom group and custom field
- $customDataParams = $this->_addCustomData();
-
- // Add New Strict Rule
- $newRuleTitle = 'IndividualStrict_' . substr(sha1(rand()), 0, 7);
- $this->openCiviPage("contact/deduperules", "reset=1");
-
- $this->click("xpath=//div[@id='browseValues_Individual']/div[2]/a/span");
- $this->waitForElementPresent('_qf_DedupeRules_next-bottom');
- $this->type('title', $newRuleTitle);
- $this->click("CIVICRM_QFID_Supervised_used");
- $this->select("where_0", "label=$customDataParams[1]");
- $this->type('weight_0', '10');
- $this->type('threshold', '10');
- $this->click('_qf_DedupeRules_next-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForText("crm-notification-container", "The rule '{$newRuleTitle}' has been saved.");
-
- $rgId = explode('&rgid=', $this->getAttribute("xpath=//div[@id='browseValues_Individual']/div/div/table/tbody//tr/td[text()='{$newRuleTitle}']/../td[3]/span/a[1][text()='Use Rule']@href"));
- $rgId = explode('&', $rgId[1]);
-
- // Add Contact
- $firstName2 = 'An_' . substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName2, "Summerson");
-
- // Edit and expand all tabs
- $this->click('link=Edit');
- $this->waitForElementPresent('_qf_Contact_cancel');
- $this->click('link=Expand all tabs');
-
- // Fill custom data
- $this->waitForElementPresent("{$customDataParams[0]}_1");
- $this->type("{$customDataParams[0]}_1", 'This is a test field');
- $this->click('_qf_Contact_upload_view');
-
- // Get sample import data.
- list($headers, $rows) = $this->_individualCustomCSVData($customDataParams, $firstName1);
-
- // Import and check Individual contacts in Skip mode.
- $other = array(
- 'saveMapping' => TRUE,
- 'callbackImportSummary' => 'checkDuplicateContacts',
- 'dedupe' => $rgId[0],
- );
-
- // Check duplicates
- $this->importContacts($headers, $rows, 'Individual', 'Skip', array(), $other);
-
- // Import without duplicate checking
- $other = array('saveMapping' => TRUE);
- $this->importContacts($headers, $rows, 'Individual', 'No Duplicate Checking', array(), $other);
-
- // Type search name in autocomplete.
- $this->click('sort_name_navigation');
- $this->type('css=input#sort_name_navigation', $firstName1);
- $this->typeKeys('css=input#sort_name_navigation', $firstName1);
-
- // Wait for result list.
- $this->waitForElementPresent("css=ul.ui-autocomplete li");
-
- // Visit contact summary page.
- $this->click("css=ul.ui-autocomplete li");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->assertTrue($this->isTextPresent('This is a test field'));
- }
-
- /**
- * Helper function to provide data for custom data import.
- *
- * @param array $customDataParams
- * @param string $firstName1
- *
- * @return array
- */
- public function _individualCustomCSVData($customDataParams, $firstName1) {
- $headers = array(
- 'first_name' => 'First Name',
- 'last_name' => 'Last Name',
- "custom_{$customDataParams[0]}" => "{$customDataParams[1]} :: {$customDataParams[2]}",
- );
-
- $rows = array(
- array(
- 'first_name' => $firstName1,
- 'last_name' => 'Anderson',
- "custom_{$customDataParams[0]}" => 'This is a test field',
- ),
- );
-
- return array($headers, $rows);
- }
-
- /**
- * @param $originalHeaders
- * @param $originalRows
- * @param $checkSummary
- */
- public function checkDuplicateContacts($originalHeaders, $originalRows, $checkSummary) {
- $this->assertTrue($this->isTextPresent('CiviCRM has detected one record which is a duplicate of existing CiviCRM contact record. These records have not been imported.'));
- }
-
- /**
- * @return array
- */
- public function _addCustomData() {
-
- $this->openCiviPage("admin/custom/group", "reset=1");
-
- //add new custom data
- $this->click("//a[@id='newCustomDataGroup']/span");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- //fill custom group title
- $customGroupTitle = 'Custom ' . substr(sha1(rand()), 0, 7);
- $this->click('title');
- $this->type('title', $customGroupTitle);
-
- //custom group extends
- $this->click('extends[0]');
- $this->select('extends[0]', "value=Contact");
- $this->click("//option[@value='Contact']");
- $this->clickLink('_qf_Group_next-bottom');
-
- //Is custom group created?
- $this->waitForText('crm-notification-container', $customGroupTitle);
- $this->waitForElementPresent('_qf_Field_cancel-bottom');
- $gid = $this->urlArg('gid');
-
- // create another custom field - Date
- $customField = 'Custom field ' . substr(sha1(rand()), 0, 4);
- $this->type('label', $customField);
-
- //enter pre help message
- $this->type("help_pre", "this is field pre help");
-
- //enter post help message
- $this->type("help_post", "this field post help");
-
- //Is searchable?
- $this->click("is_searchable");
-
- // clicking save
- $this->click('_qf_Field_done-bottom');
- $this->waitForElementPresent("xpath=//div[@id='field_page']//table/tbody//tr/td");
-
- $this->waitForText('crm-notification-container', "Custom field '{$customField}' has been saved.");
- $customFieldId = explode('&id=', $this->getAttribute("xpath=//div[@id='field_page']//table/tbody//tr/td/div[text()='$customField']/../../td[8]/span/a@href"));
- $customFieldId = $customFieldId[1];
-
- return array("custom_{$customFieldId}", $customField, $customGroupTitle);
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'WebTest/Import/ImportCiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Import_ContactSubtypeTest
- */
-class WebTest_Import_ContactSubtypeTest extends ImportCiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- /**
- * Test contact import for Individuals Subtype.
- */
- public function testIndividualSubtypeImport() {
- $this->webtestLogin();
-
- // Get sample import data.
- list($headers, $rows) = $this->_individualSubtypeCSVData();
-
- // Import and check Individual contacts in Skip mode with contact type Parent.
- $other = array('contactSubtype' => 'Parent');
-
- $this->importContacts($headers, $rows, 'Individual', 'Skip', array(), $other);
-
- // Get imported contact Ids
- $importedContactIds = $this->_getImportedContactIds($rows);
-
- // Build update mode import headers
- $updateHeaders = array(
- 'contact_id' => 'Internal Contact ID',
- 'first_name' => 'First Name',
- 'last_name' => 'Last Name',
- );
-
- // Create update mode import rows
- $updateRows = array();
- foreach ($importedContactIds as $cid) {
- $updateRows[$cid] = array(
- 'contact_id' => $cid,
- 'first_name' => substr(sha1(rand()), 0, 7),
- 'last_name' => 'Anderson' . substr(sha1(rand()), 0, 7),
- );
- }
-
- // Import and check Individual contacts in Update mode with contact type Parent.
- $this->importContacts($updateHeaders, $updateRows, 'Individual', 'Update', array(), $other);
-
- // Visit contacts to check updated data.
- foreach ($updateRows as $updatedRow) {
- $this->openCiviPage("contact/view", "reset=1&cid={$updatedRow['contact_id']}");
- $displayName = "{$updatedRow['first_name']} {$updatedRow['last_name']}";
- $this->assertTrue($this->isTextPresent("$displayName"), "Contact did not update!");
- }
-
- // Headers that should not updated.
- $fillHeaders = $updateHeaders;
-
- // Headers that should fill.
- $fillHeaders['gender'] = 'Gender';
- $fillHeaders['dob'] = 'Birth Date';
-
- $fillRows = array();
- foreach ($importedContactIds as $cid) {
- $fillRows[$cid] = array(
- 'contact_id' => $cid,
- // should not update
- 'first_name' => substr(sha1(rand()), 0, 7),
- // should not update
- 'last_name' => 'Anderson' . substr(sha1(rand()), 0, 7),
- 'gender' => 'Male',
- 'dob' => '1986-04-16',
- );
- }
-
- // Import and check Individual contacts in Update mode with contact type Parent.
- $this->importContacts($fillHeaders, $fillRows, 'Individual', 'Fill', array(), $other);
-
- // Visit contacts to check filled data.
- foreach ($fillRows as $cid => $fillRow) {
- $this->openCiviPage("contact/view", "reset=1&cid={$fillRow['contact_id']}");
-
- // Check old display name.
- $displayName = "{$updateRows[$cid]['first_name']} {$updateRows[$cid]['last_name']}";
- $this->assertTrue($this->isTextPresent("$displayName"), "Contact should not update in fill mode!");
-
- $this->verifyText("css=div#contact-summary div.crm-contact-gender_display", preg_quote($fillRow['gender']));
- }
-
- // Recreate same conacts using 'No Duplicate Checking' with contact type Parent.
- $this->importContacts($headers, $rows, 'Individual', 'No Duplicate Checking', array(), $other);
- }
-
- /**
- * Test contact import for Organization Subtype.
- */
- public function testOrganizationSubtypeImport() {
- $this->webtestLogin();
-
- // Get sample import data.
- list($headers, $rows) = $this->_organizationSubtypeCSVData();
-
- // Import and check Organization contacts
- $other = array('contactSubtype' => 'Team');
-
- $this->importContacts($headers, $rows, 'Organization', 'Skip', array(), $other);
-
- // Get imported contact Ids
- $importedContactIds = $this->_getImportedContactIds($rows, 'Organization');
-
- // Build update mode import headers
- $updateHeaders = array(
- 'contact_id' => 'Internal Contact ID',
- 'organization_name' => 'Organization Name',
- );
-
- // Create update mode import rows
- $updateRows = array();
- foreach ($importedContactIds as $cid) {
- $updateRows[$cid] = array(
- 'contact_id' => $cid,
- 'organization_name' => 'UpdatedOrg ' . substr(sha1(rand()), 0, 7),
- );
- }
-
- // Import and check Individual contacts in Update mode with contact type Team.
- $this->importContacts($updateHeaders, $updateRows, 'Organization', 'Update', array(), $other);
-
- // Visit contacts to check updated data.
- foreach ($updateRows as $updatedRow) {
- $organizationName = $updatedRow['organization_name'];
- $this->openCiviPage("contact/view", "reset=1&cid={$updatedRow['contact_id']}");
-
- $this->assertTrue($this->isTextPresent("$organizationName"), "Contact did not update!");
- }
-
- // Headers that should not updated.
- $fillHeaders = $updateHeaders;
-
- // Headers that should fill.
- $fillHeaders['legal_name'] = 'Legal Name';
-
- $fillRows = array();
- foreach ($importedContactIds as $cid) {
- $fillRows[$cid] = array(
- 'contact_id' => $cid,
- // should not update
- 'organization_name' => 'UpdateOrg ' . substr(sha1(rand()), 0, 7),
- 'legal_name' => 'org ' . substr(sha1(rand()), 0, 7),
- );
- }
-
- // Import and check Individual contacts in Update mode with contact type Team.
- $this->importContacts($fillHeaders, $fillRows, 'Organization', 'Fill', array(), $other);
-
- // Visit contacts to check filled data.
- foreach ($fillRows as $cid => $fillRow) {
- $this->openCiviPage("contact/view", "reset=1&cid={$fillRow['contact_id']}");
-
- // Check old Organization name.
- $organizationName = $updateRows[$cid]['organization_name'];
- $this->assertTrue($this->isTextPresent("$organizationName"), "Contact should not update in fill mode!");
- $this->verifyText("xpath=//div[@id='crm-contactinfo-content']/div/div[3]/div[2]", preg_quote($fillRow['legal_name']));
- }
-
- // Recreate same conacts using 'No Duplicate Checking' with contact type Team.
- $this->importContacts($headers, $rows, 'Organization', 'No Duplicate Checking', array(), $other);
- }
-
- /**
- * Test contact import for Household Subtype.
- */
- public function testHouseholdSubtypeImport() {
- $this->webtestLogin();
-
- // Create Household Subtype
- $householdSubtype = $this->_createHouseholdSubtype();
-
- // Get sample import data.
- list($headers, $rows) = $this->_householdSubtypeCSVData();
-
- // Import and check Organization contacts
- $other = array('contactSubtype' => $householdSubtype);
-
- $this->importContacts($headers, $rows, 'Household', 'Skip', array(), $other);
-
- // Get imported contact Ids
- $importedContactIds = $this->_getImportedContactIds($rows, 'Household');
-
- // Build update mode import headers
- $updateHeaders = array(
- 'contact_id' => 'Internal Contact ID',
- 'household_name' => 'Household Name',
- );
-
- // Create update mode import rows
- $updateRows = array();
- foreach ($importedContactIds as $cid) {
- $updateRows[$cid] = array(
- 'contact_id' => $cid,
- 'household_name' => 'UpdatedHousehold ' . substr(sha1(rand()), 0, 7),
- );
- }
-
- // Import and check Individual contacts in Update mode.
- $this->importContacts($updateHeaders, $updateRows, 'Household', 'Update', array(), $other);
-
- // Visit contacts to check updated data.
- foreach ($updateRows as $updatedRow) {
- $householdName = $updatedRow['household_name'];
- $this->openCiviPage("contact/view", "reset=1&cid={$updatedRow['contact_id']}");
-
- $this->assertTrue($this->isTextPresent("$householdName"), "Contact did not update!");
- }
-
- // Headers that should not updated.
- $fillHeaders = $updateHeaders;
-
- // Headers that should fill.
- $fillHeaders['nick_name'] = 'Nick Name';
-
- $fillRows = array();
- foreach ($importedContactIds as $cid) {
- $fillRows[$cid] = array(
- 'contact_id' => $cid,
- // should not update
- 'household_name' => 'UpdatedHousehold ' . substr(sha1(rand()), 0, 7),
- 'nick_name' => 'Household ' . substr(sha1(rand()), 0, 7),
- );
- }
-
- // Import and check Individual contacts in Update mode.
- $this->importContacts($fillHeaders, $fillRows, 'Household', 'Fill', array(), $other);
-
- // Visit contacts to check filled data.
- foreach ($fillRows as $cid => $fillRow) {
- $this->openCiviPage("contact/view", "reset=1&cid={$fillRow['contact_id']}");
-
- // Check old Household name.
- $householdName = $updateRows[$cid]['household_name'];
- $this->assertTrue($this->isTextPresent("$householdName"), "Contact should not update in fill mode!");
- $this->verifyText("xpath=//div[@id='crm-contactinfo-content']/div/div[2]/div[2]", preg_quote($fillRow['nick_name']));
- }
-
- // Recreate same conacts using 'No Duplicate Checking'
- $this->importContacts($headers, $rows, 'Household', 'No Duplicate Checking', array(), $other);
- }
-
- /*
- * Helper function to create Household Subtype.
- */
- /**
- * @return string
- */
- public function _createHouseholdSubtype() {
-
- // Visit to create contact subtype
- $this->openCiviPage("admin/options/subtype", "action=add&reset=1");
-
- // Create Household subtype
- $householdSubtype = substr(sha1(rand()), 0, 7);
- $this->type("label", $householdSubtype);
- $this->select("parent_id", "label=Household");
- $this->click("_qf_ContactType_next-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- return $householdSubtype;
- }
-
- /*
- * Helper function to provide data for contact import for Individuals Subtype.
- */
- /**
- * @return array
- */
- public function _individualSubtypeCSVData() {
- $headers = array(
- 'first_name' => 'First Name',
- 'middle_name' => 'Middle Name',
- 'last_name' => 'Last Name',
- 'email' => 'Email',
- 'phone' => 'Phone',
- 'address_1' => 'Additional Address 1',
- 'address_2' => 'Additional Address 2',
- 'city' => 'City',
- 'state' => 'State',
- 'country' => 'Country',
- );
-
- $rows = array(
- array(
- 'first_name' => substr(sha1(rand()), 0, 7),
- 'middle_name' => substr(sha1(rand()), 0, 7),
- 'last_name' => 'Anderson',
- 'email' => substr(sha1(rand()), 0, 7) . '@example.com',
- 'phone' => '6949912154',
- 'address_1' => 'Add 1',
- 'address_2' => 'Add 2',
- 'city' => 'Watson',
- 'state' => 'NY',
- 'country' => 'UNITED STATES',
- ),
- array(
- 'first_name' => substr(sha1(rand()), 0, 7),
- 'middle_name' => substr(sha1(rand()), 0, 7),
- 'last_name' => 'Summerson',
- 'email' => substr(sha1(rand()), 0, 7) . '@example.com',
- 'phone' => '6944412154',
- 'address_1' => 'Add 1',
- 'address_2' => 'Add 2',
- 'city' => 'Watson',
- 'state' => 'NY',
- 'country' => 'UNITED STATES',
- ),
- );
-
- return array($headers, $rows);
- }
-
- /*
- * Helper function to provide data for contact import for Organizations Subtype.
- */
- /**
- * @return array
- */
- public function _organizationSubtypeCSVData() {
- $headers = array(
- 'organization_name' => 'Organization Name',
- 'email' => 'Email',
- 'phone' => 'Phone',
- 'address_1' => 'Additional Address 1',
- 'address_2' => 'Additional Address 2',
- 'city' => 'City',
- 'state' => 'State',
- 'country' => 'Country',
- );
-
- $rows = array(
- array(
- 'organization_name' => 'org_' . substr(sha1(rand()), 0, 7),
- 'email' => substr(sha1(rand()), 0, 7) . '@example.org',
- 'phone' => '9949912154',
- 'address_1' => 'Add 1',
- 'address_2' => 'Add 2',
- 'city' => 'Watson',
- 'state' => 'NY',
- 'country' => 'UNITED STATES',
- ),
- array(
- 'organization_name' => 'org_' . substr(sha1(rand()), 0, 7),
- 'email' => substr(sha1(rand()), 0, 7) . '@example.org',
- 'phone' => '6949412154',
- 'address_1' => 'Add 1',
- 'address_2' => 'Add 2',
- 'city' => 'Watson',
- 'state' => 'NY',
- 'country' => 'UNITED STATES',
- ),
- );
-
- return array($headers, $rows);
- }
-
- /*
- * Helper function to provide data for contact import for Household Subtype.
- */
- /**
- * @return array
- */
- public function _householdSubtypeCSVData() {
- $headers = array(
- 'household_name' => 'Household Name',
- 'email' => 'Email',
- 'phone' => 'Phone',
- 'address_1' => 'Additional Address 1',
- 'address_2' => 'Additional Address 2',
- 'city' => 'City',
- 'state' => 'State',
- 'country' => 'Country',
- );
-
- $rows = array(
- array(
- 'household_name' => 'household_' . substr(sha1(rand()), 0, 7),
- 'email' => substr(sha1(rand()), 0, 7) . '@example.org',
- 'phone' => '3949912154',
- 'address_1' => 'Add 1',
- 'address_2' => 'Add 2',
- 'city' => 'Watson',
- 'state' => 'NY',
- 'country' => 'UNITED STATES',
- ),
- array(
- 'household_name' => 'household_' . substr(sha1(rand()), 0, 7),
- 'email' => substr(sha1(rand()), 0, 7) . '@example.org',
- 'phone' => '5949412154',
- 'address_1' => 'Add 1',
- 'address_2' => 'Add 2',
- 'city' => 'Watson',
- 'state' => 'NY',
- 'country' => 'UNITED STATES',
- ),
- );
-
- return array($headers, $rows);
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'WebTest/Import/ImportCiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Import_ContactTest
- */
-class WebTest_Import_ContactTest extends ImportCiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- /**
- * Test contact import for Individuals.
- */
- public function testIndividualImport() {
- $this->webtestLogin();
-
- // Get sample import data.
- list($headers, $rows) = $this->_individualCSVData();
-
- // Import and check Individual contacts in Skip mode.
- $other = array(
- 'saveMapping' => TRUE,
- 'createGroup' => TRUE,
- 'createTag' => TRUE,
- );
-
- $this->importContacts($headers, $rows, 'Individual', 'Skip', array(), $other);
-
- // Get imported contact Ids
- $importedContactIds = $this->_getImportedContactIds($rows);
-
- // Build update mode import headers
- $updateHeaders = array(
- 'contact_id' => 'Internal Contact ID',
- 'first_name' => 'First Name',
- 'last_name' => 'Last Name',
- );
-
- // Create update mode import rows
- $updateRows = array();
- foreach ($importedContactIds as $cid) {
- $updateRows[$cid] = array(
- 'contact_id' => $cid,
- 'first_name' => substr(sha1(rand()), 0, 7),
- 'last_name' => 'Anderson' . substr(sha1(rand()), 0, 7),
- );
- }
-
- // Import and check Individual contacts in Update mode.
- $this->importContacts($updateHeaders, $updateRows, 'Individual', 'Update');
-
- // Visit contacts to check updated data.
- foreach ($updateRows as $updatedRow) {
- $this->openCiviPage("contact/view", "reset=1&cid={$updatedRow['contact_id']}");
-
- $displayName = "{$updatedRow['first_name']} {$updatedRow['last_name']}";
- $this->assertTrue($this->isTextPresent("$displayName"), "Contact did not update!");
- }
-
- // Headers that should not updated.
- $fillHeaders = $updateHeaders;
-
- // Headers that should fill.
- $fillHeaders['gender'] = 'Gender';
- $fillHeaders['dob'] = 'Birth Date';
-
- $fillRows = array();
- foreach ($importedContactIds as $cid) {
- $fillRows[$cid] = array(
- 'contact_id' => $cid,
- // should not update
- 'first_name' => substr(sha1(rand()), 0, 7),
- // should not update
- 'last_name' => 'Anderson' . substr(sha1(rand()), 0, 7),
- 'gender' => 'Male',
- 'dob' => '1986-04-16',
- );
- }
-
- // Import and check Individual contacts in Update mode.
- $this->importContacts($fillHeaders, $fillRows, 'Individual', 'Fill');
-
- // Visit contacts to check filled data.
- foreach ($fillRows as $cid => $fillRow) {
- $this->openCiviPage("contact/view", "reset=1&cid={$fillRow['contact_id']}");
-
- // Check old display name.
- $displayName = "{$updateRows[$cid]['first_name']} {$updateRows[$cid]['last_name']}";
- $this->assertTrue($this->isTextPresent("$displayName"), "Contact display name should not update in fill mode!");
-
- $this->verifyText("css=div#contact-summary div.crm-contact-gender_display", preg_quote($fillRow['gender']));
- }
-
- // Recreate same conacts using 'No Duplicate Checking'
- $this->importContacts($headers, $rows, 'Individual', 'No Duplicate Checking');
- }
-
- /**
- * Test contact import for Organization.
- */
- public function testOrganizationImport() {
-
- $this->webtestLogin();
-
- // Get sample import data.
- list($headers, $rows) = $this->_organizationCSVData();
-
- // Import and check Organization contacts
- $other = array(
- 'saveMapping' => TRUE,
- 'createGroup' => TRUE,
- 'createTag' => TRUE,
- );
-
- $this->importContacts($headers, $rows, 'Organization', 'Skip', array(), $other);
-
- // Get imported contact Ids
- $importedContactIds = $this->_getImportedContactIds($rows, 'Organization');
-
- // Build update mode import headers
- $updateHeaders = array(
- 'contact_id' => 'Internal Contact ID',
- 'organization_name' => 'Organization Name',
- );
-
- // Create update mode import rows
- $updateRows = array();
- foreach ($importedContactIds as $cid) {
- $updateRows[$cid] = array(
- 'contact_id' => $cid,
- 'organization_name' => 'UpdatedOrg ' . substr(sha1(rand()), 0, 7),
- );
- }
-
- // Import and check Individual contacts in Update mode.
- $this->importContacts($updateHeaders, $updateRows, 'Organization', 'Update');
-
- // Visit contacts to check updated data.
- foreach ($updateRows as $updatedRow) {
- $organizationName = $updatedRow['organization_name'];
- $this->openCiviPage("contact/view", "reset=1&cid={$updatedRow['contact_id']}");
-
- $this->assertTrue($this->isTextPresent("$organizationName"), "Contact did not update!");
- }
-
- // Headers that should not updated.
- $fillHeaders = $updateHeaders;
-
- // Headers that should fill.
- $fillHeaders['legal_name'] = 'Legal Name';
-
- $fillRows = array();
- foreach ($importedContactIds as $cid) {
- $fillRows[$cid] = array(
- 'contact_id' => $cid,
- // should not update
- 'organization_name' => 'UpdateOrg ' . substr(sha1(rand()), 0, 7),
- 'legal_name' => 'org ' . substr(sha1(rand()), 0, 7),
- );
- }
-
- // Import and check Individual contacts in Update mode.
- $this->importContacts($fillHeaders, $fillRows, 'Organization', 'Fill');
-
- // Visit contacts to check filled data.
- foreach ($fillRows as $cid => $fillRow) {
- $this->openCiviPage("contact/view", "reset=1&cid={$fillRow['contact_id']}");
-
- // Check old Organization name.
- $organizationName = $updateRows[$cid]['organization_name'];
- $this->assertTrue($this->isTextPresent("$organizationName"), "Contact should not update in fill mode!");
- $this->verifyText("xpath=//div[@id='crm-contactinfo-content']/div/div[3]/div[2]", preg_quote($fillRow['legal_name']));
- }
-
- // Recreate same conacts using 'No Duplicate Checking'
- $this->importContacts($headers, $rows, 'Organization', 'No Duplicate Checking');
- }
-
- /**
- * Test contact import for Household.
- */
- public function testHouseholdImport() {
-
- $this->webtestLogin();
-
- // Get sample import data.
- list($headers, $rows) = $this->_householdCSVData();
-
- // Import and check Household contacts
- $other = array(
- 'saveMapping' => TRUE,
- 'createGroup' => TRUE,
- 'createTag' => TRUE,
- );
-
- $this->importContacts($headers, $rows, 'Household', 'Skip', array(), $other);
-
- // Get imported contact Ids
- $importedContactIds = $this->_getImportedContactIds($rows, 'Household');
-
- // Build update mode import headers
- $updateHeaders = array(
- 'contact_id' => 'Internal Contact ID',
- 'household_name' => 'Household Name',
- );
-
- // Create update mode import rows
- $updateRows = array();
- foreach ($importedContactIds as $cid) {
- $updateRows[$cid] = array(
- 'contact_id' => $cid,
- 'household_name' => 'UpdatedHousehold ' . substr(sha1(rand()), 0, 7),
- );
- }
-
- // Import and check Individual contacts in Update mode.
- $this->importContacts($updateHeaders, $updateRows, 'Household', 'Update');
-
- // Visit contacts to check updated data.
- foreach ($updateRows as $updatedRow) {
- $householdName = $updatedRow['household_name'];
- $this->openCiviPage("contact/view", "reset=1&cid={$updatedRow['contact_id']}");
-
- $this->assertTrue($this->isTextPresent("$householdName"), "Contact did not update!");
- }
-
- // Headers that should not updated.
- $fillHeaders = $updateHeaders;
-
- // Headers that should fill.
- $fillHeaders['nick_name'] = 'Nick Name';
-
- $fillRows = array();
- foreach ($importedContactIds as $cid) {
- $fillRows[$cid] = array(
- 'contact_id' => $cid,
- // should not update
- 'household_name' => 'UpdatedHousehold ' . substr(sha1(rand()), 0, 7),
- 'nick_name' => 'Household ' . substr(sha1(rand()), 0, 7),
- );
- }
-
- // Import and check Individual contacts in Update mode.
- $this->importContacts($fillHeaders, $fillRows, 'Household', 'Fill');
-
- // Visit contacts to check filled data.
- foreach ($fillRows as $cid => $fillRow) {
- $this->openCiviPage("contact/view", "reset=1&cid={$fillRow['contact_id']}");
-
- // Check old Household name.
- $householdName = $updateRows[$cid]['household_name'];
- $this->assertTrue($this->isTextPresent("$householdName"), "Contact should not update in fill mode!");
- $this->verifyText("xpath=//div[@id='crm-contactinfo-content']/div/div[2]/div[2]", preg_quote($fillRow['nick_name']));
- }
-
- // Recreate same conacts using 'No Duplicate Checking'
- $this->importContacts($headers, $rows, 'Household', 'No Duplicate Checking');
- }
-
- /*
- * Helper function to provide data for contact import for Individuals.
- */
- /**
- * @return array
- */
- public function _individualCSVData() {
- $headers = array(
- 'first_name' => 'First Name',
- 'middle_name' => 'Middle Name',
- 'last_name' => 'Last Name',
- 'email' => 'Email',
- 'phone' => 'Phone',
- 'address_1' => 'Additional Address 1',
- 'address_2' => 'Additional Address 2',
- 'city' => 'City',
- 'state' => 'State',
- 'country' => 'Country',
- );
-
- $rows = array(
- array(
- 'first_name' => substr(sha1(rand()), 0, 7),
- 'middle_name' => substr(sha1(rand()), 0, 7),
- 'last_name' => 'Anderson',
- 'email' => substr(sha1(rand()), 0, 7) . '@example.com',
- 'phone' => '6949912154',
- 'address_1' => 'Add 1',
- 'address_2' => 'Add 2',
- 'city' => 'Watson',
- 'state' => 'NY',
- 'country' => 'UNITED STATES',
- ),
- array(
- 'first_name' => substr(sha1(rand()), 0, 7),
- 'middle_name' => substr(sha1(rand()), 0, 7),
- 'last_name' => 'Summerson',
- 'email' => substr(sha1(rand()), 0, 7) . '@example.com',
- 'phone' => '6944412154',
- 'address_1' => 'Add 1',
- 'address_2' => 'Add 2',
- 'city' => 'Watson',
- 'state' => 'NY',
- 'country' => 'UNITED STATES',
- ),
- );
-
- return array($headers, $rows);
- }
-
- /*
- * Helper function to provide data for contact import for Organizations.
- */
- /**
- * @return array
- */
- public function _organizationCSVData() {
- $headers = array(
- 'organization_name' => 'Organization Name',
- 'email' => 'Email',
- 'phone' => 'Phone',
- 'address_1' => 'Additional Address 1',
- 'address_2' => 'Additional Address 2',
- 'city' => 'City',
- 'state' => 'State',
- 'country' => 'Country',
- );
-
- $rows = array(
- array(
- 'organization_name' => 'org_' . substr(sha1(rand()), 0, 7),
- 'email' => substr(sha1(rand()), 0, 7) . '@example.org',
- 'phone' => '9949912154',
- 'address_1' => 'Add 1',
- 'address_2' => 'Add 2',
- 'city' => 'Watson',
- 'state' => 'NY',
- 'country' => 'UNITED STATES',
- ),
- array(
- 'organization_name' => 'org_' . substr(sha1(rand()), 0, 7),
- 'email' => substr(sha1(rand()), 0, 7) . '@example.org',
- 'phone' => '6949412154',
- 'address_1' => 'Add 1',
- 'address_2' => 'Add 2',
- 'city' => 'Watson',
- 'state' => 'NY',
- 'country' => 'UNITED STATES',
- ),
- );
-
- return array($headers, $rows);
- }
-
- /*
- * Helper function to provide data for contact import for Household.
- */
- /**
- * @return array
- */
- public function _householdCSVData() {
- $headers = array(
- 'household_name' => 'Household Name',
- 'email' => 'Email',
- 'phone' => 'Phone',
- 'address_1' => 'Additional Address 1',
- 'address_2' => 'Additional Address 2',
- 'city' => 'City',
- 'state' => 'State',
- 'country' => 'Country',
- );
-
- $rows = array(
- array(
- 'household_name' => 'household_' . substr(sha1(rand()), 0, 7),
- 'email' => substr(sha1(rand()), 0, 7) . '@example.org',
- 'phone' => '3949912154',
- 'address_1' => 'Add 1',
- 'address_2' => 'Add 2',
- 'city' => 'Watson',
- 'state' => 'NY',
- 'country' => 'UNITED STATES',
- ),
- array(
- 'household_name' => 'household_' . substr(sha1(rand()), 0, 7),
- 'email' => substr(sha1(rand()), 0, 7) . '@example.org',
- 'phone' => '5949412154',
- 'address_1' => 'Add 1',
- 'address_2' => 'Add 2',
- 'city' => 'Watson',
- 'state' => 'NY',
- 'country' => 'UNITED STATES',
- ),
- );
-
- return array($headers, $rows);
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'WebTest/Import/ImportCiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Import_ContributionTest
- */
-class WebTest_Import_ContributionTest extends ImportCiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testContributionImportIndividual() {
-
- $this->webtestLogin();
-
- // Get sample import data.
- list($headers, $rows) = $this->_contributionIndividualCSVData();
-
- // Create and import csv from provided data and check imported data.
- $fieldMapper = array(
- 'mapper[0][0]' => 'email',
- 'mapper[2][0]' => 'financial_type',
- 'mapper[4][0]' => 'total_amount',
- );
- $this->importCSVComponent('Contribution', $headers, $rows, 'Individual', 'Insert new contributions', $fieldMapper);
- }
-
- public function testContributionImportOrganization() {
-
- $this->webtestLogin();
-
- // Get sample import data.
- list($headers, $rows) = $this->_contributionOrganizationCSVData();
- $fieldMapper = array(
- 'mapper[0][0]' => 'organization_name',
- 'mapper[2][0]' => 'financial_type',
- 'mapper[4][0]' => 'total_amount',
- );
- $this->importCSVComponent('Contribution', $headers, $rows, 'Organization', 'Insert new contributions', $fieldMapper);
- }
-
- public function testContributionImportHousehold() {
-
- $this->webtestLogin();
-
- // Get sample import data.
- list($headers, $rows) = $this->_contributionHouseholdCSVData();
- $fieldMapper = array(
- 'mapper[0][0]' => 'household_name',
- 'mapper[2][0]' => 'financial_type',
- 'mapper[4][0]' => 'total_amount',
- );
- $this->importCSVComponent('Contribution', $headers, $rows, 'Household', 'Insert new contributions', $fieldMapper);
- }
-
- /**
- * @return array
- */
- public function _contributionIndividualCSVData() {
- $firstName1 = substr(sha1(rand()), 0, 7);
- $email1 = 'mail_' . substr(sha1(rand()), 0, 7) . '@example.com';
- $this->webtestAddContact($firstName1, 'Anderson', $email1);
-
- $firstName2 = substr(sha1(rand()), 0, 7);
- $email2 = 'mail_' . substr(sha1(rand()), 0, 7) . '@example.com';
- $this->webtestAddContact($firstName2, 'Anderson', $email2);
-
- $headers = array(
- 'email' => 'Email',
- 'fee_amount' => 'Fee Amount',
- 'financial_type' => 'Financial Type',
- 'contribution_status_id' => 'Contribution Status',
- 'total_amount' => 'Total Amount',
- );
-
- $rows = array(
- array(
- 'email' => $email1,
- 'fee_amount' => '200',
- 'financial_type' => 'Donation',
- 'contribution_status_id' => 'Completed',
- 'total_amount' => '200',
- ),
- array(
- 'email' => $email2,
- 'fee_amount' => '400',
- 'financial_type' => 'Donation',
- 'contribution_status_id' => 'Completed',
- 'total_amount' => '400',
- ),
- );
-
- return array($headers, $rows);
- }
-
- /**
- * @return array
- */
- public function _contributionHouseholdCSVData() {
- $household1 = substr(sha1(rand()), 0, 7) . ' home';
- $this->webtestAddHousehold($household1, TRUE);
-
- $household2 = substr(sha1(rand()), 0, 7) . ' home';
- $this->webtestAddHousehold($household2, TRUE);
-
- $headers = array(
- 'household' => 'Household Name',
- 'fee_amount' => 'Fee Amount',
- 'financial_type' => 'financial Type',
- 'contribution_status_id' => 'Contribution Status',
- 'total_amount' => 'Total Amount',
- );
-
- $rows = array(
- array(
- 'household' => $household1,
- 'fee_amount' => '200',
- 'financial_type' => 'Donation',
- 'contribution_status_id' => 'Completed',
- 'total_amount' => '200',
- ),
- array(
- 'household' => $household2,
- 'fee_amount' => '400',
- 'financial_type' => 'Donation',
- 'contribution_status_id' => 'Completed',
- 'total_amount' => '400',
- ),
- );
-
- return array($headers, $rows);
- }
-
- /**
- * @return array
- */
- public function _contributionOrganizationCSVData() {
- $organization1 = substr(sha1(rand()), 0, 7) . ' org';
- $this->webtestAddOrganization($organization1, TRUE);
-
- $organization2 = substr(sha1(rand()), 0, 7) . ' org';
- $this->webtestAddOrganization($organization2, TRUE);
-
- $headers = array(
- 'organization' => 'Organization Name',
- 'fee_amount' => 'Fee Amount',
- 'financial_type' => 'Financial Type',
- 'contribution_status_id' => 'Contribution Status',
- 'total_amount' => 'Total Amount',
- );
-
- $rows = array(
- array(
- 'organization' => $organization1,
- 'fee_amount' => '200',
- 'financial_type' => 'Donation',
- 'contribution_status_id' => 'Completed',
- 'total_amount' => '200',
- ),
- array(
- 'organization' => $organization2,
- 'fee_amount' => '400',
- 'financial_type' => 'Donation',
- 'contribution_status_id' => 'Completed',
- 'total_amount' => '400',
- ),
- );
-
- return array($headers, $rows);
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'WebTest/Import/ImportCiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Import_CustomDataTest
- */
-class WebTest_Import_CustomDataTest extends ImportCiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testCustomDataImport() {
- $this->webtestLogin();
-
- $firstName1 = 'Ma_' . substr(sha1(rand()), 0, 7);
- $firstName2 = 'An_' . substr(sha1(rand()), 0, 7);
- $customGroupTitle = 'Custom ' . substr(sha1(rand()), 0, 7);
-
- $firstName3 = 'Ma' . substr(sha1(rand()), 0, 4);
- $this->webtestAddContact($firstName3, "Anderson", TRUE);
- $sortName3 = "$firstName3 Anderson";
- $id1 = $this->urlArg('cid');
-
- $firstName4 = 'Ma' . substr(sha1(rand()), 0, 4);
- $this->webtestAddContact($firstName4, "Anderson", TRUE);
- $sortName4 = "$firstName4 Anderson";
- $id2 = $this->urlArg('cid');
-
- // Get sample import data.
- list($headers, $rows, $customDataVerify) = $this->_individualCustomCSVData($customGroupTitle, $firstName1, $firstName2,
- $id1, $id2
- );
-
- // Import and check Individual contacts in Skip mode.
- $other = array(
- 'saveMapping' => TRUE,
- 'createGroup' => TRUE,
- 'createTag' => TRUE,
- );
-
- $this->importContacts($headers, $rows, 'Individual', 'Skip', array(), $other);
-
- // Find the contact
- $this->openCiviPage("contact/search", "reset=1", '_qf_Basic_refresh');
- $this->type('sort_name', $firstName1);
- $this->click('_qf_Basic_refresh');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->click("xpath=//div[@class='crm-search-results']/table/tbody/tr/td[11]/span/a[text()='View']");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- for ($cnt = 0; $cnt < 2; $cnt++) {
- foreach ($customDataVerify['rows'][$cnt] as $key => $values) {
- $rows[$cnt][$key] = $values;
- }
- }
-
- $CGTableId = preg_replace('/\s/', '_', trim($customGroupTitle));
- if ($this->isElementPresent("xpath=//table[@id='{$CGTableId}_0']")) {
- $this->click("xpath=//table[@id='{$CGTableId}_0']/tbody/tr[@class='columnheader']/td[@class='grouplabel']/a");
- }
- elseif ($this->isElementPresent("xpath=//table[@id='{$CGTableId}_1']")) {
- $this->click("xpath=//table[@id='{$CGTableId}_1']/tbody/tr[@class='columnheader']/td[@class='grouplabel']/a");
- }
-
- // Verify if custom data added
- $cnt = 1;
- foreach ($rows[0] as $key => $value) {
- if ($cnt == 4) {
- $value = date('F jS, Y');
- }
- elseif ($cnt == 7) {
- $value = $sortName3;
- }
- $this->assertTrue($this->isTextPresent($value));
- $cnt++;
- }
- }
-
- /**
- * Helper function to provide data for custom data import.
- *
- * @param $customGroupTitle
- * @param string $firstName1
- * @param string $firstName2
- * @param $id1
- * @param $id2
- *
- * @return array
- */
- public function _individualCustomCSVData($customGroupTitle, $firstName1, $firstName2, $id1, $id2) {
- list($customDataParams, $customDataVerify) = $this->_addCustomData($customGroupTitle, $id1, $id2);
-
- $headers = array(
- 'first_name' => 'First Name',
- 'last_name' => 'Last Name',
- 'email' => 'Email',
- );
-
- foreach ($customDataParams['headers'] as $key => $values) {
- $headers[$key] = $values;
- }
-
- $rows = array(
- array(
- 'first_name' => $firstName1,
- 'last_name' => 'Anderson',
- 'email' => substr(sha1(rand()), 0, 7) . '@example.com',
- ),
- array(
- 'first_name' => $firstName2,
- 'last_name' => 'Summerson',
- 'email' => substr(sha1(rand()), 0, 7) . '@example.com',
- ),
- );
-
- for ($cnt = 0; $cnt < 2; $cnt++) {
- foreach ($customDataParams['rows'][$cnt] as $key => $values) {
- $rows[$cnt][$key] = $values;
- }
- }
-
- return array($headers, $rows, $customDataVerify);
- }
-
- /**
- * @param $customGroupTitle
- * @param $id1
- * @param $id2
- *
- * @return array
- */
- public function _addCustomData($customGroupTitle, $id1, $id2) {
-
- $this->openCiviPage("admin/custom/group", "reset=1");
-
- //add new custom data
- $this->click("//a[@id='newCustomDataGroup']/span");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- //fill custom group title
- $this->click("title");
- $this->type("title", $customGroupTitle);
-
- //custom group extends
- $this->click("extends[0]");
- $this->select("extends[0]", "value=Contact");
- $this->click("//option[@value='Contact']");
- $this->clickLink('_qf_Group_next-bottom');
-
- //Is custom group created?
- $this->assertTrue($this->isTextPresent("Your custom field set '{$customGroupTitle}' has been added. You can add custom fields now."));
- $this->waitForElementPresent('_qf_Field_cancel-bottom');
- $url = explode('gid=', $this->getLocation());
- $gid = $url[1];
-
- // create another custom field - Date
- $dateFieldLabel = 'custom_field_date_' . substr(sha1(rand()), 0, 4);
- $this->type('label', $dateFieldLabel);
- $this->click('data_type[0]');
- $this->select('data_type[0]', "label=Date");
- $this->waitForElementPresent('start_date_years');
-
- // enter years prior to current date
- $this->type('start_date_years', 3);
-
- // enter years up to the end year
- $this->type('end_date_years', 3);
-
- // select the date and time format
- $this->select('date_format', "value=yy-mm-dd");
- $this->select('time_format', "value=2");
-
- //enter pre help message
- $this->type("help_pre", "this is field pre help");
-
- //enter post help message
- $this->type("help_post", "this field post help");
-
- //Is searchable?
- $this->click("is_searchable");
-
- // clicking save
- $this->click('_qf_Field_done-bottom');
- $this->waitForElementPresent('newCustomField');
-
- $this->waitForText('crm-notification-container', "Custom field '{$dateFieldLabel}' has been saved.");
-
- $this->assertTrue($this->isTextPresent($dateFieldLabel), 'Missing text: ' . $dateFieldLabel);
- $dateFieldId = explode('&id=', $this->getAttribute("xpath=//div[@id='field_page']//table/tbody//tr/td/div[text()='$dateFieldLabel']/../../td[8]/span/a@href"));
- $dateFieldId = $dateFieldId[1];
-
- // create another custom field - Integer Radio
- $this->click("//a[@id='newCustomField']/span");
- $this->waitForElementPresent('_qf_Field_cancel-bottom');
- $this->click("data_type[0]");
- $this->select("data_type[0]", "value=1");
- $this->click("//option[@value='1']");
- $this->click("data_type[1]");
- $this->select("data_type[1]", "value=Radio");
- $this->click("//option[@value='Radio']");
-
- $radioFieldLabel = 'custom_field_radio' . substr(sha1(rand()), 0, 4);
- $this->type("label", $radioFieldLabel);
- $radioOptionLabel1 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
- $this->type("option_label_1", $radioOptionLabel1);
- $this->type("option_value_1", "1");
- $radioOptionLabel2 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
- $this->type("option_label_2", $radioOptionLabel2);
- $this->type("option_value_2", "2");
-
- //select options per line
- $this->type("options_per_line", "3");
-
- //enter pre help msg
- $this->type("help_pre", "this is field pre help");
-
- //enter post help msg
- $this->type("help_post", "this is field post help");
-
- //Is searchable?
- $this->click("is_searchable");
-
- //clicking save
- $this->click("_qf_Field_done");
- $this->waitForElementPresent('newCustomField');
-
- //Is custom field created
- $this->waitForText("crm-notification-container", "Custom field '$radioFieldLabel' has been saved.");
- $this->waitForElementPresent("xpath=//div[@id='field_page']//table/tbody//tr/td/div[text()='$radioFieldLabel']/parent::td/parent::tr/td[8]/span/a");
- $radioFieldId = explode('&id=', $this->getAttribute("xpath=//div[@id='field_page']//table/tbody//tr/td/div[text()='$radioFieldLabel']/../../td[8]/span/a@href"));
- $radioFieldId = $radioFieldId[1];
-
- // create another custom field - multiselect
- $this->click("//a[@id='newCustomField']/span");
- $this->waitForElementPresent('_qf_Field_cancel-bottom');
- $multiSelectLabel = 'custom_field_multiSelect_' . substr(sha1(rand()), 0, 4);
- $this->type('label', $multiSelectLabel);
- $this->click('data_type[1]');
- $this->select('data_type[1]', "label=Multi-Select");
- $this->waitForElementPresent('option_label_1');
-
- // enter multiple choice options
- $multiSelectOptionLabel1 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
- $this->type('option_label_1', $multiSelectOptionLabel1);
- $this->type('option_value_1', 1);
- $multiSelectOptionLabel2 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
- $this->type('option_label_2', $multiSelectOptionLabel2);
- $this->type('option_value_2', 2);
- $this->click("link=another choice");
- $multiSelectOptionLabel3 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
- $this->type('option_label_3', $multiSelectOptionLabel3);
- $this->type('option_value_3', 3);
- $this->click("link=another choice");
-
- //enter pre help msg
- $this->type("help_pre", "this is field pre help");
-
- //enter post help msg
- $this->type("help_post", "this is field post help");
-
- //Is searchable?
- $this->click("is_searchable");
-
- // clicking save
- $this->click('_qf_Field_done-bottom');
- $this->waitForElementPresent('newCustomField');
- $this->waitForText("crm-notification-container", "Custom field '{$multiSelectLabel}' has been saved.");
- $this->waitForElementPresent("xpath=//div[@id='field_page']//table/tbody//tr/td/div[text()='$multiSelectLabel']/parent::td/parent::tr/");
- $multiSelectFieldId = explode('&id=', $this->getAttribute("xpath=//div[@id='field_page']//table/tbody//tr/td/div[text()='$multiSelectLabel']/parent::td/parent::tr/td[8]/span/a@href"));
- $multiSelectFieldId = $multiSelectFieldId[1];
-
- // create another custom field - contact reference
- $this->click("//a[@id='newCustomField']/span");
- $this->waitForElementPresent('_qf_Field_cancel-bottom');
- $contactReferenceLabel = 'custom_field_contactReference_' . substr(sha1(rand()), 0, 4);
- $this->type('label', $contactReferenceLabel);
- $this->click('data_type[0]');
- $this->select('data_type[0]', "label=Contact Reference");
-
- //enter pre help msg
- $this->type("help_pre", "this is field pre help");
-
- //enter post help msg
- $this->type("help_post", "this is field post help");
-
- //Is searchable?
- $this->click("is_searchable");
-
- // clicking save
- $this->click('_qf_Field_done-bottom');
- $this->waitForElementPresent('newCustomField');
-
- $this->waitForText("crm-notification-container", "Custom field '{$contactReferenceLabel}' has been saved.");
- $this->waitForElementPresent("xpath=//div[@id='field_page']//table/tbody//tr/td/div[text()='$contactReferenceLabel']/parent::td/parent::tr/");
- $contactReferenceFieldId = explode('&id=', $this->getAttribute("xpath=//div[@id='field_page']//table/tbody//tr/td/div[text()='$contactReferenceLabel']/parent::td/parent::tr/td[8]/span/a@href"));
- $contactReferenceFieldId = $contactReferenceFieldId[1];
-
- $customDataParams = array(
- 'headers' => array(
- "custom_{$dateFieldId}" => "$dateFieldLabel :: $customGroupTitle",
- "custom_{$radioFieldId}" => "$radioFieldLabel :: $customGroupTitle",
- "custom_{$multiSelectFieldId}" => "$multiSelectLabel :: $customGroupTitle",
- "custom_{$contactReferenceFieldId}" => "$contactReferenceLabel :: $customGroupTitle",
- ),
- 'rows' => array(
- 0 => array(
- "custom_{$dateFieldId}" => date('Y-m-d'),
- "custom_{$radioFieldId}" => '2',
- "custom_{$multiSelectFieldId}" => '3',
- "custom_{$contactReferenceFieldId}" => $id1,
- ),
- 1 => array(
- "custom_{$dateFieldId}" => date('Y-m-d', mktime(0, 0, 0, 4, 5, date('Y'))),
- "custom_{$radioFieldId}" => '1',
- "custom_{$multiSelectFieldId}" => '2',
- "custom_{$contactReferenceFieldId}" => $id2,
- ),
- ),
- );
-
- $customDataVerify = $customDataParams;
- $customDataVerify['rows'][0]["custom_{$radioFieldId}"] = $radioOptionLabel2;
- $customDataVerify['rows'][1]["custom_{$radioFieldId}"] = $radioOptionLabel1;
- $customDataVerify['rows'][0]["custom_{$multiSelectFieldId}"] = $multiSelectOptionLabel3;
- $customDataVerify['rows'][1]["custom_{$multiSelectFieldId}"] = $multiSelectOptionLabel2;
-
- return array($customDataParams, $customDataVerify);
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'WebTest/Import/ImportCiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Import_DateFormatTest
- */
-class WebTest_Import_DateFormatTest extends ImportCiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- /**
- * Test contact import for yyyy_mm_dd date format.
- */
- public function testDateFormat_yyyy_mm_dd() {
- $this->webtestLogin();
-
- // Get sample import data.
- list($headers, $rows) = $this->_individualCSVData_yyyy_mm_dd();
-
- // Import and check Individual contacts in Skip mode and yyyy-mm-dd OR yyyymmdd dateformat.
- $other = array('dateFormat' => 'yyyy-mm-dd OR yyyymmdd');
-
- $this->importContacts($headers, $rows, 'Individual', 'Skip', array(), $other);
- }
-
- /**
- * Test contact import for mm_dd_yy date format.
- */
- public function testDateFormat_mm_dd_yy() {
- $this->webtestLogin();
-
- // Get sample import data.
- list($headers, $rows) = $this->_individualCSVData_mm_dd_yy();
-
- // Import and check Individual contacts in Skip mode and
- // mm/dd/yy OR mm-dd-yy date format.
- $other = array('dateFormat' => 'mm/dd/yy OR mm-dd-yy');
-
- $this->importContacts($headers, $rows, 'Individual', 'Skip', array(), $other);
- }
-
- /**
- * Test contact import for mm_dd_yyyy date format.
- */
- public function testDateFormat_mm_dd_yyyy() {
- // 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
- $this->webtestLogin();
-
- // Get sample import data.
- list($headers, $rows) = $this->_individualCSVData_mm_dd_yyyy();
-
- // Import and check Individual contacts in Skip mode and
- // mm/dd/yyyy OR mm-dd-yyyy date format.
- $other = array('dateFormat' => 'mm/dd/yyyy OR mm-dd-yyyy');
-
- $this->importContacts($headers, $rows, 'Individual', 'Skip', array(), $other);
- }
-
- /**
- * Test contact import for Month_dd_yyyy date format.
- */
- public function testDateFormat_Month_dd_yyyy() {
- // 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
- $this->webtestLogin();
-
- // Get sample import data.
- list($headers, $rows) = $this->_individualCSVData_Month_dd_yyyy();
-
- // Import and check Individual contacts in Skip mode and
- // Month dd, yyyy date format.
- $other = array('dateFormat' => 'Month dd, yyyy');
-
- $this->importContacts($headers, $rows, 'Individual', 'Skip', array(), $other);
- }
-
- /**
- * Test contact import for dd_mon_yy date format.
- */
- public function testDateFormat_dd_mon_yy() {
- // 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
- $this->webtestLogin();
-
- // Get sample import data.
- list($headers, $rows) = $this->_individualCSVData_dd_mon_yy();
-
- // Import and check Individual contacts in Skip mode and
- // dd-mon-yy OR dd/mm/yy date format.
- $other = array('dateFormat' => 'dd-mon-yy OR dd/mm/yy');
-
- $this->importContacts($headers, $rows, 'Individual', 'Skip', array(), $other);
- }
-
- /**
- * Test contact import for dd_mm_yyyy date format.
- */
- public function testDateFormat_dd_mm_yyyy() {
- // 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
- $this->webtestLogin();
-
- // Get sample import data.
- list($headers, $rows) = $this->_individualCSVData_dd_mm_yyyy();
-
- // Import and check Individual contacts in Skip mode and
- // dd/mm/yyyy date format.
- $other = array('dateFormat' => 'dd/mm/yyyy');
-
- $this->importContacts($headers, $rows, 'Individual', 'Skip', array(), $other);
- }
-
- /**
- * Helper function to provide data for contact import for Individuals and yyyy-mm-dd OR yyyymmdd dateformat.
- */
- /**
- * @return array
- */
- public function _individualCSVData_yyyy_mm_dd() {
- $headers = array(
- 'first_name' => 'First Name',
- 'middle_name' => 'Middle Name',
- 'last_name' => 'Last Name',
- 'email' => 'Email',
- 'phone' => 'Phone',
- 'address_1' => 'Additional Address 1',
- 'address_2' => 'Additional Address 2',
- 'city' => 'City',
- 'state' => 'State',
- 'country' => 'Country',
- 'birth_date' => 'Birth Date',
- );
-
- $rows = array(
- array(
- 'first_name' => substr(sha1(rand()), 0, 7),
- 'middle_name' => substr(sha1(rand()), 0, 7),
- 'last_name' => 'Anderson',
- 'email' => substr(sha1(rand()), 0, 7) . '@example.com',
- 'phone' => '6949912154',
- 'address_1' => 'Add 1',
- 'address_2' => 'Add 2',
- 'city' => 'Watson',
- 'state' => 'NY',
- 'country' => 'UNITED STATES',
- 'birth_date' => '1998-12-25',
- ),
- array(
- 'first_name' => substr(sha1(rand()), 0, 7),
- 'middle_name' => substr(sha1(rand()), 0, 7),
- 'last_name' => 'Summerson',
- 'email' => substr(sha1(rand()), 0, 7) . '@example.com',
- 'phone' => '6944412154',
- 'address_1' => 'Add 1',
- 'address_2' => 'Add 2',
- 'city' => 'Watson',
- 'state' => 'NY',
- 'country' => 'UNITED STATES',
- 'birth_date' => '1999-11-26',
- ),
- );
-
- return array($headers, $rows);
- }
-
- /**
- * Helper function to provide data for contact import for Individuals and mm/dd/yy OR mm-dd-yy dateformat.
- */
- /**
- * @return array
- */
- public function _individualCSVData_mm_dd_yy() {
- $headers = array(
- 'first_name' => 'First Name',
- 'middle_name' => 'Middle Name',
- 'last_name' => 'Last Name',
- 'email' => 'Email',
- 'phone' => 'Phone',
- 'address_1' => 'Additional Address 1',
- 'address_2' => 'Additional Address 2',
- 'city' => 'City',
- 'state' => 'State',
- 'country' => 'Country',
- 'birth_date' => 'Birth Date',
- );
-
- $rows = array(
- array(
- 'first_name' => substr(sha1(rand()), 0, 7),
- 'middle_name' => substr(sha1(rand()), 0, 7),
- 'last_name' => 'Anderson',
- 'email' => substr(sha1(rand()), 0, 7) . '@example.com',
- 'phone' => '6949912154',
- 'address_1' => 'Add 1',
- 'address_2' => 'Add 2',
- 'city' => 'Watson',
- 'state' => 'NY',
- 'country' => 'UNITED STATES',
- 'birth_date' => '12/23/98',
- ),
- array(
- 'first_name' => substr(sha1(rand()), 0, 7),
- 'middle_name' => substr(sha1(rand()), 0, 7),
- 'last_name' => 'Summerson',
- 'email' => substr(sha1(rand()), 0, 7) . '@example.com',
- 'phone' => '6944412154',
- 'address_1' => 'Add 1',
- 'address_2' => 'Add 2',
- 'city' => 'Watson',
- 'state' => 'NY',
- 'country' => 'UNITED STATES',
- 'birth_date' => '11/24/88',
- ),
- );
-
- return array($headers, $rows);
- }
-
- /**
- * Helper function to provide data for contact import for Individuals and mm/dd/yyyy OR mm-dd-yyyy dateformat.
- */
- /**
- * @return array
- */
- public function _individualCSVData_mm_dd_yyyy() {
- $headers = array(
- 'first_name' => 'First Name',
- 'middle_name' => 'Middle Name',
- 'last_name' => 'Last Name',
- 'email' => 'Email',
- 'phone' => 'Phone',
- 'address_1' => 'Additional Address 1',
- 'address_2' => 'Additional Address 2',
- 'city' => 'City',
- 'state' => 'State',
- 'country' => 'Country',
- 'birth_date' => 'Birth Date',
- );
-
- $rows = array(
- array(
- 'first_name' => substr(sha1(rand()), 0, 7),
- 'middle_name' => substr(sha1(rand()), 0, 7),
- 'last_name' => 'Anderson',
- 'email' => substr(sha1(rand()), 0, 7) . '@example.com',
- 'phone' => '6949912154',
- 'address_1' => 'Add 1',
- 'address_2' => 'Add 2',
- 'city' => 'Watson',
- 'state' => 'NY',
- 'country' => 'UNITED STATES',
- 'birth_date' => '11/12/1995',
- ),
- array(
- 'first_name' => substr(sha1(rand()), 0, 7),
- 'middle_name' => substr(sha1(rand()), 0, 7),
- 'last_name' => 'Summerson',
- 'email' => substr(sha1(rand()), 0, 7) . '@example.com',
- 'phone' => '6944412154',
- 'address_1' => 'Add 1',
- 'address_2' => 'Add 2',
- 'city' => 'Watson',
- 'state' => 'NY',
- 'country' => 'UNITED STATES',
- 'birth_date' => '12/12/1995',
- ),
- );
-
- return array($headers, $rows);
- }
-
- /**
- * Helper function to provide data for contact import for Individuals and Month dd, yyyy dateformat.
- */
- /**
- * @return array
- */
- public function _individualCSVData_Month_dd_yyyy() {
- $headers = array(
- 'first_name' => 'First Name',
- 'middle_name' => 'Middle Name',
- 'last_name' => 'Last Name',
- 'email' => 'Email',
- 'phone' => 'Phone',
- 'address_1' => 'Additional Address 1',
- 'address_2' => 'Additional Address 2',
- 'city' => 'City',
- 'state' => 'State',
- 'country' => 'Country',
- 'birth_date' => 'Birth Date',
- );
-
- $rows = array(
- array(
- 'first_name' => substr(sha1(rand()), 0, 7),
- 'middle_name' => substr(sha1(rand()), 0, 7),
- 'last_name' => 'Anderson',
- 'email' => substr(sha1(rand()), 0, 7) . '@example.com',
- 'phone' => '6949912154',
- 'address_1' => 'Add 1',
- 'address_2' => 'Add 2',
- 'city' => 'Watson',
- 'state' => 'NY',
- 'country' => 'UNITED STATES',
- 'birth_date' => 'December 12, 1998',
- ),
- array(
- 'first_name' => substr(sha1(rand()), 0, 7),
- 'middle_name' => substr(sha1(rand()), 0, 7),
- 'last_name' => 'Summerson',
- 'email' => substr(sha1(rand()), 0, 7) . '@example.com',
- 'phone' => '6944412154',
- 'address_1' => 'Add 1',
- 'address_2' => 'Add 2',
- 'city' => 'Watson',
- 'state' => 'NY',
- 'country' => 'UNITED STATES',
- 'birth_date' => 'December 13, 1998',
- ),
- );
-
- return array($headers, $rows);
- }
-
- /**
- * Helper function to provide data for contact import for Individuals and dd-mon-yy OR dd/mm/yy dateformat.
- */
- /**
- * @return array
- */
- public function _individualCSVData_dd_mon_yy() {
- $headers = array(
- 'first_name' => 'First Name',
- 'middle_name' => 'Middle Name',
- 'last_name' => 'Last Name',
- 'email' => 'Email',
- 'phone' => 'Phone',
- 'address_1' => 'Additional Address 1',
- 'address_2' => 'Additional Address 2',
- 'city' => 'City',
- 'state' => 'State',
- 'country' => 'Country',
- 'birth_date' => 'Birth Date',
- );
-
- $rows = array(
- array(
- 'first_name' => substr(sha1(rand()), 0, 7),
- 'middle_name' => substr(sha1(rand()), 0, 7),
- 'last_name' => 'Anderson',
- 'email' => substr(sha1(rand()), 0, 7) . '@example.com',
- 'phone' => '6949912154',
- 'address_1' => 'Add 1',
- 'address_2' => 'Add 2',
- 'city' => 'Watson',
- 'state' => 'NY',
- 'country' => 'UNITED STATES',
- 'birth_date' => '25/12/98',
- ),
- array(
- 'first_name' => substr(sha1(rand()), 0, 7),
- 'middle_name' => substr(sha1(rand()), 0, 7),
- 'last_name' => 'Summerson',
- 'email' => substr(sha1(rand()), 0, 7) . '@example.com',
- 'phone' => '6944412154',
- 'address_1' => 'Add 1',
- 'address_2' => 'Add 2',
- 'city' => 'Watson',
- 'state' => 'NY',
- 'country' => 'UNITED STATES',
- 'birth_date' => '26/12/99',
- ),
- );
-
- return array($headers, $rows);
- }
-
- /**
- * Helper function to provide data for contact import for Individuals and dd/mm/yyyy dateformat.
- */
- /**
- * @return array
- */
- public function _individualCSVData_dd_mm_yyyy() {
- $headers = array(
- 'first_name' => 'First Name',
- 'middle_name' => 'Middle Name',
- 'last_name' => 'Last Name',
- 'email' => 'Email',
- 'phone' => 'Phone',
- 'address_1' => 'Additional Address 1',
- 'address_2' => 'Additional Address 2',
- 'city' => 'City',
- 'state' => 'State',
- 'country' => 'Country',
- 'birth_date' => 'Birth Date',
- );
-
- $rows = array(
- array(
- 'first_name' => substr(sha1(rand()), 0, 7),
- 'middle_name' => substr(sha1(rand()), 0, 7),
- 'last_name' => 'Anderson',
- 'email' => substr(sha1(rand()), 0, 7) . '@example.com',
- 'phone' => '6949912154',
- 'address_1' => 'Add 1',
- 'address_2' => 'Add 2',
- 'city' => 'Watson',
- 'state' => 'NY',
- 'country' => 'UNITED STATES',
- 'birth_date' => '25/12/1998',
- ),
- array(
- 'first_name' => substr(sha1(rand()), 0, 7),
- 'middle_name' => substr(sha1(rand()), 0, 7),
- 'last_name' => 'Summerson',
- 'email' => substr(sha1(rand()), 0, 7) . '@example.com',
- 'phone' => '6944412154',
- 'address_1' => 'Add 1',
- 'address_2' => 'Add 2',
- 'city' => 'Watson',
- 'state' => 'NY',
- 'country' => 'UNITED STATES',
- 'birth_date' => '24/11/1996',
- ),
- );
-
- return array($headers, $rows);
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'WebTest/Import/ImportCiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Import_DuplicateMatchingTest
- */
-class WebTest_Import_DuplicateMatchingTest extends ImportCiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- /**
- * Test contact import for Individuals Duplicate Matching.
- */
- public function testIndividualDuplicateMatchingImport() {
- $this->webtestLogin();
-
- $this->openCiviPage("contact/add", "reset=1&ct=Individual", 'first_name');
-
- $email = substr(sha1(rand()), 0, 7) . '@example.com';
-
- // fill in first name
- $firstName = substr(sha1(rand()), 0, 7);
- $this->type('first_name', $firstName);
-
- // fill in last name
- $lastName = substr(sha1(rand()), 0, 7);
- $this->type('last_name', $lastName);
-
- //fill in email
- $this->type('email_1_email', $email);
-
- // Clicking save.
- $this->click('_qf_Contact_upload_view');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForText('crm-notification-container', "Contact Saved");
-
- $existingContact = array(
- 'first_name' => $firstName,
- 'last_name' => $lastName,
- 'email' => $email,
- );
-
- // Get sample import data.
- list($headers, $rows) = $this->_individualDuplicateMatchingCSVData($existingContact);
-
- // Import and check Individual contacts in Skip mode.
- $other = array('callbackImportSummary' => 'checkDuplicateContacts');
- $this->importContacts($headers, $rows, 'Individual', 'Skip', array(), $other);
-
- // Get imported contact Ids
- $importedContactIds = $this->_getImportedContactIds($rows);
-
- // Build update mode import headers
- $updateHeaders = array(
- 'email' => 'Email',
- 'first_name' => 'First Name',
- 'last_name' => 'Last Name',
- );
-
- // Create update mode import rows
- $updateRows = array();
- $contact = current($rows);
- foreach ($importedContactIds as $cid) {
- $updateRows[$cid] = array(
- 'email' => $contact['email'],
- 'first_name' => substr(sha1(rand()), 0, 7),
- 'last_name' => 'Anderson' . substr(sha1(rand()), 0, 7),
- );
- $contact = next($rows);
- }
-
- // Import and check Individual contacts in Update mode.
- $this->importContacts($updateHeaders, $updateRows, 'Individual', 'Update');
-
- // Headers that should not updated.
- $fillHeaders = $updateHeaders;
-
- // Headers that should fill.
- $fillHeaders['gender'] = 'Gender';
- $fillHeaders['dob'] = 'Birth Date';
-
- $fillRows = array();
- foreach ($importedContactIds as $cid) {
- $fillRows[$cid] = array(
- 'email' => $updateRows[$cid]['email'],
- // should not update
- 'first_name' => substr(sha1(rand()), 0, 7),
- // should not update
- 'last_name' => 'Anderson' . substr(sha1(rand()), 0, 7),
- 'gender' => 'Male',
- 'dob' => '1986-04-16',
- );
- }
-
- // Import and check Individual contacts in Fill mode.
- $this->importContacts($fillHeaders, $fillRows, 'Individual', 'Fill');
-
- foreach ($importedContactIds as $cid) {
- $this->openCiviPage("contact/view", "reset=1&cid={$cid}");
-
- // Check old display name.
- $displayName = "{$updateRows[$cid]['first_name']} {$updateRows[$cid]['last_name']}";
- $this->assertTrue($this->isTextPresent("$displayName"), 'Contact display name should not update in fill mode!');
-
- $this->verifyText('css=div.crm-contact-gender_display', preg_quote($fillRows[$cid]['gender']));
- }
-
- // Recreate same conacts using 'No Duplicate Checking'
- $this->importContacts($headers, $rows, 'Individual', 'No Duplicate Checking');
- }
-
- /**
- * Test contact import for Organization Duplicate Matching.
- */
- public function testOrganizationDuplicateMatchingImport() {
- $this->webtestLogin();
-
- //create oranization
- $this->openCiviPage("contact/add", "reset=1&ct=Organization", 'organization_name');
-
- // get value for organization contact
- $organizationName = 'org_' . substr(sha1(rand()), 0, 7);
- $organizationEmail = substr(sha1(rand()), 0, 7) . '@example.org';
-
- $this->click('organization_name');
-
- //fill in first name
- $this->type('organization_name', $organizationName);
-
- //fill in Email
- $this->type('email_1_email', $organizationEmail);
-
- // Clicking save.
- $this->click('_qf_Contact_upload_view');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Reset Organization strict dedupe rule for Organization name
- // and Organization email (default)
- $this->webtestStrictDedupeRuleDefault('Organization');
-
- $organizationFields = array(
- 'organization_name' => $organizationName,
- 'email' => $organizationEmail,
- );
- // Get sample import data.
- list($headers, $rows) = $this->_organizationDuplicateMatchingCSVData($organizationFields);
-
- // Import and check Individual contacts in Skip mode.
- $other = array('callbackImportSummary' => 'checkDuplicateContacts');
- $this->importContacts($headers, $rows, 'Organization', 'Skip', array(), $other);
-
- // Get imported contact Ids
- $importedContactIds = $this->_getImportedContactIds($rows, 'Organization');
-
- // Build update mode import headers
- $updateHeaders = array(
- 'email' => 'Email',
- 'organization_name' => 'Organization Name',
- );
-
- // Create update mode import rows
- $updateRows = array();
- $contact = current($rows);
- foreach ($importedContactIds as $cid) {
- $updateRows[$cid] = array(
- 'email' => $contact['email'],
- 'organization_name' => 'UpdatedOrg ' . substr(sha1(rand()), 0, 7),
- );
- $contact = next($rows);
- }
-
- // Import and check Individual contacts in Update mode.
- $this->importContacts($updateHeaders, $updateRows, 'Organization', 'Update');
-
- // Headers that should not updated.
- $fillHeaders = $updateHeaders;
-
- // Headers that should fill.
- $fillHeaders['legal_name'] = 'Legal Name';
-
- $fillRows = array();
- foreach ($importedContactIds as $cid) {
- $fillRows[$cid] = array(
- 'email' => $updateRows[$cid]['email'],
- // should not update
- 'organization_name' => 'UpdateOrg ' . substr(sha1(rand()), 0, 7),
- 'legal_name' => 'org ' . substr(sha1(rand()), 0, 7),
- );
- }
-
- // Import and check Individual contacts in Fill mode.
- $this->importContacts($fillHeaders, $fillRows, 'Organization', 'Fill');
-
- foreach ($importedContactIds as $cid) {
- $this->openCiviPage("contact/view", "reset=1&cid={$cid}");
-
- // Check old Organization name.
- $organizationName = $updateRows[$cid]['organization_name'];
- $this->assertTrue($this->isTextPresent("$organizationName"), 'Contact should not update in fill mode!');
- $this->verifyText("xpath=//div[@id='crm-contactinfo-content']/div/div[3]/div[2]", preg_quote($fillRows[$cid]['legal_name']));
- }
-
- // Recreate same conacts using 'No Duplicate Checking'
- $this->importContacts($headers, $rows, 'Organization', 'No Duplicate Checking');
- }
-
- /**
- * Test contact import for Household Duplicate Matching.
- */
- public function testHouseholdDuplicateMatchingImport() {
- $this->webtestLogin();
-
- // create household
- $this->openCiviPage("contact/add", "reset=1&ct=Household", 'household_name');
-
- // get values for household contact
- $householdName = 'household_' . substr(sha1(rand()), 0, 7);
- $householdEmail = substr(sha1(rand()), 0, 7) . '@example.com';
-
- //fill in household name
- $this->type('household_name', $householdName);
-
- //fill in Email
- $this->type('email_1_email', $householdEmail);
-
- // Clicking save.
- $this->click('_qf_Contact_upload_view');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Reset Household strict dedupe rule for Household name
- // and Household email (default)
- $this->webtestStrictDedupeRuleDefault('Household');
-
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Store household contact value in array
- $householdFields = array(
- 'household_name' => $householdName,
- 'email' => $householdEmail,
- );
-
- // Get sample import data.
- list($headers, $rows) = $this->_householdDuplicateMatchingCSVData($householdFields);
-
- // Import and check Individual contacts in Skip mode.
- $other = array('callbackImportSummary' => 'checkDuplicateContacts');
- $this->importContacts($headers, $rows, 'Household', 'Skip', array(), $other);
-
- // Get imported contact Ids
- $importedContactIds = $this->_getImportedContactIds($rows, 'Household');
-
- // Build update mode import headers
- $updateHeaders = array(
- 'email' => 'Email',
- 'household_name' => 'Household Name',
- );
-
- // Create update mode import rows
- $updateRows = array();
- $contact = current($rows);
- foreach ($importedContactIds as $cid) {
- $updateRows[$cid] = array(
- 'email' => $contact['email'],
- 'household_name' => 'UpdatedHousehold ' . substr(sha1(rand()), 0, 7),
- );
- $contact = next($rows);
- }
-
- $this->importContacts($updateHeaders, $updateRows, 'Household', 'Update');
-
- // Headers that should not updated.
- $fillHeaders = $updateHeaders;
-
- // Headers that should fill.
- $fillHeaders['nick_name'] = 'Nick Name';
-
- $fillRows = array();
- foreach ($importedContactIds as $cid) {
- $fillRows[$cid] = array(
- 'email' => $updateRows[$cid]['email'],
- // should not update
- 'household_name' => 'UpdatedHousehold ' . substr(sha1(rand()), 0, 7),
- 'nick_name' => 'Household ' . substr(sha1(rand()), 0, 7),
- );
- }
-
- // Import and check Individual contacts in Fill mode.
- $this->importContacts($fillHeaders, $fillRows, 'Household', 'Fill');
-
- foreach ($importedContactIds as $cid) {
- $this->openCiviPage("contact/view", "reset=1&cid={$cid}");
-
- // Check old Household name.
- $householdName = $updateRows[$cid]['household_name'];
- $this->assertTrue($this->isTextPresent("$householdName"), 'Contact should not update in fill mode!');
- $this->verifyText("xpath=//div[@id='crm-contactinfo-content']/div/div[2]/div[2]", preg_quote($fillRows[$cid]['nick_name']));
- }
-
- // Recreate same conacts using 'No Duplicate Checking'
- $this->importContacts($headers, $rows, 'Household', 'No Duplicate Checking');
- }
-
- /**
- * @param $originalHeaders
- * @param $originalRows
- * @param $checkSummary
- */
- public function checkDuplicateContacts($originalHeaders, $originalRows, $checkSummary) {
- $this->assertTrue($this->isTextPresent('CiviCRM has detected one record which is a duplicate of existing CiviCRM contact record. These records have not been imported.'));
-
- $checkSummary = array(
- 'Total Rows' => '2',
- 'Duplicate Rows' => '1',
- 'Total Contacts' => '1',
- );
-
- foreach ($checkSummary as $label => $value) {
- $this->verifyText("xpath=//table[@id='summary-counts']/tbody/tr/td[text()='{$label}']/following-sibling::td", preg_quote($value));
- }
- }
-
- /*
- * Helper function to provide data for contact import for
- * Individual Duplicate Matching.
- */
- /**
- * @param $individualFields
- *
- * @return array
- */
- public function _individualDuplicateMatchingCSVData($individualFields) {
- $headers = array(
- 'first_name' => 'First Name',
- 'middle_name' => 'Middle Name',
- 'last_name' => 'Last Name',
- 'email' => 'Email',
- 'phone' => 'Phone',
- 'address_1' => 'Additional Address 1',
- 'address_2' => 'Additional Address 2',
- 'city' => 'City',
- 'state' => 'State',
- 'country' => 'Country',
- );
-
- $rows = array(
- array(
- 'first_name' => isset($individualFields['first_name']) ? $individualFields['first_name'] : substr(sha1(rand()), 0, 7),
- 'middle_name' => isset($individualFields['middle_name']) ? $individualFields['middle_name'] : substr(sha1(rand()), 0, 7),
- 'last_name' => isset($individualFields['last_name']) ? $individualFields['last_name'] : 'Anderson',
- 'email' => isset($individualFields['email']) ? $individualFields['email'] : substr(sha1(rand()), 0, 7) . '@example.com',
- 'phone' => '6949912154',
- 'address_1' => 'Add 1',
- 'address_2' => 'Add 2',
- 'city' => 'Watson',
- 'state' => 'NY',
- 'country' => 'UNITED STATES',
- ),
- array(
- 'first_name' => substr(sha1(rand()), 0, 7),
- 'middle_name' => substr(sha1(rand()), 0, 7),
- 'last_name' => 'Summerson',
- 'email' => substr(sha1(rand()), 0, 7) . '@example.com',
- 'phone' => '6944412154',
- 'address_1' => 'Add 1',
- 'address_2' => 'Add 2',
- 'city' => 'Watson',
- 'state' => 'NY',
- 'country' => 'UNITED STATES',
- ),
- );
-
- return array($headers, $rows);
- }
-
- /*
- * Helper function to provide data for contact import for
- * Organizations Duplicate Matching.
- */
- /**
- * @param $organizationFields
- *
- * @return array
- */
- public function _organizationDuplicateMatchingCSVData($organizationFields) {
- $headers = array(
- 'organization_name' => 'Organization Name',
- 'email' => 'Email',
- 'phone' => 'Phone',
- 'address_1' => 'Additional Address 1',
- 'address_2' => 'Additional Address 2',
- 'city' => 'City',
- 'state' => 'State',
- 'country' => 'Country',
- );
- $rows = array(
- array(
- 'organization_name' => isset($organizationFields['organization_name']) ? $organizationFields['organization_name'] : 'org_' . substr(sha1(rand()), 0, 7),
- 'email' => isset($organizationFields['email']) ? $organizationFields['email'] : substr(sha1(rand()), 0, 7) . 'example.org',
- 'phone' => '9949912154',
- 'address_1' => 'Add 1',
- 'address_2' => 'Add 2',
- 'city' => 'Watson',
- 'state' => 'NY',
- 'country' => 'UNITED STATES',
- ),
- array(
- 'organization_name' => 'org_' . substr(sha1(rand()), 0, 7),
- 'email' => substr(sha1(rand()), 0, 7) . '@example.org',
- 'phone' => '6949412154',
- 'address_1' => 'Add 1',
- 'address_2' => 'Add 2',
- 'city' => 'Watson',
- 'state' => 'NY',
- 'country' => 'UNITED STATES',
- ),
- );
-
- return array($headers, $rows);
- }
-
- /**
- * Helper function to provide data for contact import for Household.
- * Duplicate Matching.
- *
- * @param $householdFields
- *
- * @return array
- */
- public function _householdDuplicateMatchingCSVData($householdFields) {
- $headers = array(
- 'household_name' => 'Household Name',
- 'email' => 'Email',
- 'phone' => 'Phone',
- 'address_1' => 'Additional Address 1',
- 'address_2' => 'Additional Address 2',
- 'city' => 'City',
- 'state' => 'State',
- 'country' => 'Country',
- );
-
- $rows = array(
- array(
- 'household_name' => isset($householdFields['household_name']) ? $householdFields['household_name'] : 'household_' . substr(sha1(rand()), 0, 7),
- 'email' => isset($householdFields['email']) ? $householdFields['email'] : substr(sha1(rand()), 0, 7) . '@example.com',
- 'phone' => '3949912154',
- 'address_1' => 'Add 1',
- 'address_2' => 'Add 2',
- 'city' => 'Watson',
- 'state' => 'NY',
- 'country' => 'UNITED STATES',
- ),
- array(
- 'household_name' => 'household_' . substr(sha1(rand()), 0, 7),
- 'email' => substr(sha1(rand()), 0, 7) . '@example.org',
- 'phone' => '5949412154',
- 'address_1' => 'Add 1',
- 'address_2' => 'Add 2',
- 'city' => 'Watson',
- 'state' => 'NY',
- 'country' => 'UNITED STATES',
- ),
- );
-
- return array($headers, $rows);
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'WebTest/Import/ImportCiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Import_GroupTest
- */
-class WebTest_Import_GroupTest extends ImportCiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- /**
- * Test contact import for Individuals.
- */
- public function testIndividualImportWithGroup() {
- $this->webtestLogin();
-
- // Get sample import data.
- list($headers, $rows) = $this->_individualGroupCSVData();
-
- // Group Name
- $groupName = substr(sha1(rand()), 0, 7);
-
- // Import and check Individual Contacts in Skip mode and Add them in Group
- $other = array(
- 'createGroup' => TRUE,
- 'createGroupName' => $groupName,
- );
-
- // Create New Group And Import Contacts In Group
- $this->importContacts($headers, $rows, 'Individual', 'Skip', array(), $other);
-
- $count = count($rows);
-
- // Direct URL To Search
- $this->openCiviPage("contact/search", "reset=1");
-
- // Select GroupName
- $this->select("group", "label={$groupName}");
-
- $this->clickLink("_qf_Basic_refresh");
-
- // To Check Number Of Imported Contacts
- $this->assertTrue($this->isTextPresent("{$count} Contacts"), "Contacts Not Found");
-
- // To Add New Contacts In Already Existing Group
- $other = array('selectGroup' => $groupName);
-
- // Create New Individual Record
- list($headers, $rows) = $this->_individualGroupCSVData();
-
- // Import Contacts In Existing Group
- $this->importContacts($headers, $rows, 'Individual', 'Skip', array(), $other);
- $count += count($rows);
-
- // Direct URL To Search
- $this->openCiviPage("contact/search", "reset=1");
-
- // Select GroupName
- $this->select("group", "label={$groupName}");
-
- $this->clickLink("_qf_Basic_refresh");
-
- // To Check Imported Contacts
- $this->assertTrue($this->isTextPresent("{$count} Contacts"), "Contacts Not Found");
- }
-
- /**
- * Helper function to provide data for contact import for Individuals.
- *
- * @return array
- */
- public function _individualGroupCSVData() {
- $headers = array(
- 'first_name' => 'First Name',
- 'middle_name' => 'Middle Name',
- 'last_name' => 'Last Name',
- 'email' => 'Email',
- 'phone' => 'Phone',
- 'address_1' => 'Additional Address 1',
- 'address_2' => 'Additional Address 2',
- 'city' => 'City',
- 'state' => 'State',
- 'country' => 'Country',
- );
-
- $rows = array(
- array(
- 'first_name' => substr(sha1(rand()), 0, 7),
- 'middle_name' => substr(sha1(rand()), 0, 7),
- 'last_name' => 'Anderson',
- 'email' => substr(sha1(rand()), 0, 7) . '@example.com',
- 'phone' => '6949912154',
- 'address_1' => 'Add 1',
- 'address_2' => 'Add 2',
- 'city' => 'Watson',
- 'state' => 'NY',
- 'country' => 'UNITED STATES',
- ),
- array(
- 'first_name' => substr(sha1(rand()), 0, 7),
- 'middle_name' => substr(sha1(rand()), 0, 7),
- 'last_name' => 'Summerson',
- 'email' => substr(sha1(rand()), 0, 7) . '@example.com',
- 'phone' => '6944412154',
- 'address_1' => 'Add 1',
- 'address_2' => 'Add 2',
- 'city' => 'Watson',
- 'state' => 'NY',
- 'country' => 'UNITED STATES',
- ),
- );
- return array($headers, $rows);
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-require_once 'CRM/Utils/Array.php';
-
-/**
- * Class ImportCiviSeleniumTestCase
- */
-class ImportCiviSeleniumTestCase extends CiviSeleniumTestCase {
-
- /**
- * Test csv import for each component.
- *
- * @param string $component
- * Component name ( Event, Contribution, Membership, Activity etc).
- * @param array $headers
- * Csv data headers.
- * @param array $rows
- * Csv data rows.
- * @param string $contactType
- * Contact type.
- * @param string $mode
- * Import mode.
- * @param array $fieldMapper
- * Select mapper fields while import.
- * @param array $other
- * Other parameters.
- * useMappingName : to reuse mapping
- * dateFormat : date format of data
- * checkMapperHeaders : to override default check mapper headers
- * saveMapping : save current mapping?
- * saveMappingName : to override mapping name
- */
- public function importCSVComponent(
- $component,
- $headers,
- $rows,
- $contactType = 'Individual',
- $mode = 'Skip',
- $fieldMapper = array(),
- $other = array()
- ) {
-
- // Go to contact import page.
- $this->openCiviPage($this->_getImportComponentUrl($component), 'reset=1', "uploadFile");
-
- // Create csv file of sample data.
- $csvFile = $this->webtestCreateCSV($headers, $rows);
-
- // Attach csv file.
- $this->webtestAttachFile('uploadFile', $csvFile);
-
- // First row is header.
- $this->click('skipColumnHeader');
-
- // select mode, default is 'Skip'.
- if ($mode == 'Update') {
- $this->click("CIVICRM_QFID_4_4");
- }
- elseif ($mode == 'No Duplicate Checking') {
- $this->click("CIVICRM_QFID_16_6");
- }
-
- // select contact type, default is 'Individual'.
- if ($component != 'Activity') {
- $contactTypeOption = $this->_getImportComponentContactType($component, $contactType);
- $this->click($contactTypeOption);
- }
-
- // Date format, default: yyyy-mm-dd OR yyyymmdd
- if (isset($other['dateFormat'])) {
- // default
- $dateFormatMapper = array(
- 'yyyy-mm-dd OR yyyymmdd' => "CIVICRM_QFID_1_14",
- 'mm/dd/yy OR mm-dd-yy' => "CIVICRM_QFID_2_16",
- 'mm/dd/yyyy OR mm-dd-yyyy' => "CIVICRM_QFID_4_18",
- 'Month dd, yyyy' => "CIVICRM_QFID_8_20",
- 'dd-mon-yy OR dd/mm/yy' => "CIVICRM_QFID_16_22",
- 'dd/mm/yyyy' => "CIVICRM_QFID_32_24",
- );
- $this->click($dateFormatMapper[$other['dateFormat']]);
- }
-
- // Use already created mapping
- $existingMapping = NULL;
- if (isset($other['useMappingName'])) {
- $this->select('savedMapping', "label=" . $other['useMappingName']);
- $existingMapping = $other['useMappingName'];
- }
-
- // Submit form.
- $this->click('_qf_DataSource_upload');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Select matching field for cvs data.
- if (!empty($fieldMapper)) {
- foreach ($fieldMapper as $field => $value) {
- $this->select($field, "value={$value}");
- }
- }
-
- // Check mapping data.
- $this->_checkImportMapperData($headers,
- $rows,
- $existingMapping,
- isset($other['checkMapperHeaders']) ? $other['checkMapperHeaders'] : array()
- );
-
- // Save mapping
- if (isset($other['saveMapping'])) {
- $mappingName = isset($other['saveMappingName']) ? $other['saveMappingName'] : "{$component}Import_" . substr(sha1(rand()), 0, 7);
-
- $this->click('saveMapping');
- $this->type('saveMappingName', $mappingName);
- $this->type('saveMappingDesc', "Mapping for {$contactType}");
- }
-
- // Submit form.
- $this->click('_qf_MapField_next');
- $this->waitForElementPresent('_qf_Preview_next-bottom');
-
- // Check mapping data.
- $this->_checkImportMapperData($headers, $rows, $existingMapping, isset($other['checkMapperHeaders']) ? $other['checkMapperHeaders'] : array());
-
- // Submit form.
- $this->clickLink('_qf_Preview_next-bottom', "_qf_Summary_next");
-
- // Check success message.
- $this->assertTrue($this->isTextPresent("Import has completed successfully. The information below summarizes the results."));
-
- // Check summary Details.
- $importedRecords = count($rows);
- $checkSummary = array(
- 'Total Rows' => $importedRecords,
- 'Records Imported' => $importedRecords,
- );
-
- foreach ($checkSummary as $label => $value) {
- $this->verifyText("xpath=//table[@id='summary-counts']/tbody/tr/td[text()='{$label}']/following-sibling::td", preg_quote($value));
- }
- }
-
- /**
- * Test contact import.
- *
- * @param array $headers
- * Csv data headers.
- * @param array $rows
- * Csv data rows.
- * @param string $contactType
- * Contact type.
- * @param string $mode
- * Import mode.
- * @param array $fieldMapper
- * Select mapper fields while import.
- * @param array $other
- * Other parameters.
- * contactSubtype : import for selected Contact Subtype
- * useMappingName : to reuse mapping
- * dateFormat : date format of data
- * checkMapperHeaders : to override default check mapper headers
- * saveMapping : save current mapping?
- * saveMappingName : to override mapping name
- * createGroup : create new group?
- * createGroupName : to override new Group name
- * createTag : create new tag?
- * createTagName : to override new Tag name
- * selectGroup : select existing group for contacts
- * selectTag : select existing tag for contacts
- * callbackImportSummary : function to override default import summary assertions
- *
- * @param string $type
- * Import type (csv/sql).
- * @todo:currently only supports csv, need to work on sql import
- */
- public function importContacts($headers, $rows, $contactType = 'Individual', $mode = 'Skip', $fieldMapper = array(), $other = array(), $type = 'csv') {
-
- // Go to contact import page.
- $this->openCiviPage("import/contact", "reset=1", "uploadFile");
-
- $originalHeaders = $headers;
- $originalRows = $rows;
-
- // format headers and row to import contacts with relationship data.
- $this->_formatContactCSVdata($headers, $rows);
-
- // Create csv file of sample data.
- $csvFile = $this->webtestCreateCSV($headers, $rows);
-
- // Attach csv file.
- $this->webtestAttachFile('uploadFile', $csvFile);
-
- // First row is header.
- $this->click('skipColumnHeader');
-
- // select mode, default is 'Skip'.
- if ($mode == 'Update') {
- $this->click("CIVICRM_QFID_4_4");
- }
- elseif ($mode == 'Fill') {
- $this->click("CIVICRM_QFID_8_6");
- }
- elseif ($mode == 'No Duplicate Checking') {
- $this->click("CIVICRM_QFID_16_8");
- }
-
- // select contact type, default is 'Individual'.
- if ($contactType == 'Organization') {
- $this->click("CIVICRM_QFID_4_14");
- }
- elseif ($contactType == 'Household') {
- $this->click("CIVICRM_QFID_2_12");
- }
-
- // Select contact subtype
- if (isset($other['contactSubtype'])) {
- $this->waitForElementPresent("xpath=//div[@id='common-form-controls']/table/tbody/tr[1]/td[2]/span");
- $this->select('subType', $other['contactSubtype']);
- }
-
- if (isset($other['dedupe'])) {
- $this->waitForElementPresent("dedupe");
- $this->select('dedupe', 'value=' . $other['dedupe']);
- }
-
- // Use already created mapping
- $existingMapping = NULL;
- if (isset($other['useMappingName'])) {
- $this->select('savedMapping', "label=" . $other['useMappingName']);
- $existingMapping = $other['useMappingName'];
- }
-
- // Date format, default: yyyy-mm-dd OR yyyymmdd
- if (isset($other['dateFormat'])) {
- // default
- $dateFormatMapper = array(
- 'yyyy-mm-dd OR yyyymmdd' => "CIVICRM_QFID_1_16",
- 'mm/dd/yy OR mm-dd-yy' => "CIVICRM_QFID_2_18",
- 'mm/dd/yyyy OR mm-dd-yyyy' => "CIVICRM_QFID_4_20",
- 'Month dd, yyyy' => "CIVICRM_QFID_8_22",
- 'dd-mon-yy OR dd/mm/yy' => "CIVICRM_QFID_16_24",
- 'dd/mm/yyyy' => "CIVICRM_QFID_32_26",
- );
- $this->click($dateFormatMapper[$other['dateFormat']]);
- }
-
- // Submit form.
- $this->clickLink('_qf_DataSource_upload');
-
- if (isset($other['checkMapperHeaders'])) {
- $checkMapperHeaders = $other['checkMapperHeaders'];
- }
- else {
- $checkMapperHeaders = array(
- 1 => 'Column Names',
- 2 => 'Import Data (row 1)',
- 3 => 'Import Data (row 2)',
- 4 => 'Matching CiviCRM Field',
- );
- }
-
- // Check mapping data.
- $this->_checkImportMapperData($headers, $rows, $existingMapping, $checkMapperHeaders, 'td');
-
- // Select matching field for cvs data.
- if (!empty($fieldMapper)) {
- foreach ($fieldMapper as $field => $value) {
- $this->select($field, "value={$value}");
- }
- }
-
- // Save mapping
- if (isset($other['saveMapping'])) {
- $mappingName = isset($other['saveMappingName']) ? $other['saveMappingName'] : 'ContactImport_' . substr(sha1(rand()), 0, 7);
- $this->click('saveMapping');
- $this->type('saveMappingName', $mappingName);
- $this->type('saveMappingDesc', "Mapping for {$contactType}");
- }
-
- // Submit form.
- $this->click('_qf_MapField_next');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Check mapping data.
- $this->_checkImportMapperData($headers, $rows, $existingMapping, $checkMapperHeaders, 'td');
-
- // Add imported contacts in new group.
- $groupName = NULL;
- $existingGroups = array();
- if (isset($other['createGroup'])) {
- $groupName = isset($other['createGroupName']) ? $other['createGroupName'] : 'ContactImport_' . substr(sha1(rand()), 0, 7);
-
- $this->click("css=#new-group div.crm-accordion-header");
- $this->type('newGroupName', $groupName);
- $this->type('newGroupDesc', "Group For {$contactType}");
- }
- if (isset($other['selectGroup'])) {
- // reuse existing groups.
- if (is_array($other['selectGroup'])) {
- foreach ($other['selectGroup'] as $existingGroup) {
- $this->select('groups[]', 'label=' . $existingGroup);
- $existingGroups[] = $existingGroup;
- }
- }
- else {
- $this->select('groups[]', 'label=' . $other['selectGroup']);
- $existingGroups[] = $other['selectGroup'];
- }
- }
-
- // Assign new tag to the imported contacts.
- $tagName = NULL;
- $existingTags = array();
- if (isset($other['createTag'])) {
- $tagName = isset($other['createTagName']) ? $other['createTagName'] : "{$contactType}_" . substr(sha1(rand()), 0, 7);
-
- $this->click("css=#new-tag div.crm-accordion-header");
- $this->type('newTagName', $tagName);
- $this->type('newTagDesc', "Tag for {$contactType}");
- }
- if (isset($other['selectTag'])) {
- $this->click("css=#existing-tags div.crm-accordion-header");
- // reuse existing tags.
- if (is_array($other['selectTag'])) {
- foreach ($other['selectTag'] as $existingTag) {
- $this->click("xpath=//div[@id='existing-tags']//div[@class='crm-accordion-body']//label[text()='{$existingTag}']");
- $existingTags[] = $existingTag;
- }
- }
- else {
- $this->click("xpath=//div[@id='existing-tags']//div[@class='crm-accordion-body']//label[text()='" . $other['selectTag'] . "']");
- $existingTags[] = $other['selectTag'];
- }
- }
-
- // Submit form.
- $this->click('_qf_Preview_next');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Check confirmation alert.
- $this->assertTrue((bool) preg_match("/^Backing up your database before importing is recommended, as there is no Undo for this. Are you sure you want to Import now[\s\S]$/", $this->getConfirmation()));
- $this->chooseOkOnNextConfirmation();
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Visit summary page.
- $this->waitForElementPresent("_qf_Summary_next");
-
- // Check success message.
- $this->assertTrue($this->isTextPresent("Import has completed successfully. The information below summarizes the results."));
-
- // Check summary Details.
- $importedContacts = $totalRows = count($originalRows);
-
- // Include relationships contacts ( if exists )
- if (isset($originalHeaders['contact_relationships']) && is_array($originalHeaders['contact_relationships'])) {
- foreach ($originalRows as $row) {
- $importedContacts += count($row['contact_relationships']);
- }
- }
-
- $importedContactsCount = ($importedContacts == 1) ? 'One contact' : "$importedContacts contacts";
- $taggedContactsCount = ($importedContacts == 1) ? 'One contact is' : "$importedContacts contacts are";
- $checkSummary = array(
- 'Total Rows' => $totalRows,
- 'Total Contacts' => $importedContacts,
- );
-
- if ($groupName) {
- $checkSummary['Import to Groups'] = "{$groupName}: {$importedContactsCount} added to this new group.";
- }
-
- if ($tagName) {
- $checkSummary['Tagged Imported Contacts'] = "{$tagName}: {$taggedContactsCount} tagged with this tag.";
- }
-
- if ($existingGroups) {
- if (!isset($checkSummary['Import to Groups'])) {
- $checkSummary['Import to Groups'] = '';
- }
- foreach ($existingGroups as $existingGroup) {
- $checkSummary['Import to Groups'] .= "{$existingGroup}: {$importedContactsCount} added to this existing group.";
- }
- }
-
- if ($existingTags) {
- if (!isset($checkSummary['Tagged Imported Contacts'])) {
- $checkSummary['Tagged Imported Contacts'] = '';
- }
- foreach ($existingTags as $existingTag) {
- $checkSummary['Tagged Imported Contacts'] .= "{$existingTag}: {$taggedContactsCount} tagged with this tag.";
- }
- }
-
- if (!empty($other['callbackImportSummary']) && is_callable(array(
- $this,
- $other['callbackImportSummary'],
- ))
- ) {
- $callbackImportSummary = $other['callbackImportSummary'];
- $this->$callbackImportSummary($originalHeaders, $originalRows, $checkSummary);
- }
- else {
- foreach ($checkSummary as $label => $value) {
- $this->verifyText("xpath=//table[@id='summary-counts']/tbody/tr/td[text()='{$label}']/following-sibling::td", preg_quote($value));
- }
- }
- }
-
- /**
- * Helper function to get the import url of the component.
- * @param string $component
- * Component name.
- *
- * @return string
- * import url
- */
- private function _getImportComponentUrl($component) {
- $importComponentUrl = array(
- 'Event' => 'event/import',
- 'Contribution' => 'contribute/import',
- 'Membership' => 'member/import',
- 'Activity' => 'import/activity',
- );
-
- return $importComponentUrl[$component];
- }
-
- /**
- * @param $component
- * @param $contactType
- *
- * @return string
- */
- public function _getImportComponentContactType($component, $contactType) {
- $importComponentMode = array(
- 'Event' => array(
- 'Individual' => 'CIVICRM_QFID_1_20',
- 'Household' => 'CIVICRM_QFID_2_22',
- 'Organization' => 'CIVICRM_QFID_4_24',
- ),
- 'Contribution' => array(
- 'Individual' => 'CIVICRM_QFID_1_18',
- 'Household' => 'CIVICRM_QFID_2_20',
- 'Organization' => 'CIVICRM_QFID_4_22',
- ),
- 'Membership' => array(
- 'Individual' => 'CIVICRM_QFID_1_18',
- 'Household' => 'CIVICRM_QFID_2_20',
- 'Organization' => 'CIVICRM_QFID_4_22',
- ),
- );
-
- return $importComponentMode[$component][$contactType];
- }
-
- /**
- * Helper function to check import mapping fields.
- * @param array $headers
- * @param array $rows
- * @param null $existingMapping
- * @param array $checkMapperHeaders
- * @param string $headerSelector
- */
- public function _checkImportMapperData($headers, $rows, $existingMapping = NULL, $checkMapperHeaders = array(), $headerSelector = 'th') {
-
- if (empty($checkMapperHeaders)) {
- $checkMapperHeaders = array(
- 1 => 'Column Headers',
- 2 => 'Import Data (row 2)',
- 3 => 'Import Data (row 3)',
- 4 => 'Matching CiviCRM Field',
- );
- }
-
- $rowNumber = 1;
- if ($existingMapping) {
- $this->verifyText("xpath=//div[@id='map-field']//table[1]/tbody/tr[{$rowNumber}]/th[1]", preg_quote("Saved Field Mapping: {$existingMapping}"));
- $rowNumber++;
- }
-
- foreach ($checkMapperHeaders as $rownum => $value) {
- $this->verifyText("xpath=//div[@id='map-field']//table[1]/tbody/tr[{$rowNumber}]/{$headerSelector}[{$rownum}]", preg_quote($value));
- }
- $rowNumber++;
-
- foreach ($headers as $field => $header) {
- $this->verifyText("xpath=//div[@id='map-field']//table[1]/tbody/tr[{$rowNumber}]/td[1]", preg_quote($header));
- $colnum = 2;
- foreach ($rows as $row) {
- $this->verifyText("xpath=//div[@id='map-field']//table[1]/tbody/tr[{$rowNumber}]/td[{$colnum}]", preg_quote($row[$field]));
- $colnum++;
- }
- $rowNumber++;
- }
- }
-
- /**
- * Helper function to get imported contact ids.
- *
- * @param array $rows
- * @param string $contactType
- *
- * @return array
- * imported contact ids
- */
- public function _getImportedContactIds($rows, $contactType = 'Individual') {
- $contactIds = array();
-
- foreach ($rows as $row) {
- $searchName = '';
-
- // Build search name.
- if ($contactType == 'Individual') {
- $searchName = "{$row['last_name']}, {$row['first_name']}";
- }
- elseif ($contactType == 'Organization') {
- $searchName = $row['organization_name'];
- }
- elseif ($contactType == 'Household') {
- $searchName = $row['household_name'];
- }
-
- $this->openCiviPage("dashboard", "reset=1");
-
- // Type search name in autocomplete.
- $this->click("css=input#sort_name_navigation");
- $this->type("css=input#sort_name_navigation", $searchName);
- $this->typeKeys("css=input#sort_name_navigation", $searchName);
-
- // Wait for result list.
- $this->waitForElementPresent("css=ul.ui-autocomplete li");
-
- // Visit contact summary page.
- $this->click("css=ul.ui-autocomplete li");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Get contact id from url.
- $contactIds[] = $this->urlArg('cid');
- }
-
- return $contactIds;
- }
-
- /**
- * Helper function to format headers and rows for contact relationship data.
- *
- * @param array $headers
- * @param array $rows
- */
- public function _formatContactCSVdata(&$headers, &$rows) {
- if (!isset($headers['contact_relationships'])) {
- return;
- }
-
- $relationshipHeaders = $headers['contact_relationships'];
- unset($headers['contact_relationships']);
-
- if (empty($relationshipHeaders) || !is_array($relationshipHeaders)) {
- return;
- }
-
- foreach ($relationshipHeaders as $relationshipHeader) {
- $headers = array_merge($headers, $relationshipHeader);
- }
-
- foreach ($rows as & $row) {
- $relationshipRows = $row['contact_relationships'];
- unset($row['contact_relationships']);
- foreach ($relationshipRows as $relationshipRow) {
- $row = array_merge($row, $relationshipRow);
- }
- }
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'WebTest/Import/ImportCiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Import_MatchExternalIdTest
- */
-class WebTest_Import_MatchExternalIdTest extends ImportCiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- /**
- * Test participant import for Individuals matching on external identifier.
- */
- public function testContributionImport() {
- $this->webtestLogin();
-
- // Get sample import data.
- list($headers, $rows, $fieldMapper) = $this->_contributionIndividualCSVData();
-
- // Create and import csv from provided data and check imported data.
- $this->importCSVComponent('Contribution', $headers, $rows, 'Individual', 'Insert new contributions', $fieldMapper);
- }
-
- /**
- * Test membership import for Individuals matching on external identifier.
- */
- public function testMemberImportIndividual() {
- $this->webtestLogin();
-
- // Get membership import data for Individuals.
- list($headers, $rows, $fieldMapper) = $this->_memberIndividualCSVData();
-
- // Import participants and check imported data.
- $this->importCSVComponent('Membership', $headers, $rows, 'Individual', 'Skip', $fieldMapper);
- }
-
- /**
- * Test participant import for Individuals matching on external identifier.
- */
- public function testParticipantImportIndividual() {
- // Log in using webtestLogin() method
- $this->webtestLogin();
-
- // Get sample import data.
- list($headers, $rows, $fieldMapper) = $this->_participantIndividualCSVData();
-
- // Create and import csv from provided data and check imported data.
- $this->importCSVComponent('Event', $headers, $rows, 'Individual', 'Skip', $fieldMapper);
- }
-
- /**
- * Helper function to provide data for contribution import for Individual.
- *
- * @return array
- */
- public function _contributionIndividualCSVData() {
- $firstName1 = substr(sha1(rand()), 0, 7);
- $lastName1 = substr(sha1(rand()), 0, 7);
- $externalId1 = substr(sha1(rand()), 0, 4);
-
- $this->_addContact($firstName1, $lastName1, $externalId1);
-
- $firstName2 = substr(sha1(rand()), 0, 7);
- $lastName2 = substr(sha1(rand()), 0, 7);
- $externalId2 = substr(sha1(rand()), 0, 4);
-
- $this->_addContact($firstName2, $lastName2, $externalId2);
-
- $headers = array(
- 'external_identifier' => 'External Identifier',
- 'fee_amount' => 'Fee Amount',
- 'financial_type' => 'Financial Type',
- 'contribution_status_id' => 'Contribution Status',
- 'total_amount' => 'Total Amount',
- );
-
- $rows = array(
- array(
- 'external_identifier' => $externalId1,
- 'fee_amount' => '200',
- 'financial_type' => 'Donation',
- 'contribution_status_id' => 'Completed',
- 'total_amount' => '200',
- ),
- array(
- 'external_identifier' => $externalId2,
- 'fee_amount' => '400',
- 'financial_type' => 'Donation',
- 'contribution_status_id' => 'Completed',
- 'total_amount' => '400',
- ),
- );
- $fieldMapper = array(
- 'mapper[0][0]' => 'external_identifier',
- 'mapper[2][0]' => 'financial_type',
- 'mapper[4][0]' => 'total_amount',
- );
- return array($headers, $rows, $fieldMapper);
- }
-
- /**
- * Helper function to provide data for membership import for Individual.
- *
- * @return array
- */
- public function _memberIndividualCSVData() {
- $memTypeParams = $this->webtestAddMembershipType();
-
- $firstName1 = substr(sha1(rand()), 0, 7);
- $lastName1 = substr(sha1(rand()), 0, 7);
- $externalId1 = substr(sha1(rand()), 0, 4);
-
- $this->_addContact($firstName1, $lastName1, $externalId1);
- $startDate1 = date('Y-m-d');
- $year = date('Y') - 1;
-
- $firstName2 = substr(sha1(rand()), 0, 7);
- $lastName2 = substr(sha1(rand()), 0, 7);
- $externalId2 = substr(sha1(rand()), 0, 4);
-
- $this->_addContact($firstName2, $lastName2, $externalId2);
- $startDate2 = date('Y-m-d', mktime(0, 0, 0, 9, 10, $year));
-
- $headers = array(
- 'external_identifier' => 'External Identifier',
- 'membership_type_id' => 'Membership Type',
- 'membership_start_date' => 'Membership Start Date',
- );
- $rows = array(
- array(
- 'external_identifier' => $externalId1,
- 'membership_type_id' => $memTypeParams['membership_type'],
- 'membership_start_date' => $startDate1,
- ),
- array(
- 'external_identifier' => $externalId2,
- 'membership_type_id' => $memTypeParams['membership_type'],
- 'membership_start_date' => $startDate2,
- ),
- );
-
- $fieldMapper = array(
- 'mapper[0][0]' => 'external_identifier',
- 'mapper[1][0]' => 'membership_type_id',
- 'mapper[2][0]' => 'membership_start_date',
- );
- return array($headers, $rows, $fieldMapper);
- }
-
- /**
- * Helper function to provide data for participant import for Individual.
- *
- * @return array
- */
- public function _participantIndividualCSVData() {
- $eventInfo = $this->_addNewEvent();
-
- $firstName1 = substr(sha1(rand()), 0, 7);
- $lastName1 = substr(sha1(rand()), 0, 7);
- $externalId1 = substr(sha1(rand()), 0, 4);
-
- $this->_addContact($firstName1, $lastName1, $externalId1);
-
- $firstName2 = substr(sha1(rand()), 0, 7);
- $lastName2 = substr(sha1(rand()), 0, 7);
- $externalId2 = substr(sha1(rand()), 0, 4);
-
- $this->_addContact($firstName2, $lastName2, $externalId2);
-
- $headers = array(
- 'external_identifier' => 'External Identifier',
- 'event_id' => 'Event Id',
- 'fee_level' => 'Fee Level',
- 'role' => 'Participant Role',
- 'status' => 'Participant Status',
- 'register_date' => 'Register date',
- );
-
- $rows = array(
- array(
- 'external_identifier' => $externalId1,
- 'event_id' => $eventInfo['event_id'],
- 'fee_level' => 'Member',
- 'role' => 1,
- 'status' => 1,
- 'register_date' => '2011-03-30',
- ),
- array(
- 'external_identifier' => $externalId2,
- 'event_id' => $eventInfo['event_id'],
- 'fee_level' => 'Non-Member',
- 'role' => 1,
- 'status' => 1,
- 'register_date' => '2011-03-30',
- ),
- );
-
- $fieldMapper = array(
- 'mapper[0][0]' => 'external_identifier',
- 'mapper[1][0]' => 'event_id',
- 'mapper[2][0]' => 'participant_fee_level',
- 'mapper[4][0]' => 'participant_status_id',
- );
-
- return array($headers, $rows, $fieldMapper);
- }
-
- /**
- * Helper function to add new contact.
- *
- * @param string $firstName
- * @param string $lastName
- * @param int $externalId
- *
- * @return int
- * external id
- */
- public function _addContact($firstName, $lastName, $externalId) {
- $this->openCiviPage('contact/add', 'reset=1&ct=Individual');
-
- //fill in first name
- $this->type("first_name", $firstName);
-
- //fill in last name
- $this->type("last_name", $lastName);
-
- //fill in external identifier
- $this->type("external_identifier", $externalId);
-
- // Clicking save.
- $this->click("_qf_Contact_upload_view");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForText('crm-notification-container', "Contact Saved");
-
- return $externalId;
- }
-
- /**
- * Helper function to add new event.
- *
- * @param array $params
- *
- * @return array
- * event details of newly created event
- */
- public function _addNewEvent($params = array()) {
- if (empty($params)) {
-
- // Use default payment processor
- $processorName = 'Test Processor';
- $this->webtestAddPaymentProcessor($processorName);
-
- // create an event
- $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7);
- $params = array(
- 'title' => $eventTitle,
- 'template_id' => 6,
- 'event_type_id' => 4,
- 'payment_processor' => $processorName,
- 'fee_level' => array(
- 'Member' => "250.00",
- 'Non-Member' => "325.00",
- ),
- );
- }
-
- $this->openCiviPage('event/add', 'reset=1&action=add', '_qf_EventInfo_upload-bottom');
-
- $this->select("event_type_id", "value={$params['event_type_id']}");
-
- // Attendee role s/b selected now.
- $this->select("default_role_id", "value=1");
-
- // Enter Event Title, Summary and Description
- $this->type("title", $params['title']);
- $this->type("summary", "This is a great conference. Sign up now!");
- $this->fillRichTextField("description", "Here is a description for this event.", 'CKEditor');
-
- // Choose Start and End dates.
- // Using helper webtestFillDate function.
- $this->webtestFillDateTime("start_date", "+1 week");
- $this->webtestFillDateTime("end_date", "+1 week 1 day 8 hours ");
-
- $this->type("max_participants", "50");
- $this->click("is_map");
- $this->click("_qf_EventInfo_upload-bottom");
-
- // Wait for Location tab form to load
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Go to Fees tab
- $this->click("link=Fees");
- $this->waitForElementPresent("_qf_Fee_upload-bottom");
- $this->click("CIVICRM_QFID_1_is_monetary");
- $this->select2('payment_processor', $processorName, TRUE);
- $this->select("financial_type_id", "value=4");
-
- $counter = 1;
- foreach ($params['fee_level'] as $label => $amount) {
- $this->type("label_{$counter}", $label);
- $this->type("value_{$counter}", $amount);
- $counter++;
- }
-
- $this->click("_qf_Fee_upload-bottom");
- $this->waitForElementPresent("_qf_Fee_upload-bottom");
-
- // Go to Online Registration tab
- $this->click("link=Online Registration");
- $this->waitForElementPresent("_qf_Registration_upload-bottom");
-
- $this->click("is_online_registration");
- $this->assertChecked("is_online_registration");
-
- $this->fillRichTextField("intro_text", "Fill in all the fields below and click Continue.", 'CKEditor', TRUE);
-
- // enable confirmation email
- $this->click("CIVICRM_QFID_1_is_email_confirm");
- $this->type("confirm_from_name", "Jane Doe");
- $this->type("confirm_from_email", "jane.doe@example.org");
-
- $this->click("_qf_Registration_upload-bottom");
- $this->waitForElementPresent("_qf_Registration_upload-bottom");
- $this->waitForText('crm-notification-container', "'Online Registration' information has been saved");
-
- // verify event input on info page
- // start at Manage Events listing
- $this->openCiviPage('event/manage', 'reset=1');
- $this->type("xpath=//div[@class='crm-block crm-form-block crm-event-searchevent-form-block']/table/tbody/tr/td/input", $params['title']);
- $this->click("_qf_SearchEvent_refresh");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->clickLink("link=" . $params['title'], NULL);
-
- $params['event_id'] = $this->urlArg('id');
-
- return $params;
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'WebTest/Import/ImportCiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Import_MemberTest
- */
-class WebTest_Import_MemberTest extends ImportCiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- /**
- * Test participant import for Individuals.
- */
- public function testMemberImportIndividual() {
-
- $this->webtestLogin();
-
- // Get membership import data for Individuals.
- list($headers, $rows, $fieldMapper) = $this->_memberIndividualCSVData();
-
- // Import participants and check imported data.
- $this->importCSVComponent('Membership', $headers, $rows, 'Individual', 'Skip', $fieldMapper);
- }
-
- /**
- * Test participant import for Households.
- */
- public function testMemberImportHousehold() {
-
- $this->webtestLogin();
-
- // Get membership import data for Households.
- list($headers, $rows, $fieldMapper) = $this->_memberHouseholdCSVData();
-
- // Import participants and check imported data.
- $this->importCSVComponent('Membership', $headers, $rows, 'Household', 'Skip', $fieldMapper);
- }
-
- /**
- * Test participant import for Organizations.
- */
- public function testMemberImportOrganization() {
-
- $this->webtestLogin();
-
- // Get membership import data for Organizations.
- list($headers, $rows, $fieldMapper) = $this->_memberOrganizationCSVData();
-
- // Import participants and check imported data.
- $this->importCSVComponent('Membership', $headers, $rows, 'Organization', 'Skip', $fieldMapper);
- }
-
- /**
- * Helper function to provide data for Membeship import for Individuals.
- *
- * @return array
- */
- public function _memberIndividualCSVData() {
- $memTypeParams = $this->webtestAddMembershipType();
-
- $firstName1 = substr(sha1(rand()), 0, 7);
- $email1 = 'mail_' . substr(sha1(rand()), 0, 7) . '@example.com';
- $this->webtestAddContact($firstName1, 'Anderson', $email1);
- $startDate1 = date('Y-m-d');
-
- $firstName2 = substr(sha1(rand()), 0, 7);
- $email2 = 'mail_' . substr(sha1(rand()), 0, 7) . '@example.com';
- $this->webtestAddContact($firstName2, 'Anderson', $email2);
- $year = date('Y') - 1;
- $startDate2 = date('Y-m-d', mktime(0, 0, 0, 9, 10, $year));
-
- $headers = array(
- 'email' => 'Email',
- 'membership_type_id' => 'Membership Type',
- 'membership_start_date' => 'Membership Start Date',
- );
-
- $rows = array(
- array(
- 'email' => $email1,
- 'membership_type_id' => $memTypeParams['membership_type'],
- 'membership_start_date' => $startDate1,
- ),
- array(
- 'email' => $email2,
- 'membership_type_id' => $memTypeParams['membership_type'],
- 'membership_start_date' => $startDate2,
- ),
- );
-
- $fieldMapper = array(
- 'mapper[0][0]' => 'email',
- 'mapper[1][0]' => 'membership_type_id',
- 'mapper[2][0]' => 'membership_start_date',
- );
- return array($headers, $rows, $fieldMapper);
- }
-
- /**
- * Helper function to provide data for Membeship import for Households.
- *
- * @return array
- */
- public function _memberHouseholdCSVData() {
- $memTypeParams = $this->webtestAddMembershipType();
-
- $household1 = substr(sha1(rand()), 0, 7) . ' home';
- $this->webtestAddHousehold($household1, TRUE);
- $startDate1 = date('Y-m-d');
-
- $household2 = substr(sha1(rand()), 0, 7) . ' home';
- $this->webtestAddHousehold($household2, TRUE);
- $year = date('Y') - 1;
- $startDate2 = date('Y-m-d', mktime(0, 0, 0, 12, 31, $year));
-
- $headers = array(
- 'household_name' => 'Household Name',
- 'membership_type_id' => 'Membership Type',
- 'membership_start_date' => 'Membership Start Date',
- );
-
- $rows = array(
- array(
- 'household_name' => $household1,
- 'membership_type_id' => $memTypeParams['membership_type'],
- 'membership_start_date' => $startDate1,
- ),
- array(
- 'household_name' => $household2,
- 'membership_type_id' => $memTypeParams['membership_type'],
- 'membership_start_date' => $startDate2,
- ),
- );
-
- $fieldMapper = array(
- 'mapper[0][0]' => 'household_name',
- 'mapper[1][0]' => 'membership_type_id',
- 'mapper[2][0]' => 'membership_start_date',
- );
- return array($headers, $rows, $fieldMapper);
- }
-
- /**
- * Helper function to provide data for Membeship import for Organizations.
- *
- * @return array
- */
- public function _memberOrganizationCSVData() {
- $memTypeParams = $this->webtestAddMembershipType();
-
- $organization1 = substr(sha1(rand()), 0, 7) . ' org';
- $this->webtestAddOrganization($organization1, TRUE);
- $startDate1 = date('Y-m-d');
-
- $organization2 = substr(sha1(rand()), 0, 7) . ' org';
- $this->webtestAddOrganization($organization2, TRUE);
- $year = date('Y') - 1;
- $startDate2 = date('Y-m-d', mktime(0, 0, 0, 12, 31, $year));
-
- $headers = array(
- 'organization_name' => 'Organization Name',
- 'membership_type_id' => 'Membership Type',
- 'membership_start_date' => 'Membership Start Date',
- );
-
- $rows = array(
- array(
- 'organization_name' => $organization1,
- 'membership_type_id' => $memTypeParams['membership_type'],
- 'membership_start_date' => $startDate1,
- ),
- array(
- 'organization_name' => $organization2,
- 'membership_type_id' => $memTypeParams['membership_type'],
- 'membership_start_date' => $startDate2,
- ),
- );
-
- $fieldMapper = array(
- 'mapper[0][0]' => 'organization_name',
- 'mapper[1][0]' => 'membership_type_id',
- 'mapper[2][0]' => 'membership_start_date',
- );
- return array($headers, $rows, $fieldMapper);
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'WebTest/Import/ImportCiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Import_MultipleRelationshipTest
- */
-class WebTest_Import_MultipleRelationshipTest extends ImportCiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- /**
- * Test Multiple Relationship import for Individuals.
- */
- public function testMultipleRelationshipImport() {
- $this->webtestLogin();
-
- // Get sample import data.
- list($headers, $rows, $fieldMapper) = $this->_individualRelationshipCSVData();
-
- // Import Individuals with multiple relationships
- $this->importContacts($headers, $rows, 'Individual', 'Skip', $fieldMapper);
- }
-
- /**
- * Helper function to provide data for multiple relationship import.
- * for Individuals.
- *
- * @return array
- */
- public function _individualRelationshipCSVData() {
-
- $headers = array(
- 'first_name' => 'First Name',
- 'middle_name' => 'Middle Name',
- 'last_name' => 'Last Name',
- 'email' => 'Email',
- 'phone' => 'Phone',
- 'address_1' => 'Additional Address 1',
- 'address_2' => 'Additional Address 2',
- 'city' => 'City',
- 'state' => 'State',
- 'country' => 'Country',
- 'contact_relationships' =>
- array(
- '4_a_b' => array(
- 'organization_name' => 'Organization Name',
- 'organization_email' => 'Organization Email',
- 'organization_add' => 'Organization Street Address',
- 'organization_city' => 'Organization City',
- 'organization_state' => 'Organization State',
- 'organization_country' => 'Organization Country',
- ),
- '7_a_b' => array(
- 'household_name' => 'Household Name',
- 'household_email' => 'Household Name',
- 'household_add' => 'Household Street Address',
- 'household_city' => 'Household City',
- 'household_state' => 'Household State',
- 'household_country' => 'Household Country',
- ),
- '2_a_b' => array(
- 'spouse_f_name' => 'Spouse First Name',
- 'spouse_l_name' => 'Spouse Last Name',
- 'spouse_email' => 'Spouse Email',
- 'spouse_add' => 'Spouse Street Address',
- 'spouse_city' => 'Spouse City',
- 'spouse_state' => 'Spouse State',
- 'spouse_country' => 'Spouse Country',
- ),
- ),
- );
-
- $rows = array(
- array(
- 'first_name' => substr(sha1(rand()), 0, 7),
- 'middle_name' => substr(sha1(rand()), 0, 7),
- 'last_name' => 'Anderson',
- 'email' => substr(sha1(rand()), 0, 7) . '@example.com',
- 'phone' => '6949912154',
- 'address_1' => 'Add 1',
- 'address_2' => 'Add 2',
- 'city' => 'Watson',
- 'state' => 'NY',
- 'country' => 'UNITED STATES',
- 'contact_relationships' =>
- array(
- '4_a_b' => array(
- 'organization_name' => 'Org ' . substr(sha1(rand()), 0, 7),
- 'organization_email' => substr(sha1(rand()), 0, 7) . 'org@example.org',
- 'organization_add' => 'Org Street Address',
- 'organization_city' => 'Org City',
- 'organization_state' => 'NY',
- 'organization_country' => 'UNITED STATES',
- ),
- '7_a_b' => array(
- 'household_name' => 'House ' . substr(sha1(rand()), 0, 7),
- 'household_email' => substr(sha1(rand()), 0, 7) . 'house@example.org',
- 'household_add' => 'House Street Address',
- 'household_city' => 'House City',
- 'household_state' => 'NY',
- 'household_country' => 'UNITED STATES',
- ),
- '2_a_b' => array(
- 'spouse_f_name' => substr(sha1(rand()), 0, 7),
- 'spouse_l_name' => substr(sha1(rand()), 0, 7),
- 'spouse_email' => substr(sha1(rand()), 0, 7) . 'spouse@example.org',
- 'spouse_add' => 'Spouse Street Address',
- 'spouse_city' => 'Spouse City',
- 'spouse_state' => 'NY',
- 'spouse_country' => 'UNITED STATES',
- ),
- ),
- ),
- array(
- 'first_name' => substr(sha1(rand()), 0, 7),
- 'middle_name' => substr(sha1(rand()), 0, 7),
- 'last_name' => 'Summerson',
- 'email' => substr(sha1(rand()), 0, 7) . '@example.com',
- 'phone' => '6944412154',
- 'address_1' => 'Add 1',
- 'address_2' => 'Add 2',
- 'city' => 'Watson',
- 'state' => 'NY',
- 'country' => 'UNITED STATES',
- 'contact_relationships' =>
- array(
- '4_a_b' => array(
- 'organization_name' => 'Org ' . substr(sha1(rand()), 0, 7),
- 'organization_email' => substr(sha1(rand()), 0, 7) . 'org@example.org',
- 'organization_add' => 'Org Street Address',
- 'organization_city' => 'Org City',
- 'organization_state' => 'NY',
- 'organization_country' => 'UNITED STATES',
- ),
- '7_a_b' => array(
- 'household_name' => 'House ' . substr(sha1(rand()), 0, 7),
- 'household_email' => substr(sha1(rand()), 0, 7) . 'house@example.org',
- 'household_add' => 'House Street Address',
- 'household_city' => 'House City',
- 'household_state' => 'NY',
- 'household_country' => 'UNITED STATES',
- ),
- '2_a_b' => array(
- 'spouse_f_name' => substr(sha1(rand()), 0, 7),
- 'spouse_l_name' => substr(sha1(rand()), 0, 7),
- 'spouse_email' => substr(sha1(rand()), 0, 7) . 'spouse@example.org',
- 'spouse_add' => 'Spouse Street Address',
- 'spouse_city' => 'Spouse City',
- 'spouse_state' => 'NY',
- 'spouse_country' => 'UNITED STATES',
- ),
- ),
- ),
- );
- // for Employee of relationship
- $fieldMapper = array(
- 'mapper[10][0]' => '5_a_b',
- 'mapper[10][1]' => 'organization_name',
- 'mapper[11][0]' => '5_a_b',
- 'mapper[11][1]' => 'email',
- 'mapper[12][0]' => '5_a_b',
- 'mapper[12][1]' => 'street_address',
- 'mapper[13][0]' => '5_a_b',
- 'mapper[13][1]' => 'city',
- 'mapper[14][0]' => '5_a_b',
- 'mapper[14][1]' => 'state_province',
- 'mapper[15][0]' => '5_a_b',
- 'mapper[15][1]' => 'country',
- // for Household Member of relationship
- 'mapper[16][0]' => '8_a_b',
- 'mapper[16][1]' => 'household_name',
- 'mapper[17][0]' => '8_a_b',
- 'mapper[17][1]' => 'email',
- 'mapper[18][0]' => '8_a_b',
- 'mapper[18][1]' => 'street_address',
- 'mapper[19][0]' => '8_a_b',
- 'mapper[19][1]' => 'city',
- 'mapper[20][0]' => '8_a_b',
- 'mapper[20][1]' => 'state_province',
- 'mapper[21][0]' => '8_a_b',
- 'mapper[21][1]' => 'country',
- // for Spouse of relationship
- 'mapper[22][0]' => '2_a_b',
- 'mapper[22][1]' => 'first_name',
- 'mapper[23][0]' => '2_a_b',
- 'mapper[23][1]' => 'last_name',
- 'mapper[24][0]' => '2_a_b',
- 'mapper[24][1]' => 'email',
- 'mapper[25][0]' => '2_a_b',
- 'mapper[25][1]' => 'street_address',
- 'mapper[26][0]' => '2_a_b',
- 'mapper[26][1]' => 'city',
- 'mapper[27][0]' => '2_a_b',
- 'mapper[27][1]' => 'state_province',
- 'mapper[28][0]' => '2_a_b',
- 'mapper[28][1]' => 'country',
- );
-
- return array($headers, $rows, $fieldMapper);
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'WebTest/Import/ImportCiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Import_ParticipantTest
- */
-class WebTest_Import_ParticipantTest extends ImportCiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- /**
- * Test participant import for Individuals.
- */
- public function testParticipantImportIndividual() {
- // Log in using webtestLogin() method
- $this->webtestLogin();
-
- // Get sample import data.
- list($headers, $rows) = $this->_participantIndividualCSVData();
-
- // Create and import csv from provided data and check imported data.
- $fieldMapper = array(
- 'mapper[0][0]' => 'email',
- 'mapper[1][0]' => 'event_id',
- 'mapper[2][0]' => 'participant_fee_level',
- 'mapper[4][0]' => 'participant_status_id',
- );
-
- $this->importCSVComponent('Event', $headers, $rows, 'Individual', 'Skip', $fieldMapper);
- }
-
- /**
- * Test participant import for Organizations.
- */
- public function testParticipantImportOrganization() {
- // Log in using webtestLogin() method
- $this->webtestLogin();
-
- // Get sample import data.
- list($headers, $rows) = $this->_participantOrganizationCSVData();
-
- // Create and import csv from provided data and check imported data.
- $fieldMapper = array(
- 'mapper[0][0]' => 'organization_name',
- 'mapper[1][0]' => 'event_id',
- 'mapper[2][0]' => 'participant_fee_level',
- 'mapper[4][0]' => 'participant_status_id',
- );
-
- $this->importCSVComponent('Event', $headers, $rows, 'Organization', 'Skip', $fieldMapper);
- }
-
- /**
- * Test participant import for Households.
- */
- public function testParticipantImportHousehold() {
- // Log in using webtestLogin() method
- $this->webtestLogin();
-
- // Get sample import data.
- list($headers, $rows) = $this->_participantHouseholdCSVData();
-
- // Create and import csv from provided data and check imported data.
- $fieldMapper = array(
- 'mapper[0][0]' => 'household_name',
- 'mapper[1][0]' => 'event_id',
- 'mapper[2][0]' => 'participant_fee_level',
- 'mapper[4][0]' => 'participant_status_id',
- );
-
- $this->importCSVComponent('Event', $headers, $rows, 'Household', 'Skip', $fieldMapper);
- }
-
- /**
- * Helper function to provide data for participant import for Individuals.
- *
- * @return array
- */
- public function _participantIndividualCSVData() {
- $eventInfo = $this->_addNewEvent();
-
- $firstName1 = substr(sha1(rand()), 0, 7);
- $email1 = 'mail_' . substr(sha1(rand()), 0, 7) . '@example.com';
- $this->webtestAddContact($firstName1, 'Anderson', $email1);
-
- $firstName2 = substr(sha1(rand()), 0, 7);
- $email2 = 'mail_' . substr(sha1(rand()), 0, 7) . '@example.com';
- $this->webtestAddContact($firstName2, 'Anderson', $email2);
-
- $headers = array(
- 'email' => 'Email',
- 'event_id' => 'Event Id',
- 'fee_level' => 'Fee Level',
- 'role' => 'Participant Role',
- 'status' => 'Participant Status',
- 'register_date' => 'Register date',
- );
-
- $rows = array(
- array(
- 'email' => $email1,
- 'event_id' => $eventInfo['event_id'],
- 'fee_level' => 'Member',
- 'role' => 1,
- 'status' => 1,
- 'register_date' => '2011-03-30',
- ),
- array(
- 'email' => $email2,
- 'event_id' => $eventInfo['event_id'],
- 'fee_level' => 'Non-Member',
- 'role' => 1,
- 'status' => 1,
- 'register_date' => '2011-03-30',
- ),
- );
-
- return array($headers, $rows);
- }
-
- /**
- * Helper function to provide data for participant import for Household.
- *
- * @return array
- */
- public function _participantHouseholdCSVData() {
- $eventInfo = $this->_addNewEvent();
-
- $household1 = substr(sha1(rand()), 0, 7) . ' home';
- $this->webtestAddHousehold($household1, TRUE);
-
- $household2 = substr(sha1(rand()), 0, 7) . ' home';
- $this->webtestAddHousehold($household2, TRUE);
-
- $headers = array(
- 'household' => 'Household Name',
- 'event_id' => 'Event Id',
- 'fee_level' => 'Fee Level',
- 'role' => 'Participant Role',
- 'status' => 'Participant Status',
- 'register_date' => 'Register date',
- );
-
- $rows = array(
- array(
- 'household' => $household1,
- 'event_id' => $eventInfo['event_id'],
- 'fee_level' => 'Member',
- 'role' => 1,
- 'status' => 1,
- 'register_date' => '2011-03-30',
- ),
- array(
- 'household' => $household2,
- 'event_id' => $eventInfo['event_id'],
- 'fee_level' => 'Non-Member',
- 'role' => 1,
- 'status' => 1,
- 'register_date' => '2011-03-30',
- ),
- );
-
- return array($headers, $rows);
- }
-
- /**
- * Helper function to provide data for participant import for Organization.
- * @return array
- */
- public function _participantOrganizationCSVData() {
- $eventInfo = $this->_addNewEvent();
-
- $organization1 = substr(sha1(rand()), 0, 7) . ' org';
- $this->webtestAddOrganization($organization1, TRUE);
-
- $organization2 = substr(sha1(rand()), 0, 7) . ' org';
- $this->webtestAddOrganization($organization2, TRUE);
-
- $headers = array(
- 'organization' => 'Organization Name',
- 'event_id' => 'Event Id',
- 'fee_level' => 'Fee Level',
- 'role' => 'Participant Role',
- 'status' => 'Participant Status',
- 'register_date' => 'Register date',
- );
-
- $rows = array(
- array(
- 'organization' => $organization1,
- 'event_id' => $eventInfo['event_id'],
- 'fee_level' => 'Member',
- 'role' => 1,
- 'status' => 1,
- 'register_date' => '2011-03-30',
- ),
- array(
- 'organization' => $organization2,
- 'event_id' => $eventInfo['event_id'],
- 'fee_level' => 'Non-Member',
- 'role' => 1,
- 'status' => 1,
- 'register_date' => '2011-03-30',
- ),
- );
-
- return array($headers, $rows);
- }
-
- /**
- * Helper function to add new event.
- *
- * @param array $params
- * Parameters to create an event.
- *
- * @return array
- * event details of newly created event
- */
- public function _addNewEvent($params = array()) {
-
- if (empty($params)) {
-
- // Use default payment processor
- $processorName = 'Test Processor';
- $this->webtestAddPaymentProcessor($processorName);
-
- // create an event
- $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7);
- $params = array(
- 'title' => $eventTitle,
- 'template_id' => 6,
- 'event_type_id' => 4,
- 'payment_processor' => $processorName,
- 'fee_level' => array(
- 'Member' => "250.00",
- 'Non-Member' => "325.00",
- ),
- );
- }
-
- $this->openCiviPage('event/add', 'reset=1&action=add', '_qf_EventInfo_upload-bottom');
-
- $this->select("event_type_id", "value={$params['event_type_id']}");
-
- // Attendee role s/b selected now.
- $this->select("default_role_id", "value=1");
-
- // Enter Event Title, Summary and Description
- $this->type("title", $params['title']);
- $this->type("summary", "This is a great conference. Sign up now!");
- $this->fillRichTextField("description", "Here is a description for this event.", 'CKEditor');
-
- // Choose Start and End dates.
- // Using helper webtestFillDate function.
- $this->webtestFillDateTime("start_date", "+1 week");
- $this->webtestFillDateTime("end_date", "+1 week 1 day 8 hours ");
-
- $this->type("max_participants", "50");
- $this->click("is_map");
- $this->click("_qf_EventInfo_upload-bottom");
-
- // Wait for Location tab form to load
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Go to Fees tab
- $this->click("link=Fees");
- $this->waitForElementPresent("_qf_Fee_upload-bottom");
- $this->click("CIVICRM_QFID_1_is_monetary");
-
- // select newly created processor
- $this->select2('payment_processor', $processorName, TRUE);
- $this->assertElementContainsText('paymentProcessor', $processorName);
- $this->select("financial_type_id", "value=4");
-
- $counter = 1;
- foreach ($params['fee_level'] as $label => $amount) {
- $this->type("label_{$counter}", $label);
- $this->type("value_{$counter}", $amount);
- $counter++;
- }
-
- $this->click("_qf_Fee_upload-bottom");
- $this->waitForElementPresent("_qf_Fee_upload-bottom");
-
- // Go to Online Registration tab
- $this->click("link=Online Registration");
- $this->waitForElementPresent("_qf_Registration_upload-bottom");
-
- $this->click("is_online_registration");
- $this->assertChecked("is_online_registration");
-
- $this->fillRichTextField("intro_text", "Fill in all the fields below and click Continue.", 'CKEditor', TRUE);
-
- // enable confirmation email
- $this->click("CIVICRM_QFID_1_is_email_confirm");
- $this->type("confirm_from_name", "Jane Doe");
- $this->type("confirm_from_email", "jane.doe@example.org");
-
- $this->click("_qf_Registration_upload-bottom");
- $this->waitForElementPresent("_qf_Registration_upload-bottom");
- $this->waitForTextPresent("'Online Registration' information has been saved.");
-
- // verify event input on info page
- // start at Manage Events listing
- $this->openCiviPage('event/manage', 'reset=1');
- $this->clickLink("link=" . $params['title'], NULL);
-
- $params['event_id'] = $this->urlArg('id');;
-
- return $params;
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'WebTest/Import/ImportCiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Import_SavedMapping
- */
-class WebTest_Import_SavedMappingTest extends ImportCiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- /**
- * Test Saved Import Mapping for Individuals.
- */
- public function testSaveIndividualMapping() {
-
- // Logging in.
- $this->webtestLogin();
-
- // Get sample import data.
- list($headers, $rows) = $this->_individualCSVData();
-
- // Create New Mapping Name
- $mappingName = 'contactimport_' . substr(sha1(rand()), 0, 7);
-
- $other = array(
- 'saveMapping' => TRUE,
- 'saveMappingName' => $mappingName,
- );
-
- // Map Fields
- $fieldMapper = array(
- 'mapper[0][0]' => 'prefix_id',
- 'mapper[4][0]' => 'suffix_id',
- 'mapper[6][0]' => 'phone',
- 'mapper[6][1]' => '5',
- 'mapper[7][0]' => 'supplemental_address_1',
- 'mapper[7][1]' => '5',
- 'mapper[8][0]' => 'supplemental_address_2',
- 'mapper[8][1]' => '5',
- 'mapper[9][0]' => 'supplemental_address_3',
- 'mapper[9][1]' => '5',
- 'mapper[10][0]' => 'city',
- 'mapper[10][1]' => '5',
- 'mapper[11][0]' => 'state_province',
- 'mapper[11][1]' => '5',
- 'mapper[12][0]' => 'country',
- 'mapper[12][1]' => '5',
- );
-
- // Import and check Individual contacts in Skip mode.
- $this->importContacts($headers, $rows, 'Individual', 'Skip', $fieldMapper, $other);
-
- list($headers, $rows) = $this->_individualCSVData();
-
- // Sending Mapped Name for Re-use
- $other = array('useMappingName' => $mappingName);
- $this->importContacts($headers, $rows, 'Individual', 'Skip', array(), $other);
- }
-
- /**
- * Helper function to provide csv data for Individuals contact import.
- *
- * @return array
- */
- public function _individualCSVData() {
- $headers = array(
- 'individual_prefix' => 'Individual Prefix',
- 'first_name' => 'First Name',
- 'middle_name' => 'Middle Name',
- 'last_name' => 'Last Name',
- 'individual_suffix' => 'Individual Suffix',
- 'email' => 'Email',
- 'phone' => 'Phone',
- 'address_1' => 'Additional Address 1',
- 'address_2' => 'Additional Address 2',
- 'city' => 'City',
- 'state' => 'State',
- 'country' => 'Country',
- );
-
- $rows = array(
- array(
- 'individual_prefix' => 'Mr.',
- 'first_name' => substr(sha1(rand()), 0, 7),
- 'middle_name' => substr(sha1(rand()), 0, 7),
- 'last_name' => 'Anderson',
- 'individual_suffix' => 'Jr.',
- 'email' => substr(sha1(rand()), 0, 7) . '@example.com',
- 'phone' => '6949912154',
- 'address_1' => 'Add 1',
- 'address_2' => 'Add 2',
- 'city' => 'Watson',
- 'state' => 'NY',
- 'country' => 'UNITED STATES',
- ),
- array(
- 'individual_prefix' => 'Mr.',
- 'first_name' => substr(sha1(rand()), 0, 7),
- 'middle_name' => substr(sha1(rand()), 0, 7),
- 'last_name' => 'Summerson',
- 'individual_suffix' => 'Jr.',
- 'email' => substr(sha1(rand()), 0, 7) . '@example.com',
- 'phone' => '6944412154',
- 'address_1' => 'Add 1',
- 'address_2' => 'Add 2',
- 'city' => 'Watson',
- 'state' => 'NY',
- 'country' => 'UNITED STATES',
- ),
- );
-
- return array($headers, $rows);
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'WebTest/Import/ImportCiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Import_TagTest
- */
-class WebTest_Import_TagTest extends ImportCiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- /**
- * Test contact import for Individuals.
- */
- public function testContactImportWithTag() {
- $this->webtestLogin();
-
- // Get sample import data.
- list($headers, $rows) = $this->_contactTagCSVData();
-
- // Creating a new Tag
- $tagName = 'tag_' . substr(sha1(rand()), 0, 7);
-
- // Import and check Individual contacts in Skip mode.
- $other = array(
- 'createTag' => TRUE,
- 'createTagName' => $tagName,
- );
-
- $this->importContacts($headers, $rows, 'Individual', 'Skip', array(), $other);
-
- $this->openCiviPage("contact/search", "reset=1");
- $this->select('tag', "label={$tagName}");
- // click to search
- $this->click('_qf_Basic_refresh');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // count rows
- $countContacts = count($rows);
- // Is status message correct?
- $this->assertTrue($this->isTextPresent("{$countContacts} Contacts"));
-
- // Get sample import data.
- list($headers, $rows) = $this->_contactTagCSVData();
-
- // Import and check Individual contacts in Skip mode.
- // Sending Tag Name For Re-use
- $other = array('selectTag' => array($tagName));
-
- $this->importContacts($headers, $rows, 'Individual', 'Skip', array(), $other);
-
- $this->openCiviPage("contact/search", "reset=1");
-
- $this->select('tag', "label={$tagName}");
- // click to search
- $this->click('_qf_Basic_refresh');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- //Counting Contact rows old rows + new rows
- $countContacts += count($rows);
- // Is status message correct?
- $this->assertTrue($this->isTextPresent("{$countContacts} Contacts"));
- }
-
- /**
- * Helper function to provide data for contact import for sample.
- *
- * @return array
- */
- public function _contactTagCSVData() {
- $headers = array(
- 'first_name' => 'First Name',
- 'middle_name' => 'Middle Name',
- 'last_name' => 'Last Name',
- 'email' => 'Email',
- 'phone' => 'Phone',
- 'address_1' => 'Additional Address 1',
- 'address_2' => 'Additional Address 2',
- 'city' => 'City',
- 'state' => 'State',
- 'country' => 'Country',
- );
-
- $rows = array(
- array(
- 'first_name' => substr(sha1(rand()), 0, 7),
- 'middle_name' => substr(sha1(rand()), 0, 7),
- 'last_name' => 'Anderson',
- 'email' => substr(sha1(rand()), 0, 7) . '@example.com',
- 'phone' => '6949912154',
- 'address_1' => 'Add 1',
- 'address_2' => 'Add 2',
- 'city' => 'Watson',
- 'state' => 'NY',
- 'country' => 'UNITED STATES',
- ),
- array(
- 'first_name' => substr(sha1(rand()), 0, 7),
- 'middle_name' => substr(sha1(rand()), 0, 7),
- 'last_name' => 'Summerson',
- 'email' => substr(sha1(rand()), 0, 7) . '@example.com',
- 'phone' => '6944412154',
- 'address_1' => 'Add 1',
- 'address_2' => 'Add 2',
- 'city' => 'Watson',
- 'state' => 'NY',
- 'country' => 'UNITED STATES',
- ),
- );
-
- return array($headers, $rows);
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Mailing_ABMailingTest
- */
-class WebTest_Mailing_ABMailingTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testWithDifferentSubject() {
- $this->markTestSkipped('Skipping for now as it works fine locally.');
- $this->webtestLogin();
-
- //----do create test mailing group
- $this->openCiviPage("group/add", "reset=1", "_qf_Edit_upload");
-
- // make group name
- $groupName = 'group_' . substr(sha1(rand()), 0, 7);
-
- // fill group name
- $this->type("title", $groupName);
-
- // fill description
- $this->type("description", "New mailing group for Webtest");
-
- // enable Mailing List
- $this->click("group_type[2]");
-
- // select Visibility as Public Pages
- $this->select("visibility", "value=Public Pages");
-
- // Clicking save.
- $this->clickLink("_qf_Edit_upload");
-
- // Is status message correct?
- $this->waitForText('crm-notification-container', "The Group '$groupName' has been saved.");
-
- // no. of user to add into group
- $totalUser = 10;
-
- //---- create mailing contact and add to mailing Group
- for ($i = 1; $i <= $totalUser; $i++) {
- $firstName = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName, "Mailson", "mailino$firstName@mailson.co.in");
-
- // Get contact id from url.
- $contactId = $this->urlArg('cid');
-
- // go to group tab and add to mailing group
- $this->click("css=li#tab_group a");
- $this->waitForElementPresent("_qf_GroupContact_next");
- $this->select("group_id", "$groupName");
- $this->clickLink("_qf_GroupContact_next", "_qf_GroupContact_next", FALSE);
- }
- // configure default mail-box
- $this->setupDefaultMailbox();
-
- $this->openCiviPage("a/#/abtest/new", NULL, "xpath=//div[@class='crm-wizard-buttons']");
- $this->waitForElementPresent("xpath=//input[@name='abName']");
-
- $ABTestName = substr(sha1(rand()), 0, 7) . "ABTestName";
- $this->type("xpath=//input[@name='abName']", "$ABTestName");
-
- $this->click("xpath=//input[@value='subject']");
-
- //click on next
- $this->click("//button[@ng-click='crmUiWizardCtrl.next()']");
-
- // Add the test mailing group
- $this->select2("s2id_crmUiId_13", $groupName, TRUE);
-
- //$this->fireEvent('xpath=//div[@class="ui-slider-range"]', 'drag');
-
- //click on next
- $this->click("//button[@ng-click='crmUiWizardCtrl.next()']");
- $this->waitForElementPresent("xpath=//input[@name='subjectA']");
-
- //-------Compose Mail----------
- $tokens = ' {domain.address}{action.optOutUrl}';
-
- // fill subject for mailing
- $MailingSubject = substr(sha1(rand()), 0, 7);
- $this->type("xpath=//input[@name='subjectA']", "Test subject {$MailingSubject} for A");
- $this->type("xpath=//input[@name='subjectB']", "Test subject {$MailingSubject} for B");
-
- // HTML format message
- $HTMLMessage = "This is HTML formatted content for Mailing {$MailingSubject} Webtest.";
- $this->fillRichTextField("crmUiId_1", $HTMLMessage . $tokens);
-
- // FIXME: Selenium can't access content in an iframe
- //$this->click("xpath=//div[@class='preview-popup']//a[text()='Preview as HTML']");
- //$this->waitForTextPresent($HTMLMessage);
- //$this->waitForAjaxContent();
- //$this->click("xpath=//button[@title='Close']");
-
- // Open Plain-text Format pane and type text format msg
- $this->click("//div[starts-with(text(),'Plain Text')]");
- $this->type("xpath=//*[@name='body_text']", "This is text formatted content for Mailing {$MailingSubject} Webtest.$tokens");
-
- $this->click("xpath=//div[@class='preview-popup']//a[text()='Preview as Plain Text']");
- $this->waitForTextPresent("This is text formatted content for Mailing {$MailingSubject} Webtest.");
- $this->waitForAjaxContent();
- $this->click("xpath=//button[@title='Close']");
-
- // click next with default settings
- $this->click("xpath=//div[@class='crm-wizard-buttons']/button[text()='Next']");
-
- // click next with nominal content
- $this->click("xpath=//center/a/div[text()='Submit Mailing']");
-
- $this->waitForElementPresent("xpath=//button[text()='Select as Final']");
- $this->click("xpath=//button[text()='Select as Final']");
- $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']/button/span[text()='Submit final mailing']");
- $this->click("xpath=//div[@class='ui-dialog-buttonset']/button/span[text()='Submit final mailing']");
-
- //----------end New Mailing-------------
-
- $this->waitForAjaxContent();
-
- //check redirected page to Scheduled and Sent Mailings and verify for mailing name
- $this->openCiviPage("mailing/browse/scheduled", "reset=1&scheduled=true");
- $this->waitForTextPresent("Find Mailings");
-
- //--------- mail delivery verification---------
-
- // click report link of created mailing
- $this->clickLink("xpath=//form[@id='Search']/table/tbody//tr/td[@class='crm-mailing-name'][text()='Final ($ABTestName)']/..//td/span/a[text()='Report']");
-
- // directly send schedule mailing -- not working right now
- $this->openCiviPage("mailing/queue", "reset=1");
-
- //click report link of created mailing
- $this->clickLink("xpath=//form[@id='Search']/table/tbody//tr/td[@class='crm-mailing-name'][text()='Final ($ABTestName)']/..//td/span/a[text()='Report']");
-
- //get actual number of user for mailing
- $mailedUser = round($totalUser * ($totalUser / 100));
-
- //---- check for delivery detail--
-
- $this->waitForElementPresent("xpath=//table[@class='crm-mailing-ab-table']/tbody/tr//td//a[text()=" . $mailedUser . "]");
- $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']/tbody/tr//td//a[2]", "$mailedUser");
- $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']//tbody//tr//td/span", 'Complete');
-
- //check value for Mailing A
- $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']/tbody[3]//tr/td[2]", 'Test A (' . $ABTestName . ')');
- $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']/tbody[3]/tr[3]//td[2]", 'Test subject ' . $MailingSubject . ' for A');
- $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']//tbody//tr[@ng-controller='ViewRecipCtrl']//td/div", "Include: " . $groupName);
-
- ////check value for Mailing B
- $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']/tbody[3]//tr//td[3]", 'Test B (' . $ABTestName . ')');
- $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']/tbody[3]/tr[3]//td[3]", 'Test subject ' . $MailingSubject . ' for B');
-
- //check value for Mailing Final
- $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']/tbody[3]//tr//td[4]", 'Final (' . $ABTestName . ')');
- $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']/tbody[3]/tr[3]//td[4]", 'Test subject ' . $MailingSubject . ' for A');
- $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']//tbody//tr[@ng-controller='ViewRecipCtrl']//td/div", "Include: " . $groupName);
- }
-
- public function testWithDifferentFrom() {
- $this->markTestSkipped('Skipping for now as it works fine locally.');
- $this->webtestLogin();
-
- //----do create test mailing group
- $this->openCiviPage("group/add", "reset=1", "_qf_Edit_upload");
-
- // make group name
- $groupName = 'group_' . substr(sha1(rand()), 0, 7);
-
- // fill group name
- $this->type("title", $groupName);
-
- // fill description
- $this->type("description", "New mailing group for Webtest");
-
- // enable Mailing List
- $this->click("group_type[2]");
-
- // select Visibility as Public Pages
- $this->select("visibility", "value=Public Pages");
-
- // Clicking save.
- $this->clickLink("_qf_Edit_upload");
-
- // Is status message correct?
- $this->waitForText('crm-notification-container', "The Group '$groupName' has been saved.");
-
- // no. of user to add into group
- $totalUser = 10;
-
- //---- create mailing contact and add to mailing Group
- for ($i = 1; $i <= $totalUser; $i++) {
- $firstName = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName, "Mailson", "mailino$firstName@mailson.co.in");
-
- // Get contact id from url.
- $contactId = $this->urlArg('cid');
-
- // go to group tab and add to mailing group
- $this->click("css=li#tab_group a");
- $this->waitForElementPresent("_qf_GroupContact_next");
- $this->select("group_id", "$groupName");
- $this->clickLink("_qf_GroupContact_next", "_qf_GroupContact_next", FALSE);
- }
- // configure default mail-box
- $this->setupDefaultMailbox();
-
- // configure new Form
- $this->openCiviPage("admin/options/from_email_address", "reset=1");
- $this->waitForElementPresent("xpath=//div[@class='action-link']/a/span[contains(text(), 'Add From Email Address')]");
- $this->click("xpath=//div[@class='action-link']/a/span[contains(text(), 'Add From Email Address')]");
- $this->waitForAjaxContent();
-
- // make Form Email address
- $formEmailAddressA = 'ABMailing_' . substr(sha1(rand()), 0, 7);
- $aEmailID = '"' . $formEmailAddressA . '" <' . $formEmailAddressA . '@abtest.org>';
- $this->type("xpath=//input[@name='label']", "$aEmailID");
- $this->click("xpath=//button/span[text()='Save']");
-
- // make Form Email address
- $this->click("xpath=//div[@class='action-link']/a/span[contains(text(), 'Add From Email Address')]");
- $this->waitForAjaxContent();
- $formEmailAddressB = 'ABMailing_' . substr(sha1(rand()), 0, 7);
- $bEmailID = '"' . $formEmailAddressB . '" <' . $formEmailAddressB . '@abtest.org>';
- $this->type("xpath=//input[@name='label']", "$bEmailID");
- $this->click("xpath=//button/span[text()='Save']");
-
- $this->openCiviPage("a/#/abtest/new", NULL, "xpath=//div[@class='crm-wizard-buttons']");
- $this->waitForElementPresent("xpath=//input[@name='abName']");
-
- $ABTestName = substr(sha1(rand()), 0, 7) . "ABTestName";
- $this->type("xpath=//input[@name='abName']", "$ABTestName");
-
- $this->click("xpath=//input[@value='from']");
-
- //click on next
- $this->click("//button[@ng-click='crmUiWizardCtrl.next()']");
-
- // Add the test mailing group
- $this->select2("s2id_crmUiId_13", $groupName, TRUE);
-
- //click on next
- $this->click("//button[@ng-click='crmUiWizardCtrl.next()']");
- $this->waitForElementPresent("xpath=//input[@name='subject']");
-
- //-------Compose Mail----------
- $tokens = ' {domain.address}{action.optOutUrl}';
-
- // fill subject for mailing
- $MailingSubject = substr(sha1(rand()), 0, 7);
- $this->type("xpath=//input[@name='subject']", "Test subject {$MailingSubject} for webtest");
- $this->waitForElementPresent("xpath=//div[@id='s2id_crmUiId_20']");
-
- // choose form email address for A
- $this->select("crmUiId_20", "value=$aEmailID");
-
- // choose form email address for B
- $this->select("crmUiId_21", "value=$bEmailID");
-
- // HTML format message
- $HTMLMessage = "This is HTML formatted content for Mailing {$MailingSubject} Webtest.";
- $this->fillRichTextField("crmUiId_1", $HTMLMessage . $tokens);
-
- // FIXME: Selenium can't access content in an iframe
- //$this->click("xpath=//div[@class='preview-popup']//a[text()='Preview as HTML']");
- //$this->waitForTextPresent($HTMLMessage);
- //$this->waitForAjaxContent();
- //$this->click("xpath=//button[@title='Close']");
-
- // Open Plain-text Format pane and type text format msg
- $this->click("//div[starts-with(text(),'Plain Text')]");
- $this->type("xpath=//*[@name='body_text']", "This is text formatted content for Mailing {$MailingSubject} Webtest.$tokens");
-
- $this->click("xpath=//div[@class='preview-popup']//a[text()='Preview as Plain Text']");
- $this->waitForTextPresent("This is text formatted content for Mailing {$MailingSubject} Webtest.");
- $this->waitForAjaxContent();
- $this->click("xpath=//button[@title='Close']");
-
- // click next with default settings
- $this->click("xpath=//div[@class='crm-wizard-buttons']/button[text()='Next']");
-
- // click next with nominal content
- $this->click("xpath=//center/a/div[text()='Submit Mailing']");
-
- $this->waitForElementPresent("xpath=//button[text()='Select as Final']");
- $this->click("xpath=//button[text()='Select as Final']");
- $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']/button/span[text()='Submit final mailing']");
- $this->click("xpath=//div[@class='ui-dialog-buttonset']/button/span[text()='Submit final mailing']");
-
- //----------end New Mailing-------------
-
- $this->waitForAjaxContent();
-
- //check redirected page to Scheduled and Sent Mailings and verify for mailing name
- $this->openCiviPage("mailing/browse/scheduled", "reset=1&scheduled=true");
- $this->waitForTextPresent("Find Mailings");
-
- //--------- mail delivery verification---------
-
- // click report link of created mailing
- $this->clickLink("xpath=//form[@id='Search']/table/tbody//tr/td[@class='crm-mailing-name'][text()='Final ($ABTestName)']/..//td/span/a[text()='Report']");
-
- // directly send schedule mailing -- not working right now
- $this->openCiviPage("mailing/queue", "reset=1");
-
- //click report link of created mailing
- $this->clickLink("xpath=//form[@id='Search']/table/tbody//tr/td[@class='crm-mailing-name'][text()='Final ($ABTestName)']/..//td/span/a[text()='Report']");
-
- //get actual number of user for mailing
- $mailedUser = round($totalUser * ($totalUser / 100));
-
- //---- check for delivery detail--
- $this->waitForElementPresent("xpath=//table[@class='crm-mailing-ab-table']/tbody/tr//td//a[text()=" . $mailedUser . "]");
- $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']/tbody/tr//td//a[2]", "$mailedUser");
- $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']//tbody//tr//td/span", 'Complete');
-
- //check value for Mailing A
- $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']/tbody[3]//tr/td[2]", 'Test A (' . $ABTestName . ')');
- $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']/tbody[3]/tr[2]/td[2]", "$aEmailID");
- $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']/tbody[3]/tr[3]//td[2]", 'Test subject ' . $MailingSubject . ' for webtest');
- $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']//tbody//tr[@ng-controller='ViewRecipCtrl']//td/div", "Include: " . $groupName);
-
- //check value for Mailing B
- $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']/tbody[3]//tr//td[3]", 'Test B (' . $ABTestName . ')');
- $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']/tbody[3]/tr[2]/td[3]", "$bEmailID");
- $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']/tbody[3]/tr[3]//td[3]", 'Test subject ' . $MailingSubject . ' for webtest');
-
- //check value for Mailing Final
- $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']/tbody[3]//tr//td[4]", 'Final (' . $ABTestName . ')');
- $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']/tbody[3]/tr[2]/td[4]", "$aEmailID");
- $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']/tbody[3]/tr[3]//td[4]", 'Test subject ' . $MailingSubject . ' for webtest');
- $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']//tbody//tr[@ng-controller='ViewRecipCtrl']//td/div", "Include: " . $groupName);
- }
-
- public function testWithDifferentABMailing() {
- $this->markTestSkipped('Skipping for now as it works fine locally.');
- $this->webtestLogin();
-
- //----do create test mailing group
- $this->openCiviPage("group/add", "reset=1", "_qf_Edit_upload");
-
- // make group name
- $groupName = 'group_' . substr(sha1(rand()), 0, 7);
-
- // fill group name
- $this->type("title", $groupName);
-
- // fill description
- $this->type("description", "New mailing group for Webtest");
-
- // enable Mailing List
- $this->click("group_type[2]");
-
- // select Visibility as Public Pages
- $this->select("visibility", "value=Public Pages");
-
- // Clicking save.
- $this->clickLink("_qf_Edit_upload");
-
- // Is status message correct?
- $this->waitForText('crm-notification-container', "The Group '$groupName' has been saved.");
-
- // no. of user to add into group
- $totalUser = 10;
-
- //---- create mailing contact and add to mailing Group
- for ($i = 1; $i <= $totalUser; $i++) {
- $firstName = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName, "Mailson", "mailino$firstName@mailson.co.in");
-
- // Get contact id from url.
- $contactId = $this->urlArg('cid');
-
- // go to group tab and add to mailing group
- $this->click("css=li#tab_group a");
- $this->waitForElementPresent("_qf_GroupContact_next");
- $this->select("group_id", "$groupName");
- $this->clickLink("_qf_GroupContact_next", "_qf_GroupContact_next", FALSE);
- }
- // configure default mail-box
- $this->setupDefaultMailbox();
-
- $this->openCiviPage("a/#/abtest/new", NULL, "xpath=//div[@class='crm-wizard-buttons']");
- $this->waitForElementPresent("xpath=//input[@name='abName']");
-
- $ABTestName = substr(sha1(rand()), 0, 7) . "ABTestName";
- $this->type("xpath=//input[@name='abName']", "$ABTestName");
-
- $this->click("xpath=//input[@value='full_email']");
-
- //click on next
- $this->click("//button[@ng-click='crmUiWizardCtrl.next()']");
-
- // Add the test mailing group
- $this->select2("s2id_crmUiId_13", $groupName, TRUE);
-
- //click on next
- $this->click("//button[@ng-click='crmUiWizardCtrl.next()']");
- $this->waitForElementPresent("xpath=//input[@name='subjectA']");
-
- //-------Compose A----------
- $tokens = ' {domain.address}{action.optOutUrl}';
-
- // fill subject for mailing
- $AMailingSubject = substr(sha1(rand()), 0, 7);
- $this->type("xpath=//input[@name='subjectA']", "Test subject {$AMailingSubject} for Webtest");
-
- // HTML format message
- $AHTMLMessage = "This is HTML formatted content for Mailing {$AMailingSubject} Webtest.";
- $this->fillRichTextField("crmUiId_19", $AHTMLMessage . $tokens);
-
- // FIXME: Selenium can't access content in an iframe
- //$this->click("xpath=//div[@class='preview-popup']//a[text()='Preview as HTML']");
- //$this->waitForTextPresent($AHTMLMessage);
- //$this->waitForAjaxContent();
- //$this->click("xpath=//button[@title='Close']");
-
- // Open Plain-text Format pane and type text format msg
- $this->click("//div[starts-with(text(),'Plain Text')]");
- $this->type("xpath=//*[@name='body_text']", "This is text formatted content for Mailing {$AMailingSubject} Webtest.$tokens");
-
- $this->click("xpath=//div[@class='preview-popup']//a[text()='Preview as Plain Text']");
- $this->waitForTextPresent("This is text formatted content for Mailing {$AMailingSubject} Webtest.");
- $this->waitForAjaxContent();
- $this->click("xpath=//button[@title='Close']");
-
- // click next with default settings
- $this->click("xpath=//div[@class='crm-wizard-buttons']/button[text()='Next']");
- $this->waitForElementPresent("xpath=//input[@name='subjectB']");
-
- //-------Compose B----------
-
- // fill subject for mailing
- $BMailingSubject = substr(sha1(rand()), 0, 7);
- $this->type("xpath=//input[@name='subjectB']", "Test subject {$BMailingSubject} for Webtest");
-
- // HTML format message
- $BHTMLMessage = "This is HTML formatted content for Mailing {$BMailingSubject} Webtest.";
- $this->fillRichTextField("crmUiId_28", $BHTMLMessage . $tokens);
-
- // FIXME: Selenium can't access content in an iframe
- //$this->click("xpath=//div[@class='preview-popup']//a[text()='Preview as HTML']");
- //$this->waitForTextPresent($BHTMLMessage);
- //$this->waitForAjaxContent();
- //$this->click("xpath=//button[@title='Close']");
-
- // Open Plain-text Format pane and type text format msg
- $this->waitForElementPresent("xpath=//div[@id='tab-mailingB']//div[contains(text(), 'Plain Text')]");
- $this->click("xpath=//div[@id='tab-mailingB']//div[contains(text(), 'Plain Text')]");
- $this->type("xpath=//div[@id='tab-mailingB']//*[@name='body_text']", "This is text formatted content for Mailing {$BMailingSubject} Webtest.$tokens");
-
- $this->click("xpath=//div[@crm-mailing='abtest.mailings.b']//div[@class='preview-popup']//a[text()='Preview as Plain Text']");
- $this->waitForTextPresent("This is text formatted content for Mailing {$BMailingSubject} Webtest.");
- $this->waitForAjaxContent();
- $this->click("xpath=//button[@title='Close']");
-
- // click next with default settings
- $this->click("xpath=//div[@class='crm-wizard-buttons']/button[text()='Next']");
-
- // click next with nominal content
- $this->click("xpath=//center/a/div[text()='Submit Mailing']");
-
- $this->waitForElementPresent("xpath=//button[text()='Select as Final']");
- $this->click("xpath=//button[text()='Select as Final']");
- $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']/button/span[text()='Submit final mailing']");
- $this->click("xpath=//div[@class='ui-dialog-buttonset']/button/span[text()='Submit final mailing']");
-
- //----------end New Mailing-------------
-
- $this->waitForAjaxContent();
-
- //check redirected page to Scheduled and Sent Mailings and verify for mailing name
- $this->openCiviPage("mailing/browse/scheduled", "reset=1&scheduled=true");
- $this->waitForTextPresent("Find Mailings");
-
- //--------- mail delivery verification---------
-
- // click report link of created mailing
- $this->clickLink("xpath=//form[@id='Search']/table/tbody//tr/td[@class='crm-mailing-name'][text()='Final ($ABTestName)']/..//td/span/a[text()='Report']");
-
- // directly send schedule mailing -- not working right now
- $this->openCiviPage("mailing/queue", "reset=1");
-
- //click report link of created mailing
- $this->clickLink("xpath=//form[@id='Search']/table/tbody//tr/td[@class='crm-mailing-name'][text()='Final ($ABTestName)']/..//td/span/a[text()='Report']");
-
- //get actual number of user for mailing
- $mailedUser = round($totalUser * ($totalUser / 100));
-
- //---- check for delivery detail--
- $this->waitForElementPresent("xpath=//table[@class='crm-mailing-ab-table']/tbody/tr//td//a[text()=" . $mailedUser . "]");
- $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']/tbody/tr//td//a[2]", "$mailedUser");
- $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']//tbody//tr//td/span", 'Complete');
-
- //check value for Mailing A
- $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']/tbody[3]//tr/td[2]", 'Test A (' . $ABTestName . ')');
- $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']/tbody[3]/tr[3]//td[2]", 'Test subject ' . $AMailingSubject . ' for Webtest');
- $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']//tbody//tr[@ng-controller='ViewRecipCtrl']//td/div", "Include: " . $groupName);
-
- //check value for Mailing B
- $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']/tbody[3]//tr//td[3]", 'Test B (' . $ABTestName . ')');
- $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']/tbody[3]/tr[3]//td[3]", 'Test subject ' . $BMailingSubject . ' for Webtest');
-
- //check value for Mailing Final
- $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']/tbody[3]//tr//td[4]", 'Final (' . $ABTestName . ')');
- $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']/tbody[3]/tr[3]//td[4]", 'Test subject ' . $AMailingSubject . ' for Webtest');
- $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']//tbody//tr[@ng-controller='ViewRecipCtrl']//td/div", "Include: " . $groupName);
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Mailing_AddMessageTemplateTest
- */
-class WebTest_Mailing_AddMessageTemplateTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- /**
- * @param bool $useTokens
- * @param null $msgTitle
- */
- public function testTemplateAdd($useTokens = FALSE, $msgTitle = NULL) {
- $this->webtestLogin();
-
- $this->openCiviPage("admin/messageTemplates/add", "action=add&reset=1");
-
- $this->waitForElementPresent("_qf_MessageTemplates_cancel-bottom");
- // Fill message title.
- if (!$msgTitle) {
- $msgTitle = 'msg_' . substr(sha1(rand()), 0, 7);
- }
- $this->type("msg_title", $msgTitle);
- if ($useTokens) {
- //Add Tokens
- $this->select2("msg_subject", "Display Name");
- $this->select2("msg_subject", "Contact Type");
- $this->select2("xpath=//*[contains(@data-field,'msg_text')]/../div/a", "Display Name", FALSE, TRUE);
- $this->select2("xpath=//*[contains(@data-field,'msg_text')]/../div/a", "Contact Type", FALSE, TRUE);
- $this->select2("xpath=//*[contains(@data-field,'html_message')]/../div/a", "Display Name", FALSE, TRUE);
- $this->select2("xpath=//*[contains(@data-field,'html_message')]/../div/a", "Contact Type", FALSE, TRUE);
- }
- else {
- // Fill message subject.
- $msgSubject = "This is subject for message";
- $this->type("msg_subject", $msgSubject);
-
- // Fill text message.
- $txtMsg = "This is text message";
- $this->type("msg_text", $txtMsg);
-
- // Fill html message.
- $htmlMsg = "This is HTML message";
- $this->type("msg_html", $htmlMsg);
- }
- // Clicking save.
- $this->click("_qf_MessageTemplates_next");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Is status message correct
- $this->waitForText('crm-notification-container', "The Message Template '$msgTitle' has been saved.");
-
- // Verify text.
- $this->assertTrue($this->isElementPresent("xpath=id('user')//div//div/table[@class='display dataTable no-footer']/tbody//tr/td[1][contains(text(), '$msgTitle')]"),
- 'Message Template Title not found!');
- if (!$useTokens) {
- $this->assertTrue($this->isElementPresent("xpath=id('user')//div//div/table[@class='display dataTable no-footer']/tbody//tr/td[2][contains(text(), '$msgSubject')]"),
- 'Message Subject not found!');
- }
- }
-
- public function testAddMailingWithMessageTemplate() {
- $this->markTestSkipped('Skipping for now as it works fine locally.');
- // Call the above test to set up our environment
- $msgTitle = 'msg_' . substr(sha1(rand()), 0, 7);
- $this->testTemplateAdd(TRUE, $msgTitle);
-
- // create new mailing group
- $groupName = $this->WebtestAddGroup();
-
- //Create new contact and add to mailing Group
- $firstName = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName, "Mailson", "mailino$firstName@mailson.co.in");
- $this->click("css=li#tab_group a");
- $this->waitForElementPresent("_qf_GroupContact_next");
- $this->select("group_id", "$groupName");
- $this->click("_qf_GroupContact_next");
-
- // configure default mail-box
- $this->setupDefaultMailbox();
-
- $this->openCiviPage("a/#/mailing/new");
- $this->waitForElementPresent("xpath=//input[@name='mailingName']");
-
- // fill mailing name
- $mailingName = substr(sha1(rand()), 0, 7);
- $this->type("xpath=//input[@name='mailingName']", "Mailing $mailingName Webtest");
-
- // Add the test mailing group
- $this->select2("s2id_crmUiId_8", $groupName, TRUE);
-
- // do check count for Recipient
- $this->waitForTextPresent("~1 recipient");
- $this->click("msg_template_id");
- $this->select("msg_template_id", "label=$msgTitle");
- $this->waitForAjaxContent();
- $this->select2('s2id_autogen1', "Unsubscribe via web page");
- $this->select2('s2id_autogen1', "Domain (organization) address");
- $this->waitForAjaxContent();
- $this->select2('s2id_autogen3', "Unsubscribe via web page");
- $this->select2('s2id_autogen3', "Domain (organization) address");
- $this->waitForAjaxContent();
- $this->click("xpath=//div[@class='preview-popup']//a[text()='Preview as Plain Text']");
- $this->click('subject');
-
- // check for default settings options
- $this->click('link=Tracking');
- $this->assertChecked("url_tracking");
- $this->assertChecked("open_tracking");
-
- // check for default header and footer ( with label )
- $this->click('link=Header and Footer');
- $this->select('header_id', "label=Mailing Header");
- $this->select('footer_id', "label=Mailing Footer");
-
- // click next
- $this->click("xpath=//div[@class='crm-wizard-buttons']/button[text()='Next']");
-
- $this->assertChecked("xpath=//input[@id='schedule-send-now']");
- $this->waitForTextPresent("Mailing $mailingName Webtest");
- $this->click("xpath=//div[@class='content']//a[text()='~1 recipient']");
- $this->webtestVerifyTabularData(array("$firstName Mailson" => "mailino$firstName@mailson.co.in"));
- $this->click("xpath=//button[@title='Close']");
- $this->waitForTextPresent("(Include: $groupName)");
-
- // finally schedule the mail by clicking submit
- $this->click("xpath=//center/a/div[text()='Submit Mailing']");
-
- //check redirected page to Scheduled and Sent Mailings and verify for mailing name
- $this->waitForTextPresent("Find Mailings");
- $this->isTextPresent("Mailing $mailingName Webtest");
- $this->openCiviPage('mailing/queue', 'reset=1');
-
- // verify status
- $this->verifyText("xpath=id('Search')/table/tbody/tr[1]/td[2]", preg_quote("Complete"));
-
- //View Activity
- $this->openCiviPage('activity/search', "reset=1", "_qf_Search_refresh");
- $this->type("sort_name", $firstName);
- $this->select("activity_type_id", "label=Bulk Email");
- $this->click("_qf_Search_refresh");
- $this->waitForElementPresent("xpath=//form[@id='Search']/div[3]/div/div[2]/table[@class='selector row-highlight']/tbody/tr[2]/td[9]/span/a[1][text()='View']");
- $this->click("xpath=//form[@id='Search']/div[3]/div/div[2]/table[@class='selector row-highlight']/tbody/tr[2]/td[9]/span/a[1][text()='View']");
- $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']/button/span[2]");
- $this->assertElementContainsText("xpath=//div[@class='help']", "Bulk Email Sent.", "Status message didn't show up after saving!");
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Mailing_AddNewMailingComponentTest
- */
-class WebTest_Mailing_AddNewMailingComponentTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testHeaderAdd() {
- $this->webtestLogin();
-
- $this->openCiviPage("admin/component", "action=add&reset=1");
-
- // fill component name.
- $componentName = 'ComponentName_' . substr(sha1(rand()), 0, 7);
- $this->type("name", $componentName);
-
- // fill component type
- $this->click("component_type");
- $this->select("component_type", "value=Header");
-
- // fill subject
- $subject = "This is subject for New Mailing Component.";
- $this->type("subject", $subject);
-
- // fill text message
- $txtMsg = "This is Header Text Message";
- $this->type("body_text", $txtMsg);
-
- // fill html message
- $htmlMsg = "This is Header HTML Message";
- $this->type("body_html", $htmlMsg);
- $this->click("is_default");
-
- // Clicking save.
- $this->click("_qf_Component_next");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Is status message correct.
- $this->waitForText('crm-notification-container', "The mailing component '$componentName' has been saved.");
-
- // Verify text.
- $this->assertTrue($this->isElementPresent("xpath=//table/tbody//tr/td/div[text()='{$componentName}']/../../td[2][text()='Header']/../td[3][text()='{$subject}']/../td[4][text()='{$txtMsg}']/../td[5][text()='{$htmlMsg}']"), "The row doesn't consists of proper component details");
- }
-
- public function testFooterAdd() {
- $this->webtestLogin();
-
- $this->openCiviPage("admin/component", "action=add&reset=1");
-
- // fill component name.
- $componentName = 'ComponentName_' . substr(sha1(rand()), 0, 7);
- $this->type("name", $componentName);
-
- // fill component type
- $this->click("component_type");
- $this->select("component_type", "value=Footer");
-
- // fill subject
- $subject = "This is subject for New Mailing Component.";
- $this->type("subject", $subject);
-
- // fill text message
- $txtMsg = "This is Footer Text Message";
- $this->type("body_text", $txtMsg);
-
- // fill html message
- $htmlMsg = "This is Footer HTML Message";
- $this->type("body_html", $htmlMsg);
- $this->click("is_default");
-
- // Clicking save.
- $this->click("_qf_Component_next");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Is status message correct.
- $this->waitForText('crm-notification-container', "The mailing component '$componentName' has been saved.");
-
- // Verify text.
- $this->assertTrue($this->isElementPresent("xpath=//table/tbody//tr/td/div[text()='{$componentName}']/../../td[2][text()='Footer']/../td[3][text()='{$subject}']/../td[4][text()='{$txtMsg}']/../td[5][text()='{$htmlMsg}']"), "The row doesn't consists of proper component details");
- }
-
- public function testAutomatedAdd() {
- $this->webtestLogin();
-
- $this->openCiviPage("admin/component", "action=add&reset=1");
-
- // fill component name.
- $componentName = 'ComponentName_' . substr(sha1(rand()), 0, 7);
- $this->type("name", $componentName);
-
- // fill component type
- $this->click("component_type");
- $this->select("component_type", "value=Reply");
-
- // fill subject
- $subject = "This is subject for New Mailing Component.";
- $this->type("subject", $subject);
-
- // fill text message
- $txtMsg = "This is Automated Text Message";
- $this->type("body_text", $txtMsg);
-
- // fill html message
- $htmlMsg = "This is Automated HTML Message";
- $this->type("body_html", $htmlMsg);
- $this->click("is_default");
-
- // Clicking save.
- $this->click("_qf_Component_next");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Is status message correct.
- $this->waitForText('crm-notification-container', "The mailing component '$componentName' has been saved.");
-
- // Verify text
- $this->assertTrue($this->isElementPresent("xpath=//table/tbody//tr/td/div[text()='{$componentName}']/../../td[2][text()='Reply']/../td[3][text()='{$subject}']/../td[4][text()='{$txtMsg}']/../td[5][text()='{$htmlMsg}']"), "The row doesn't consists of proper component details");
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Mailing_MailingTest
- */
-class WebTest_Mailing_MailingTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testAddMailing() {
- $this->webtestLogin();
-
- //----do create test mailing group
- $this->openCiviPage("group/add", "reset=1", "_qf_Edit_upload");
-
- // make group name
- $groupName = 'group_' . substr(sha1(rand()), 0, 7);
-
- // fill group name
- $this->type("title", $groupName);
-
- // fill description
- $this->type("description", "New mailing group for Webtest");
-
- // enable Mailing List
- $this->click("group_type[2]");
-
- // select Visibility as Public Pages
- $this->select("visibility", "value=Public Pages");
-
- // Clicking save.
- $this->clickLink("_qf_Edit_upload");
-
- // Is status message correct?
- $this->waitForText('crm-notification-container', "The Group '$groupName' has been saved.");
-
- //---- create mailing contact and add to mailing Group
- $firstName = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName, "Mailson", "mailino$firstName@mailson.co.in");
-
- // Get contact id from url.
- $contactId = $this->urlArg('cid');
-
- // go to group tab and add to mailing group
- $this->click("css=li#tab_group a");
- $this->waitForElementPresent("_qf_GroupContact_next");
- $this->select("group_id", "$groupName");
- $this->clickLink("_qf_GroupContact_next", "_qf_GroupContact_next", FALSE);
-
- // configure default mail-box
- $this->setupDefaultMailbox();
-
- $this->openCiviPage("a/#/mailing/new");
-
- //-------select recipients----------
- $tokens = ' {domain.address}{action.optOutUrl}';
-
- // fill mailing name
- $mailingName = substr(sha1(rand()), 0, 7);
- $this->waitForElementPresent("xpath=//input[@name='mailingName']");
- $this->type("xpath=//input[@name='mailingName']", "Mailing $mailingName Webtest");
-
- // Add the test mailing group
- $this->select2("s2id_crmUiId_8", $groupName, TRUE);
-
- // do check count for Recipient
- $this->waitForTextPresent("~1 recipient");
-
- // fill subject for mailing
- $this->type("xpath=//input[@name='subject']", "Test subject {$mailingName} for Webtest");
-
- // HTML format message
- $HTMLMessage = "This is HTML formatted content for Mailing {$mailingName} Webtest.";
- $this->fillRichTextField("crmUiId_1", $HTMLMessage . $tokens);
-
- // FIXME: Selenium can't access content in an iframe
- //$this->click("xpath=//div[@class='preview-popup']//a[text()='Preview as HTML']");
- //$this->waitForTextPresent($HTMLMessage);
- //$this->waitForAjaxContent();
- //$this->click("xpath=//button[@title='Close']");
-
- // Open Plain-text Format pane and type text format msg
- $this->click("//div[starts-with(text(),'Plain Text')]");
- $this->type("xpath=//*[@name='body_text']", "This is text formatted content for Mailing {$mailingName} Webtest.$tokens");
-
- $this->click("xpath=//div[@class='preview-popup']//a[text()='Preview as Plain Text']");
- $this->waitForTextPresent("This is text formatted content for Mailing {$mailingName} Webtest.");
- $this->waitForAjaxContent();
- $this->click("xpath=//button[@title='Close']");
-
- // select default header and footer ( with label )
- $this->click('link=Header and Footer');
- $this->select2("s2id_crmUiId_10", "Mailing Header");
- $this->select2("s2id_crmUiId_11", "Mailing Footer");
-
- //--------track and respond----------
-
- // check for default settings options
- $this->click('link=Tracking');
- $this->assertChecked("url_tracking");
- $this->assertChecked("open_tracking");
-
- // click next with default settings
- $this->click("xpath=//div[@class='crm-wizard-buttons']/button[text()='Next']");
-
- $this->waitForTextPresent("Mailing $mailingName Webtest");
- $this->click("xpath=//div[@class='content']//a[text()='~1 recipient']");
- $this->webtestVerifyTabularData(array("$firstName Mailson" => "mailino$firstName@mailson.co.in"));
- $this->click("xpath=//button[@title='Close']");
- $this->waitForTextPresent("(Include: $groupName)");
-
- //----------Schedule or Send------------
-
- // do check for default option enabled
- $this->assertChecked("xpath=//input[@id='schedule-send-now']");
-
- // click next with nominal content
- $this->click("xpath=//center/a/div[text()='Submit Mailing']");
-
- //---------------Test------------------
-
- ////////--Commenting test mailing and mailing preview (test mailing and preview not presently working).
-
- // send test mailing
- //$this->type("test_email", "mailino@mailson.co.in");
- //$this->click("sendtest");
-
- // verify status message
- //$this->assertTrue($this->isTextPresent("Your test message has been sent. Click 'Next' when you are ready to Schedule or Send your live mailing (you will still have a chance to confirm or cancel sending this mailing on the next page)."));
-
- // check mailing preview
- //$this->click("//form[@id='Test']/div[2]/div[4]/div[1]");
- //$this->assertTrue($this->isTextPresent("this is test content for Mailing $mailingName Webtest"));
-
- ////////
-
- //----------end New Mailing-------------
-
- //check redirected page to Scheduled and Sent Mailings and verify for mailing name
- $this->waitForTextPresent("Find Mailings");
- $this->assertElementContainsText("xpath=//table[@class='selector row-highlight']/tbody//tr//td", "Mailing $mailingName Webtest");
-
- //--------- mail delivery verification---------
- // test undelivered report
-
- // click report link of created mailing
- $this->clickLink("xpath=//table//tbody/tr[td[1]/text()='Mailing $mailingName Webtest']/descendant::a[text()='Report']");
-
- // verify undelivered status message
- $this->assertElementContainsText('css=.messages', "Delivery has not yet begun for this mailing. If the scheduled delivery date and time is past, ask the system administrator or technical support contact for your site to verify that the automated mailer task ('cron job') is running - and how frequently.");
-
- // do check for recipient group
- $this->assertElementContainsText("xpath=//fieldset/legend[text()='Recipients']/../table/tbody//tr/td", "Members of $groupName");
-
- // directly send schedule mailing -- not working right now
- $this->openCiviPage("mailing/queue", "reset=1");
-
- //click report link of created mailing
- $this->clickLink("xpath=//table//tbody/tr[td[1]/text()='Mailing $mailingName Webtest']/descendant::a[text()='Report']");
-
- // do check again for recipient group
- $this->assertElementContainsText("xpath=//fieldset/legend[text()='Recipients']/../table/tbody//tr/td", "Members of $groupName");
-
- // verify intended recipients
- $this->verifyText("xpath=//table//tr[td/a[text()='Intended Recipients']]/descendant::td[2]", preg_quote("1"));
-
- // verify successful deliveries
- $this->verifyText("xpath=//table//tr[td/a[text()='Successful Deliveries']]/descendant::td[2]", preg_quote("1 (100.00%)"));
-
- // verify status
- $this->verifyText("xpath=//table//tr[td[1]/text()='Status']/descendant::td[2]", preg_quote("Complete"));
-
- // verify mailing name
- $this->verifyText("xpath=//table//tr[td[1]/text()='Mailing Name']/descendant::td[2]", preg_quote("Mailing $mailingName Webtest"));
-
- // verify mailing subject
- $this->verifyText("xpath=//table//tr[td[1]/text()='Subject']/descendant::td[2]", preg_quote("Test subject $mailingName for Webtest"));
-
- //---- check for delivery detail--
-
- $this->clickLink("link=Successful Deliveries");
-
- // check for open page
- $this->waitForTextPresent("Successful Deliveries");
-
- // verify email
- $this->verifyText("xpath=//table[@id='mailing_event']/tbody//tr/td[3]", preg_quote("mailino$firstName@mailson.co.in"));
-
- $eventQueue = new CRM_Mailing_Event_DAO_Queue();
- $eventQueue->contact_id = $contactId;
- $eventQueue->find(TRUE);
-
- $permission = array('edit-1-access-civimail-subscribeunsubscribe-pages');
- $this->changePermissions($permission);
- $this->webtestLogout();
-
- // build forward url
- $forwardUrl = array(
- "mailing/forward",
- "reset=1&jid={$eventQueue->job_id}&qid={$eventQueue->id}&h={$eventQueue->hash}",
- );
- $this->openCiviPage($forwardUrl[0], $forwardUrl[1], NULL);
-
- $this->type("email_0", substr(sha1(rand()), 0, 7) . '@example.com');
- $this->type("email_1", substr(sha1(rand()), 0, 7) . '@example.com');
-
- $this->click("comment_show");
- $this->type("forward_comment", "Test Message");
-
- $this->click("_qf_ForwardMailing_next-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->assertElementContainsText('css=div.messages', 'Mailing is forwarded successfully to 2 email addresses');
-
- $this->webtestLogin();
-
- $this->openCiviPage("mailing/browse/scheduled", "reset=1&scheduled=true");
-
- //click report link of created mailing
- $this->clickLink("xpath=//table//tbody/tr[td[1]/text()='Mailing $mailingName Webtest']/descendant::a[text()='Report']");
-
- // verify successful forwards
- $this->verifyText("xpath=//table//tr[td/a[text()='Forwards']]/descendant::td[2]", "2");
-
- // Mailing is forwarded successfully to 2 email addresses.
- //------end delivery verification---------
-
- // //------ check with unsubscribe -------
- // // FIX ME: there is an issue with DSN setting for Webtest, need to handle by separate DSN setting for Webtests
- // // build unsubscribe link
- // require_once 'CRM/Mailing/Event/DAO/Queue.php';
- // $eventQueue = new CRM_Mailing_Event_DAO_Queue( );
- // $eventQueue->contact_id = $contactId;
- // $eventQueue->find(true);
-
- // // unsubscribe link
- // $unsubscribeUrl = "civicrm/mailing/optout?reset=1&jid={$eventQueue->job_id}&qid={$eventQueue->id}&h={$eventQueue->hash}&confirm=1";
-
- // // logout to unsubscribe
- // $this->webtestLogout();
-
- // // click(visit) unsubscribe path
- // $this->open($this->sboxPath . $unsubscribeUrl);
- // $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // $this->assertTrue($this->isTextPresent('Optout'));
- // $this->assertTrue($this->isTextPresent("mailino$firstName@mailson.co.in"));
-
- // // unsubscribe
- // $this->click('_qf_optout_next');
- // $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // $this->assertTrue($this->isTextPresent('Optout'));
- // $this->assertTrue($this->isTextPresent("mailino$firstName@mailson.co.in"));
- // $this->assertTrue($this->isTextPresent('has been successfully opted out.'));
-
- // //------ end unsubscribe -------
- }
-
- public function testAdvanceSearchAndReportCheck() {
-
- $this->webtestLogin();
-
- $this->openCiviPage("group/add", "reset=1", "_qf_Edit_upload");
-
- // make group name
- $groupName = 'group_' . substr(sha1(rand()), 0, 7);
-
- // fill group name
- $this->type("title", $groupName);
-
- // fill description
- $this->type("description", "New mailing group for Webtest");
-
- // enable Mailing List
- $this->click("group_type[2]");
-
- // select Visibility as Public Pages
- $this->select("visibility", "value=Public Pages");
-
- // Clicking save.
- $this->clickLink("_qf_Edit_upload");
-
- // Is status message correct?
- $this->waitForText('crm-notification-container', "The Group '$groupName' has been saved.");
-
- //---- create mailing contact and add to mailing Group
- $firstName = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName, "Mailson", "mailino$firstName@mailson.co.in");
-
- // Get contact id from url.
- $contactId = $this->urlArg('cid');
-
- // go to group tab and add to mailing group
- $this->click("css=li#tab_group a");
- $this->waitForElementPresent("_qf_GroupContact_next");
- $this->select("group_id", "$groupName");
- $this->clickLink("_qf_GroupContact_next", "_qf_GroupContact_next", FALSE);
-
- // configure default mail-box
- $this->openCiviPage("admin/mailSettings", "action=update&id=1&reset=1", '_qf_MailSettings_cancel-bottom');
- $this->waitForElementPresent('name');
- $this->type('name', 'Test Domain');
- $this->type('domain', 'example.com');
- $this->select('protocol', 'value=1');
- $this->clickLink('_qf_MailSettings_next-bottom');
-
- $this->openCiviPage("a/#/mailing/new");
-
- //-------select recipients----------
- $tokens = ' {domain.address}{action.optOutUrl}';
-
- // fill mailing name
- $mailingName = substr(sha1(rand()), 0, 7);
- $this->waitForElementPresent("xpath=//input[@name='mailingName']");
- $this->type("xpath=//input[@name='mailingName']", "Mailing $mailingName Webtest");
-
- // Add the test mailing group
- $this->select2("s2id_crmUiId_8", $groupName, TRUE);
-
- // do check count for Recipient
- $this->waitForTextPresent("~1 recipient");
-
- // fill subject for mailing
- $this->waitForElementPresent("xpath=//input[@name='subject']");
- $this->type("xpath=//input[@name='subject']", "Test subject {$mailingName} for Webtest");
-
- // HTML format message
- $HTMLMessage = "This is HTML formatted content for Mailing {$mailingName} Webtest.";
- $this->fillRichTextField("crmUiId_1", $HTMLMessage . $tokens);
-
- // FIXME: Selenium can't access content in an iframe
- //$this->click("xpath=//div[@class='preview-popup']//a[text()='Preview as HTML']");
- //$this->waitForElementPresent($HTMLMessage);
- //$this->waitForAjaxContent();
- //$this->click("xpath=//button[@title='Close']");
-
- // Open Plain-text Format pane and type text format msg
- $this->click("//div[starts-with(text(),'Plain Text')]");
- $this->type("xpath=//*[@name='body_text']", "This is text formatted content for Mailing {$mailingName} Webtest.$tokens");
-
- $this->click("xpath=//div[@class='preview-popup']//a[text()='Preview as Plain Text']");
- $this->waitForTextPresent("This is text formatted content for Mailing {$mailingName} Webtest.");
- $this->waitForAjaxContent();
- $this->click("xpath=//button[@title='Close']");
-
- // select default header and footer ( with label )
- $this->click('link=Header and Footer');
- $this->select2("s2id_crmUiId_10", "Mailing Header");
- $this->select2("s2id_crmUiId_11", "Mailing Footer");
-
- //--------track and respond----------
-
- // check for default settings options
- $this->click('link=Tracking');
- $this->assertChecked("url_tracking");
- $this->assertChecked("open_tracking");
-
- // click next with default settings
- $this->click("xpath=//div[@class='crm-wizard-buttons']/button[text()='Next']");
-
- $this->waitForTextPresent("Mailing $mailingName Webtest");
- $this->click("xpath=//div[@class='content']//a[text()='~1 recipient']");
- $this->webtestVerifyTabularData(array("$firstName Mailson" => "mailino$firstName@mailson.co.in"));
- $this->click("xpath=//button[@title='Close']");
- $this->waitForTextPresent("(Include: $groupName)");
-
- //----------Schedule or Send------------
-
- // do check for default option enabled
- $this->assertChecked("xpath=//input[@id='schedule-send-now']");
-
- // click next with nominal content
- $this->click("xpath=//center/a/div[text()='Submit Mailing']");
-
- //----------end New Mailing-------------
-
- //check redirected page to Scheduled and Sent Mailings and verify for mailing name
- $this->waitForTextPresent("Find Mailings");
- $this->assertElementContainsText("xpath=//table[@class='selector row-highlight']/tbody//tr//td", "Mailing $mailingName Webtest");
-
- // directly send schedule mailing -- not working right now
- $this->openCiviPage("mailing/queue", "reset=1");
-
- //click report link of created mailing
- $this->clickLink("xpath=//table//tbody/tr[td[1]/text()='Mailing $mailingName Webtest']/descendant::a[text()='Report']");
-
- $mailingReportUrl = $this->getLocation();
- // do check again for recipient group
- $this->assertElementContainsText("xpath=//fieldset/legend[text()='Recipients']/../table/tbody//tr/td", "Members of $groupName");
-
- // verify successful deliveries
- $this->verifyText("xpath=//table//tr[td/a[text()='Successful Deliveries']]/descendant::td[2]", preg_quote("1 (100.00%)"));
-
- $summaryInfoLinks = array(
- 'Intended Recipients',
- 'Successful Deliveries',
- 'Unique Opens', //as per CRM-16506- Fixed and improve mailing stats changes
- 'Total Opens',
- 'Click-throughs',
- 'Forwards',
- 'Replies',
- 'Bounces',
- 'Unsubscribe Requests',
- 'Opt-out Requests',
- );
-
- //check for report and adv search links
- foreach ($summaryInfoLinks as $value) {
- $this->assertTrue($this->isElementPresent("xpath=//fieldset/legend[text()='Delivery Summary']/../table//tr[td/a[text()='{$value}']]/descendant::td[3]/span/a[1][text()='Report']"), "Report link missing for {$value}");
- $this->assertTrue($this->isElementPresent("xpath=//fieldset/legend[text()='Delivery Summary']/../table//tr[td/a[text()='{$value}']]/descendant::td[3]/span/a[2][text()='Advanced Search']"), "Advance Search link missing for {$value}");
- }
- // verify mailing name
- $this->verifyText("xpath=//table//tr[td[1]/text()='Mailing Name']/descendant::td[2]", preg_quote("Mailing $mailingName Webtest"));
-
- // verify mailing subject
- $this->verifyText("xpath=//table//tr[td[1]/text()='Subject']/descendant::td[2]", preg_quote("Test subject $mailingName for Webtest"));
-
- // after asserts do clicks and confirm filters
- $criteriaCheck = array(
- 'Intended Recipients' => array(
- 'report' => array('report_name' => 'Mailing Details', 'Mailing' => "Mailing $mailingName Webtest"),
- 'search' => array('Mailing Name IN' => "\"Mailing {$mailingName} Webtest"),
- ),
- 'Successful Deliveries' => array(
- 'report' => array(
- 'report_name' => 'Mailing Details',
- 'Mailing' => "Mailing $mailingName Webtest",
- "Delivery Status" => " Successful",
- ),
- 'search' => array(
- 'Mailing Name IN' => "\"Mailing {$mailingName} Webtest",
- 'Mailing Delivery -' => "Successful",
- ),
- ),
- 'Unique Opens' => array(
- 'report' => array('report_name' => 'Mail Opened', 'Mailing' => "Mailing $mailingName Webtest"),
- 'search' => array(
- 'Mailing Name IN' => "\"Mailing {$mailingName} Webtest",
- 'Mailing: Trackable Opens -' => "Opened",
- ),
- ),
- 'Click-throughs' => array(
- 'report' => array('report_name' => 'Mail Click-Throughs', 'Mailing' => "Mailing $mailingName Webtest"),
- 'search' => array(
- 'Mailing Name IN' => "\"Mailing {$mailingName} Webtest",
- 'Mailing: Trackable URL Clicks -' => "Clicked",
- ),
- ),
- 'Forwards' => array(
- 'report' => array(
- 'report_name' => 'Mailing Details',
- 'Mailing' => "Mailing $mailingName Webtest",
- 'Forwarded' => 'Is equal to Yes',
- ),
- 'search' => array('Mailing Name IN' => "\"Mailing {$mailingName} Webtest", 'Mailing: -' => "Forwards"),
- ),
- 'Replies' => array(
- 'report' => array(
- 'report_name' => 'Mailing Details',
- 'Mailing' => "Mailing $mailingName Webtest",
- 'Replied' => 'Is equal to Yes',
- ),
- 'search' => array(
- 'Mailing Name IN' => "\"Mailing {$mailingName} Webtest",
- 'Mailing: Trackable Replies -' => "Replied",
- ),
- ),
- 'Bounces' => array(
- 'report' => array('report_name' => 'Mail Bounces', 'Mailing' => "Mailing $mailingName Webtest"),
- 'search' => array(
- 'Mailing Name IN' => "\"Mailing {$mailingName} Webtest",
- 'Mailing Delivery -' => "Bounced",
- ),
- ),
- 'Unsubscribe Requests' => array(
- 'report' => array(
- 'report_name' => 'Mailing Details',
- 'Mailing' => "Mailing $mailingName Webtest",
- 'Unsubscribed' => 'Is equal to Yes',
- ),
- 'search' => array(
- 'Mailing Name IN' => "\"Mailing {$mailingName} Webtest",
- 'Mailing: -' => "Unsubscribe Requests",
- ),
- ),
- 'Opt-out Requests' => array(
- 'report' => array(
- 'report_name' => 'Mailing Details',
- 'Mailing' => "Mailing $mailingName Webtest",
- 'Opted-out' => 'Is equal to Yes',
- ),
- 'search' => array(
- 'Mailing Name IN' => "\"Mailing {$mailingName} Webtest",
- 'Mailing: -' => "Opt-out Requests",
- ),
- ),
- );
- $this->criteriaCheck($criteriaCheck, $mailingReportUrl);
- }
-
- /**
- * @param $criteriaCheck
- * @param $mailingReportUrl
- */
- public function criteriaCheck($criteriaCheck, $mailingReportUrl) {
- foreach ($criteriaCheck as $key => $infoFilter) {
- foreach ($infoFilter as $entity => $dataToCheck) {
- $this->open($mailingReportUrl);
- if ($entity == "report") {
- $this->clickLink("xpath=//fieldset/legend[text()='Delivery Summary']/../table//tr[td/a[text()='{$key}']]/descendant::td[3]/span/a[1][text()='Report']");
- }
- else {
- $this->clickLink("xpath=//fieldset/legend[text()='Delivery Summary']/../table//tr[td/a[text()='{$key}']]/descendant::td[3]/span/a[2][text()='Advanced Search']");
- }
- $this->_verifyCriteria($key, $dataToCheck, $entity);
- }
- }
- }
-
- /**
- * @param $summaryInfo
- * @param $dataToCheck
- * @param $entity
- */
- public function _verifyCriteria($summaryInfo, $dataToCheck, $entity) {
- foreach ($dataToCheck as $key => $value) {
- if ($entity == 'report') {
- if ($key == 'report_name') {
- $this->waitForTextPresent("{$value}");
- continue;
- }
- $this->assertTrue($this->isElementPresent("xpath=//form//div[3]/table/tbody//tr/th[contains(text(),'{$key}')]/../td[contains(text(),'{$value}')]"), "Criteria check for {$key} failed for Report for {$summaryInfo}");
- }
- else {
- $this->waitForTextPresent("Advanced Search");
- $assertedValue = $this->isElementPresent("xpath=//div[@class='crm-results-block']//div[@class='qill'][contains(text(),'{$key} {$value}')]");
- if (!$assertedValue) {
- $assertedValue = $this->isTextPresent("{$key} {$value}");
- }
- $this->assertTrue($assertedValue, "Criteria check for {$key} failed for Advance Search for {$summaryInfo}");
- }
- }
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-require_once 'CiviTest/CiviMailUtils.php';
-
-/**
- * Class WebTest_Mailing_SpoolTest
- */
-class WebTest_Mailing_SpoolTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testSpooledMailing() {
- $this->markTestSkipped('Skipping for now as it works fine locally.');
- $this->webtestLogin();
-
- // Start spooling mail
- $mut = new CiviMailUtils($this, TRUE);
-
- // Add a contact
- $fname = substr(sha1(rand()), 0, 6);
- $lname = substr(sha1(rand()), 0, 6);
- $email = $this->webtestAddContact($fname, $lname, TRUE);
-
- // Get the contact id of the newly added contact
- $cid = $this->urlArg('cid');
-
- // Send an email to the added contact
- $this->openCiviPage("activity/email/add", "action=add&reset=1&cid={$cid}&selectedChild=activity&atype=3");
- $this->type('subject', 'test spool');
- $this->fillRichTextField('html_message', 'Unit tests keep children safe.');
- $this->click("_qf_Email_upload");
-
- // Retrieve an ezc mail object version of the email
- $msg = $mut->getMostRecentEmail('ezc');
-
- $this->assertNotEmpty($msg, 'Mail message empty or not found.');
- $this->assertEquals($msg->subject, 'test spool');
- // should really walk through the 'to' array, but this is legal according to the docs
- $this->assertContains($email, implode(';', $msg->to), 'Recipient incorrect.');
-
- $context = new ezcMailPartWalkContext(array(get_class($this), 'mailWalkCallback'));
- $msg->walkParts($context, $msg);
-
- /*
- * Now try a regular activity with cc to assignee
- */
- $this->WebtestAddActivity();
- $msg = $mut->getMostRecentEmail('raw');
- $this->assertNotEmpty($msg, 'Mail message empty or not found.');
- $this->assertContains('Subject: This is subject of test activity', $msg, 'Subject of email is wrong.');
-
- $mut->stop();
- }
-
- /**
- * @param $context
- * @param $mailPart
- */
- public static function mailWalkCallback($context, $mailPart) {
- if ($mailPart instanceof ezcMailText) {
- self::assertEquals($mailPart->subType, 'html');
- self::assertContains('Unit tests keep children safe', $mailPart->generateBody());
- }
-
- $disp = $mailPart->contentDisposition;
- if ($disp) {
-
- }
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-/**
- * Class WebTest_Mailing_ValidateBodyMailingComponentTest
- */
-class WebTest_Mailing_ValidateBodyMailingComponentTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testWithoutBodyTextAndHTML() {
- $this->webtestLogin();
-
- $this->openCiviPage("admin/component", "action=add&reset=1");
-
- // fill component name.
- $componentName = 'ComponentName_' . substr(base_convert(rand(), 10, 36), 0, 7);
- $this->type("name", $componentName);
-
- // fill component type
- $this->click("component_type");
- $this->select("component_type", "value=Header");
-
- // fill subject
- $subject = "This is subject for New Mailing Component.";
- $this->type("subject", $subject);
-
- // fill no text message
-
- // fill no html message
-
- $this->click("is_default");
- // Clicking save.
- $this->click("_qf_Component_next");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Is status message correct.
- $status = "Please provide either HTML or TEXT format for the Body.";
- $this->waitForText('crm-notification-container', $status);
-
- // Verify the error text.
- $this->assertTrue($this->isElementPresent("xpath=//table/tbody//tr/td[2]/span[text()='{$status}']"), "The row doesn't consists of proper component details");
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Member_BatchUpdateViaProfileTest
- */
-class WebTest_Member_BatchUpdateViaProfileTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testMemberAdd() {
- // Log in using webtestLogin() method
- $this->webtestLogin();
-
- // Create a membership type to use for this test (defaults for this helper function are rolling 1 year membership)
- $memTypeParams = $this->webtestAddMembershipType();
-
- $endDate = date('F jS, Y', strtotime("+1 year +1 month -1 day"));
-
- // Add new individual using Quick Add block on the main page
- $firstName1 = "John_" . substr(sha1(rand()), 0, 7);
- $lastName = "Smith_" . substr(sha1(rand()), 0, 7);
- $Name1 = $lastName . ', ' . $firstName1;
- $this->webtestAddContact($firstName1, $lastName, "$firstName1.$lastName@example.com");
-
- // Add membership for this individual
- $this->_addMembership($memTypeParams);
- // Is status message correct?
- $this->waitForText('crm-notification-container', "membership for $firstName1 $lastName has been added");
-
- // click through to the membership view screen
- $this->click("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']");
- $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
-
- // Verify End date
- $verifyData = array(
- 'Membership Type' => $memTypeParams['membership_type'],
- 'Status' => 'New',
- 'End date' => $endDate,
- );
- $this->webtestVerifyTabularData($verifyData);
-
- // Add new individual using Quick Add block on the main page
- $firstName2 = "John_" . substr(sha1(rand()), 0, 7);
- $Name2 = $lastName . ', ' . $firstName2;
- $this->webtestAddContact($firstName2, $lastName, "$firstName2.$lastName@example.com");
-
- // Add membership for this individual
- $this->_addMembership($memTypeParams);
- // Is status message correct?
-
- $this->waitForText('crm-notification-container', "membership for $firstName2 $lastName has been added.");
-
- // click through to the membership view screen
- $this->click("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']");
- $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
-
- // Verify End date
- $verifyData = array(
- 'Membership Type' => $memTypeParams['membership_type'],
- 'Status' => 'New',
- 'End date' => $endDate,
- );
- $this->webtestVerifyTabularData($verifyData);
-
- $profileTitle = 'Profile_' . substr(sha1(rand()), 0, 4);
- $customDataParams = $this->_addCustomData();
- $this->_addProfile($profileTitle, $customDataParams);
-
- // Find Members
- $this->openCiviPage("member/search", "reset=1", '_qf_Search_refresh');
-
- $this->type('sort_name', $lastName);
- $this->click('_qf_Search_refresh');
-
- // Update multiple memberships
- $this->waitForElementPresent("xpath=//div[@id='search-status']/table/tbody/tr[2]/td[2]/input");
- $this->click("xpath=//div[@id='search-status']/table/tbody/tr[2]/td[2]/input");
- //$this->click('CIVICRM_QFID_ts_all_10');
- $this->select('task', "label=Update multiple memberships");
- $this->waitForElementPresent('_qf_PickProfile_back-bottom');
- $this->waitForElementPresent('uf_group_id');
- $this->select('uf_group_id', "label={$profileTitle}");
- $this->click('_qf_PickProfile_next-bottom');
-
- $this->waitForElementPresent('_qf_Batch_back-bottom');
- $this->type("xpath=//form[@id='Batch']/div[2]/table/tbody//tr/td[text()='{$Name1}']/../td[3]/input", "This is test custom data text1");
- $this->select("xpath=//form[@id='Batch']/div[2]/table/tbody//tr/td[text()='{$Name1}']/../td[4]/select", "label=Current");
-
- $this->type("xpath=//form[@id='Batch']/div[2]/table/tbody//tr/td[text()='{$Name2}']/../td[3]/input", "This is test custom data text2");
- $this->select("xpath=//form[@id='Batch']/div[2]/table/tbody//tr/td[text()='{$Name2}']/../td[4]/select", "label=Grace");
-
- $this->click('_qf_Batch_next-bottom');
- $this->waitForElementPresent('_qf_Result_done');
- $this->click('_qf_Result_done');
-
- // View Membership
- $this->waitForElementPresent("xpath=//div[@id='memberSearch']/table/tbody//tr/td[3]/a[text()='{$Name1}']/../../td[11]/span[1]/a[1][text()='View']");
- $this->click("xpath=//div[@id='memberSearch']/table/tbody//tr/td[3]/a[text()='{$Name1}']/../../td[11]/span[1]/a[1][text()='View']");
- $this->waitForElementPresent('_qf_MembershipView_cancel-bottom');
-
- // Verify End date
- $verifyData = array(
- 'Membership Type' => $memTypeParams['membership_type'],
- 'Status' => 'Current',
- 'End date' => $endDate,
- );
- $this->webtestVerifyTabularData($verifyData);
-
- $this->click('_qf_MembershipView_cancel-bottom');
-
- // View Membership
- $this->click("xpath=//div[@id='memberSearch']/table/tbody//tr/td[3]/a[text()='{$Name2}']/../../td[11]/span/a[text()='View']");
- $this->waitForElementPresent('_qf_MembershipView_cancel-bottom');
-
- // Verify End date
- $verifyData = array(
- 'Membership Type' => $memTypeParams['membership_type'],
- 'Status' => 'Grace',
- 'End date' => $endDate,
- );
- $this->webtestVerifyTabularData($verifyData);
- }
-
- /**
- * @param array $memTypeParams
- */
- public function _addMembership($memTypeParams) {
- // click through to the membership view screen
- $this->click("css=li#tab_member a");
- $this->waitForElementPresent("link=Add Membership");
- $this->click("link=Add Membership");
- $this->waitForElementPresent("_qf_Membership_cancel-bottom");
-
- // fill in Membership Organization and Type
- $this->select("membership_type_id[0]", "label={$memTypeParams['member_of_contact']}");
- // Wait for membership type select to reload
- $this->waitForTextPresent($memTypeParams['membership_type']);
- // Because it tends to cause problems, all uses of sleep() must be justified in comments
- // Sleep should never be used for wait for anything to load from the server
- // Justification for this instance: FIXME
- sleep(3);
- $this->select("membership_type_id[1]", "label={$memTypeParams['membership_type']}");
-
- $sourceText = "Membership ContactAddTest Webtest";
- // fill in Source
- $this->type("source", $sourceText);
-
- // Let Join Date stay default
-
- // fill in Start Date
- $this->webtestFillDate('start_date');
-
- // Clicking save.
- $this->click("_qf_Membership_upload");
-
- // page was loaded
- $this->waitForTextPresent($sourceText);
- }
-
- /**
- * @param $profileTitle
- * @param array $customDataParams
- */
- public function _addProfile($profileTitle, $customDataParams) {
-
- $this->openCiviPage("admin/uf/group", "reset=1");
-
- $this->click('link=Add Profile');
- // Add membership custom data field to profile
- $this->waitForElementPresent('_qf_Group_cancel-bottom');
- $this->type('title', $profileTitle);
- $this->click('uf_group_type_Profile');
- $this->clickLink('_qf_Group_next-bottom');
-
- $this->waitForText('crm-notification-container', "Your CiviCRM Profile '{$profileTitle}' has been added. You can add fields to this profile now.");
- $gid = $this->urlArg('gid');
-
- $this->openCiviPage('admin/uf/group/field/add', array(
- 'action' => 'add',
- 'reset' => 1,
- 'gid' => $gid,
- ), 'field_name[0]');
-
- $this->select('field_name[0]', "value=Membership");
- $this->select('field_name[1]', "label={$customDataParams[0]} :: {$customDataParams[1]}");
- $this->click('field_name[1]');
- $this->click('label');
-
- // Clicking save and new
- $this->click('_qf_Field_next_new-bottom');
- $this->waitForText('crm-notification-container', "Your CiviCRM Profile Field '{$customDataParams[0]}' has been saved to '{$profileTitle}'.");
-
- // Add membership status field to profile - CRM-8618
- $this->select('field_name[0]', "value=Membership");
- $this->select('field_name[1]', "label=Membership Status");
- $this->click('field_name[1]');
- $this->click('label');
- // Clicking save
- $this->click('_qf_Field_next-bottom');
- $this->waitForText('crm-notification-container', "Your CiviCRM Profile Field 'Membership Status' has been saved to '{$profileTitle}'.");
- }
-
- /**
- * @return array
- */
- public function _addCustomData() {
- $customGroupTitle = 'Custom_' . substr(sha1(rand()), 0, 4);
-
- $this->openCiviPage('admin/custom/group', 'reset=1');
-
- //add new custom data
- $this->click("//a[@id='newCustomDataGroup']/span");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- //fill custom group title
- $this->click("title");
- $this->type("title", $customGroupTitle);
-
- //custom group extends
- $this->click("extends[0]");
- $this->select("extends[0]", "value=Membership");
- $this->click("//option[@value='Membership']");
- $this->click('_qf_Group_next-bottom');
- $this->waitForElementPresent('_qf_Field_cancel-bottom');
-
- //Is custom group created?
- $this->waitForText('crm-notification-container', "Your custom field set '{$customGroupTitle}' has been added. You can add custom fields now.");
-
- $textFieldLabel = 'Custom Field Text_' . substr(sha1(rand()), 0, 4);
- $this->type('label', $textFieldLabel);
-
- //enter pre help msg
- $this->type('help_pre', "this is field pre help");
-
- //enter post help msg
- $this->type('help_post', "this is field post help");
-
- //Is searchable?
- $this->click('is_searchable');
-
- //clicking save
- $this->click('_qf_Field_done-bottom');
-
- //Is custom field created
- $this->waitForText('crm-notification-container', "Custom field '$textFieldLabel' has been saved.");
-
- return array($textFieldLabel, $customGroupTitle);
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Member_ContactContextAddTest
- */
-class WebTest_Member_ContactContextAddTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testContactMemberAdd() {
- $this->webtestLogin();
-
- // Create a membership type to use for this test (defaults for this helper function are rolling 1 year membership)
- $memTypeParams = $this->webtestAddMembershipType();
- $lifeTimeMemTypeParams = $this->webtestAddMembershipType('rolling', 1, 'lifetime');
-
- $this->openCiviPage("contact/add", "reset=1&ct=Individual");
-
- $firstName = "John_" . substr(sha1(rand()), 0, 7);
-
- //fill in first name
- $this->type("first_name", $firstName);
-
- //fill in last name
- $lastName = "Smith_" . substr(sha1(rand()), 0, 7);
- $this->type("last_name", $lastName);
-
- //fill in email
- $email = substr(sha1(rand()), 0, 7) . "john@gmail.com";
- $this->type("email_1_email", $email);
-
- // Clicking save.
- $this->click("_qf_Contact_upload_view");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForText('crm-notification-container', "$firstName $lastName");
-
- // click through to the membership view screen
- $this->click("css=li#tab_member a");
-
- $this->waitForElementPresent("link=Add Membership");
- $this->click("link=Add Membership");
-
- $this->waitForElementPresent("_qf_Membership_cancel-bottom");
-
- // fill in Membership Organization and Type
- $this->select("membership_type_id[0]", "label={$memTypeParams['member_of_contact']}");
- // Wait for membership type select to reload
- $this->waitForTextPresent($memTypeParams['membership_type']);
- // Because it tends to cause problems, all uses of sleep() must be justified in comments
- // Sleep should never be used for wait for anything to load from the server
- // Justification for this instance: FIXME
- sleep(3);
- $this->select("membership_type_id[1]", "label={$memTypeParams['membership_type']}");
-
- $sourceText = "Membership ContactAddTest Webtest";
- // fill in Source
- $this->type("source", $sourceText);
-
- // Let Join Date stay default
-
- // fill in Start Date
- $this->webtestFillDate('start_date');
-
- // Clicking save.
- $this->click("_qf_Membership_upload");
-
- // page was loaded
- $this->waitForTextPresent($sourceText);
-
- // Is status message correct?
- $this->waitForText('crm-notification-container', "membership for $firstName $lastName has been added.");
-
- // click through to the membership view screen
- $this->click("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']");
- $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
-
- $verifyData = array(
- 'Membership Type' => $memTypeParams['membership_type'],
- 'Status' => 'New',
- 'Source' => $sourceText,
- );
- $this->webtestVerifyTabularData($verifyData);
-
- $this->click("_qf_MembershipView_cancel-bottom");
- // page was loaded
- $this->waitForTextPresent($sourceText);
-
- $this->waitForElementPresent("css=li#tab_activity a");
- // click through to the activities screen
- $this->click("css=li#tab_activity a");
- // page was loaded
- $this->waitForTextPresent('Membership Signup');
-
- // click through to the activiy view screen (which is the membership view
- $this->click("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']");
- $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
-
- $verifyData = array(
- 'Membership Type' => $memTypeParams['membership_type'],
- 'Status' => 'New',
- 'Source' => $sourceText,
- );
- $this->webtestVerifyTabularData($verifyData);
- $this->clickLink("_qf_MembershipView_cancel-bottom", "xpath=//div[@id='memberships']/div/table/tbody//tr/td[1][text()='{$memTypeParams['membership_type']}']/../td[7]", FALSE);
- $this->click("xpath=//div[@id='memberships']/div/table/tbody//tr/td[1][text()='{$memTypeParams['membership_type']}']/../td[9]/span/a[2][text()='Edit']");
- $this->waitForElementPresent("_qf_Membership_cancel-bottom");
-
- // fill in Membership Organization and Type
- $this->select("membership_type_id[0]", "label={$lifeTimeMemTypeParams['member_of_contact']}");
- // Wait for membership type select to reload
- $this->waitForTextPresent($lifeTimeMemTypeParams['membership_type']);
- $this->select("membership_type_id[1]", "label={$lifeTimeMemTypeParams['membership_type']}");
-
- $this->waitForElementPresent("xpath=//form[@id='Membership']/div[2]/div[2]//table/tbody//tr[@class='crm-membership-form-block-end_date']/td[2]");
- $this->click("xpath=//form[@id='Membership']/div[2]/div[2]/table/tbody//tr[@class='crm-membership-form-block-end_date']/td[2]/a");
-
- $this->click("_qf_Membership_upload-bottom");
-
- $this->waitForElementPresent("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']");
- // page was loaded
- $this->waitForTextPresent($sourceText);
- $this->click("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']");
- $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
-
- $verifyData = array(
- 'Status' => 'New',
- 'Source' => $sourceText,
- 'End date' => '',
- );
- $this->webtestVerifyTabularData($verifyData);
- }
-
- public function testMemberAddWithLifeTimeMembershipType() {
- $this->webtestLogin();
-
- // Create a membership type to use for this test (defaults for this helper function are rolling 1 year membership)
- $lifeTimeMemTypeParams = $this->webtestAddMembershipType('rolling', 1, 'lifetime');
-
- $this->openCiviPage("contact/add", "reset=1&ct=Individual");
-
- $firstName = "John_" . substr(sha1(rand()), 0, 7);
-
- //fill in first name
- $this->type("first_name", $firstName);
-
- //fill in last name
- $lastName = "Smith_" . substr(sha1(rand()), 0, 7);;
- $this->type("last_name", $lastName);
-
- //fill in email
- $email = substr(sha1(rand()), 0, 7) . "john@gmail.com";
- $this->type("email_1_email", $email);
-
- // Clicking save.
- $this->click("_qf_Contact_upload_view");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForText('crm-notification-container', "$firstName $lastName has been created.");
-
- // click through to the membership view screen
- $this->click("css=li#tab_member a");
-
- $this->waitForElementPresent("link=Add Membership");
- $this->click("link=Add Membership");
-
- $this->waitForElementPresent("_qf_Membership_cancel-bottom");
-
- // fill in Membership Organization and Type
- $this->select("membership_type_id[0]", "label={$lifeTimeMemTypeParams['member_of_contact']}");
-
- // Wait for membership type select to reload
- $this->waitForTextPresent($lifeTimeMemTypeParams['membership_type']);
- // Because it tends to cause problems, all uses of sleep() must be justified in comments
- // Sleep should never be used for wait for anything to load from the server
- // Justification for this instance: FIXME
- sleep(3);
- $this->select("membership_type_id[1]", "label={$lifeTimeMemTypeParams['membership_type']}");
-
- $sourceText = "Check Lifetime membership type webtest";
- // fill in Source
- $this->type("source", $sourceText);
-
- // Let Join Date stay default
-
- // fill in Start Date
- $this->webtestFillDate('start_date');
-
- // Clicking save.
- $this->click("_qf_Membership_upload");
-
- // page was loaded
- $this->waitForTextPresent($sourceText);
-
- // Is status message correct?
- $this->waitForText('crm-notification-container', "membership for $firstName $lastName has been added.");
-
- // click through to the membership view screen
- $this->click("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']");
- $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
-
- $verifyData = array(
- 'Status' => 'New',
- 'Source' => $sourceText,
- 'End date' => '',
- );
- $this->webtestVerifyTabularData($verifyData);
- $this->click("_qf_MembershipView_cancel-bottom");
- $this->waitForElementPresent("mainTabContainer");
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Member_DefaultMembershipPricesetTest
- */
-class WebTest_Member_DefaultMembershipPricesetTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testDefaultPricesetSelection() {
- // Log in using webtestLogin() method
- $this->webtestLogin();
-
- $title = substr(sha1(rand()), 0, 7);
- $setTitle = "Membership Fees - $title";
- $usedFor = 'Membership';
- $contributionType = 'Member Dues';
- $setHelp = 'Select your membership options.';
- $this->_testAddSet($setTitle, $usedFor, $contributionType, $setHelp);
-
- // Get the price set id ($sid) by retrieving and parsing the URL of the New Price Field form
- // which is where we are after adding Price Set.
- $sid = $this->urlArg('sid');
- $this->assertType('numeric', $sid);
-
- $fields = array("National Membership $title" => 'Radio');
- list($memTypeTitle1, $memTypeTitle2, $memTypeTitle3) = $this->_testAddPriceFields($fields, $validateStrings, FALSE, $title, $sid, TRUE, $contributionType);
-
- $fields = array("Second Membership $title" => 'CheckBox');
- list($memTypeTitle1, $memTypeTitle2, $memTypeTitle3) = $this->_testAddPriceFields($fields, $validateStrings, FALSE, $title, $sid, FALSE, $contributionType);
-
- $hash = substr(sha1(rand()), 0, 7);
- $rand = 2 * rand(2, 50);
- $pageTitle = 'Contribution page for membership ' . $hash;
- $processorName = 'Dummy ' . $hash;
- $memPriceSetId = $sid;
- $membershipContributionPageId = $this->webtestAddContributionPage($hash, $rand, $pageTitle, array($processorName => 'Dummy'), TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, $memPriceSetId, FALSE, NULL, NULL, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, TRUE);
-
- $firstName = 'John_' . substr(sha1(rand()), 0, 7);
- $lastName = 'Anderson_' . substr(sha1(rand()), 0, 7);
- $email = "{$firstName}.{$lastName}@example.com";
- $contactParams = array(
- 'first_name' => $firstName,
- 'last_name' => $lastName,
- 'email-5' => $email,
- );
- $streetAddress = "100 Main Street";
-
- //adding contact for membership sign up
- $this->webtestAddContact($firstName, $lastName, $email);
- $urlElements = $this->parseURL();
- $cid = $urlElements['queryString']['cid'];
- $this->assertType('numeric', $cid);
-
- //senario 1
- $this->openCiviPage("contribute/transact", "reset=1&id={$membershipContributionPageId}&cid={$cid}&action=preview", "_qf_Main_upload-bottom");
-
- $this->_testDefaultSenarios("national_membership_{$title}-section", 2);
- $this->contactInfoFill($firstName, $lastName, $email, $contactParams, $streetAddress);
- $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
- $this->click("_qf_Confirm_next-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- //senario 2
- $this->openCiviPage("contribute/transact", "reset=1&id={$membershipContributionPageId}&cid={$cid}&action=preview", "_qf_Main_upload-bottom");
- // checking
- $this->checkOptions("national_membership_{$title}-section", 2);
- // senario 1
- $this->_testDefaultSenarios("national_membership_{$title}-section", 4);
- $this->_testDefaultSenarios("second_membership_{$title}-section", 2);
- $this->contactInfoFill($firstName, $lastName, $email, $contactParams, $streetAddress);
- $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
- $this->click("_qf_Confirm_next-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- //senario 3
- $this->openCiviPage("contribute/transact", "reset=1&id={$membershipContributionPageId}&cid={$cid}&action=preview", "_qf_Main_upload-bottom");
- // checking
- $this->checkOptions("second_membership_{$title}-section", 2);
- // senario 2
-
- $this->_testDefaultSenarios("national_membership_{$title}-section", 3);
- $this->contactInfoFill($firstName, $lastName, $email, $contactParams, $streetAddress);
- $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
- $this->click("_qf_Confirm_next-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- //senario 4
- $this->openCiviPage("contribute/transact", "reset=1&id={$membershipContributionPageId}&cid={$cid}&action=preview", "_qf_Main_upload-bottom");
- // checking senario 3
- $this->assertTrue($this->isTextPresent("You have a current Lifetime Membership which does not need to be renewed."));
-
- $this->_testDefaultSenarios("national_membership_{$title}-section", 1);
- $this->contactInfoFill($firstName, $lastName, $email, $contactParams, $streetAddress);
- $this->clickLink("_qf_Main_upload-bottom", "_qf_Main_upload-bottom");
- $this->assertTrue($this->isTextPresent("You already have a lifetime membership and cannot select a membership with a shorter term."));
- }
-
- /**
- * @param string $firstName
- * @param string $lastName
- * @param $email
- * @param array $contactParams
- * @param $streetAddress
- */
- public function contactInfoFill($firstName, $lastName, $email, $contactParams, $streetAddress) {
- //Credit Card Info
- $this->select("credit_card_type", "value=Visa");
- $this->type("credit_card_number", "4111111111111111");
- $this->type("cvv2", "000");
- $this->select("credit_card_exp_date[M]", "value=1");
- $this->select("credit_card_exp_date[Y]", "value=2020");
-
- //Billing Info
- $this->type("billing_first_name", $contactParams['first_name'] . "billing");
- $this->type("billing_last_name", $contactParams['last_name'] . "billing");
- $this->type("billing_street_address-5", "15 Main St.");
- $this->type(" billing_city-5", "San Jose");
- $this->select("billing_country_id-5", "value=1228");
- $this->select("billing_state_province_id-5", "value=1004");
- $this->type("billing_postal_code-5", "94129");
- }
-
- /**
- * @param $priceSetSection
- * @param $optionNumber
- */
- public function checkOptions($priceSetSection, $optionNumber) {
- $this->assertChecked("xpath=//div[@id='priceset']/div[@class='crm-section {$priceSetSection}']/div[2]/div[{$optionNumber}]/span/input");
- }
-
- /**
- * @param $priceSetSection
- * @param $optionNumber
- */
- public function _testDefaultSenarios($priceSetSection, $optionNumber) {
- $this->click("xpath=//div[@id='priceset']/div[@class='crm-section {$priceSetSection}']/div[2]/div[{$optionNumber}]/span/input");
- }
-
- /**
- * @param $setTitle
- * @param $usedFor
- * @param null $contributionType
- * @param $setHelp
- */
- public function _testAddSet($setTitle, $usedFor, $contributionType = NULL, $setHelp) {
- $this->openCiviPage("admin/price", "reset=1&action=add", '_qf_Set_next-bottom');
-
- // Enter Priceset fields (Title, Used For ...)
- $this->type('title', $setTitle);
- if ($usedFor == 'Event') {
- $this->check('extends[1]');
- }
- elseif ($usedFor == 'Contribution') {
- $this->check('extends[2]');
- }
- elseif ($usedFor == 'Membership') {
- $this->click('extends[3]');
- $this->waitForElementPresent('financial_type_id');
- $this->select("css=select.crm-form-select", "label={$contributionType}");
- }
-
- $this->type('help_pre', $setHelp);
-
- $this->assertChecked('is_active', 'Verify that Is Active checkbox is set.');
- $this->clickLink('_qf_Set_next-bottom');
- $this->assertTrue($this->isTextPresent("Your Set '{$setTitle}' has been added. You can add fields to this set now."));
- }
-
- /**
- * @param $fields
- * @param $validateString
- * @param bool $dateSpecificFields
- * @param $title
- * @param int $sid
- * @param bool $defaultPriceSet
- * @param $contributionType
- *
- * @return array
- */
- public function _testAddPriceFields(&$fields, &$validateString, $dateSpecificFields = FALSE, $title, $sid, $defaultPriceSet = FALSE, $contributionType) {
- if ($defaultPriceSet) {
-
- $memTypeTitle1 = 'General';
- $memTypeId1 = 1;
-
- $memTypeTitle2 = 'Student';
- $memTypeId2 = 2;
-
- $memTypeTitle3 = 'Lifetime';
- $memTypeId3 = 3;
- }
- elseif (!$defaultPriceSet) {
- $memTypeParams1 = $this->webtestAddMembershipType();
- $memTypeTitle1 = $memTypeParams1['membership_type'];
- $memTypeId1 = explode('&id=', $this->getAttribute("xpath=//div[@id='membership_type']/table/tbody//tr/td/div[text()='{$memTypeTitle1}']/../../td[12]/span/a[3]@href"));
- $memTypeId1 = $memTypeId1[1];
-
- $memTypeParams2 = $this->webtestAddMembershipType();
- $memTypeTitle2 = $memTypeParams2['membership_type'];
- $memTypeId2 = explode('&id=', $this->getAttribute("xpath=//div[@id='membership_type']/table/tbody//tr/td/div[text()='{$memTypeTitle2}']/../../td[12]/span/a[3]@href"));
- $memTypeId2 = $memTypeId2[1];
-
- $memTypeParams3 = $this->webtestAddMembershipType();
- $memTypeTitle3 = $memTypeParams3['membership_type'];
- $memTypeId3 = explode('&id=', $this->getAttribute("xpath=//div[@id='membership_type']/table/tbody//tr/td/div[text()='{$memTypeTitle3}']/../../td[12]/span/a[3]@href"));
- $memTypeId3 = $memTypeId3[1];
- }
-
- $this->openCiviPage("admin/price/field", "reset=1&action=add&sid={$sid}");
-
- foreach ($fields as $label => $type) {
- $validateStrings[] = $label;
-
- $this->type('label', $label);
- $this->select('html_type', "value={$type}");
-
- switch ($type) {
- case 'Radio':
- $options = array(
- 1 => array(
- 'label' => "$memTypeTitle1",
- 'membership_type_id' => $memTypeId1,
- 'amount' => '100.00',
- ),
- 2 => array(
- 'label' => "$memTypeTitle2",
- 'membership_type_id' => $memTypeId2,
- 'amount' => '50.00',
- ),
- 3 => array(
- 'label' => "$memTypeTitle3",
- 'membership_type_id' => $memTypeId3,
- 'amount' => '1,200.00',
- ),
- );
- $this->addMultipleChoiceOptions($options, $validateStrings);
- break;
-
- case 'CheckBox':
- $options = array(
- 1 => array(
- 'label' => "$memTypeTitle1",
- 'membership_type_id' => $memTypeId1,
- 'amount' => '100.00',
- ),
- 2 => array(
- 'label' => "$memTypeTitle2",
- 'membership_type_id' => $memTypeId2,
- 'amount' => '50.00',
- ),
- 3 => array(
- 'label' => "$memTypeTitle3",
- 'membership_type_id' => $memTypeId3,
- 'amount' => '1,200.00',
- ),
- );
- $this->addMultipleChoiceOptions($options, $validateStrings);
- break;
-
- default:
- break;
- }
- $this->select("financial_type_id", "label={$contributionType}");
- $this->clickLink('_qf_Field_next_new-bottom', '_qf_Field_next-bottom');
- $this->assertTrue($this->isTextPresent("Price Field '{$label}' has been saved."));
- }
- return array($memTypeTitle1, $memTypeTitle2, $memTypeTitle3);
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Member_EditMembershipTest
- */
-class WebTest_Member_EditMembershipTest extends CiviSeleniumTestCase {
- protected function setUp() {
- parent::setUp();
- }
-
- public function testEditMembershipActivityTypes() {
- // Log in using webtestLogin() method
- $this->webtestLogin();
- // create contact
- $firstName = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName, "Memberson", "Memberson{$firstName}@memberson.name");
- $contactName = "Memberson, {$firstName}";
- $displayName = "{$firstName} Memberson";
-
- // Add new Financial Account
- $orgName = 'Alberta ' . substr(sha1(rand()), 0, 7);
- $financialAccountTitle = 'Financial Account ' . substr(sha1(rand()), 0, 4);
- $financialAccountDescription = "{$financialAccountTitle} Description";
- $accountingCode = 1033;
- $financialAccountType = 'Liability';
- $taxDeductible = TRUE;
- $isActive = FALSE;
- $isTax = TRUE;
- $taxRate = 10.00;
- $isDefault = FALSE;
-
- //Add new organisation
- $this->webtestAddOrganization($orgName);
-
- $this->_testAddFinancialAccount($financialAccountTitle,
- $financialAccountDescription,
- $accountingCode,
- $orgName,
- $financialAccountType,
- $taxDeductible,
- $isActive,
- $isTax,
- $taxRate,
- $isDefault
- );
-
- //Add new Financial Type
- $financialType['name'] = 'Taxable FinancialType ' . substr(sha1(rand()), 0, 4);
- $financialType['is_deductible'] = TRUE;
- $financialType['is_reserved'] = FALSE;
- $this->addeditFinancialType($financialType);
-
- // Assign the created Financial Account $financialAccountTitle to $financialType
- $this->click("xpath=id('ltype')/div/table/tbody/tr/td[1]/div[text()='$financialType[name]']/../../td[7]/span/a[text()='Accounts']");
- $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']//button/span[contains(text(), 'Assign Account')]");
- $this->click("xpath=//div[@class='ui-dialog-buttonset']//button/span[contains(text(), 'Assign Account')]");
- $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']/button/span[text()='Save']");
- $this->select('account_relationship', "label=Sales Tax Account is");
- $this->waitForAjaxContent();
- $this->select('financial_account_id', "label=" . $financialAccountTitle);
- $this->click("xpath=//div[@class='ui-dialog-buttonset']/button/span[text()='Save']");
- $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']//button/span[contains(text(), 'Assign Account')]");
-
- // add membership type
- $membershipTypes = $this->webtestAddMembershipType('rolling', 1, 'year', 'no', 100, $financialType['name']);
-
- // now add membership
- $this->openCiviPage("member/add", "reset=1&action=add&context=standalone", "_qf_Membership_upload");
-
- // select contact
- $this->webtestFillAutocomplete($contactName);
-
- // fill in Membership Organization
- $this->select("membership_type_id[0]", "label={$membershipTypes['member_of_contact']}");
-
- // select membership type
- $this->select("membership_type_id[1]", "label={$membershipTypes['membership_type']}");
-
- // fill in Source
- $this->type("source", "Membership StandaloneAddTest Webtest");
-
- // Let Join Date and Start Date stay default
- $this->click("_qf_Membership_upload");
-
- //Open related 'Edit Contribution' form
- $this->waitForElementPresent("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']");
- $this->click("xpath=//div[@id='memberships']//table/tbody/tr[1]/td[9]/span/a[text()='View']");
- $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
- //CRM-17417, Simply open and save edit contribution form to check that tax shouldn't be reapplied
- $this->clickLink("xpath=//a[@title='Edit Contribution']", "_qf_Contribution_upload", FALSE);
- $this->click("_qf_Contribution_upload");
- $this->waitForAjaxContent();
- $this->assertTrue($this->isTextPresent("$ 110.00"), "Contribution Amount got updated as Sale Tax got reapplied which is wrong");
-
- //View Membership
- $this->click("css=li#tab_member a");
- $this->waitForElementPresent("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']");
- $this->click("xpath=//div[@id='memberships']//table/tbody/tr[1]/td[9]/span/a[text()='View']");
- $expected = array(
- 'Membership Type' => $membershipTypes['membership_type'],
- 'Status' => 'New',
- 'Source' => 'Membership StandaloneAddTest Webtest',
- );
- $this->webtestVerifyTabularData($expected);
-
- // now edit and update type and status
- $this->click("crm-membership-edit-button-top");
- $this->waitForElementPresent("_qf_Membership_upload-bottom");
- $this->click('is_override');
- $this->waitForElementPresent('status_id');
- $this->select('status_id', 'label=Current');
- $this->select('membership_type_id[0]', 'value=1');
- $this->select('membership_type_id[1]', 'value=1');
- $this->click('_qf_Membership_upload-bottom');
-
- $this->waitForElementPresent("access");
-
- // Use activity search to find the expected activities
- $this->openCiviPage('activity/search', 'reset=1', "_qf_Search_refresh");
-
- $this->type("sort_name", $contactName);
- $this->select('activity_type_id', 'value=35');
- $this->select('activity_type_id', 'value=36');
- $this->clickLink("_qf_Search_refresh");
-
- $this->assertTrue($this->isElementPresent("xpath=//div[@class='crm-search-results']/table/tbody/tr[2]/td[2][text()='Change Membership Type']"));
- $this->assertTrue($this->isElementPresent("xpath=//div[@class='crm-search-results']/table/tbody/tr[2]/td[3][text()='Type changed from {$membershipTypes['membership_type']} to General']"));
- $this->assertTrue($this->isElementPresent("xpath=//div[@class='crm-search-results']/table/tbody/tr[2]/td[5]/a[text()='{$contactName}']"));
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Member_FixedMembershipTypeTest
- */
-class WebTest_Member_FixedMembershipTypeTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testMembershipTypeScenario1() {
- // Scenario 1
- // Rollover Date < Start Date
- // Join Date > Rollover Date and Join Date < Start Date
-
- // Log in using webtestLogin() method
- $this->webtestLogin();
-
- $this->openCiviPage("contact/add", "reset=1&ct=Organization", '_qf_Contact_cancel');
-
- $title = substr(sha1(rand()), 0, 7);
- $this->type('organization_name', "Organization $title");
- $this->type('email_1_email', "$title@org.com");
- $this->click('_qf_Contact_upload_view');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->assertTrue($this->isTextPresent("Organization $title has been created."));
-
- $this->openCiviPage("admin/member/membershipType", "reset=1&action=browse");
-
- $this->click("link=Add Membership Type");
- $this->waitForElementPresent('_qf_MembershipType_cancel-bottom');
-
- $this->type('name', "Membership Type $title");
- $this->select2('member_of_contact_id', $title);
-
- $this->type('minimum_fee', '100');
- $this->select('financial_type_id', 'value=2');
- $this->type('duration_interval', 1);
- $this->select('duration_unit', "label=year");
-
- $this->select('period_type', "value=fixed");
- $this->waitForElementPresent('fixed_period_rollover_day[d]');
-
- // fixed period start set to April 1
- $this->select('fixed_period_start_day[M]', 'value=4');
- // rollover date set to Jan 31
- $this->select('fixed_period_rollover_day[M]', 'value=1');
-
- $this->click('relationship_type_id', 'value=4_b_a');
-
- $this->click('_qf_MembershipType_upload-bottom');
- $this->waitForElementPresent('link=Add Membership Type');
- $this->waitForText('crm-notification-container', "The membership type 'Membership Type $title' has been saved.");
-
- $this->openCiviPage("contact/add", "reset=1&ct=Individual");
-
- $firstName = "John_" . substr(sha1(rand()), 0, 7);
-
- //fill in first name
- $this->type('first_name', $firstName);
-
- //fill in last name
- $lastName = "Smith_" . substr(sha1(rand()), 0, 7);;
- $this->type('last_name', $lastName);
-
- //fill in email
- $email = substr(sha1(rand()), 0, 7) . "john@gmail.com";
- $this->type('email_1_email', $email);
-
- // Clicking save.
- $this->click('_qf_Contact_upload_view');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->assertTrue($this->isTextPresent("$firstName $lastName has been created."));
-
- // click through to the membership view screen
- $this->click('css=li#tab_member a');
-
- $this->waitForElementPresent('link=Add Membership');
- $this->click('link=Add Membership');
-
- $this->waitForElementPresent('_qf_Membership_cancel-bottom');
-
- // fill in Membership Organization and Type
- $this->select('membership_type_id[0]', "label=Organization $title");
- $this->select('membership_type_id[1]', "label=Membership Type $title");
-
- $sourceText = "Membership ContactAddTest with Fixed Membership Type";
- // fill in Source
- $this->type('source', $sourceText);
-
- //build the membership dates.
- require_once 'CRM/Core/Config.php';
- require_once 'CRM/Utils/Array.php';
- require_once 'CRM/Utils/Date.php';
- $currentYear = date('Y');
- $currentMonth = date('m');
- $previousYear = $currentYear - 1;
- $nextYear = $currentYear + 1;
-
- $todayDate = date('Y-m-d');
-
- // the member-since date we will type in to membership form
- $joinDate = date('Y-m-d', mktime(0, 0, 0, 3, 25, $currentYear));
-
- // expected calc'd start date
- $startDate = date('Y-m-d', mktime(0, 0, 0, 4, 1, $previousYear));
-
- // expected calc'd end date
- $endDate = date('Y-m-d', mktime(0, 0, 0, 3, 31, $nextYear));
-
- foreach (array(
- 'joinDate',
- 'startDate',
- 'endDate',
- ) as $date) {
- $$date = CRM_Utils_Date::customFormat($$date, $this->webtestGetSetting('dateformatFull'));
- }
-
- $query = "
-SELECT end_event_adjust_interval
-
- FROM civicrm_membership_status
-
- WHERE start_event = 'join_date'
- AND name = 'New'";
- $endInterval = CRM_Core_DAO::singleValueQuery($query);
-
- // Add endInterval to March 25 (join date month above) to get end of New status period
- $endNewStatus = date('Y-m-d', mktime(0, 0, 0, $endInterval + 3, 25, $currentYear));
-
- $status = 'Current';
- // status will be 'New' if today is >= join date and <= endNewStatus date
- if ((strtotime($todayDate) >= strtotime($joinDate)) && (strtotime($todayDate) <= strtotime($endNewStatus))) {
- $status = 'New';
- }
-
- // fill in Join Date
- $this->webtestFillDate('join_date', $joinDate);
-
- // Clicking save.
- $this->click('_qf_Membership_upload');
-
- // page was loaded
- $this->waitForTextPresent($sourceText);
-
- $this->waitForElementPresent("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']");
- // Is status message correct?
- $this->assertTrue($this->isTextPresent("Membership Type $title membership for $firstName $lastName has been added."),
- "Status message didn't show up after saving!"
- );
-
- // click through to the membership view screen
- $this->click("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']");
- $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
-
- $this->webtestVerifyTabularData(
- array(
- 'Membership Type' => "Membership Type $title",
- 'Status' => $status,
- 'Source' => $sourceText,
- 'Member Since' => $joinDate,
- 'Start date' => $startDate,
- 'End date' => $endDate,
- )
- );
- }
-
- public function testMembershipTypeScenario2() {
- // Scenario 2
- // Rollover Date < Join Date
-
- // Log in using webtestLogin() method
- $this->webtestLogin();
-
- $this->openCiviPage("contact/add", "reset=1&ct=Organization", '_qf_Contact_cancel');
-
- $title = substr(sha1(rand()), 0, 7);
- $this->type('organization_name', "Organization $title");
- $this->type('email_1_email', "$title@org.com");
- $this->click('_qf_Contact_upload_view');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->assertTrue($this->isTextPresent("Organization $title has been created."));
-
- $this->openCiviPage("admin/member/membershipType", "reset=1&action=browse");
-
- $this->click("link=Add Membership Type");
- $this->waitForElementPresent('_qf_MembershipType_cancel-bottom');
-
- $this->type('name', "Membership Type $title");
- $this->select2('member_of_contact_id', $title);
-
- $this->type('minimum_fee', '100');
- $this->select('financial_type_id', 'value=2');
-
- $this->type('duration_interval', 2);
- $this->select('duration_unit', "label=year");
-
- $this->select('period_type', "value=fixed");
- $this->waitForElementPresent('fixed_period_rollover_day[d]');
-
- $this->select('fixed_period_start_day[M]', 'value=9');
- $this->select('fixed_period_rollover_day[M]', 'value=6');
- $this->select('fixed_period_rollover_day[d]', 'value=30');
-
- $this->click('relationship_type_id', 'value=4_b_a');
-
- $this->click('_qf_MembershipType_upload-bottom');
- $this->waitForElementPresent('link=Add Membership Type');
- $this->waitForText('crm-notification-container', "The membership type 'Membership Type $title' has been saved.");
-
- $this->openCiviPage("contact/add", "reset=1&ct=Individual");
-
- $firstName = "John_" . substr(sha1(rand()), 0, 7);
-
- //fill in first name
- $this->type('first_name', $firstName);
-
- //fill in last name
- $lastName = "Smith_" . substr(sha1(rand()), 0, 7);;
- $this->type('last_name', $lastName);
-
- //fill in email
- $email = substr(sha1(rand()), 0, 7) . "john@gmail.com";
- $this->type('email_1_email', $email);
-
- // Clicking save.
- $this->click('_qf_Contact_upload_view');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->assertTrue($this->isTextPresent("$firstName $lastName has been created."));
-
- // click through to the membership add screen
- $this->click('css=li#tab_member a');
-
- $this->waitForElementPresent('link=Add Membership');
- $this->click('link=Add Membership');
-
- $this->waitForElementPresent('_qf_Membership_cancel-bottom');
-
- // fill in Membership Organization and Type
- $this->select('membership_type_id[0]', "label=Organization {$title}");
- // Wait for membership type select to reload
- $this->waitForTextPresent("Membership Type {$title}");
- $this->select('membership_type_id[1]', "label=Membership Type {$title}");
-
- $sourceText = "Membership ContactAddTest with Fixed Membership Type Scenario 2";
- // fill in Source
- $this->type('source', $sourceText);
-
- //build the membership dates.
- require_once 'CRM/Core/Config.php';
- require_once 'CRM/Utils/Array.php';
- require_once 'CRM/Utils/Date.php';
- $currentYear = date('Y');
- $currentMonth = date('m');
- $previousYear = $currentYear - 1;
-
- $todayDate = date('Y-m-d');
-
- // the member-since date we will type in to membership form
- $joinDate = date('Y-m-d', mktime(0, 0, 0, 7, 15, $currentYear));
-
- // expected calc'd start date
- $startDate = date('Y-m-d', mktime(0, 0, 0, 9, 1, $previousYear));
-
- // expected calc'd end date
- $endDate = date('Y-m-d', mktime(0, 0, 0, 8, 31, $currentYear + 2));
- foreach (array(
- 'joinDate',
- 'startDate',
- 'endDate',
- ) as $date) {
- $$date = CRM_Utils_Date::customFormat($$date, $this->webtestGetSetting('dateformatFull'));
- }
-
- $query = "
-SELECT end_event_adjust_interval
-
- FROM civicrm_membership_status
-
- WHERE start_event = 'join_date'
- AND name = 'New'";
- $endInterval = CRM_Core_DAO::singleValueQuery($query);
-
- // Add endInterval to July 15 (join date month above) to get end of New status period
- $endNewStatus = date('Y-m-d', mktime(0, 0, 0, $endInterval + 7, 15, $currentYear));
-
- $status = 'Current';
- // status will be 'New' if today is >= join date and <= endNewStatus date
- if ((strtotime($todayDate) >= strtotime($joinDate)) && (strtotime($todayDate) <= strtotime($endNewStatus))) {
- $status = 'New';
- }
-
- // fill in Join Date
- $this->webtestFillDate('join_date', $joinDate);
-
- // Clicking save.
- $this->click('_qf_Membership_upload');
- $this->waitForElementPresent("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']");
-
- // page was loaded
- $this->waitForTextPresent($sourceText);
-
- // Is status message correct?
- $this->assertTrue($this->isTextPresent("Membership Type $title membership for $firstName $lastName has been added."),
- "Status message didn't show up after saving!"
- );
-
- // click through to the membership view screen
- $this->click("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']");
- $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
-
- $this->webtestVerifyTabularData(
- array(
- 'Membership Type' => "Membership Type {$title}",
- 'Status' => $status,
- 'Source' => $sourceText,
- 'Member Since' => $joinDate,
- 'Start date' => $startDate,
- 'End date' => $endDate,
- )
- );
- }
-
- public function testMembershipTypeScenario3() {
- // Scenario 3
- // Standard Fixed scenario - Jan 1 Fixed Period Start and October 31 rollover
- // Join Date is later than Rollover Date
-
- // Log in using webtestLogin() method
- $this->webtestLogin();
-
- $this->openCiviPage("contact/add", "reset=1&ct=Organization", '_qf_Contact_cancel');
-
- $title = substr(sha1(rand()), 0, 7);
- $this->type('organization_name', "Organization $title");
- $this->type('email_1_email', "$title@org.com");
- $this->click('_qf_Contact_upload_view');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->assertTrue($this->isTextPresent("Organization $title has been created."));
-
- $this->openCiviPage("admin/member/membershipType", "reset=1&action=browse");
-
- $this->click("link=Add Membership Type");
- $this->waitForElementPresent('_qf_MembershipType_cancel-bottom');
-
- $this->type('name', "Membership Type $title");
- $this->select2('member_of_contact_id', $title);
-
- $this->type('minimum_fee', '100');
- $this->select('financial_type_id', 'value=2');
- $this->type('duration_interval', 1);
- $this->select('duration_unit', "label=year");
-
- $this->select('period_type', "value=fixed");
- $this->waitForElementPresent('fixed_period_rollover_day[d]');
-
- $this->select('fixed_period_rollover_day[M]', 'value=10');
- $this->select('fixed_period_rollover_day[d]', 'value=31');
-
- $this->click('relationship_type_id', 'value=4_b_a');
-
- $this->click('_qf_MembershipType_upload-bottom');
- $this->waitForElementPresent('link=Add Membership Type');
-
- $this->waitForText('crm-notification-container', "The membership type 'Membership Type $title' has been saved.");
- $this->openCiviPage("contact/add", "reset=1&ct=Individual");
-
- $firstName = "John_" . substr(sha1(rand()), 0, 7);
-
- //fill in first name
- $this->type('first_name', $firstName);
-
- //fill in last name
- $lastName = "Smith_" . substr(sha1(rand()), 0, 7);;
- $this->type('last_name', $lastName);
-
- //fill in email
- $email = substr(sha1(rand()), 0, 7) . "john@gmail.com";
- $this->type('email_1_email', $email);
-
- // Clicking save.
- $this->click('_qf_Contact_upload_view');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->assertTrue($this->isTextPresent("$firstName $lastName has been created."));
-
- // click through to the membership view screen
- $this->click('css=li#tab_member a');
-
- $this->waitForElementPresent('link=Add Membership');
- $this->click('link=Add Membership');
-
- $this->waitForElementPresent('_qf_Membership_cancel-bottom');
-
- // fill in Membership Organization and Type
- $this->select('membership_type_id[0]', "label=Organization {$title}");
- // Wait for membership type select to reload
- $this->waitForTextPresent("Membership Type {$title}");
- $this->select('membership_type_id[1]', "label=Membership Type {$title}");
-
- $sourceText = "Membership ContactAddTest with Fixed Membership Type Scenario 3";
- // fill in Source
- $this->type('source', $sourceText);
-
- //build the membership dates.
- require_once 'CRM/Core/Config.php';
- require_once 'CRM/Utils/Array.php';
- require_once 'CRM/Utils/Date.php';
- $currentYear = date('Y');
- $currentMonth = date('m');
- $previousYear = $currentYear - 1;
- $nextYear = $currentYear + 1;
- $todayDate = date('Y-m-d');
- $joinDate = date('Y-m-d', mktime(0, 0, 0, 11, 15, $currentYear));
- $startDate = date('Y-m-d', mktime(0, 0, 0, 1, 1, $currentYear));
- $endDate = date('Y-m-d', mktime(0, 0, 0, 12, 31, $nextYear));
- foreach (array(
- 'joinDate',
- 'startDate',
- 'endDate',
- ) as $date) {
- $$date = CRM_Utils_Date::customFormat($$date, $this->webtestGetSetting('dateformatFull'));
- }
-
- $query = "
-SELECT end_event_adjust_interval
-
- FROM civicrm_membership_status
-
- WHERE start_event = 'join_date'
- AND name = 'New'";
- $endInterval = CRM_Core_DAO::singleValueQuery($query);
-
- // Add endInterval to Nov 15 (join date month above) to get end of New status period
- $endNewStatus = date('Y-m-d', mktime(0, 0, 0, $endInterval - 1, 15, $nextYear));
-
- $status = 'Current';
- // status will be 'New' if today is >= join date and <= endNewStatus date
- if ((strtotime($todayDate) >= strtotime($joinDate)) && (strtotime($todayDate) <= strtotime($endNewStatus))) {
- $status = 'New';
- }
-
- // fill in Join Date
- $this->webtestFillDate('join_date', $joinDate);
-
- // Clicking save.
- $this->click('_qf_Membership_upload');
- $this->waitForElementPresent("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']");
-
- // page was loaded
- $this->waitForTextPresent($sourceText);
-
- // Is status message correct?
- $this->assertTrue($this->isTextPresent("Membership Type $title membership for $firstName $lastName has been added."),
- "Status message didn't show up after saving!"
- );
-
- // click through to the membership view screen
- $this->click("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']");
- $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
-
- $this->webtestVerifyTabularData(
- array(
- 'Membership Type' => "Membership Type {$title}",
- 'Status' => $status,
- 'Source' => $sourceText,
- 'Member Since' => $joinDate,
- 'Start date' => $startDate,
- 'End date' => $endDate,
- )
- );
- }
-
- public function testMembershipTypeScenario4() {
- // Scenario 4
- // Standard Fixed scenario - Jan 1 Fixed Period Start and October 31 rollover
- // Join Date is earlier than Rollover Date
-
- // Log in using webtestLogin() method
- $this->webtestLogin();
-
- $this->openCiviPage("contact/add", "reset=1&ct=Organization", '_qf_Contact_cancel');
-
- $title = substr(sha1(rand()), 0, 7);
- $this->type('organization_name', "Organization $title");
- $this->type('email_1_email', "$title@org.com");
- $this->click('_qf_Contact_upload_view');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->assertTrue($this->isTextPresent("Organization $title has been created."));
-
- $this->openCiviPage("admin/member/membershipType", "reset=1&action=browse");
-
- $this->click("link=Add Membership Type");
- $this->waitForElementPresent("xpath=//button//span[contains(text(),'Cancel')]");
-
- $this->type('name', "Membership Type $title");
- $this->select2('member_of_contact_id', $title);
-
- $this->type('minimum_fee', '100');
- $this->select('financial_type_id', 'value=2');
- $this->type('duration_interval', 1);
- $this->select('duration_unit', "label=year");
-
- $this->select('period_type', "value=fixed");
- $this->waitForElementPresent('fixed_period_rollover_day[d]');
-
- $this->select('fixed_period_start_day[M]', 'value=1');
- $this->select('fixed_period_rollover_day[M]', 'value=10');
- $this->select('fixed_period_rollover_day[d]', 'value=31');
-
- $this->click('relationship_type_id', 'value=4_b_a');
-
- $this->click('_qf_MembershipType_upload-bottom');
- $this->waitForElementPresent('link=Add Membership Type');
- $this->waitForText('crm-notification-container', "The membership type 'Membership Type $title' has been saved.");
-
- $this->openCiviPage("contact/add", "reset=1&ct=Individual");
-
- $firstName = "John_" . substr(sha1(rand()), 0, 7);
-
- //fill in first name
- $this->type('first_name', $firstName);
-
- //fill in last name
- $lastName = "Smith_" . substr(sha1(rand()), 0, 7);;
- $this->type('last_name', $lastName);
-
- //fill in email
- $email = substr(sha1(rand()), 0, 7) . "john@gmail.com";
- $this->type('email_1_email', $email);
-
- // Clicking save.
- $this->click('_qf_Contact_upload_view');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->assertTrue($this->isTextPresent("$firstName $lastName has been created."));
-
- // click through to the membership view screen
- $this->click('css=li#tab_member a');
-
- $this->waitForElementPresent('link=Add Membership');
- $this->click('link=Add Membership');
-
- $this->waitForElementPresent('_qf_Membership_cancel-bottom');
-
- // fill in Membership Organization and Type
- $this->select('membership_type_id[0]', "label=Organization $title");
- $this->select('membership_type_id[1]', "label=Membership Type $title");
-
- $sourceText = "Membership ContactAddTest with Fixed Membership Type Scenario 4";
- // fill in Source
- $this->type('source', $sourceText);
-
- //build the membership dates.
- require_once 'CRM/Core/Config.php';
- require_once 'CRM/Utils/Array.php';
- require_once 'CRM/Utils/Date.php';
- $currentYear = date('Y');
- $currentMonth = date('m');
- $nextYear = $currentYear + 1;
- $todayDate = date('Y-m-d');
-
- // the member-since date we will type in to membership form
- $joinDate = date('Y-m-d', mktime(0, 0, 0, 1, 15, $currentYear));
-
- // expected calc'd start and end dates
- $startDate = date('Y-m-d', mktime(0, 0, 0, 1, 1, $currentYear));
- $endDate = date('Y-m-d', mktime(0, 0, 0, 12, 31, $currentYear));
- foreach (array(
- 'joinDate',
- 'startDate',
- 'endDate',
- ) as $date) {
- $$date = CRM_Utils_Date::customFormat($$date, $this->webtestGetSetting('dateformatFull'));
- }
-
- $query = "
-SELECT end_event_adjust_interval
-
- FROM civicrm_membership_status
-
- WHERE start_event = 'join_date'
- AND name = 'New'";
- $endInterval = CRM_Core_DAO::singleValueQuery($query);
-
- // Add endInterval to Jan 6 (join date month above) to get end of New status period
- $endNewStatus = date('Y-m-d', mktime(0, 0, 0, $endInterval + 1, 15, $currentYear));
-
- $status = 'Current';
- // status will be 'New' if today is >= join date and <= endNewStatus date
- if ((strtotime($todayDate) >= strtotime($joinDate)) && (strtotime($todayDate) <= strtotime($endNewStatus))) {
- $status = 'New';
- }
-
- // fill in Join Date
- $this->webtestFillDate('join_date', $joinDate);
-
- // Clicking save.
- $this->click('_qf_Membership_upload');
- $this->waitForElementPresent("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']");
-
- // page was loaded
- $this->waitForTextPresent($sourceText);
-
- // Is status message correct?
- $this->assertTrue($this->isTextPresent("Membership Type $title membership for $firstName $lastName has been added."),
- "Status message didn't show up after saving!"
- );
-
- // click through to the membership view screen
- $this->click("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']");
- $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
-
- $this->webtestVerifyTabularData(
- array(
- 'Membership Type' => "Membership Type $title",
- 'Status' => $status,
- 'Source' => $sourceText,
- 'Member Since' => $joinDate,
- 'Start date' => $startDate,
- 'End date' => $endDate,
- )
- );
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Member_InheritedMembershipTest
- */
-class WebTest_Member_InheritedMembershipTest extends CiviSeleniumTestCase {
- protected function setUp() {
- parent::setUp();
- }
-
- public function testInheritedMembership() {
- //$this->markTestSkipped('Skipping for now as it works fine locally.');
- // Log in using webtestLogin() method
- $this->webtestLogin();
-
- $this->openCiviPage('contact/add', 'reset=1&ct=Organization', '_qf_Contact_cancel');
-
- $title = substr(sha1(rand()), 0, 7);
- $this->type('organization_name', "Organization $title");
- $this->type('email_1_email', "$title@org.com");
- $this->click('_qf_Contact_upload_view');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForText('crm-notification-container', "Organization {$title} has been created.");
-
- $this->openCiviPage('admin/member/membershipType', 'reset=1&action=browse');
-
- $this->click('link=Add Membership Type');
- $this->waitForElementPresent('_qf_MembershipType_cancel-bottom');
-
- $this->type('name', "Membership Type $title");
-
- $this->select2('member_of_contact_id', $title);
-
- $this->type('minimum_fee', '100');
- $this->select('financial_type_id', 'value=2');
- $this->type('duration_interval', 1);
- $this->select('duration_unit', 'label=year');
-
- $this->select('period_type', 'value=rolling');
-
- $this->select2('relationship_type_id', 'Employer of', TRUE);
- $this->type('max_related', '5');
-
- $this->click('_qf_MembershipType_upload-bottom');
- $this->waitForElementPresent('link=Add Membership Type');
- $this->waitForText('crm-notification-container', "Membership Type $title");
-
- $this->openCiviPage('contact/add', 'reset=1&ct=Organization', '_qf_Contact_cancel');
-
- // creating another Orgnization
- $title1 = substr(sha1(rand()), 0, 7);
- $this->type('organization_name', "Organization $title1");
- $this->type('email_1_email', "$title1@org.com");
- $this->click('_qf_Contact_upload_view');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // click through to the membership view screen
- $this->click('css=li#tab_member a');
-
- $this->waitForElementPresent('link=Add Membership');
- $this->click('link=Add Membership');
-
- $this->waitForElementPresent('_qf_Membership_cancel-bottom');
-
- // fill in Membership Organization and Type
- $this->select('membership_type_id[0]', "label=Organization $title");
- $this->select('membership_type_id[1]', "label=Membership Type $title");
-
- $sourceText = 'Membership ContactAddTest with Fixed Membership Type';
- // fill in Source
- $this->type('source', $sourceText);
-
- // Clicking save.
- $this->click('_qf_Membership_upload');
- $this->waitForElementPresent('link=Add Membership');
-
- // page was loaded
- $this->waitForTextPresent($sourceText);
-
- // Is status message correct?
- $this->waitForText('crm-notification-container', "Membership Type $title");
-
- // click through to the membership view screen
- $this->click("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']");
- $this->waitForElementPresent('_qf_MembershipView_cancel-bottom');
-
- $joinDate = date('Y-m-d');
- $startDate = date('Y-m-d');
- $endDate = date('Y-m-d', mktime(0, 0, 0, date('m'), date('d') - 1, date('Y') + 1));
- foreach (array(
- 'joinDate',
- 'startDate',
- 'endDate',
- ) as $date) {
- $$date = CRM_Utils_Date::customFormat($$date, $this->webtestGetSetting('dateformatFull'));
- }
-
- $this->webtestVerifyTabularData(
- array(
- 'Membership Type' => "Membership Type $title",
- 'Status' => 'New',
- 'Source' => $sourceText,
- 'Member Since' => $joinDate,
- 'Start date' => $startDate,
- 'End date' => $endDate,
- 'Max related' => "5",
- )
- );
-
- // Adding contact
- // We're using Quick Add block on the main page for this.
- $firstName = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName, 'Anderson', "$firstName@anderson.name");
-
- // visit relationship tab
- $this->click('css=li#tab_rel a');
- $this->waitForElementPresent('css=div.action-link');
- $this->click("//div[@class='action-link']/a/span");
- $this->waitForElementPresent('_qf_Relationship_cancel-bottom');
- $this->click('relationship_type_id');
- $this->select('relationship_type_id', 'label=Employee of');
-
- $this->select2('related_contact_id', $title1, TRUE);
-
- $description = 'Well here is some description !!!!';
- $this->type('description', $description);
-
- //save the relationship
- $this->click('_qf_Relationship_upload-bottom');
- $this->waitForElementPresent("xpath=//div[@class='crm-contact-relationship-current']");
- //check the status message
- $this->waitForText('crm-notification-container', 'Relationship created.');
-
- $this->waitForElementPresent("xpath=//div[@class='crm-contact-relationship-current']/div/table/tbody//tr/td[9]/span/a[text()='View']");
-
- // click through to the membership view screen
- $this->click('css=li#tab_member a');
- $this->waitForElementPresent('css=div#memberships');
-
- // click through to the membership view screen
- $this->click("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']");
- $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
-
- $this->webtestVerifyTabularData(
- array(
- 'Membership Type' => "Membership Type $title",
- 'Status' => 'New',
- 'Source' => $sourceText,
- 'Member Since' => $joinDate,
- 'Start date' => $startDate,
- 'End date' => $endDate,
- )
- );
- $this->click("_qf_MembershipView_cancel-bottom");
- $this->waitForElementPresent('css=div#memberships');
-
- //1. change relationship status on form
- $this->click('css=li#tab_rel a');
- $this->waitForElementPresent('css=div.action-link');
-
- $this->click("//li[@id='tab_rel']/a");
- $this->waitForElementPresent("xpath=//div[@class='crm-contact-relationship-current']/div/table/tbody//tr/td[9]/span/a[text()='Edit']");
- $id = explode('&id=', $this->getAttribute("xpath=//div[@class='crm-contact-relationship-current']/div/table/tbody//tr/td[9]/span/a@href"));
- $id = explode('&', $id[0]);
- $id = explode('=', $id[2]);
- $id = $id[1];
- $this->click("xpath=//div[@class='crm-contact-relationship-current']/div/table/tbody//tr/td[9]/span/a[text()='Edit']");
-
- $this->waitForElementPresent('is_active');
- //disable relationship
- if ($this->isChecked('is_active')) {
- $this->click('is_active');
- }
- $this->click('_qf_Relationship_upload');
- $this->waitForElementPresent("xpath=//div[@class='crm-contact-relationship-current']");
- //check the status message
- $this->waitForText('crm-notification-container', 'Relationship record has been updated');
-
- // click through to the membership view screen
- $this->click('css=li#tab_member a');
-
- //verify inherited membership has been removed
- $this->openCiviPage("contact/view", "reset=1&cid=$id&selectedChild=member", "xpath=//div[@class='view-content']/div[3]");
- $this->waitForTextPresent("No memberships have been recorded for this contact.");
-
- // visit relationship tab and re-enable the relationship
- $this->click('css=li#tab_rel a');
- $this->waitForElementPresent('css=div.action-link');
- $this->click("//li[@id='tab_rel']/a");
-
- $this->waitForElementPresent("xpath=//div[@class='crm-contact-relationship-past']/div/table/tbody//tr/td[9]/span/a[text()='Edit']");
- $this->click("xpath=//div[@class='crm-contact-relationship-past']/div/table/tbody//tr/td[9]/span/a[text()='Edit']");
- $this->waitForElementPresent('is_active');
- if (!$this->isChecked('is_active')) {
- $this->click('is_active');
- }
- $this->click('_qf_Relationship_upload');
- $this->waitForElementPresent("xpath=//div[@class='crm-contact-relationship-current']");
- //check the status message
- $this->waitForText('crm-notification-container', 'Relationship record has been updated.');
-
- //check for memberships
- $this->click('css=li#tab_member a');
- $this->waitForElementPresent('css=div#memberships');
-
- //2 . visit relationship tab and disable the relationship (by links)
- //disable relationship
- $this->click('css=li#tab_rel a');
- $this->waitForElementPresent('css=div.action-link');
- $this->waitForElementPresent("xpath=//div[@class='crm-contact-relationship-current']/div/table/tbody//tr/td[9]/span[2][text()='more']/ul/li[1]/a[text()='Disable']");
- $this->click("xpath=//div[@class='crm-contact-relationship-current']/div/table/tbody//tr/td[9]/span[2][text()='more']/ul/li[1]/a[text()='Disable']");
- $this->waitForTextPresent('Are you sure you want to disable this relationship?');
- $this->click("xpath=//div[@class='ui-dialog-buttonset']//button//span[text()='Yes']");
- // Because it tends to cause problems, all uses of sleep() must be justified in comments
- // Sleep should never be used for wait for anything to load from the server
- // Justification for this instance: FIXME
- sleep(10);
-
- //verify inherited membership has been removed
- $this->openCiviPage("contact/view", "reset=1&cid={$id}&selectedChild=member", "xpath=//div[@class='view-content']/div[3]");
- $this->waitForTextPresent("No memberships have been recorded for this contact.");
-
- //enable relationship
- $this->click('css=li#tab_rel a');
- $this->waitForElementPresent('css=div.action-link');
-
- $this->waitForElementPresent("xpath=//div[@class='crm-contact-relationship-past']/div/table/tbody/tr/td[9]/span[2][text()='more']/ul/li[1]/a[text()='Enable']");
- $this->click("xpath=//div[@class='crm-contact-relationship-past']/div/table/tbody/tr/td[9]/span[2][text()='more']/ul/li[1]/a[text()='Enable']");
-
- //verify membership
- $this->click('css=li#tab_member a');
- $this->waitForTextPresent("No memberships have been recorded for this contact.");
- }
-
- /**
- * Webtest for CRM-10146
- */
- public function testInheritedMembershipActivity() {
- // Log in using webtestLogin() method
- $this->webtestLogin();
-
- $this->openCiviPage('contact/add', 'reset=1&ct=Organization', '_qf_Contact_cancel');
-
- $title = substr(sha1(rand()), 0, 7);
- $this->type('organization_name', "Organization $title");
- $this->type('email_1_email', "$title@org.com");
- $this->clickLink('_qf_Contact_upload_view');
- $this->waitForText('crm-notification-container', "Organization {$title} has been created.");
-
- $this->openCiviPage('admin/member/membershipType', 'reset=1&action=browse');
-
- $this->click('link=Add Membership Type');
- $this->waitForElementPresent('_qf_MembershipType_cancel-bottom');
-
- $this->type('name', "Membership Type $title");
-
- $this->select2('member_of_contact_id', $title);
-
- $this->type('minimum_fee', '100');
- $this->select('financial_type_id', 'label=Member Dues');
- $this->type('duration_interval', 1);
- $this->select('duration_unit', 'label=year');
-
- $this->select('period_type', 'value=rolling');
-
- $this->select2('relationship_type_id', 'Employer of', TRUE);
-
- $this->type('max_related', '5');
-
- $this->click('_qf_MembershipType_upload-bottom');
- $this->waitForElementPresent('link=Add Membership Type');
- $this->waitForText('crm-notification-container', "Membership Type $title");
-
- // creating another Organization
- $this->openCiviPage('contact/add', 'reset=1&ct=Organization', '_qf_Contact_cancel');
- $org1 = substr(sha1(rand()), 0, 7);
- $this->type('organization_name', "Organization $org1");
- $this->type('email_1_email', "$org1@org.com");
- $this->clickLink('_qf_Contact_upload_view');
-
- // click through to the membership view screen
- $this->click('css=li#tab_member a');
-
- $this->waitForElementPresent('link=Add Membership');
- $this->click('link=Add Membership');
-
- $this->waitForElementPresent('_qf_Membership_cancel-bottom');
-
- // fill in Membership Organization and Type
- $this->select('membership_type_id[0]', "label=Organization $title");
- $this->select('membership_type_id[1]', "label=Membership Type $title");
-
- $sourceText = 'Membership ContactAddTest with Rolling Membership Type';
- // fill in Source
- $this->type('source', $sourceText);
-
- // Clicking save.
- $this->click('_qf_Membership_upload');
-
- // page was loaded
- $this->waitForTextPresent($sourceText);
-
- // Is status message correct?
- $this->waitForText('crm-notification-container', "Membership Type $title");
-
- // Adding contact
- $this->openCiviPage('contact/add', 'reset=1&ct=Individual', '_qf_Contact_cancel-bottom');
- $firstName = substr(sha1(rand()), 0, 7);
- $lastName = 'Anderson';
- $email = "$firstName@anderson.name";
- $this->type("first_name", $firstName);
- $this->type("last_name", $lastName);
-
- // Set Current Employer
- $this->select2('employer_id', $org1);
- $this->waitForText('s2id_employer_id', $org1);
-
- $this->type("email_1_email", $email);
- $this->clickLink("_qf_Contact_upload_view-bottom");
- $cid = $this->urlArg('cid');
-
- // click through to the membership view screen
- $this->click('css=li#tab_member a');
- $this->waitForElementPresent("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']");
-
- // check number of membership for contact
- $this->assertEquals(1, $this->getText("xpath=//li[@id='tab_member']/a/em"));
-
- $url = $this->parseURL($this->getAttribute("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']@href"));
- $expectedMembershipId = $url['queryString']['id'];
-
- // click through to the activity view screen
- $this->click('css=li#tab_activity a');
- $this->waitForElementPresent("xpath=//table[@class='contact-activity-selector-activity crm-ajax-table dataTable no-footer']/tbody/tr/td[8]/span/a");
-
- // check number of activity for contact
- $this->assertEquals(1, $this->getText("xpath=//li[@id='tab_activity']/a/em"));
-
- $url = $this->parseURL($this->getAttribute("xpath=//table[@class='contact-activity-selector-activity crm-ajax-table dataTable no-footer']/tbody/tr/td[8]/span/a@href"));
- $expectedMembershipActivityId = $url['queryString']['id'];
-
- // verify membership id with membership activity id
- $this->assertEquals($expectedMembershipId, $expectedMembershipActivityId);
-
- // click through to the relationship view screen
- $this->click('css=li#tab_rel a');
- $this->waitForElementPresent("xpath=//div[@class='crm-contact-relationship-current']/div/table/tbody/tr/td[2]/a");
- $this->assertTrue($this->isElementPresent("xpath=//div[@class='crm-contact-relationship-current']/div/table/tbody/tr/td[2]/a[text()='Organization $org1']"));
- $this->assertEquals(1, $this->getText("xpath=//li[@id='tab_rel']/a/em"));
-
- // Edit Contact but do not change any field
- $this->waitForElementPresent("xpath=//ul[@id='actions']/li[2]/a/span");
- $this->clickLink("xpath=//ul[@id='actions']/li[2]/a/span");
- $this->waitForElementPresent('_qf_Contact_cancel-bottom');
- $this->clickLink("_qf_Contact_upload_view-top");
-
- // click through to the membership view screen after edit
- $this->click('css=li#tab_member a');
- $this->waitForElementPresent("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']");
- $this->assertEquals(1, $this->getText("xpath=//li[@id='tab_member']/a/em"));
-
- $url = $this->parseURL($this->getAttribute("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']@href"));
- $actualMembershipId1 = $url['queryString']['id'];
-
- // click through to the activity view screen after edit
- $this->click('css=li#tab_activity a');
- $this->waitForElementPresent("xpath=//table[@class='contact-activity-selector-activity crm-ajax-table dataTable no-footer']/tbody/tr/td[8]/span/a");
- $this->assertEquals(1, $this->getText("xpath=//li[@id='tab_activity']/a/em"));
- $url = $this->parseURL($this->getAttribute("xpath=//table[@class='contact-activity-selector-activity crm-ajax-table dataTable no-footer']/tbody/tr/td[8]/span/a@href"));
- $actualMembershipActivityId1 = $url['queryString']['id'];
-
- // verify membership id and membership activity id with previous one
- // FIXME: These 2 lines are currently failing because the inherited membership and signup activity or being recreated when contact is edited/saved. dgg
- $this->assertEquals($expectedMembershipId, $actualMembershipId1);
- $this->assertEquals($expectedMembershipActivityId, $actualMembershipActivityId1);
-
- // click through to the relationship view screen after edit
- $this->click('css=li#tab_rel a');
- $this->waitForElementPresent("xpath=//div[@class='crm-contact-relationship-current']/div/table/tbody/tr/td[2]/a");
- $this->assertTrue($this->isElementPresent("xpath=//div[@class='crm-contact-relationship-current']/div/table/tbody/tr/td[2]/a[text()='Organization $org1']"));
- $this->assertEquals(1, $this->getText("xpath=//li[@id='tab_rel']/a/em"));
-
- // change the current employer of the contact
- // creating another membership type
- $this->openCiviPage('admin/member/membershipType', 'reset=1&action=browse');
-
- $this->click('link=Add Membership Type');
- $this->waitForElementPresent('_qf_MembershipType_cancel-bottom');
-
- $this->type('name', "Membership Type Another $title");
-
- $this->select2('member_of_contact_id', $title);
-
- $this->type('minimum_fee', '100');
- $this->select('financial_type_id', 'label=Member Dues');
- $this->type('duration_interval', 1);
- $this->select('duration_unit', 'label=year');
-
- $this->select('period_type', 'value=rolling');
-
- $this->select2('relationship_type_id', 'Employer of', TRUE);
- $this->type('max_related', '5');
-
- $this->click('_qf_MembershipType_upload-bottom');
- $this->waitForElementPresent('link=Add Membership Type');
- $this->waitForText('crm-notification-container', "Membership Type Another $title");
-
- // creating another Orgnization
- $this->openCiviPage('contact/add', 'reset=1&ct=Organization', '_qf_Contact_cancel');
- $org2 = substr(sha1(rand()), 0, 7);
- $this->type('organization_name', "Organization $org2");
- $this->type('email_1_email', "$org2@org.com");
- $this->clickLink('_qf_Contact_upload_view');
-
- // click through to the membership view screen
- $this->click('css=li#tab_member a');
- $this->waitForElementPresent('link=Add Membership');
- $this->click('link=Add Membership');
- $this->waitForElementPresent('_qf_Membership_cancel-bottom');
-
- // fill in Membership Organization and Type
- $this->select('membership_type_id[0]', "label=Organization $title");
- $this->select('membership_type_id[1]', "label=Membership Type Another $title");
-
- $sourceText = 'Membership ContactAddTest with Rolling Membership Type';
- $this->type('source', $sourceText);
- $this->clickLink('_qf_Membership_upload', 'link=Add Membership', FALSE);
- $this->waitForTextPresent($sourceText);
-
- // Is status message correct?
- $this->waitForText('crm-notification-container', "Membership Type Another $title");
-
- // edit contact
- $this->openCiviPage("contact/add", "reset=1&action=update&cid=$cid", "_qf_Contact_cancel-bottom");
-
- // change Current Employer
- $this->select2('employer_id', $org2);
- $this->clickLink("_qf_Contact_upload_view-bottom");
-
- // click through to the membership view screen
- $this->click('css=li#tab_member a');
- $this->waitForElementPresent("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']");
- $this->assertEquals(1, $this->getText("xpath=//li[@id='tab_member']/a/em"));
- $url = $this->parseURL($this->getAttribute("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']@href"));
- $actualMembershipId2 = $url['queryString']['id'];
-
- // click through to the activity view screen
- $this->click('css=li#tab_activity a');
- $this->waitForElementPresent("xpath=//table[@class='contact-activity-selector-activity crm-ajax-table dataTable no-footer']/tbody//tr/td[8]/span/a[text()='View']");
- $this->assertEquals(1, $this->getText("xpath=//li[@id='tab_activity']/a/em"));
- $url = $this->parseURL($this->getAttribute("xpath=//table[@class='contact-activity-selector-activity crm-ajax-table dataTable no-footer']/tbody//tr/td[8]/span/a[text()='View']@href"));
- $actualMembershipActivityId2 = $url['queryString']['id'];
-
- // verify membership id and membership activity id with previous one
- $this->assertNotEquals($expectedMembershipId, $actualMembershipId2);
- $this->assertNotEquals($expectedMembershipId, $actualMembershipActivityId2);
-
- // click through to the relationship view screen
- $this->click('css=li#tab_rel a');
- $this->waitForElementPresent("xpath=//div[@class='crm-contact-relationship-current']/div/table/tbody/tr/td[2]/a");
- $this->assertTrue($this->isElementPresent("xpath=//div[@class='crm-contact-relationship-current']/div/table/tbody/tr/td[2]/a[text()='Organization $org2']"));
- $this->assertEquals(1, $this->getText("xpath=//li[@id='tab_rel']/a/em"));
-
- // creating another Orgnization with no membership
- $this->openCiviPage('contact/add', 'reset=1&ct=Organization', '_qf_Contact_cancel');
- $org3 = substr(sha1(rand()), 0, 7);
- $this->type('organization_name', "Organization $org3");
- $this->type('email_1_email', "$org3@org.com");
- $this->clickLink('_qf_Contact_upload_view');
-
- // edit contact
- $this->openCiviPage("contact/add", "reset=1&action=update&cid=$cid", "_qf_Contact_cancel-bottom");
-
- // change Current Employer
- $this->select2('employer_id', $org3);
- $this->clickLink("_qf_Contact_upload_view-bottom");
-
- // click through to the membership view screen
- $this->click('css=li#tab_member a');
-
- $this->waitForAjaxContent();
- $this->waitForTextPresent("No memberships have been recorded for this contact.");
- $this->assertEquals(0, $this->getText("xpath=//li[@id='tab_member']/a/em"));
-
- // click through to the activity view screen
- $this->click('css=li#tab_activity a');
- $this->waitForText("xpath=//table[@class='contact-activity-selector-activity crm-ajax-table dataTable no-footer']/tbody/tr/td", "None found.");
- $this->assertEquals(0, $this->getText("xpath=//li[@id='tab_activity']/a/em"));
-
- // click through to the relationship view screen
- $this->click('css=li#tab_rel a');
- $this->waitForElementPresent("xpath=//div[@class='crm-contact-relationship-current']/div/table/tbody/tr/td[2]/a");
- $this->assertTrue($this->isElementPresent("xpath=//div[@class='crm-contact-relationship-current']/div/table/tbody/tr/td[2]/a[text()='Organization $org3']"));
- $this->assertEquals(1, $this->getText("xpath=//li[@id='tab_rel']/a/em"));
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Member_OfflineAutoRenewMembershipTest
- */
-class WebTest_Member_OfflineAutoRenewMembershipTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testOfflineAutoRenewMembership() {
- $this->webtestLogin();
-
- // We need a payment processor
- $processorName = "Webtest AuthNet" . substr(sha1(rand()), 0, 7);
- $this->webtestAddPaymentProcessor($processorName, 'AuthNet');
-
- // Create a membership type to use for this test
- $periodType = 'rolling';
- $duration_interval = 1;
- $duration_unit = 'year';
- $auto_renew = "optional";
-
- $memTypeParams = $this->webtestAddMembershipType($periodType, $duration_interval, $duration_unit, $auto_renew);
-
- // create a new contact for whom membership is to be created
- $firstName = 'Apt' . substr(sha1(rand()), 0, 4);
- $lastName = 'Mem' . substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName, $lastName, "{$firstName}@example.com");
- $contactName = "$firstName $lastName";
-
- $this->click('css=li#tab_member a');
-
- $this->waitForElementPresent('link=Add Membership');
-
- // since we don't have live credentials we will switch to test mode
- $this->waitForElementPresent("xpath=//div[@class='view-content']//div[@class='action-link']/a[1]");
- $url = $this->getAttribute("xpath=//a[contains(text(), 'Add Membership')]@href");
- $url .= '&mode=test';
- $this->open($url);
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // start filling membership form
- $this->waitForElementPresent('payment_processor_id');
- $this->select("payment_processor_id", "label={$processorName}");
-
- // fill in Membership Organization and Type
- $this->waitForElementPresent('membership_type_id[0]');
- $this->select("membership_type_id[0]", "label={$memTypeParams['member_of_contact']}");
- // Wait for membership type select to reload
- $this->waitForTextPresent($memTypeParams['membership_type']);
- $this->select("membership_type_id[1]", "label={$memTypeParams['membership_type']}");
-
- $this->click("source");
- $this->type("source", "Online Membership: Admin Interface");
-
- $this->waitForElementPresent('auto_renew');
- $this->click("auto_renew");
- $this->webtestAddCreditCardDetails();
-
- $this->webtestAddBillingDetails($firstName, NULL, $lastName);
-
- $this->clickLink("_qf_Membership_upload-bottom");
-
- // Use Find Members to make sure membership exists
- $this->openCiviPage("member/search", "reset=1", "member_end_date_high");
-
- $this->type("sort_name", "$lastName, $firstName");
- $this->click("member_test");
- $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='memberSearch']/table/tbody/tr[1]/td[11]/span/a[text()='View']");
- $this->clickAjaxLink("xpath=//div[@id='memberSearch']/table/tbody/tr[1]/td[11]/span/a[text()='View']", "_qf_MembershipView_cancel-bottom");
-
- // View Membership Record
- $verifyData = array(
- 'Member' => "$firstName $lastName",
- 'Membership Type' => $memTypeParams['membership_type'],
- 'Source' => 'Online Membership: Admin Interface',
- 'Status' => 'Pending',
- 'Auto-renew' => 'Yes',
- );
- foreach ($verifyData as $label => $value) {
- $this->verifyText("xpath=//form[@id='MembershipView']//table/tbody/tr/td[text()='{$label}']/following-sibling::td",
- preg_quote($value)
- );
- }
- }
-
- /**
- * CRM-18050: create price set with auto-renewing memberships.
- */
- public function testCreatePriceSetWithAutoRenewMembershipType() {
- $this->webtestLogin();
-
- // Create a membership type to use for this test
- $periodType = 'rolling';
- $duration_interval = 1;
- $duration_unit = 'year';
- $auto_renew = "required";
- $priceSetTitle = 'Membership PriceSet' . substr(sha1(rand()), 0, 7);
- $memTypeParams = $this->webtestAddMembershipType($periodType, $duration_interval, $duration_unit, $auto_renew);
-
- // Create a price set with membership type.
- $this->openCiviPage("admin/price", "reset=1&action=add", '_qf_Set_cancel-bottom');
- $this->type('title', $priceSetTitle);
- $this->click("xpath=//table[@class='form-layout']/tbody//tr/td[2]/label[text()='Membership']");
- $this->select('financial_type_id', "value=2");
- $this->click("_qf_Set_next-bottom");
- $this->waitForAjaxContent();
- $this->waitForElementPresent('is_active');
- $fieldLablel = 'Field Label' . substr(sha1(rand()), 0, 7);
- $this->type('label', $fieldLablel);
- $this->select('html_type', "value=Radio");
- $this->waitForAjaxContent();
- $this->waitForElementPresent('membership_type_id[1]');
- $this->select('membership_type_id[1]', "label={$memTypeParams['membership_type']}");
- $this->waitForAjaxContent();
- $this->click("xpath=//div[@class='ui-dialog-buttonset']//button//span[text()='Save']");
- $this->waitForElementPresent('field_page');
- $this->assertElementContainsText("xpath=//div[@id='crm-main-content-wrapper']/div[@id='field_page']/table/tbody/tr/td[1]/div", "{$fieldLablel}");
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Member_OfflineMembershipAddPricesetTest
- */
-class WebTest_Member_OfflineMembershipAddPricesetTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testAddPriceSet() {
- // Log in using webtestLogin() method
- $this->webtestLogin();
-
- $title = substr(sha1(rand()), 0, 7);
- $setTitle = "Membership Fees - $title";
- $usedFor = 'Membership';
- $contributionType = 'Donation';
- $setHelp = 'Select your membership options.';
- $this->_testAddSet($setTitle, $usedFor, $contributionType, $setHelp);
-
- // Get the price set id ($sid) by retrieving and parsing the URL of the New Price Field form
- // which is where we are after adding Price Set.
- $sid = $this->urlArg('sid');
- $this->assertType('numeric', $sid);
-
- $fields = array(
- "National Membership $title" => 'Radio',
- "Local Chapter $title" => 'CheckBox',
- );
-
- list($memTypeTitle1, $memTypeTitle2) = $this->_testAddPriceFields($fields, $validateStrings, FALSE, $title, $sid, $contributionType);
-
- // load the Price Set Preview and check for expected values
- $this->_testVerifyPriceSet($validateStrings, $sid);
-
- // Sign up for membership
- $firstName = 'John_' . substr(sha1(rand()), 0, 7);
- $lastName = 'Anderson_' . substr(sha1(rand()), 0, 7);
- $email = "{$firstName}.{$lastName}@example.com";
- $contactParams = array(
- 'first_name' => $firstName,
- 'last_name' => $lastName,
- 'email-5' => $email,
- );
-
- // Add a contact from the quick add block
- $this->webtestAddContact($firstName, $lastName, $email);
-
- $this->_testSignUpOrRenewMembership($sid, $contactParams, $memTypeTitle1, $memTypeTitle2);
-
- // Renew this membership
- $this->_testSignUpOrRenewMembership($sid, $contactParams, $memTypeTitle1, $memTypeTitle2, $renew = TRUE);
- }
-
- public function testAddPriceSetWithMultipleTerms() {
- // Log in using webtestLogin() method
- $this->webtestLogin();
-
- $title = substr(sha1(rand()), 0, 7);
- $setTitle = "Membership Fees - $title";
- $usedFor = 'Membership';
- $contributionType = 'Member Dues';
- $setHelp = 'Select your membership options.';
- $memTypeParams1 = $this->webtestAddMembershipType();
- $memTypeTitle1 = $memTypeParams1['membership_type'];
- $memTypeId1 = explode('&id=', $this->getAttribute("xpath=//div[@id='membership_type']/table/tbody//tr/td[1]/div[text()='{$memTypeTitle1}']/../../td[12]/span/a[3]@href"));
- $memTypeId1 = $memTypeId1[1];
- $this->_testAddSet($setTitle, $usedFor, $contributionType, $setHelp);
-
- // Get the price set id ($sid) by retrieving and parsing the URL of the New Price Field form
- // which is where we are after adding Price Set.
- $sid = $this->urlArg('sid');
- $this->assertType('numeric', $sid);
-
- $fields = array("National Membership $title", "Radio");
- $this->openCiviPage("admin/price/field", "reset=1&action=add&sid={$sid}");
-
- $validateStrings[] = $fields[0];
- $this->type('label', $fields[0]);
- $this->select('html_type', "value={$fields[1]}");
- $options = array(
- 1 => array(
- 'label' => $memTypeTitle1 . "_1",
- 'membership_type_id' => $memTypeId1,
- 'amount' => 50.00,
- 'membership_num_terms' => 1,
- ),
- 2 => array(
- 'label' => $memTypeTitle1 . "_2",
- 'membership_type_id' => $memTypeId1,
- 'amount' => 90.00,
- 'membership_num_terms' => 2,
- ),
- 3 => array(
- 'label' => $memTypeTitle1 . "_3",
- 'membership_type_id' => $memTypeId1,
- 'amount' => 120.00,
- 'membership_num_terms' => 3,
- ),
- );
- $i = 2;
- foreach ($options as $index => $values) {
- $this->select("membership_type_id_{$index}", "value={$values['membership_type_id']}");
- // Because it tends to cause problems, all uses of sleep() must be justified in comments
- // Sleep should never be used for wait for anything to load from the server
- // Justification for this instance: FIXME
- sleep(1);
- $this->type("xpath=//table[@id='optionField']/tbody/tr[$i]/td[4]/input", $values['membership_num_terms']);
- $this->type("xpath=//table[@id='optionField']/tbody/tr[$i]/td[5]/input", $values['label']);
- $this->type("xpath=//table[@id='optionField']/tbody/tr[$i]/td[6]/input", $values['amount']);
- if ($i > 3) {
- $this->click('link=another choice');
- }
- $i++;
- }
- $this->waitForElementPresent('financial_type_id');
- $this->select("financial_type_id", "label={$contributionType}");
- $this->waitForElementPresent('_qf_Field_next-bottom');
- $this->click('_qf_Field_next-bottom');
- $this->waitForText('crm-notification-container', "Price Field '{$fields[0]}' has been saved.");
-
- // load the Price Set Preview and check for expected values
- $this->_testVerifyPriceSet($validateStrings, $sid);
-
- $firstName = 'John_' . substr(sha1(rand()), 0, 7);
- $lastName = 'Anderson_' . substr(sha1(rand()), 0, 7);
- $email = "{$firstName}.{$lastName}@example.com";
-
- $contactParams = array(
- 'first_name' => $firstName,
- 'last_name' => $lastName,
- 'email-5' => $email,
- );
- $this->webtestAddContact($firstName, $lastName, $email);
- //membership with number of terms as 3
- $this->_testMultilpeTermsMembershipRegistration($sid, $contactParams, $memTypeTitle1, 3);
- //membership with number of terms as 2
- $this->_testMultilpeTermsMembershipRegistration($sid, $contactParams, $memTypeTitle1, 2);
-
- }
-
- /**
- * @param $setTitle
- * @param $usedFor
- * @param null $contributionType
- * @param $setHelp
- */
- public function _testAddSet($setTitle, $usedFor, $contributionType = NULL, $setHelp) {
- $this->openCiviPage('admin/price', 'reset=1&action=add', '_qf_Set_next-bottom');
-
- // Enter Priceset fields (Title, Used For ...)
- $this->type('title', $setTitle);
- if ($usedFor == 'Event') {
- $this->check('extends_1');
- }
- elseif ($usedFor == 'Contribution') {
- $this->check('extends_2');
- }
- elseif ($usedFor == 'Membership') {
- $this->click('extends_3');
- $this->waitForElementPresent('financial_type_id');
- $this->select("css=select.crm-form-select", "label={$contributionType}");
- }
- $this->type('help_pre', $setHelp);
- $this->assertChecked('is_active', 'Verify that Is Active checkbox is set.');
-
- $this->click('_qf_Set_next-bottom');
- $this->waitForElementPresent("xpath=//div[@id='crm-main-content-wrapper']//div[2]/a");
- $this->waitForText('crm-notification-container', "Your Set '{$setTitle}' has been added. You can add fields to this set now.");
- }
-
- /**
- * @param $fields
- * @param $validateString
- * @param bool $dateSpecificFields
- * @param $title
- * @param int $sid
- * @param $contributionType
- *
- * @return array
- */
- public function _testAddPriceFields(&$fields, &$validateString, $dateSpecificFields = FALSE, $title, $sid, $contributionType) {
- $memTypeParams1 = $this->webtestAddMembershipType();
- $memTypeTitle1 = $memTypeParams1['membership_type'];
-
- $memTypeId1 = explode('&id=', $this->getAttribute("xpath=//div[@id='membership_type']/table/tbody//tr/td[1]/div[text()='{$memTypeTitle1}']/../../td[12]/span/a[3]@href"));
- $memTypeId1 = $memTypeId1[1];
-
- $memTypeParams2 = $this->webtestAddMembershipType();
- $memTypeTitle2 = $memTypeParams2['membership_type'];
- $memTypeId2 = explode('&id=', $this->getAttribute("xpath=//div[@id='membership_type']/table/tbody//tr/td[1]/div[text()='{$memTypeTitle2}']/../../td[12]/span/a[3]@href"));
- $memTypeId2 = $memTypeId2[1];
-
- $this->openCiviPage("admin/price/field", "reset=1&action=add&sid={$sid}");
-
- foreach ($fields as $label => $type) {
- $validateStrings[] = $label;
-
- $this->type('label', $label);
- $this->select('html_type', "value={$type}");
-
- switch ($type) {
- case 'Radio':
- $options = array(
- 1 => array(
- 'label' => "$memTypeTitle1",
- 'membership_type_id' => $memTypeId1,
- 'amount' => 100.00,
- ),
- 2 => array(
- 'label' => "$memTypeTitle2",
- 'membership_type_id' => $memTypeId2,
- 'amount' => 50.00,
- ),
- );
- $this->addMultipleChoiceOptions($options, $validateStrings);
- break;
-
- case 'CheckBox':
- $options = array(
- 1 => array(
- 'label' => "$memTypeTitle1",
- 'membership_type_id' => $memTypeId1,
- 'amount' => 100.00,
- ),
- 2 => array(
- 'label' => "$memTypeTitle2",
- 'membership_type_id' => $memTypeId2,
- 'amount' => 50.00,
- ),
- );
- $this->addMultipleChoiceOptions($options, $validateStrings);
- break;
-
- default:
- break;
- }
- $this->select("financial_type_id", "label={$contributionType}");
- $this->click('_qf_Field_next_new-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForText('crm-notification-container', "Price Field '{$label}' has been saved.");
- }
- return array($memTypeTitle1, $memTypeTitle2);
- }
-
- /**
- * @param $validateStrings
- * @param int $sid
- */
- public function _testVerifyPriceSet($validateStrings, $sid) {
- // verify Price Set at Preview page
- // start at Manage Price Sets listing
- $this->openCiviPage('admin/price', 'reset=1');
-
- // Use the price set id ($sid) to pick the correct row
- $this->click("css=tr#price_set-{$sid} a[title='Preview Price Set']");
-
- // Look for Register button
- $this->waitForElementPresent('_qf_Preview_cancel-bottom');
-
- // Check for expected price set field strings
- $this->assertStringsPresent($validateStrings);
- }
-
- /**
- * @param int $sid
- * @param array $contactParams
- * @param $memTypeTitle1
- * @param $memTypeTitle2
- * @param bool $renew
- */
- public function _testSignUpOrRenewMembership($sid, $contactParams, $memTypeTitle1, $memTypeTitle2, $renew = FALSE) {
- //build the membership dates.
- require_once 'CRM/Core/Config.php';
- require_once 'CRM/Utils/Array.php';
- require_once 'CRM/Utils/Date.php';
- $currentYear = date('Y');
- $currentMonth = date('m');
- $previousDay = date('d') - 1;
- $endYear = ($renew) ? $currentYear + 2 : $currentYear + 1;
- $joinDate = date('Y-m-d', mktime(0, 0, 0, $currentMonth, date('d'), $currentYear));
- $startDate = date('Y-m-d', mktime(0, 0, 0, $currentMonth, date('d'), $currentYear));
- $endDate = date('Y-m-d', mktime(0, 0, 0, $currentMonth, $previousDay, $endYear));
- foreach (array(
- 'joinDate',
- 'startDate',
- 'endDate',
- ) as $date) {
- $$date = CRM_Utils_Date::customFormat($$date, $this->webtestGetSetting('dateformatFull'));
- }
-
- if (!$renew) {
-
- $this->click('css=li#tab_member a');
- $this->waitForElementPresent('link=Add Membership');
- if ($this->isTextPresent("No memberships have been recorded for this contact.")) {
- $this->waitForTextPresent('No memberships have been recorded for this contact.');
- }
-
- $this->clickAjaxLink('link=Add Membership');
- $this->waitForElementPresent('_qf_Membership_cancel-bottom');
-
- $this->select('price_set_id', "value={$sid}");
- $this->waitForElementPresent('pricesetTotal');
-
- $this->click("xpath=//div[@id='priceset']/div[2]/div[2]/div/span/input");
- $this->click("xpath=//div[@id='priceset']/div[3]/div[2]/div[2]/span/input");
-
- $this->type('source', 'Offline membership Sign Up Test Text');
- $this->click('_qf_Membership_upload-bottom');
- }
- else {
- $this->click("xpath=//div[@id='memberships']/div//table/tbody//tr/td[text()='{$memTypeTitle1}']/../td[9]/span[2][text()='Renew...']/ul/li/a[text()='Renew']");
- $this->waitForElementPresent('_qf_MembershipRenewal_cancel-bottom');
- $this->waitForAjaxContent();
- $this->click('_qf_MembershipRenewal_upload-bottom');
-
- $this->waitForElementPresent("xpath=//div[@id='memberships']//table/tbody/tr");
- $this->click("xpath=//div[@id='memberships']/div//table/tbody//tr/td[text()='{$memTypeTitle2}']/../td[9]/span[2][text()='Renew...']/ul/li/a[text()='Renew']");
- $this->waitForElementPresent('_qf_MembershipRenewal_cancel-bottom');
- $this->waitForAjaxContent();
- $this->click('_qf_MembershipRenewal_upload-bottom');
- }
- $this->waitForElementPresent("xpath=//div[@id='memberships']//table/tbody//tr/td[text()='{$memTypeTitle1}']/../td[9]/span/a[text()='View']");
- $this->waitForAjaxContent();
- $this->click("xpath=//div[@id='memberships']//table/tbody//tr/td[text()='{$memTypeTitle1}']/../td[9]/span/a[text()='View']");
- $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']/button[3]");
-
- //View Membership Record
- $verifyData = array(
- 'Membership Type' => "{$memTypeTitle1}",
- 'Status' => 'New',
- 'Member Since' => $joinDate,
- 'Start date' => $startDate,
- 'End date' => $endDate,
- );
- $this->webtestVerifyTabularData($verifyData);
-
- $this->click("xpath=//div[@class='ui-dialog-buttonset']/button[3]/span[2]");
- $this->waitForElementPresent("xpath=//div[@id='memberships']//table/tbody//tr/td[text()='{$memTypeTitle2}']/../td[9]/span/a[text()='View']");
- $this->click("xpath=//div[@id='memberships']//table/tbody//tr/td[text()='{$memTypeTitle2}']/../td[9]/span/a[text()='View']");
- $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']/button[3]");
-
- //View Membership Record
- $verifyData = array(
- 'Membership Type' => "{$memTypeTitle2}",
- 'Status' => 'New',
- 'Member Since' => $joinDate,
- 'Start date' => $startDate,
- 'End date' => $endDate,
- );
- $this->webtestVerifyTabularData($verifyData);
-
- $this->click("xpath=//div[@class='ui-dialog-buttonset']/button[3]/span[2]");
- $this->waitForElementPresent("xpath=//div[@id='memberships']//table/tbody/tr");
- }
-
- /**
- * @param int $sid
- * @param array $contactParams
- * @param $memTypeTitle1
- * @param $term
- */
- public function _testMultilpeTermsMembershipRegistration($sid, $contactParams, $memTypeTitle1, $term) {
- //build the membership dates.
- require_once 'CRM/Core/Config.php';
- require_once 'CRM/Utils/Array.php';
- require_once 'CRM/Utils/Date.php';
- $currentYear = date('Y');
- $currentMonth = date('m');
- $previousDay = date('d') - 1;
- $endYear = ($term == 3) ? $currentYear + 3 : (($term == 2) ? $currentYear + 2 : $currentYear + 1);
- $joinDate = date('Y-m-d', mktime(0, 0, 0, $currentMonth, date('d'), $currentYear));
- $startDate = date('Y-m-d', mktime(0, 0, 0, $currentMonth, date('d'), $currentYear));
- $endDate = date('Y-m-d', mktime(0, 0, 0, $currentMonth, $previousDay, $endYear));
- foreach (array(
- 'joinDate',
- 'startDate',
- 'endDate',
- ) as $date) {
- $$date = CRM_Utils_Date::customFormat($$date, $this->webtestGetSetting('dateformatFull'));
- }
-
- $this->click('css=li#tab_member a');
- $this->waitForElementPresent('link=Add Membership');
- if ($this->isTextPresent("No memberships have been recorded for this contact.")) {
- $this->waitForTextPresent('No memberships have been recorded for this contact.');
- }
-
- $this->clickAjaxLink('link=Add Membership');
- $this->waitForElementPresent('_qf_Membership_cancel-bottom');
-
- $this->select('price_set_id', "value={$sid}");
- $this->waitForElementPresent('pricesetTotal');
-
- $i = ($term == 3) ? 3 : (($term == 2) ? 2 : 1);
- $this->waitForElementPresent("xpath=//div[@id='priceset']/div[2]/div[2]/div[$i]/span/input");
- $this->click("xpath=//div[@id='priceset']/div[2]/div[2]/div[$i]/span/input");
- $amount = $this->getText("xpath=//div[@id='priceset']/div[2]/div[2]/div[$i]/span/label/span[@class='crm-price-amount-amount']");
-
- $this->type('source', 'Offline membership Sign Up Test Text');
- $this->waitForElementPresent('recordContribution');
- $this->click('_qf_Membership_upload-bottom');
-
- $this->waitForElementPresent("xpath=//table[@class='display dataTable no-footer']/tbody//tr/td[4][text()='{$endDate}']/../td[9]/span[1]/a[1]");
- $this->click("xpath=//table[@class='display dataTable no-footer']/tbody//tr/td[4][text()='{$endDate}']/../td[9]/span[1]/a[1]");
- $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']/button[3]/span[2]");
- //View Membership Record
- $verifyData = array(
- 'Membership Type' => "$memTypeTitle1",
- 'Status' => 'New',
- 'Member Since' => $joinDate,
- 'Start date' => $startDate,
- 'End date' => $endDate,
- );
- $this->webtestVerifyTabularData($verifyData);
-
- //check if the membership amount is correct
- $this->waitForElementPresent("xpath=//form[@id='MembershipView']/div[2]/div/div[@class='crm-accordion-wrapper']/div[2]/table/tbody/tr/td/a");
- $this->assertElementContainsText("xpath=//form[@id='MembershipView']/div[2]/div/div[@class='crm-accordion-wrapper']/div[2]/table/tbody/tr/td/a", $amount);
- $this->click("_qf_MembershipView_cancel-bottom");
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Member_OfflineMembershipRenewTest
- */
-class WebTest_Member_OfflineMembershipRenewTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testOfflineMembershipRenew() {
- $this->webtestLogin();
-
- // make sure period is correct for the membership type we testing for,
- // since it might have been modified by other tests
- // add membership type
- $membershipTypes = $this->webtestAddMembershipType('rolling', 2);
-
- // quick create a contact
- $firstName = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName, "Memberson", "{$firstName}@memberson.com");
- $contactName = "$firstName Memberson";
-
- // click through to the membership tab
- $this->click('css=li#tab_member a');
-
- $this->waitForElementPresent('link=Add Membership');
- $this->click('link=Add Membership');
-
- $this->waitForElementPresent('_qf_Membership_cancel-bottom');
-
- // fill in Membership Organization and Type
- $this->select('membership_type_id[0]', "label={$membershipTypes['member_of_contact']}");
- $this->select('membership_type_id[1]', "label={$membershipTypes['membership_type']}");
-
- // fill in Source
- $sourceText = 'Offline Membership Renewal Webtest';
- $this->type('source', $sourceText);
-
- // Fill Member Since
- $this->webtestFillDate('join_date', '-2 year');
-
- // Let Start Date and End Date be auto computed
-
- // Because it tends to cause problems, all uses of sleep() must be justified in comments
- // Sleep should never be used for wait for anything to load from the server
- // Justification for this instance: make sure onchange for total_amount has a chance to fire
- $this->waitForAjaxContent();
-
- // Clicking save.
- $this->click('_qf_Membership_upload-bottom');
-
- // page was loaded
- $this->waitForTextPresent($sourceText);
-
- // Is status message correct?
- $this->waitForText('crm-notification-container', "{$membershipTypes['membership_type']} membership for $firstName Memberson has been added.");
- $this->waitForElementPresent("xpath=//table[@class='display dataTable no-footer']/tbody/tr/td[9]/span[2][text()='Renew...']/ul/li/a[text()='Renew']");
-
- // click through to the Membership Renewal Link
- $this->click("xpath=//table[@class='display dataTable no-footer']/tbody/tr/td[9]/span[2][text()='Renew...']/ul/li/a[text()='Renew']");
-
- $this->waitForElementPresent('_qf_MembershipRenewal_cancel-bottom');
-
- // save the renewed membership
- $this->click('_qf_MembershipRenewal_upload-bottom');
-
- // page was loaded
- $this->waitForAjaxContent();
- $this->waitForTextPresent($sourceText);
- $this->waitForElementPresent("xpath=//table[@class='display dataTable no-footer']/tbody/tr/td[9]/span[1]/a[1][contains(text(),'View')]");
-
- // click through to the membership view screen
- $this->click("xpath=//table[@class='display dataTable no-footer']/tbody/tr/td[9]/span[1]/a[1][contains(text(),'View')]");
-
- $this->waitForElementPresent("xpath=//button//span[contains(text(),'Done')]");
-
- $joinDate = $startDate = date('F jS, Y', strtotime("-2 year"));
- $endDate = date('F jS, Y', strtotime("+2 year -1 day"));
-
- // verify membership renewed
- $verifyMembershipRenewData = array(
- 'Member' => $contactName,
- 'Membership Type' => $membershipTypes['membership_type'],
- 'Status' => 'Current',
- 'Source' => $sourceText,
- 'Member Since' => $joinDate,
- 'Start date' => $startDate,
- 'End date' => $endDate,
- );
- $this->webtestVerifyTabularData($verifyMembershipRenewData);
- }
-
- public function testOfflineMemberRenewOverride() {
- $this->webtestLogin();
-
- // add membership type
- $membershipTypes = $this->webtestAddMembershipType('rolling', 2);
-
- $firstName = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName, "Memberson", "{$firstName}@memberson.com");
- $contactName = "$firstName Memberson";
-
- // click through to the membership tab
- $this->click('css=li#tab_member a');
-
- $this->waitForElementPresent('link=Add Membership');
- $this->click('link=Add Membership');
-
- $this->waitForElementPresent('_qf_Membership_cancel-bottom');
-
- // fill in Membership Organization and Type
- $this->select('membership_type_id[0]', "label={$membershipTypes['member_of_contact']}");
- $this->select('membership_type_id[1]', "label={$membershipTypes['membership_type']}");
-
- // fill in Source
- $sourceText = 'Offline Membership Renewal Webtest';
- $this->type('source', $sourceText);
-
- // Let Join Date stay default
-
- // fill in Start Date
- $this->webtestFillDate('start_date');
-
- // Let End Date be auto computed
-
- // fill in Status Override?
- $this->click('is_override', 'value=1');
- $this->waitForElementPresent('status_id');
- $this->select('status_id', 'value=3');
-
- // fill in Record Membership Payment?
- $this->click('record_contribution', 'value=1');
- $this->waitForElementPresent('contribution_status_id');
-
- // select the financial type for the selected membership type
- $this->select('financial_type_id', 'value=2');
- $this->waitForAjaxContent();
-
- // the amount for the selected membership type
- $this->type('total_amount', '100.00');
-
- // select payment instrument type = Check and enter chk number
- $this->select("payment_instrument_id", "value=4");
- $this->waitForElementPresent("check_number");
- $this->type("check_number", "check #12345");
- $this->type("trxn_id", "P5476785" . rand(100, 10000));
-
- // fill the payment status be default
- $this->select("contribution_status_id", "value=2");
-
- // Clicking save.
- $this->click('_qf_Membership_upload-bottom');
-
- // page was loaded
- $this->waitForTextPresent($sourceText);
-
- // Is status message correct?
- $this->waitForText('crm-notification-container', "{$membershipTypes['membership_type']} membership for $firstName Memberson has been added.");
-
- $this->waitForElementPresent("xpath=//table[@class='display dataTable no-footer']/tbody/tr/td[9]//span[text()='Renew...']/ul/li[1]/a[text()='Renew']");
-
- // click through to the Membership Renewal Link
- $this->click("xpath=//table[@class='display dataTable no-footer']/tbody/tr/td[9]//span[text()='Renew...']/ul/li[1]/a[text()='Renew']");
-
- $this->waitForElementPresent('_qf_MembershipRenewal_cancel-bottom');
-
- // save the renewed membership
- $this->click('_qf_MembershipRenewal_upload-bottom');
-
- // page was loaded
- $this->waitForAjaxContent();
-
- $this->waitForElementPresent("xpath=//table[@class='display dataTable no-footer']/tbody/tr/td[9]/span/a[contains(text(), 'View')]");
-
- // click through to the membership view screen
- $this->waitForAjaxContent();
- $this->click("xpath=//div[@id='memberships']/div/table[@class='display dataTable no-footer']/tbody/tr/td[9]/span/a[contains(text(), 'View')]");
- $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
-
- $joinDate = date('F jS, Y');
- $startDate = date('F jS, Y', strtotime("+1 month"));
- $endDate = date('F jS, Y', strtotime("+4 year 1 month -1 day"));
-
- // verify membership renew override
- $verifyMembershipRenewOverrideData = array(
- 'Member' => $contactName,
- 'Membership Type' => $membershipTypes['membership_type'],
- 'Status' => 'New',
- 'Source' => $sourceText,
- 'Member Since' => $joinDate,
- 'Start date' => $startDate,
- 'End date' => $endDate,
- );
- $this->webtestVerifyTabularData($verifyMembershipRenewOverrideData);
- }
-
- public function testOfflineMembershipRenewChangeType() {
- $this->webtestLogin();
-
- // make sure period is correct for the membership type we testing for,
- // since it might have been modified by other tests
- // add membership type
- $membershipTypes = $this->webtestAddMembershipType('rolling', 1);
- $newMembershipType = $this->webtestAddMembershipType('rolling', 1);
-
- $firstName = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName, "Memberson", "{$firstName}@memberson.com");
- $contactName = "$firstName Memberson";
-
- // click through to the membership tab
- $this->click('css=li#tab_member a');
-
- $this->waitForElementPresent('link=Add Membership');
- $this->click('link=Add Membership');
-
- $this->waitForElementPresent('_qf_Membership_cancel-bottom');
-
- // fill in Membership Organization and Type
- $this->select('membership_type_id[0]', "label={$membershipTypes['member_of_contact']}");
- $this->select('membership_type_id[1]', "label={$membershipTypes['membership_type']}");
-
- // fill in Source
- $sourceText = 'Offline Membership Renewal Webtest';
- $this->type('source', $sourceText);
-
- // Fill Member Since
- $this->webtestFillDate('join_date', '-2 year');
-
- // Let Start Date and End Date be auto computed
-
- // Because it tends to cause problems, all uses of sleep() must be justified in comments
- // Sleep should never be used for wait for anything to load from the server
- // Justification for this instance: make sure onchange for total_amount has a chance to fire
- $this->waitForAjaxContent();
-
- // Clicking save.
- $this->click('_qf_Membership_upload-bottom');
-
- // page was loaded
- $this->waitForTextPresent($sourceText);
-
- // Is status message correct?
- $this->waitForText('crm-notification-container', "{$membershipTypes['membership_type']} membership for $firstName Memberson has been added.");
-
- $this->waitForElementPresent("xpath=//div[@id='inactive-memberships']//table/tbody/tr/td[7]/span[2][text()='Renew...']/ul/li/a[text()='Renew']");
-
- // click through to the Membership Renewal Link
- $this->click("xpath=//div[@id='inactive-memberships']//table/tbody/tr/td[7]/span[2][text()='Renew...']/ul/li/a[text()='Renew']");
-
- $this->waitForElementPresent('_qf_MembershipRenewal_cancel-bottom');
-
- //change membership type
- $this->click("changeMembershipOrgType");
- $this->waitForElementPresent('membership_type_id[1]');
- $this->select('membership_type_id[0]', "label={$newMembershipType['member_of_contact']}");
- $this->select('membership_type_id[1]', "label={$newMembershipType['membership_type']}");
-
- $this->click('membership_type_id[0]');
- // Because it tends to cause problems, all uses of sleep() must be justified in comments
- // Sleep should never be used for wait for anything to load from the server
- // Justification for this instance: wait for onchange handler
- $this->waitForAjaxContent();
-
- // save the renewed membership
- $this->click('_qf_MembershipRenewal_upload-bottom');
-
- // page was loaded
- $this->waitForTextPresent($sourceText);
-
- $this->waitForElementPresent("xpath=//div[@id='memberships']//table/tbody/tr/td[9]/span//a[text()='View']");
-
- // click through to the membership view screen
- $this->click("xpath=//div[@id='memberships']//table/tbody/tr/td[9]/span//a[text()='View']");
-
- $this->waitForElementPresent('_qf_MembershipView_cancel-bottom');
-
- $joinDate = date('F jS, Y', strtotime("-2 year"));
- $startDate = date('F jS, Y');
- $endDate = date('F jS, Y', strtotime("+1 year -1 day"));
-
- // verify membership renewed and the membership type is changed
- $verifyMembershipData = array(
- 'Member' => $contactName,
- 'Membership Type' => $newMembershipType['membership_type'],
- 'Status' => 'Current',
- 'Source' => $sourceText,
- 'Member Since' => $joinDate,
- 'Start date' => $startDate,
- 'End date' => $endDate,
- );
- $this->webtestVerifyTabularData($verifyMembershipData);
- }
-
- public function testOfflineMembershipRenewMultipleTerms() {
- $this->webtestLogin();
-
- // make sure period is correct for the membership type we testing for,
- // since it might have been modified by other tests
- // add membership type
- $membershipTypes = $this->webtestAddMembershipType('rolling', 2);
-
- // quick create a contact
- $firstName = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName, "Memberson", "{$firstName}@memberson.com");
- $contactName = "$firstName Memberson";
-
- // click through to the membership tab
- $this->click('css=li#tab_member a');
-
- $this->waitForElementPresent('link=Add Membership');
- $this->click('link=Add Membership');
-
- $this->waitForElementPresent('_qf_Membership_cancel-bottom');
-
- // fill in Membership Organization and Type
- $this->select('membership_type_id[0]', "label={$membershipTypes['member_of_contact']}");
- $this->select('membership_type_id[1]', "label={$membershipTypes['membership_type']}");
-
- // fill in Source
- $sourceText = 'Offline Membership Renewal Webtest';
- $this->type('source', $sourceText);
-
- // Fill Member Since
- $this->webtestFillDate('join_date', '-2 year');
-
- // Let Start Date and End Date be auto computed
-
- // Record contribution
- $this->waitForElementPresent('financial_type_id');
- $this->select('financial_type_id', "label=Member Dues");
- $this->select('payment_instrument_id', "label=Check");
- $this->waitForElementPresent('check_number');
- $this->type('check_number', '1023');
- $this->select('contribution_status_id', "label=Completed");
- $this->click('send_receipt');
-
- $this->waitForElementPresent('_qf_Membership_upload-bottom');
-
- // Clicking save.
- $this->click('_qf_Membership_upload-bottom');
-
- // page was loaded
- $this->waitForTextPresent($sourceText);
- $endDate = $this->getText("xpath=//div[@id='memberships']//table/tbody/tr/td[4]");
-
- // Is status message correct?
- $this->waitForText('crm-notification-container', "{$membershipTypes['membership_type']} membership for $firstName Memberson has been added. The new membership End Date is {$endDate}. A membership confirmation and receipt has been sent to {$firstName}@memberson.com.");
-
- $this->waitForElementPresent("xpath=//div[@id='memberships']//table/tbody/tr/td[9]/span[2][text()='Renew...']/ul/li/a[text()='Renew']");
- // click through to the Membership Renewal Link
- $this->click("xpath=//div[@id='memberships']//table/tbody/tr/td[9]/span[2][text()='Renew...']/ul/li/a[text()='Renew']");
-
- $this->waitForElementPresent('_qf_MembershipRenewal_cancel-bottom');
- // Record contribution and set number of terms to 2
- $this->click('record_contribution');
- $this->waitForElementPresent('financial_type_id');
- $this->click('changeTermsLink');
- $this->waitForElementPresent('num_terms');
- $this->type('num_terms', '');
- $this->type('num_terms', '2');
- $this->waitForElementPresent('total_amount');
- $this->click('total_amount');
- $this->verifyValue('total_amount', "200.00");
- $this->select('financial_type_id', "label=Member Dues");
- $this->select('payment_instrument_id', "label=Check");
- $this->waitForElementPresent('check_number');
- $this->type('check_number', '1024');
- $this->select('contribution_status_id', "label=Completed");
- $this->click('send_receipt');
-
- // save the renewed membership
- $this->click('_qf_MembershipRenewal_upload-bottom');
-
- // page was loaded
- $this->waitForTextPresent($sourceText);
-
- $this->waitForElementPresent("xpath=//div[@id='memberships']//table/tbody/tr/td[9]/span//a[text()='View']");
-
- // click through to the membership view screen
- $this->click("xpath=//div[@id='memberships']//table/tbody/tr/td[9]/span//a[text()='View']");
-
- $this->waitForElementPresent("xpath=//button//span[contains(text(),'Done')]");
-
- $joinDate = $startDate = date('F jS, Y', strtotime("-2 year"));
- // Adding 2 x 2 years renewal to initial membership.
- $endDate = date('F jS, Y', strtotime("+4 year -1 day"));
-
- // verify membership renewed
- $verifyMembershipRenewData = array(
- 'Member' => $contactName,
- 'Membership Type' => $membershipTypes['membership_type'],
- 'Status' => 'Current',
- 'Source' => $sourceText,
- 'Member Since' => $joinDate,
- 'Start date' => $startDate,
- 'End date' => $endDate,
- );
- $this->webtestVerifyTabularData($verifyMembershipRenewData);
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Member_OnlineAutoRenewMembershipGCTest
- */
-class WebTest_Member_OnlineAutoRenewMembershipGCTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testOnlineAutoRenewMembershipAnonymous() {
- //configure membership signup page.
- $pageId = $this->_configureMembershipPage();
-
- //now do the test membership signup.
- $this->openCiviPage('contribute/transact', "reset=1&action=preview&id={$pageId}", "_qf_Main_upload-bottom");
-
- $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]/div[2]/span/label/span[1][contains(text(),'Student')]");
- $this->click("auto_renew");
-
- $firstName = 'John';
- $lastName = 'Smith_' . substr(sha1(rand()), 0, 7);
- $this->type('email-5', "{$lastName}@example.com");
-
- $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next_checkout");
-
- $text = 'I want this membership to be renewed automatically every 1 year(s).';
- $this->assertElementContainsText('css=div.display-block', $text, 'Missing text: ' . $text);
-
- $this->click("_qf_Confirm_next_checkout");
-
- }
-
- public function testOnlineAutoRenewMembershipAuthenticated() {
- //configure membership signup page.
- $pageId = $this->_configureMembershipPage();
-
- $this->webtestLogin();
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- //now do the test membership signup.
- $this->openCiviPage('contribute/transact', "reset=1&action=preview&id={$pageId}", "_qf_Main_upload-bottom");
- $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]/div[2]/span/label/span[1][contains(text(),'Student')]");
-
- $this->click("auto_renew");
-
- $firstName = 'John';
- $lastName = 'Smith_' . substr(sha1(rand()), 0, 7);
- $this->type('email-5', "{$lastName}@example.com");
-
- $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next_checkout");
-
- $text = 'I want this membership to be renewed automatically every 1 year(s).';
- $this->assertElementContainsText('css=div.display-block', $text, 'Missing text: ' . $text);
-
- $this->click("_qf_Confirm_next_checkout");
-
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Member_OnlineAutoRenewMembershipTest
- */
-class WebTest_Member_OnlineAutoRenewMembershipTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testOnlineAutoRenewMembershipAnonymous() {
- //configure membership signup page.
- $pageId = $this->_configureMembershipPage();
-
- //now do the test membership signup.
- $this->openCiviPage('contribute/transact', "reset=1&action=preview&id={$pageId}", "_qf_Main_upload-bottom");
-
- $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]/div[2]/span/label/span[1][contains(text(),'Student')]");
-
- $this->click("auto_renew");
-
- $this->webtestAddCreditCardDetails();
-
- list($firstName, $middleName, $lastName) = $this->webtestAddBillingDetails();
-
- $this->type('email-5', "{$lastName}@example.com");
-
- $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
-
- $text = 'I want this membership to be renewed automatically every 1 year(s).';
- $this->assertElementContainsText("xpath=//div[@class='crm-group amount_display-group']/div[2]/strong[2]", $text, 'Missing text: ' . $text);
-
- $this->click("_qf_Confirm_next-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $text = 'This membership will be renewed automatically every year.';
- $this->assertElementContainsText("xpath=//div[@class='crm-group amount_display-group']/div[2]/strong[3]", $text, 'Missing text: ' . $text);
- }
-
- public function testOnlineAutoRenewMembershipAuthenticated() {
- //configure membership signup page.
- $pageId = $this->_configureMembershipPage();
-
- $this->webtestLogin();
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- //now do the test membership signup.
- $this->openCiviPage('contribute/transact', "reset=1&action=preview&id={$pageId}", "_qf_Main_upload-bottom");
-
- $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]/div[2]/span/label/span[1][contains(text(),'Student')]");
-
- $this->click("auto_renew");
-
- $this->webtestAddCreditCardDetails();
-
- list($firstName, $middleName, $lastName) = $this->webtestAddBillingDetails();
-
- $this->type('email-5', "{$lastName}@example.com");
-
- $this->click("_qf_Main_upload-bottom");
- $this->waitForElementPresent("_qf_Confirm_next-bottom");
-
- $text = 'I want this membership to be renewed automatically every 1 year(s).';
- $this->assertElementContainsText("xpath=//div[@class='crm-group amount_display-group']/div[2]/strong[2]", $text, 'Missing text: ' . $text);
-
- $this->click("_qf_Confirm_next-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $text = 'This membership will be renewed automatically every year.';
- $this->assertElementContainsText("xpath=//div[@class='crm-group amount_display-group']/div[2]/strong[3]", $text, 'Missing text: ' . $text);
- }
-
- public function testOnlinePendingAutoRenewMembershipAnonymous() {
- //configure membership signup page.
- $pageId = $this->_configureMembershipPage();
-
- //now do the test membership signup.
- $this->openCiviPage('contribute/transact', "reset=1&action=preview&id={$pageId}", "_qf_Main_upload-bottom");
-
- $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]/div[2]/span/label/span[1][contains(text(),'Student')]");
-
- $this->click("auto_renew");
-
- $this->webtestAddCreditCardDetails();
- list($firstName, $middleName, $lastName) = $this->webtestAddBillingDetails();
- $this->type('email-5', "{$lastName}@example.com");
-
- $this->click("_qf_Main_upload-bottom");
- $this->waitForElementPresent("_qf_Confirm_next-bottom");
-
- $text = 'I want this membership to be renewed automatically every 1 year(s).';
- $this->assertElementContainsText("xpath=//div[@class='crm-group amount_display-group']/div[2]/strong[2]", $text, 'Missing text: ' . $text);
-
- $this->click("_qf_Confirm_next-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $text = 'This membership will be renewed automatically every year.';
- $this->assertElementContainsText("xpath=//div[@class='crm-group amount_display-group']/div[2]/strong[3]", $text, 'Missing text: ' . $text);
- }
-
- /**
- * @return null
- */
- public function _configureMembershipPage() {
- static $pageId = NULL;
-
- if (!$pageId) {
- $this->webtestLogin();
-
- //add payment processor.
- $hash = substr(sha1(rand()), 0, 7);
- $rand = 2 * rand(2, 50);
- $processorName = "Webtest Auto Renew AuthNet" . $hash;
- $this->webtestAddPaymentProcessor($processorName, 'AuthNet');
-
- // -- start updating membership types
- $this->openCiviPage('admin/member/membershipType/add', "action=update&id=1&reset=1", "_qf_MembershipType_upload-bottom");
-
- $this->click("xpath=//div[@id='membership_type_form']//table/tbody/tr[6]/td/label[contains(text(), 'Auto-renew Option')]/../../td[2]/label[contains(text(), 'Give option, but not required')]");
-
- $this->type("duration_interval", "1");
- $this->select("duration_unit", "label=year");
-
- $this->click("_qf_MembershipType_upload-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->openCiviPage('admin/member/membershipType/add', "action=update&id=2&reset=1", "_qf_MembershipType_upload-bottom");
-
- $this->click("xpath=//div[@id='membership_type_form']//table/tbody/tr[6]/td/label[contains(text(), 'Auto-renew Option')]/../../td[2]/label[contains(text(), 'Give option, but not required')]");
-
- $this->type("duration_interval", "1");
- $this->select("duration_unit", "label=year");
-
- $this->click("_qf_MembershipType_upload-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // create contribution page with randomized title and default params
- $amountSection = FALSE;
- $payLater = TRUE;
- $onBehalf = FALSE;
- $pledges = FALSE;
- $recurring = TRUE;
- $membershipTypes = array(
- array('id' => 1, 'auto_renew' => 1),
- array('id' => 2, 'auto_renew' => 1),
- );
- $memPriceSetId = NULL;
- $friend = TRUE;
- $profilePreId = NULL;
- $profilePostId = NULL;
- $premiums = TRUE;
- $widget = TRUE;
- $pcp = TRUE;
-
- $contributionTitle = "Title $hash";
- $pageId = $this->webtestAddContributionPage($hash,
- $rand,
- $contributionTitle,
- array($processorName => 'AuthNet'),
- $amountSection,
- $payLater,
- $onBehalf,
- $pledges,
- $recurring,
- $membershipTypes,
- $memPriceSetId,
- $friend,
- $profilePreId,
- $profilePostId,
- $premiums,
- $widget,
- $pcp,
- FALSE
- );
-
- //make sure we do have required permissions.
- $permissions = array("edit-1-make-online-contributions", "edit-1-profile-listings-and-forms");
- $this->changePermissions($permissions);
-
- // now logout and do membership test that way
- $this->webtestLogout();
- }
-
- return $pageId;
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Member_OnlineMembershipAddPricesetTest
- */
-class WebTest_Member_OnlineMembershipAddPricesetTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testAddPriceSet() {
- // add the required permission
- $permissions = array('edit-1-make-online-contributions');
- $this->changePermissions($permissions);
-
- // Log in as normal user
- $this->webtestLogin();
-
- $title = substr(sha1(rand()), 0, 7);
- $setTitle = "Membership Fees - $title";
- $usedFor = 'Membership';
- $contributionType = 'Donation';
- $setHelp = 'Select your membership options.';
- $this->_testAddSet($setTitle, $usedFor, $contributionType, $setHelp);
-
- // Get the price set id ($sid) by retrieving and parsing the URL of the New Price Field form
- // which is where we are after adding Price Set.
- $sid = $this->urlArg('sid');
- $this->assertType('numeric', $sid);
-
- $fields = array(
- "National Membership $title" => 'Radio',
- "Local Chapter $title" => 'CheckBox',
- );
-
- list($memTypeTitle1, $memTypeTitle2) = $this->_testAddPriceFields($fields, $validateStrings, FALSE, $title, $sid, $contributionType);
- //var_dump($validateStrings);
-
- // load the Price Set Preview and check for expected values
- $this->_testVerifyPriceSet($validateStrings, $sid);
-
- $contributionPageTitle = "Contribution Page $title";
- $pageId = $this->webtestAddContributionPage(NULL, NULL, $contributionPageTitle, array('Test Processor' => 'Dummy'),
- TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, $sid, FALSE, 1, NULL
- );
-
- // Sign up for membership
- $firstName = 'John_' . substr(sha1(rand()), 0, 7);
- $lastName = 'Anderson_' . substr(sha1(rand()), 0, 7);
- $email = "{$firstName}.{$lastName}@example.com";
-
- $contactParams = array(
- 'first_name' => $firstName,
- 'last_name' => $lastName,
- 'email-5' => $email,
- );
- $this->_testSignUpOrRenewMembership($pageId, $contactParams, $memTypeTitle1, $memTypeTitle2);
-
- // Renew this membership
- $this->_testSignUpOrRenewMembership($pageId, $contactParams, $memTypeTitle1, $memTypeTitle2, $renew = TRUE);
- }
-
- public function testAddPriceSetWithMultipleTerms() {
- // add the required permission
- $permissions = array('edit-1-make-online-contributions');
- $this->changePermissions($permissions);
-
- // Log in as normal user
- $this->webtestLogin();
-
- $title = substr(sha1(rand()), 0, 7);
- $setTitle = "Membership Fees - $title";
- $usedFor = 'Membership';
- $contributionType = 'Member Dues';
- $setHelp = 'Select your membership options.';
- $memTypeParams1 = $this->webtestAddMembershipType();
- $memTypeTitle1 = $memTypeParams1['membership_type'];
- $memTypeId1 = explode('&id=', $this->getAttribute("xpath=//div[@id='membership_type']/table/tbody//tr/td[1]/div[text()='{$memTypeTitle1}']/../../td[12]/span/a[3]@href"));
- $memTypeId1 = $memTypeId1[1];
- $this->_testAddSet($setTitle, $usedFor, $contributionType, $setHelp);
-
- // Get the price set id ($sid) by retrieving and parsing the URL of the New Price Field form
- // which is where we are after adding Price Set.
- $sid = $this->urlArg('sid');
- $this->assertType('numeric', $sid);
-
- $fields = array("National Membership $title", "Radio");
- $this->openCiviPage('admin/price/field', "reset=1&action=add&sid={$sid}");
-
- $validateStrings[] = $fields[0];
- $this->type('label', $fields[0]);
- $this->select('html_type', "value={$fields[1]}");
- $options = array(
- 1 => array(
- 'label' => $memTypeTitle1 . "_1",
- 'membership_type_id' => $memTypeId1,
- 'amount' => 50.00,
- 'membership_num_terms' => 1,
- ),
- 2 => array(
- 'label' => $memTypeTitle1 . "_2",
- 'membership_type_id' => $memTypeId1,
- 'amount' => 90.00,
- 'membership_num_terms' => 2,
- ),
- 3 => array(
- 'label' => $memTypeTitle1 . "_3",
- 'membership_type_id' => $memTypeId1,
- 'amount' => 120.00,
- 'membership_num_terms' => 3,
- ),
-
- );
- $i = 2;
- foreach ($options as $index => $values) {
- $this->select("membership_type_id_{$index}", "value={$values['membership_type_id']}");
- $this->waitForAjaxContent();
- $this->waitForElementPresent("xpath=//table[@id='optionField']/tbody/tr[$i]/td[4]/input");
- $this->type("xpath=//table[@id='optionField']/tbody/tr[$i]/td[4]/input", $values['membership_num_terms']);
- $this->type("xpath=//table[@id='optionField']/tbody/tr[$i]/td[5]/input", $values['label']);
- $this->type("xpath=//table[@id='optionField']/tbody/tr[$i]/td[6]/input", $values['amount']);
- if ($i > 3) {
- $this->click('link=another choice');
- }
- $i++;
- }
- $this->waitForElementPresent('financial_type_id');
- $this->select("financial_type_id", "label={$contributionType}");
- $this->waitForElementPresent('_qf_Field_next-bottom');
- $this->clickLink('_qf_Field_next-bottom');
- $this->waitForText('crm-notification-container', "Price Field '{$fields[0]}' has been saved.");
-
- // load the Price Set Preview and check for expected values
- $this->_testVerifyPriceSet($validateStrings, $sid);
-
- $contributionPageTitle = "Contribution Page $title";
- $pageId = $this->webtestAddContributionPage(NULL, NULL, $contributionPageTitle, array('Test Processor' => 'Dummy'),
- TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, $sid, FALSE, 1, NULL
- );
-
- // Sign up for membership
- $firstName = 'John_' . substr(sha1(rand()), 0, 7);
- $lastName = 'Anderson_' . substr(sha1(rand()), 0, 7);
- $email = "{$firstName}.{$lastName}@example.com";
-
- $contactParams = array(
- 'first_name' => $firstName,
- 'last_name' => $lastName,
- 'email-5' => $email,
- );
- //membership with number of terms as 2
- $this->_testMultilpeTermsMembershipRegistration($pageId, $contactParams, $memTypeTitle1, 2);
- //membership with number of terms as 3 which will renew the above membership
- $this->_testMultilpeTermsMembershipRegistration($pageId, $contactParams, $memTypeTitle1, 3, TRUE);
-
- }
-
- /**
- * @param $setTitle
- * @param $usedFor
- * @param null $contributionType
- * @param $setHelp
- */
- public function _testAddSet($setTitle, $usedFor, $contributionType = NULL, $setHelp) {
- $this->openCiviPage('admin/price', 'reset=1&action=add', '_qf_Set_next-bottom');
-
- // Enter Priceset fields (Title, Used For ...)
- $this->type('title', $setTitle);
- if ($usedFor == 'Event') {
- $this->check('extends[1]');
- }
- elseif ($usedFor == 'Contribution') {
- $this->check('extends[2]');
- }
- elseif ($usedFor == 'Membership') {
- $this->click('extends[3]');
- $this->waitForElementPresent('financial_type_id');
- $this->select("css=select.crm-form-select", "label={$contributionType}");
- }
-
- $this->type('help_pre', $setHelp);
-
- $this->assertChecked('is_active', 'Verify that Is Active checkbox is set.');
- $this->waitForElementPresent('_qf_Set_next-bottom');
- $this->click('_qf_Set_next-bottom');
- $this->waitForText('crm-notification-container', "Your Set '{$setTitle}' has been added. You can add fields to this set now.");
- }
-
- /**
- * @param $fields
- * @param $validateString
- * @param bool $dateSpecificFields
- * @param $title
- * @param int $sid
- * @param $contributionType
- *
- * @return array
- */
- public function _testAddPriceFields(&$fields, &$validateString, $dateSpecificFields = FALSE, $title, $sid, $contributionType) {
- $memTypeParams1 = $this->webtestAddMembershipType();
- $memTypeTitle1 = $memTypeParams1['membership_type'];
- $memTypeId1 = explode('&id=', $this->getAttribute("xpath=//div[@id='membership_type']/table/tbody//tr/td[1]/div[text()='{$memTypeTitle1}']/../../td[12]/span/a[3]@href"));
- $memTypeId1 = $memTypeId1[1];
-
- $memTypeParams2 = $this->webtestAddMembershipType();
- $memTypeTitle2 = $memTypeParams2['membership_type'];
- $memTypeId2 = explode('&id=', $this->getAttribute("xpath=//div[@id='membership_type']/table/tbody//tr/td[1]/div[text()='{$memTypeTitle2}']/../../td[12]/span/a[3]@href"));
- $memTypeId2 = $memTypeId2[1];
-
- $this->openCiviPage('admin/price/field', "reset=1&action=add&sid={$sid}");
-
- foreach ($fields as $label => $type) {
- $validateStrings[] = $label;
-
- $this->type('label', $label);
- $this->select('html_type', "value={$type}");
-
- switch ($type) {
- case 'Radio':
- $options = array(
- 1 => array(
- 'label' => "$memTypeTitle1",
- 'membership_type_id' => $memTypeId1,
- 'amount' => 100.00,
- ),
- 2 => array(
- 'label' => "$memTypeTitle2",
- 'membership_type_id' => $memTypeId2,
- 'amount' => 50.00,
- ),
- );
- $this->addMultipleChoiceOptions($options, $validateStrings);
- break;
-
- case 'CheckBox':
- $options = array(
- 1 => array(
- 'label' => "$memTypeTitle1",
- 'membership_type_id' => $memTypeId1,
- 'amount' => 100.00,
- ),
- 2 => array(
- 'label' => "$memTypeTitle2",
- 'membership_type_id' => $memTypeId2,
- 'amount' => 50.00,
- ),
- );
- $this->addMultipleChoiceOptions($options, $validateStrings);
- break;
-
- default:
- break;
- }
- $this->select("financial_type_id", "label={$contributionType}");
- $this->clickLink('_qf_Field_next_new-bottom', '_qf_Field_next-bottom');
- $this->waitForText('crm-notification-container', "Price Field '{$label}' has been saved.");
- }
- return array($memTypeTitle1, $memTypeTitle2);
- }
-
- /**
- * @param $validateStrings
- * @param int $sid
- */
- public function _testVerifyPriceSet($validateStrings, $sid) {
- // verify Price Set at Preview page
- // start at Manage Price Sets listing
- $this->openCiviPage('admin/price', 'reset=1');
-
- // Use the price set id ($sid) to pick the correct row
- $this->clickLink("css=tr#price_set-{$sid} a[title='Preview Price Set']", '_qf_Preview_cancel-bottom');
-
- // Check for expected price set field strings
- $this->assertStringsPresent($validateStrings);
- }
-
- /**
- * @param int $pageId
- * @param array $contactParams
- * @param $memTypeTitle1
- * @param $memTypeTitle2
- * @param bool $renew
- */
- public function _testSignUpOrRenewMembership($pageId, $contactParams, $memTypeTitle1, $memTypeTitle2, $renew = FALSE) {
- $this->webtestLogout();
-
- $this->openCiviPage('contribute/transact', "reset=1&id=$pageId", '_qf_Main_upload-bottom');
-
- //build the membership dates.
- $currentYear = date('Y');
- $currentMonth = date('m');
- $previousDay = date('d') - 1;
- $endYear = ($renew) ? $currentYear + 2 : $currentYear + 1;
- $joinDate = date('Y-m-d', mktime(0, 0, 0, $currentMonth, date('d'), $currentYear));
- $startDate = date('Y-m-d', mktime(0, 0, 0, $currentMonth, date('d'), $currentYear));
- $endDate = date('Y-m-d', mktime(0, 0, 0, $currentMonth, $previousDay, $endYear));
- foreach (array(
- 'joinDate',
- 'startDate',
- 'endDate',
- ) as $date) {
- $$date = CRM_Utils_Date::customFormat($$date, $this->webtestGetSetting('dateformatFull'));
- }
-
- $this->click("xpath=//div[@id='priceset']/div[2]/div[2]/div/span/input");
- $this->click("xpath=//div[@id='priceset']/div[3]/div[2]/div[2]/span/input");
-
- $this->type('email-5', $contactParams['email-5']);
- $this->type('first_name', $contactParams['first_name']);
- $this->type('last_name', $contactParams['last_name']);
-
- $streetAddress = "100 Main Street";
- $this->type("street_address-1", $streetAddress);
- $this->type("city-1", "San Francisco");
- $this->type("postal_code-1", "94117");
- $this->select("country-1", "value=1228");
- $this->select("state_province-1", "value=1001");
-
- //Credit Card Info
- $this->select("credit_card_type", "value=Visa");
- $this->type("credit_card_number", "4111111111111111");
- $this->type("cvv2", "000");
- $this->select("credit_card_exp_date[M]", "value=1");
- $this->select("credit_card_exp_date[Y]", "value=2020");
-
- //Billing Info
- $this->type("billing_first_name", $contactParams['first_name'] . "billing");
- $this->type("billing_last_name", $contactParams['last_name'] . "billing");
- $this->type("billing_street_address-5", "15 Main St.");
- $this->type(" billing_city-5", "San Jose");
- $this->select("billing_country_id-5", "value=1228");
- $this->select("billing_state_province_id-5", "value=1004");
- $this->type("billing_postal_code-5", "94129");
- $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
-
- $this->click("_qf_Confirm_next-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- //login to check membership
-
- // Log in using webtestLogin() method
- $this->webtestLogin();
-
- $this->openCiviPage('member/search', 'reset=1', 'member_end_date_high');
-
- $this->type("sort_name", "{$contactParams['first_name']} {$contactParams['last_name']}");
- $this->click("_qf_Search_refresh");
-
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->assertElementContainsText('crm-container', '2 Results');
-
- $this->waitForElementPresent("xpath=//div[@id='memberSearch']/table/tbody/tr");
- $this->click("xpath=//div[@id='memberSearch']/table/tbody//tr/td[4][text()='{$memTypeTitle1}']/../td[11]/span/a[text()='View']");
- $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
-
- //View Membership Record
- $verifyData = array(
- 'Membership Type' => "$memTypeTitle1",
- 'Status' => 'New',
- 'Member Since' => $joinDate,
- 'Start date' => $startDate,
- 'End date' => $endDate,
- );
- foreach ($verifyData as $label => $value) {
- $this->verifyText("xpath=//form[@id='MembershipView']//table/tbody/tr/td[text()='{$label}']/following-sibling::td",
- preg_quote($value)
- );
- }
-
- $this->clickLink('_qf_MembershipView_cancel-bottom', "xpath=//div[@id='memberSearch']/table/tbody/tr[2]", FALSE);
- $this->click("xpath=//div[@id='memberSearch']/table/tbody//tr/td[4][text()='{$memTypeTitle2}']/../td[11]/span/a[text()='View']");
- $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
-
- //View Membership Record
- $verifyData = array(
- 'Membership Type' => "$memTypeTitle2",
- 'Status' => 'New',
- 'Member Since' => $joinDate,
- 'Start date' => $startDate,
- 'End date' => $endDate,
- );
- foreach ($verifyData as $label => $value) {
- $this->verifyText("xpath=//form[@id='MembershipView']//table/tbody/tr/td[text()='{$label}']/following-sibling::td",
- preg_quote($value)
- );
- }
- }
-
- /**
- * @param int $pageId
- * @param array $contactParams
- * @param $memTypeTitle1
- * @param $term
- * @param bool $renew
- */
- public function _testMultilpeTermsMembershipRegistration($pageId, $contactParams, $memTypeTitle1, $term, $renew = FALSE) {
- if ($renew) {
- $this->openCiviPage('member/search', 'reset=1', 'member_end_date_high');
- $this->type("sort_name", "{$contactParams['first_name']} {$contactParams['last_name']}");
- $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='memberSearch']/table/tbody/tr");
- $this->click("xpath=//div[@id='memberSearch']/table/tbody//tr/td[4][text()='{$memTypeTitle1}']/../td[11]/span/a[text()='View']");
- $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
- $year = CRM_Utils_Date::processDate($this->getText("xpath=//form[@id='MembershipView']//table/tbody/tr/td[text()='End date']/following-sibling::td"));
- $prevYear = substr($year, 0, 4);
- }
-
- $this->webtestLogout();
-
- $this->openCiviPage('contribute/transact', "reset=1&id=$pageId", '_qf_Main_upload-bottom');
-
- //build the membership dates.
- $currentYear = date('Y');
- $currentMonth = date('m');
- $previousDay = date('d') - 1;
- $endYear = ($term == 3) ? $currentYear + 3 : (($term == 2) ? $currentYear + 2 : $currentYear + 1);
- $endYear = ($renew) ? $endYear + ($prevYear - $currentYear) : $endYear;
-
- $joinDate = date('Y-m-d', mktime(0, 0, 0, $currentMonth, date('d'), $currentYear));
- $startDate = date('Y-m-d', mktime(0, 0, 0, $currentMonth, date('d'), $currentYear));
- $endDate = date('Y-m-d', mktime(0, 0, 0, $currentMonth, $previousDay, $endYear));
- foreach (array(
- 'joinDate',
- 'startDate',
- 'endDate',
- ) as $date) {
- $$date = CRM_Utils_Date::customFormat($$date, $this->webtestGetSetting('dateformatFull'));
- }
- $i = ($term == 3) ? 3 : (($term == 2) ? 2 : 1);
- $this->waitForElementPresent("xpath=//div[@id='priceset']/div[2]/div[2]/div[$i]/span/input");
- $this->click("xpath=//div[@id='priceset']/div[2]/div[2]/div[$i]/span/input");
- $amount = $this->getText("xpath=//div[@id='priceset']/div[2]/div[2]/div[$i]/span/label/span[@class='crm-price-amount-amount']");
-
- $this->type('email-5', $contactParams['email-5']);
- $this->type('first_name', $contactParams['first_name']);
- $this->type('last_name', $contactParams['last_name']);
-
- $streetAddress = "100 Main Street";
- $this->type("street_address-1", $streetAddress);
- $this->type("city-1", "San Francisco");
- $this->type("postal_code-1", "94117");
- $this->select("country-1", "value=1228");
- $this->select("state_province-1", "value=1001");
-
- //Credit Card Info
- $this->select("credit_card_type", "value=Visa");
- $this->type("credit_card_number", "4111111111111111");
- $this->type("cvv2", "000");
- $this->select("credit_card_exp_date[M]", "value=1");
- $this->select("credit_card_exp_date[Y]", "value=2020");
-
- //Billing Info
- $this->type("billing_first_name", $contactParams['first_name'] . "billing");
- $this->type("billing_last_name", $contactParams['last_name'] . "billing");
- $this->type("billing_street_address-5", "15 Main St.");
- $this->type(" billing_city-5", "San Jose");
- $this->select("billing_country_id-5", "value=1228");
- $this->select("billing_state_province_id-5", "value=1004");
- $this->type("billing_postal_code-5", "94129");
- $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
-
- $this->click("_qf_Confirm_next-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- //login to check membership
-
- // Log in using webtestLogin() method
- $this->webtestLogin();
-
- $this->openCiviPage('member/search', 'reset=1', 'member_end_date_high');
-
- $this->type("sort_name", "{$contactParams['first_name']} {$contactParams['last_name']}");
- $this->click("_qf_Search_refresh");
-
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->assertElementContainsText('crm-container', '1 Result ');
-
- $this->waitForElementPresent("xpath=//div[@id='memberSearch']/table/tbody/tr");
- $this->click("xpath=//div[@id='memberSearch']/table/tbody//tr/td[4][text()='{$memTypeTitle1}']/../td[11]/span/a[text()='View']");
- $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
-
- //View Membership Record
- $verifyData = array(
- 'Membership Type' => "$memTypeTitle1",
- 'Status' => 'New',
- 'Member Since' => $joinDate,
- 'Start date' => $startDate,
- 'End date' => $endDate,
- );
- foreach ($verifyData as $label => $value) {
- $this->verifyText("xpath=//form[@id='MembershipView']//table/tbody/tr/td[text()='{$label}']/following-sibling::td",
- preg_quote($value)
- );
- }
- //check if the membership amount is correct
- $this->waitForElementPresent("xpath=//form[@id='MembershipView']/div[2]/div/div[2]/div[2]/table/tbody/tr/td[1]/a");
- $this->assertElementContainsText("xpath=//form[@id='MembershipView']/div[2]/div/div[2]/div[2]/table/tbody/tr/td[1]/a", $amount);
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Member_OnlineMembershipCreateTest
- */
-class WebTest_Member_OnlineMembershipCreateTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testOnlineMembershipCreate() {
- //check for online contribution and profile listings permissions
- $permissions = array("edit-1-make-online-contributions", "edit-1-profile-listings-and-forms");
- $this->changePermissions($permissions);
-
- // Log in as normal user
- $this->webtestLogin();
-
- // a random 7-char string and an even number to make this pass unique
- $hash = substr(sha1(rand()), 0, 7);
- $rand = 2 * rand(2, 50);
-
- // Use default payment processor
- $processorName = 'Test Processor';
-
- // create contribution page with randomized title and default params
- $amountSection = TRUE;
- $payLater = TRUE;
- $allowOtherAmount = FALSE;
- $onBehalf = FALSE;
- $pledges = FALSE;
- $recurring = FALSE;
- $memberships = TRUE;
- $memPriceSetId = NULL;
- $friend = TRUE;
- $profilePreId = 1;
- $profilePostId = NULL;
- $premiums = TRUE;
- $widget = FALSE;
- $pcp = TRUE;
- $isSeparatePayment = TRUE;
- $contributionTitle = "Title $hash";
- $pageId = $this->webtestAddContributionPage($hash,
- $rand,
- $contributionTitle,
- array($processorName => 'Dummy'),
- $amountSection,
- $payLater,
- $onBehalf,
- $pledges,
- $recurring,
- $memberships,
- $memPriceSetId,
- $friend,
- $profilePreId,
- $profilePostId,
- $premiums,
- $widget,
- $pcp,
- TRUE,
- FALSE,
- $isSeparatePayment,
- TRUE,
- FALSE
- );
-
- // create two new membership types
- $memTypeParams1 = $this->webtestAddMembershipType();
- $memTypeTitle1 = $memTypeParams1['membership_type'];
- $memTypeId1 = explode('&id=', $this->getAttribute("xpath=//div[@id='membership_type']/table/tbody//tr/td[1]/div[text()='{$memTypeTitle1}']/../../td[12]/span/a[3]@href"));
- $memTypeId1 = $memTypeId1[1];
-
- $memTypeParams2 = $this->webtestAddMembershipType();
- $memTypeTitle2 = $memTypeParams2['membership_type'];
- $memTypeId2 = explode('&id=', $this->getAttribute("xpath=//div[@id='membership_type']/table/tbody//tr/td[1]/div[text()='{$memTypeTitle2}']/../../td[12]/span/a[3]@href"));
- $memTypeId2 = $memTypeId2[1];
-
- // edit contribution page memberships tab to add two new membership types
- $this->openCiviPage("admin/contribute/membership", "reset=1&action=update&id={$pageId}", '_qf_MembershipBlock_next-bottom');
- $this->click("membership_type_$memTypeId1");
- $this->click("membership_type_$memTypeId2");
- $this->clickLink('_qf_MembershipBlock_next', '_qf_MembershipBlock_next-bottom');
- $text = "'MembershipBlock' information has been saved.";
- $this->waitForText('crm-notification-container', $text);
-
- //logout
- $this->webtestLogout();
-
- // signup for membership 1
- $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
- $lastName = 'An' . substr(sha1(rand()), 0, 7);
-
- $this->_testOnlineMembershipSignup($pageId, $memTypeTitle1, $firstName, $lastName, $payLater, $hash);
-
- // Log in using webtestLogin() method
- $this->webtestLogin();
-
- //Find Member
- $this->openCiviPage("member/search", "reset=1", "member_end_date_high");
- $this->click("xpath=//tr/td[1]/p/label[contains(text(),'Membership is a Test?')]/../label[contains(text(),'Yes')]/preceding-sibling::input[1]");
- $this->type("sort_name", "$lastName $firstName");
- $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='memberSearch']/table/tbody/tr");
- $this->click("xpath=//table[@class='selector row-highlight']/tbody/tr/td[11]/span/a[text()='View']");
- $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
-
- //View Membership Record
- $verifyData = array(
- 'Member' => $firstName . ' ' . $lastName,
- 'Membership Type' => $memTypeTitle1,
- 'Source' => 'Online Contribution:' . ' ' . $contributionTitle,
- 'Status' => 'Pending',
- );
- $this->webtestVerifyTabularData($verifyData);
-
- // Click View action link on associated contribution record
- $this->waitForElementPresent("xpath=//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[1][text()='View']");
- $this->click("xpath=//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[1][text()='View']");
- $this->waitForElementPresent("_qf_ContributionView_cancel-bottom");
- //View Contribution Record
- $verifyData = array(
- 'From' => $firstName . ' ' . $lastName,
- 'Total Amount' => '$ 100.00',
- 'Contribution Status' => 'Pending : Pay Later',
- );
- $this->webtestVerifyTabularData($verifyData);
-
- //CRM-15735 - verify membership dates gets changed w.r.t receive_date of contribution.
- $receiveDate = date('F jS, Y', strtotime("-1 month"));
- $endDate = date('F jS, Y', strtotime("+1 year -1 month -1 day"));
- $this->clickAjaxLink("xpath=//button//span[contains(text(),'Edit')]", 'receive_date');
- $this->select('contribution_status_id', 'Completed');
- $this->webtestFillDate('receive_date', '-1 month');
- $this->clickAjaxLink("xpath=//button//span[contains(text(),'Save')]", "xpath=//div[@class='ui-dialog-buttonset']/button[3]/span[2]");
- $updatedData = array(
- 'Status' => 'New',
- 'Member Since' => $receiveDate,
- 'Start date' => $receiveDate,
- 'End date' => $endDate,
- );
- $this->webtestVerifyTabularData($updatedData);
-
- // CRM-8141 signup for membership 2 with same anonymous user info (should create 2 separate membership records because membership orgs are different)
- //logout
- $this->webtestLogout();
-
- $this->_testOnlineMembershipSignup($pageId, $memTypeTitle2, $firstName, $lastName, $payLater, $hash);
-
- // Log in using webtestLogin() method
- $this->webtestLogin();
-
- //Find Member
- $this->openCiviPage("member/search", "reset=1", "member_end_date_high");
-
- $this->type("sort_name", "$lastName $firstName");
- $this->click("xpath=//tr/td[1]/p/label[contains(text(),'Membership is a Test?')]/../label[contains(text(),'Yes')]/preceding-sibling::input[1]");
- $this->click("_qf_Search_refresh");
-
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->assertElementContainsText('search-status', '2 Results', 'Missing text: ' . '2 Results');
- }
-
- /**
- * Test online membership signup.
- *
- * @param int $pageId
- * @param int $memTypeId
- * @param string $firstName
- * @param string $lastName
- * @param bool $payLater
- * @param string $hash
- * @param bool $otherAmount
- * @param bool $amountSection
- * @param bool $freeMembership
- */
- public function _testOnlineMembershipSignup($pageId, $memTypeId, $firstName, $lastName, $payLater, $hash, $otherAmount = FALSE, $amountSection = TRUE, $freeMembership = FALSE, $onBehalf = FALSE, $onBehalfParams = array()) {
- //Open Live Contribution Page
- $this->openCiviPage("contribute/transact", "reset=1&id=$pageId&action=preview", "_qf_Main_upload-bottom");
- // Select membership type 1
- $this->waitForElementPresent("xpath=//div[@class='crm-section membership_amount-section']/div[2]//span/label");
- if ($memTypeId != 'No thank you') {
- $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]//div/span/label/span[1][contains(text(),'$memTypeId')]");
- }
- else {
- $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]//span/label[contains(text(),'$memTypeId')]");
- }
- if (!$otherAmount && $amountSection) {
- $this->click("xpath=//div[@class='crm-section contribution_amount-section']/div[2]//span/label[text()='No thank you']");
- }
- elseif ($amountSection) {
- $this->clickAt("xpath=//div[@class='content other_amount-content']/input");
- $this->keyDown("xpath=//div[@class='content other_amount-content']/input", " ");
- $this->type("xpath=//div[@class='content other_amount-content']/input", $otherAmount);
- $this->typeKeys("xpath=//div[@class='content other_amount-content']/input", $otherAmount);
- }
- if ($payLater) {
- $this->waitForAjaxContent();
- $this->click("xpath=//label[text()='Pay later label {$hash}']");
- }
- if ($onBehalf && $onBehalfParams) {
- if ($onBehalfParams['mode'] == 'optional') {
- $this->click("is_for_organization");
- }
- $this->type("onbehalf[organization_name]", $onBehalfParams['org_name']);
- $this->type("onbehalf[phone-3-1]", $onBehalfParams['org_phone']);
- $this->type("onbehalf[email-3]", $onBehalfParams['org_email']);
- $this->type("onbehalf[street_address-3]", "100 Main Street");
- $this->type("onbehalf[city-3]", "San Francisco");
- $this->type("onbehalf[postal_code-3]", $onBehalfParams['org_postal_code']);
- $this->select("onbehalf[country-3]", "value=1228");
- $this->select("onbehalf[state_province-3]", "value=1001");
- }
- $this->type("email-5", $firstName . "@example.com");
- $this->waitForElementPresent("first_name");
- $this->type("first_name", $firstName);
- $this->waitForElementPresent("last_name");
- $this->type("last_name", $lastName);
-
- $streetAddress = "100 Main Street";
- $this->waitForElementPresent("street_address-1");
- $this->type("street_address-1", $streetAddress);
- $this->type("city-1", "San Francisco");
- $this->type("postal_code-1", "94117");
- $this->select("country-1", "value=1228");
- $this->select("state_province-1", "value=1001");
-
- if ($freeMembership) {
- $this->waitForElementPresent("xpath=//div[@id='payment_information'][@style='display: none;']");
- }
- else {
- if (!$payLater && $amountSection) {
- $this->click("xpath=//label[text()='Test Processor']");
- $this->waitForAjaxContent();
- //Credit Card Info
- $this->select("credit_card_type", "value=Visa");
- $this->type("credit_card_number", "4111111111111111");
- $this->type("cvv2", "000");
- $this->select("credit_card_exp_date[M]", "value=1");
- $this->select("credit_card_exp_date[Y]", "value=2020");
-
- //Billing Info
- $this->waitForElementPresent("billing_first_name");
- $this->type("billing_first_name", $firstName . "billing");
- $this->waitForElementPresent("billing_last_name");
- $this->type("billing_last_name", $lastName . "billing");
- $this->type("billing_street_address-5", "15 Main St.");
- $this->type(" billing_city-5", "San Jose");
- $this->select("billing_country_id-5", "value=1228");
- $this->select("billing_state_province_id-5", "value=1004");
- $this->type("billing_postal_code-5", "94129");
- }
- }
- $this->click("_qf_Main_upload-bottom");
- $this->waitForElementPresent("_qf_Confirm_next-bottom");
-
- $this->click("_qf_Confirm_next-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- }
-
- public function testOnlineMembershipCreateWithContribution() {
- //login with admin credentials & make sure we do have required permissions.
- $permissions = array("edit-1-make-online-contributions", "edit-1-profile-listings-and-forms");
- $this->changePermissions($permissions);
-
- $hash = substr(sha1(rand()), 0, 7);
- $rand = 2 * rand(2, 50);
- // Use default payment processor
- $processorName = 'Test Processor';
- $amountSection = TRUE;
- $payLater = TRUE;
- $allowOtherAmount = TRUE;
- $onBehalf = FALSE;
- $pledges = FALSE;
- $recurring = FALSE;
- $memberships = TRUE;
- $memPriceSetId = NULL;
- $friend = FALSE;
- $profilePreId = 1;
- $profilePostId = NULL;
- $premiums = FALSE;
- $widget = FALSE;
- $pcp = FALSE;
- $isSeparatePayment = FALSE;
- $membershipsRequired = FALSE;
- $fixedAmount = FALSE;
- $contributionTitle = "Title $hash";
- $pageId = $this->webtestAddContributionPage($hash,
- $rand,
- $contributionTitle,
- array($processorName => 'Dummy'),
- $amountSection,
- $payLater,
- $onBehalf,
- $pledges,
- $recurring,
- $memberships,
- $memPriceSetId,
- $friend,
- $profilePreId,
- $profilePostId,
- $premiums,
- $widget,
- $pcp,
- TRUE,
- FALSE,
- $isSeparatePayment,
- TRUE,
- $allowOtherAmount,
- TRUE,
- 'Donation',
- $fixedAmount,
- $membershipsRequired
- );
- $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
- $lastName = 'An' . substr(sha1(rand()), 0, 7);
-
- //logout
- $this->webtestLogout();
-
- $this->_testOnlineMembershipSignup($pageId, 'No thank you', $firstName, $lastName, FALSE, $hash, 50);
-
- // Log in using webtestLogin() method
- $this->webtestLogin();
-
- //Find Contribution
- $this->openCiviPage("contribute/search", "reset=1", "contribution_date_low");
-
- $this->type("sort_name", "$lastName $firstName");
- $this->click("xpath=//tr/td[1]/label[contains(text(), 'Contribution is a Test?')]/../../td[2]/label[contains(text(), 'Yes')]/preceding-sibling::input[1]");
- $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[10]/span/a[text()='View']");
-
- // assert financial data - CRM-17863
- $this->waitForElementPresent("xpath=//tr/td[@class='crm-contribution-amount']/a[@title='view payments']");
- $this->click("xpath=//tr/td[@class='crm-contribution-amount']/a[@title='view payments']");
- $this->waitForAjaxContent();
- $verifyFinancialData = array(
- 1 => '50.00',
- 2 => 'Donation',
- 6 => 'Completed',
- );
- foreach ($verifyFinancialData as $col => $data) {
- $this->verifyText("xpath=//tr[@class='crm-child-row']/td/div/table/tbody/tr[2]/td[{$col}]", $data);
- }
- $this->clickLink("xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[10]/span/a[text()='View']", "_qf_ContributionView_cancel-bottom", FALSE);
-
- //View Contribution Record and verify data
- $expected = array(
- 'From' => "{$firstName} {$lastName}",
- 'Financial Type' => 'Donation',
- 'Total Amount' => '50.00',
- 'Contribution Status' => 'Completed',
- 'Received Into' => 'Deposit Bank Account',
- 'Source' => "Online Contribution: $contributionTitle",
- 'Online Contribution Page' => $contributionTitle,
- );
- $this->webtestVerifyTabularData($expected);
- }
-
- /**
- * CRM-16302 - To check whether membership, contribution are
- * created for free membership signup.
- */
- public function testOnlineMembershipCreateWithZeroContribution() {
- //login with admin credentials & make sure we do have required permissions.
- $permissions = array("edit-1-make-online-contributions", "edit-1-profile-listings-and-forms");
- $this->changePermissions($permissions);
-
- $hash = substr(sha1(rand()), 0, 7);
- $rand = 2 * rand(2, 50);
- $amountSection = $payLater = $allowOtherAmount = $pledges = $recurring = FALSE;
- $premiums = $widget = $pcp = $isSeparatePayment = $membershipsRequired = $fixedAmount = $friend = FALSE;
- $memberships = TRUE;
- $memPriceSetId = NULL;
- $onBehalf = TRUE;
- $profilePreId = 1;
- $profilePostId = NULL;
- $contributionTitle = "Title $hash";
- $pageId = $this->webtestAddContributionPage($hash,
- $rand,
- $contributionTitle,
- NULL,
- $amountSection,
- $payLater,
- $onBehalf,
- $pledges,
- $recurring,
- $memberships,
- $memPriceSetId,
- $friend,
- $profilePreId,
- $profilePostId,
- $premiums,
- $widget,
- $pcp,
- FALSE,
- FALSE,
- $isSeparatePayment,
- FALSE,
- $allowOtherAmount,
- TRUE,
- 'Member Dues',
- $fixedAmount,
- $membershipsRequired
- );
- $memTypeParams = $this->webtestAddMembershipType('rolling', 1, 'year', 'no', 0);
- $memTypeTitle = $memTypeParams['membership_type'];
- $memTypeId = explode('&id=', $this->getAttribute("xpath=//div[@id='membership_type']/table/tbody//tr/td[1]/div[text()='{$memTypeTitle}']/../../td[12]/span/a[3]@href"));
- $memTypeId = $memTypeId[1];
-
- // edit contribution page amounts tab to uncheck real time monetary transaction
- $this->openCiviPage("admin/contribute/membership", "reset=1&action=update&id={$pageId}", '_qf_MembershipBlock_next-bottom');
- $this->click("membership_type_$memTypeId");
- $this->clickLink('_qf_MembershipBlock_next', '_qf_MembershipBlock_next-bottom');
- $text = "'MembershipBlock' information has been saved.";
- $this->waitForText('crm-notification-container', $text);
-
- $processors = array(
- 'Test Processor',
- 'AuthNet',
- 'PayPal',
- 'PayPal_Standard',
- );
- foreach ($processors as $processor) {
- if ($processor == 'Test Processor') {
- $processorName = $processor;
- }
- else {
- $processorName = $processor . substr(sha1(rand()), 0, 7);
- $this->webtestAddPaymentProcessor($processorName, $processor);
- }
- $this->openCiviPage("admin/contribute/amount", "reset=1&action=update&id={$pageId}", '_qf_Amount_upload_done-bottom');
- $this->assertTrue($this->isTextPresent($processorName));
- $this->check("xpath=//label[text() = '{$processorName}']/preceding-sibling::input[1]");
- $this->clickLink('_qf_Amount_upload_done-bottom');
- $this->waitForText('crm-notification-container', "'Amount' information has been saved.");
-
- $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
- $lastName = 'An' . substr(sha1(rand()), 0, 7);
-
- //logout
- $this->webtestLogout();
-
- $this->_testOnlineMembershipSignup($pageId, $memTypeTitle, $firstName, $lastName, $payLater, $hash, $allowOtherAmount, $amountSection, TRUE);
-
- // Log in using webtestLogin() method
- $this->webtestLogin();
-
- //Find Contribution
- $this->openCiviPage("contribute/search", "reset=1", "contribution_date_low");
- $this->type("sort_name", "$lastName $firstName");
- $this->click("xpath=//tr/td[1]/label[contains(text(), 'Contribution is a Test?')]/../../td[2]/label[contains(text(), 'Yes')]/preceding-sibling::input[1]");
- $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[10]/span/a[text()='View']");
-
- // assert financial data - CRM-17863
- $this->waitForElementPresent("xpath=//tr/td[@class='crm-contribution-amount']/a[@title='view payments']");
- $this->click("xpath=//tr/td[@class='crm-contribution-amount']/a[@title='view payments']");
- $this->waitForAjaxContent();
- $verifyFinancialData = array(
- 1 => '0.00',
- 2 => 'Member Dues',
- 3 => 'Credit Card',
- 6 => 'Completed',
- );
- foreach ($verifyFinancialData as $col => $data) {
- $this->verifyText("xpath=//tr[@class='crm-child-row']/td/div/table/tbody/tr[2]/td[{$col}]", $data);
- }
- $this->clickLink("xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[10]/span/a[text()='View']", "_qf_ContributionView_cancel-bottom", FALSE);
-
- //View Contribution Record and verify data
- $expected = array(
- 'From' => "{$firstName} {$lastName}",
- 'Financial Type' => 'Member Dues (test) ',
- 'Total Amount' => '0.00',
- 'Contribution Status' => 'Completed',
- 'Source' => "Online Contribution: $contributionTitle",
- 'Online Contribution Page' => $contributionTitle,
- );
- $this->webtestVerifyTabularData($expected);
-
- //Find Member
- $this->openCiviPage("member/search", "reset=1", "member_end_date_high");
- $this->click("xpath=//tr/td[1]/p/label[contains(text(),'Membership is a Test?')]/../label[contains(text(),'Yes')]/preceding-sibling::input[1]");
-
- $this->type("sort_name", "$lastName $firstName");
- $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='memberSearch']/table/tbody/tr");
- $this->click("xpath=//table[@class='selector row-highlight']/tbody/tr/td[11]/span/a[text()='View']");
- $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
-
- //View Membership Record
- $verifyData = array(
- 'Member' => $firstName . ' ' . $lastName,
- 'Membership Type' => $memTypeTitle,
- 'Source' => 'Online Contribution:' . ' ' . $contributionTitle,
- 'Status' => 'New',
- );
-
- $this->webtestVerifyTabularData($verifyData);
- }
- }
-
- /**
- * CRM-18163 - To check whether multiple organizations with same name
- * are created based on dedupe rule other than org name.
- */
- public function testOnlineMembershipCreateOnBehalfWithOrgDedupe() {
- // Add unsupervised dedupe rule.
- $this->webtestLogin();
- $this->openCiviPage("contact/deduperules", "reset=1");
- $this->waitForElementPresent("xpath=//div[@id='option13_wrapper']/table/tbody/tr[2]/td[3]/span/a[2][text()='Edit Rule']");
- $this->click("xpath=//div[@id='option13_wrapper']/table/tbody/tr[2]/td[3]/span/a[2][text()='Edit Rule']");
- $this->waitForElementPresent('_qf_DedupeRules_next');
-
- $this->type('title', "Postal Code unsupervised dedupe rule");
- $this->click('CIVICRM_QFID_Unsupervised_used');
- $this->select('where_0', "Organization Name");
- $this->type('weight_0', 10);
- $this->select('where_1', "Postal Code");
- $this->type('length_1', 3);
- $this->type('weight_1', 10);
- $this->type('threshold', 20);
- $this->click('_qf_DedupeRules_next');
- $this->webtestLogout();
-
- //login with admin credentials & make sure we do have required permissions.
- $permissions = array("edit-1-make-online-contributions", "edit-1-profile-listings-and-forms");
- $this->changePermissions($permissions);
-
- $hash = substr(sha1(rand()), 0, 7);
- $rand = 2 * rand(2, 50);
- $amountSection = $payLater = $allowOtherAmount = $pledges = $recurring = $membershipsRequired = FALSE;
- $premiums = $widget = $pcp = $isSeparatePayment = $fixedAmount = $friend = FALSE;
- $memberships = FALSE;
- $memPriceSetId = NULL;
- $profilePreId = 1;
- $profilePostId = NULL;
- $onBehalf = 'optional';
- $contributionTitle = "Title $hash";
- $pageId = $this->webtestAddContributionPage(
- $hash,
- $rand,
- $contributionTitle,
- NULL,
- $amountSection,
- $payLater,
- $onBehalf,
- $pledges,
- $recurring,
- $memberships,
- $memPriceSetId,
- $friend,
- $profilePreId,
- $profilePostId,
- $premiums,
- $widget,
- $pcp,
- FALSE,
- FALSE,
- $isSeparatePayment,
- FALSE,
- $allowOtherAmount,
- TRUE,
- 'Member Dues',
- $fixedAmount,
- $membershipsRequired
- );
- $memTypeParams = $this->webtestAddMembershipType('rolling', 1, 'year', 'no', 0);
- $memTypeTitle = $memTypeParams['membership_type'];
- $memTypeId = explode('&id=', $this->getAttribute("xpath=//div[@id='membership_type']/table/tbody//tr/td[1]/div[text()='{$memTypeTitle}']/../../td[12]/span/a[3]@href"));
- $memTypeId = $memTypeId[1];
-
- $this->openCiviPage("admin/contribute/membership", "reset=1&action=update&id={$pageId}", '_qf_MembershipBlock_submit_savenext');
- $this->click('member_is_active');
- $this->waitForElementPresent('displayFee');
- $this->type('new_title', "Title - New Membership $hash");
- $this->type('renewal_title', "Title - Renewals $hash");
- $this->click("membership_type_$memTypeId");
- $this->clickLink('_qf_MembershipBlock_submit_savenext');
-
- $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
- $lastName = 'An' . substr(sha1(rand()), 0, 7);
-
- $onBehalfParams = array(
- 'org_name' => 'Test Org Dedupe', // Same Org Name.
- 'org_phone' => '123-456-789',
- 'org_email' => 'testorgdedupe@test.com', // Same Email address.
- 'org_postal_code' => 'ABC 123',
- 'mode' => 'optional',
- );
-
- $this->_testOnlineMembershipSignup($pageId, $memTypeTitle, $firstName, $lastName, $payLater, $hash, $allowOtherAmount, $amountSection, TRUE, TRUE, $onBehalfParams);
- $onBehalfParams['org_postal_code'] = 'XYZ 123';
- $this->_testOnlineMembershipSignup($pageId, $memTypeTitle, $firstName, $lastName, $payLater, $hash, $allowOtherAmount, $amountSection, TRUE, TRUE, $onBehalfParams);
-
- $this->webtestLogin();
- $this->openCiviPage("contact/search", "reset=1");
- $this->waitForElementPresent("_qf_Basic_refresh");
- $this->type('sort_name', $onBehalfParams['org_email']);
- $this->click("_qf_Basic_refresh");
- $this->waitForElementPresent("xpath=//div[@class='crm-search-results']");
- $this->assertElementContainsText("xpath=//div[@id='search-status']/table/tbody/tr[2]/td[2]/label[1]", "All 2 records");
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Member_OnlineMembershipRenewTest
- */
-class WebTest_Member_OnlineMembershipRenewTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- /**
- * FIXME: This test tries to update a contribution page (id=2) that may not exist :(
- */
- public function testOnlineMembershipRenew() {
- // a random 7-char string and an even number to make this pass unique
- $hash = substr(sha1(rand()), 0, 7);
- $rand = 2 * rand(2, 50);
-
- // Log in using webtestLogin() method
- $this->webtestLogin();
-
- // Use default payment processor
- $processorName = 'Test Processor';
- $this->webtestAddPaymentProcessor($processorName);
-
- $this->openCiviPage("admin/contribute/amount", "reset=1&action=update&id=2", "_qf_Amount_next");
- // this contribution page for membership signup
- // select newly created processor
- $xpath = "xpath=//label[text() = '{$processorName}']/preceding-sibling::input[1]";
- $this->waitForText('css=.crm-contribution-contributionpage-amount-form-block-payment_processor', $processorName);
- $this->check($xpath);
-
- // save
- $this->waitForElementPresent("_qf_Amount_next");
- $this->clickLink('_qf_Amount_next');
-
- // go to Membership block
- $this->click('css=#tab_membership a');
- $this->waitForElementPresent("member_is_active");
- $this->check("member_is_active");
-
- $this->waitForElementPresent("new_title");
-
- if ($this->isElementPresent("member_price_set_id")) {
- $this->waitForElementPresent("member_price_set_id");
-
- $this->select("member_price_set_id", "label=- none -");
- }
-
- $this->waitForElementPresent("membership_type-block");
- $this->check("xpath=//tr[@id='membership_type-block']/td[2]/table/tbody/tr/td/label[text()='General']/../input[2]");
- $this->check("xpath=//tr[@id='membership_type-block']/td[2]/table/tbody/tr/td/label[text()='Student']/../input[2]");
- $this->click("_qf_MembershipBlock_next-bottom");
- $this->waitForTextPresent("'MembershipBlock' information has been saved");
-
- // go to Profiles
- $this->click('css=#tab_custom a');
-
- // fill in Profiles
- $this->waitForElementPresent('custom_pre_id');
- $this->select('css=tr.crm-contribution-contributionpage-custom-form-block-custom_pre_id span.crm-profile-selector-select select', 'value=1');
-
- // save
- $this->click('_qf_Custom_upload_done');
- $this->waitForPageToLoad();
-
- $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
- $lastName = 'An' . substr(sha1(rand()), 0, 7);
- $email = $firstName . "@example.com";
-
- //logout
- $this->webtestLogout();
-
- //Go to online membership signup page
- $this->openCiviPage("contribute/transact", "reset=1&id=2&action=preview", "_qf_Main_upload-bottom");
-
- $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]/div[2]/span/label/span[1][contains(text(),'Student')]");
-
- //Type first name and last name and email
- $this->type("first_name", $firstName);
- $this->type("last_name", $lastName);
- $this->type("email-5", $email);
- $this->select("state_province-1", "value=1001");
-
- //Credit Card Info
- $this->select("credit_card_type", "value=Visa");
- $this->select("credit_card_type", "label=Visa");
- $this->type("credit_card_number", "4111111111111111");
- $this->type("cvv2", "000");
- $this->select("credit_card_exp_date[M]", "value=1");
- $this->select("credit_card_exp_date[Y]", "value=2020");
-
- //Billing Info
- $this->type("billing_first_name", $firstName . "billing");
- $this->type("billing_last_name", $lastName . "billing");
- $this->type("billing_street_address-5", "15 Main St.");
- $this->type(" billing_city-5", "San Jose");
- $this->select("billing_country_id-5", "value=1228");
- $this->select("billing_state_province_id-5", "value=1004");
- $this->type("billing_postal_code-5", "94129");
-
- $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
-
- $this->click("_qf_Confirm_next-bottom");
-
- // Log in using webtestLogin() method
- $this->webtestLogin();
- //Find Member
- $this->openCiviPage("member/search", "reset=1", "member_end_date_high");
-
- $this->type("sort_name", "$lastName $firstName");
- $this->click("xpath=//tr/td[1]/p/label[contains(text(),'Membership is a Test?')]/../label[contains(text(),'Yes')]/preceding-sibling::input[1]");
- $this->clickLink("_qf_Search_refresh", 'css=#memberSearch table tbody tr td span a.action-item:first-child');
- $this->click('css=#memberSearch table tbody tr td span a.action-item:first-child');
- $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
-
- //View Membership Record
- $verifyMembershipData = array(
- 'Member' => $firstName . ' ' . $lastName,
- 'Membership Type' => 'Student',
- 'Status' => 'New',
- 'Source' => 'Online Contribution: Member Signup and Renewal',
- );
- foreach ($verifyMembershipData as $label => $value) {
- $this->verifyText("xpath=//form[@id='MembershipView']//table/tbody/tr/td[text()='{$label}']/following-sibling::td",
- preg_quote($value)
- );
- }
-
- //logout
- $this->webtestLogout();
-
- $this->openCiviPage("contribute/transact", "reset=1&id=2&action=preview", "_qf_Main_upload-bottom");
-
- $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]/div[2]/span/label/span[1][contains(text(),'Student')]");
-
- //Type first name and last name and email
- $this->type("first_name", $firstName);
- $this->type("last_name", $lastName);
- $this->type("email-5", $email);
- $this->select("state_province-1", "value=1001");
-
- //Credit Card Info
- $this->select("credit_card_type", "value=Visa");
- $this->select("credit_card_type", "label=Visa");
- $this->type("credit_card_number", "4111111111111111");
- $this->type("cvv2", "000");
- $this->select("credit_card_exp_date[M]", "value=1");
- $this->select("credit_card_exp_date[Y]", "value=2020");
-
- //Billing Info
- $this->type("billing_first_name", $firstName . "billing");
- $this->type("billing_last_name", $lastName . "billing");
- $this->type("billing_street_address-5", "15 Main St.");
- $this->type(" billing_city-5", "San Jose");
- $this->select("billing_country_id-5", "value=1228");
- $this->select("billing_state_province_id-5", "value=1004");
- $this->type("billing_postal_code-5", "94129");
-
- $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
- $this->click("_qf_Confirm_next-bottom");
-
- $this->webtestLogin();
- //Find Member
- $this->openCiviPage("member/search", "reset=1", "member_end_date_high");
-
- $this->type("sort_name", "$lastName $firstName");
- $this->click("xpath=//tr/td[1]/p/label[contains(text(),'Membership is a Test?')]/../label[contains(text(),'Yes')]/preceding-sibling::input[1]");
- $this->clickLink("_qf_Search_refresh", 'css=#memberSearch table tbody tr td span a.action-item:first-child');
- $this->click('css=#memberSearch table tbody tr td span a.action-item:first-child');
- $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
-
- //View Membership Record
- $verifyMembershipData = array(
- 'Member' => $firstName . ' ' . $lastName,
- 'Membership Type' => 'Student',
- 'Status' => 'New',
- 'Source' => 'Online Contribution: Member Signup and Renewal',
- );
- foreach ($verifyMembershipData as $label => $value) {
- $this->verifyText("xpath=//form[@id='MembershipView']//table/tbody/tr/td[text()='{$label}']/following-sibling::td",
- preg_quote($value)
- );
- }
- }
-
- /**
- * FIXME: This test tries to update a contribution page (id=2) that may not exist :(
- */
- public function testOnlineMembershipRenewChangeType() {
- // a random 7-char string and an even number to make this pass unique
- $hash = substr(sha1(rand()), 0, 7);
- $rand = 2 * rand(2, 50);
-
- // Log in using webtestLogin() method
- $this->webtestLogin();
-
- // Use default payment processor
- $processorName = 'Test Processor';
- $this->webtestAddPaymentProcessor($processorName);
-
- $this->openCiviPage("admin/contribute/amount", "reset=1&action=update&id=2", '_qf_Amount_next');
-
- //this contribution page for membership signup
- $xpath = "xpath=//label[text() = '{$processorName}']/preceding-sibling::input[1]";
- $this->waitForText('css=.crm-contribution-contributionpage-amount-form-block-payment_processor', $processorName);
- $this->check($xpath);
-
- // save
- $this->waitForElementPresent('_qf_Amount_next');
- $this->click('_qf_Amount_next');
- $this->waitForPageToLoad();
-
- // go to Membership block
- $this->click('css=#tab_membership a');
- $this->waitForElementPresent("member_is_active");
- $this->check("member_is_active");
-
- $this->waitForElementPresent("new_title");
- if ($this->isElementPresent("member_price_set_id")) {
- $this->waitForElementPresent("member_price_set_id");
-
- $this->select("member_price_set_id", "label=- none -");
- }
-
- $this->waitForElementPresent("membership_type-block");
- $this->check("xpath=//tr[@id='membership_type-block']/td[2]/table/tbody/tr/td/label[text()='General']/../input[2]");
- $this->check("xpath=//tr[@id='membership_type-block']/td[2]/table/tbody/tr/td/label[text()='Student']/../input[2]");
- $this->click("_qf_MembershipBlock_next-bottom");
- $this->waitForTextPresent("'MembershipBlock' information has been saved");
-
- // go to Profiles
- $this->click('css=#tab_custom a');
-
- // fill in Profiles
- $this->waitForElementPresent('custom_pre_id');
- $this->select('css=tr.crm-contribution-contributionpage-custom-form-block-custom_pre_id span.crm-profile-selector-select select', 'value=1');
-
- // save
- $this->click('_qf_Custom_upload_done');
- $this->waitForPageToLoad();
-
- $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
- $lastName = 'An' . substr(sha1(rand()), 0, 7);
-
- //Go to online membership signup page
- $this->openCiviPage("contribute/transact", "reset=1&id=2&action=preview", "_qf_Main_upload-bottom");
- $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]/div[1]/span/label/span[1][contains(text(),'General')]");
- //Type first name and last name
- $this->type("first_name", $firstName);
- $this->type("last_name", $lastName);
-
- $this->select("state_province-1", "value=1001");
- //Credit Card Info
- $this->select("credit_card_type", "value=Visa");
- $this->select("credit_card_type", "label=Visa");
- $this->type("credit_card_number", "4111111111111111");
- $this->type("cvv2", "000");
- $this->select("credit_card_exp_date[M]", "value=1");
- $this->select("credit_card_exp_date[Y]", "value=2020");
-
- //Billing Info
- $this->type("billing_first_name", $firstName . "billing");
- $this->type("billing_last_name", $lastName . "billing");
- $this->type("billing_street_address-5", "15 Main St.");
- $this->type(" billing_city-5", "San Jose");
- $this->select("billing_country_id-5", "value=1228");
- $this->select("billing_state_province_id-5", "value=1004");
- $this->type("billing_postal_code-5", "94129");
-
- $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
-
- $this->click("_qf_Confirm_next-bottom");
-
- //Find Member
- $this->openCiviPage("member/search", "reset=1", "member_end_date_high");
-
- $this->type("sort_name", "$lastName $firstName");
- $this->click("xpath=//tr/td[1]/p/label[contains(text(),'Membership is a Test?')]/../label[contains(text(),'Yes')]/preceding-sibling::input[1]");
- $this->clickLink("_qf_Search_refresh", 'css=#memberSearch table tbody tr td span a.action-item:first-child');
- $this->click('css=#memberSearch table tbody tr td span a.action-item:first-child');
- $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
-
- $membershipCreatedId = $this->urlArg('id');
-
- $memberSince = date('F jS, Y');
-
- //View Membership Record
- $verifyMembershipData = array(
- 'Member' => $firstName . ' ' . $lastName,
- 'Membership Type' => 'General',
- 'Status' => 'New',
- 'Source' => 'Online Contribution: Member Signup and Renewal',
- );
- foreach ($verifyMembershipData as $label => $value) {
- $this->verifyText("xpath=//form[@id='MembershipView']//table/tbody/tr/td[text()='{$label}']/following-sibling::td",
- preg_quote($value)
- );
- }
- $this->openCiviPage("contribute/transact", "reset=1&id=2&action=preview", "_qf_Main_upload-bottom");
- $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]/div[2]/span/label/span[1][contains(text(),'Student')]");
-
- //Credit Card Info
- $this->select("credit_card_type", "value=Visa");
- $this->select("credit_card_type", "label=Visa");
- $this->type("credit_card_number", "4111111111111111");
- $this->type("cvv2", "000");
- $this->select("credit_card_exp_date[M]", "value=1");
- $this->select("credit_card_exp_date[Y]", "value=2020");
- $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
- $this->click("_qf_Confirm_next-bottom");
-
- //Find Member
- $this->openCiviPage("member/search", "reset=1", "member_end_date_high");
-
- $this->type("sort_name", "$lastName $firstName");
- $this->click("xpath=//tr/td[1]/p/label[contains(text(),'Membership is a Test?')]/../label[contains(text(),'Yes')]/preceding-sibling::input[1]");
- $this->clickLink("_qf_Search_refresh", 'css=#memberSearch table tbody tr td span a.action-item:first-child');
- $this->click('css=#memberSearch table tbody tr td span a.action-item:first-child');
- $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
-
- $membershipRenewedId = $this->urlArg('id');
-
- //View Membership Record
- $verifyMembershipData = array(
- 'Member' => $firstName . ' ' . $lastName,
- 'Membership Type' => 'Student',
- 'Status' => 'New',
- 'Source' => 'Online Contribution: Member Signup and Renewal',
- 'Member Since' => $memberSince,
- );
- foreach ($verifyMembershipData as $label => $value) {
- $this->verifyText("xpath=//form[@id='MembershipView']//table/tbody/tr/td[text()='{$label}']/following-sibling::td",
- preg_quote($value)
- );
- }
- $this->assertEquals($membershipCreatedId, $membershipRenewedId);
- }
-
- public function testUpdateInheritedMembershipOnBehalfOfRenewal() {
- // Log in as admin
- $this->webtestLogin('admin');
-
- $this->enableComponents('CiviMember');
-
- //check for online contribution and profile listings permissions
- $permissions = array("edit-1-make-online-contributions", "edit-1-profile-listings-and-forms");
- $this->changePermissions($permissions);
-
- // Log in as normal user
- $this->webtestLogin();
-
- $this->openCiviPage("contact/add", "reset=1&ct=Organization", '_qf_Contact_cancel');
-
- $title = substr(sha1(rand()), 0, 7);
- $this->type('organization_name', "Organization $title");
- $this->type('email_1_email', "$title@org.com");
- $this->click('_qf_Contact_upload_view');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->waitForText('crm-notification-container', "Organization $title has been created.");
-
- $this->openCiviPage("admin/member/membershipType", "reset=1&action=browse");
-
- $this->click('link=Add Membership Type');
- $this->waitForElementPresent('_qf_MembershipType_cancel-bottom');
-
- $membershipTypeTitle = "Membership Type $title";
- $this->type('name', "Membership Type $title");
-
- $this->select2('member_of_contact_id', $title);
-
- $this->type('minimum_fee', '100');
- $this->select('financial_type_id', 'value=2');
- $this->type('duration_interval', 1);
- $this->select('duration_unit', 'label=year');
- $this->select('period_type', 'value=rolling');
- $this->select2('relationship_type_id', 'Employer of', TRUE);
-
- $this->click('_qf_MembershipType_upload-bottom');
- $this->waitForElementPresent('link=Add Membership Type');
- $this->waitForText('crm-notification-container', "The membership type 'Membership Type $title' has been saved.");
-
- $this->waitForElementPresent("xpath=//div[@id='membership_type']/table/tbody//tr/td[1]/div[text()='{$membershipTypeTitle}']/../../td[12]/span/a[3][text()='Delete']/@href");
- $url = $this->getAttribute("xpath=//div[@id='membership_type']/table/tbody//tr/td[1]/div[text()='{$membershipTypeTitle}']/../../td[12]/span/a[3][text()='Delete']/@href");
- $matches = array();
- preg_match('/id=([0-9]+)/', $url, $matches);
- $membershipTypeId = $matches[1];
-
- // Use default payment processor
- $processorName = 'Test Processor';
-
- // create contribution page with randomized title and default params
- $hash = substr(sha1(rand()), 0, 7);
- $rand = 2 * rand(2, 50);
- $amountSection = FALSE;
- $payLater = FALSE;
- $onBehalf = FALSE;
- $pledges = FALSE;
- $recurring = FALSE;
- $memberships = FALSE;
- $memPriceSetId = NULL;
- $friend = FALSE;
- $profilePreId = 1;
- $profilePostId = NULL;
- $premiums = FALSE;
- $widget = FALSE;
- $pcp = FALSE;
-
- $contributionTitle = "Title $hash";
- $pageId = $this->webtestAddContributionPage($hash,
- $rand,
- $contributionTitle,
- array($processorName => 'Dummy'),
- $amountSection,
- $payLater,
- $onBehalf,
- $pledges,
- $recurring,
- $memberships,
- $memPriceSetId,
- $friend,
- $profilePreId,
- $profilePostId,
- $premiums,
- $widget,
- $pcp,
- TRUE
- );
-
- $hash = substr(sha1(rand()), 0, 7);
- $this->openCiviPage("admin/contribute/settings", "reset=1&action=update&id=$pageId");
-
- $this->click('link=Title');
- $this->waitForElementPresent('_qf_Settings_cancel-bottom');
- $this->click('is_organization');
- $this->select("xpath=//input[@id='onbehalf_profile_id']/parent::td/div/div/span/select", "value=9");
- $this->type('for_organization', "On behalf $hash");
- $this->click('_qf_Settings_next-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->click('link=Memberships');
- $this->waitForElementPresent('_qf_MembershipBlock_cancel-bottom');
- $this->click('member_is_active');
- $this->type('new_title', "Title - New Membership $hash");
- $this->type('renewal_title', "Title - Renewals $hash");
- $this->click("membership_type_{$membershipTypeId}");
- $this->click('is_required');
- $this->click('_qf_MembershipBlock_next-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- //logout
- $this->webtestLogout();
-
- //get Url for Live Contribution Page
- $this->openCiviPage("contribute/transact", "reset=1&id=$pageId&action=preview", '_qf_Main_upload-bottom');
- $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]/div/span/label/span[1][contains(text(),'$membershipTypeTitle')]");
- $firstName = 'Eia' . substr(sha1(rand()), 0, 4);
- $lastName = 'Ande' . substr(sha1(rand()), 0, 4);
- $name = $firstName . ' ' . $lastName;
- $organisationName = 'TestOrg' . substr(sha1(rand()), 0, 7);
-
- $email = $firstName . '@example.com';
- $this->type('email-5', $email);
- $this->click('is_for_organization');
- $this->type('onbehalf_organization_name', $organisationName);
- $this->type('onbehalf_phone-3-1', '2222-222222');
- $this->type('onbehalf_email-3', $organisationName . '@example.com');
- $this->type('onbehalf_street_address-3', '54A Excelsior Ave. Apt 1C');
- $this->type('onbehalf_city-3', 'Driftwood');
- $this->type('onbehalf_postal_code-3', '75653');
- $this->select('onbehalf_country-3', "value=1228");
- $this->select('onbehalf_state_province-3', "value=1061");
-
- $this->type('first_name', $firstName);
- $this->type('last_name', $lastName);
- $this->select("state_province-1", "value=1001");
-
- //Credit Card Info
- $this->select("credit_card_type", "value=Visa");
- $this->select("credit_card_type", "label=Visa");
- $this->type("credit_card_number", "4111111111111111");
- $this->type("cvv2", "000");
- $this->select("credit_card_exp_date[M]", "value=1");
- $this->select("credit_card_exp_date[Y]", "value=2020");
-
- //Billing Info
- $this->type("billing_first_name", $firstName . "billing");
- $this->type("billing_last_name", $lastName . "billing");
- $this->type("billing_street_address-5", "15 Main St.");
- $this->type(" billing_city-5", "San Jose");
- $this->select("billing_country_id-5", "value=1228");
- $this->select("billing_state_province_id-5", "value=1004");
- $this->type("billing_postal_code-5", "94129");
- $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
-
- $this->click("_qf_Confirm_next-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Log in using webtestLogin() method
- $this->webtestLogin();
-
- //Find member
- $endDate = date('F jS, Y', strtotime(" +1 year -1 day"));
- $this->openCiviPage("member/search", "reset=1", "member_end_date_high");
-
- $this->type("sort_name", "$organisationName");
- $this->click("xpath=//tr/td[1]/p/label[contains(text(),'Membership is a Test?')]/../label[contains(text(),'Yes')]/preceding-sibling::input[1]");
- $this->clickLink("_qf_Search_refresh", 'css=#memberSearch table tbody tr td span a.action-item:first-child');
- $this->click('css=#memberSearch table tbody tr td span a.action-item:first-child');
- $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
-
- //View Membership Record
- $verifyMembershipData = array(
- 'Member' => $organisationName,
- 'Membership Type' => $membershipTypeTitle,
- 'Status' => 'New',
- 'End date' => $endDate,
- );
-
- foreach ($verifyMembershipData as $label => $value) {
- $this->verifyText("xpath=//form[@id='MembershipView']//table/tbody/tr/td[text()='{$label}']/following-sibling::td",
- preg_quote($value)
- );
- }
-
- $this->openCiviPage("member/search", "reset=1", "member_end_date_high");
-
- $this->type("sort_name", "$lastName, $firstName");
- $this->click("xpath=//tr/td[1]/p/label[contains(text(),'Membership is a Test?')]/../label[contains(text(),'Yes')]/preceding-sibling::input[1]");
- $this->clickLink("_qf_Search_refresh", "css=#memberSearch table tbody tr td a.action-item:first-child");
- $this->click("css=#memberSearch table tbody tr td a.action-item:first-child");
- $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
-
- //View Membership Record
- $verifyMembershipData = array(
- 'Member' => $name,
- 'Membership Type' => $membershipTypeTitle,
- 'Status' => 'New',
- 'End date' => $endDate,
- );
-
- foreach ($verifyMembershipData as $label => $value) {
- $this->verifyText("xpath=//form[@id='MembershipView']//table/tbody/tr/td[text()='{$label}']/following-sibling::td",
- preg_quote($value)
- );
- }
-
- //logout
- $this->webtestLogout();
-
- $this->openCiviPage("contribute/transact", "reset=1&id=$pageId&action=preview", "_qf_Main_upload-bottom");
-
- $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]/div/span/label/span[1][contains(text(),'$membershipTypeTitle')]");
- $this->type("email-5", $email);
- $this->click('is_for_organization');
- $this->type('onbehalf_organization_name', $organisationName);
- $this->type('onbehalf_phone-3-1', '2222-222222');
- $this->type('onbehalf_email-3', $organisationName . '@example.com');
- $this->type('onbehalf_street_address-3', '22A Excelsior Ave. Unit 1h');
- $this->type('onbehalf_city-3', 'Driftwood');
- $this->type('onbehalf_postal_code-3', '75653');
- $this->select('onbehalf_country-3', "value=1228");
- $this->select('onbehalf_state_province-3', "value=1061");
-
- $this->type('first_name', $firstName);
- $this->type('last_name', $lastName);
- $this->select("state_province-1", "value=1001");
-
- //Credit Card Info
- $this->select("credit_card_type", "value=Visa");
- $this->select("credit_card_type", "label=Visa");
- $this->type("credit_card_number", "4111111111111111");
- $this->type("cvv2", "000");
- $this->select("credit_card_exp_date[M]", "value=1");
- $this->select("credit_card_exp_date[Y]", "value=2020");
-
- //Billing Info
- $this->type("billing_first_name", $firstName . "billing");
- $this->type("billing_last_name", $lastName . "billing");
- $this->type("billing_street_address-5", "15 Main St.");
- $this->type(" billing_city-5", "San Jose");
- $this->select("billing_country_id-5", "value=1228");
- $this->select("billing_state_province_id-5", "value=1004");
- $this->type("billing_postal_code-5", "94129");
-
- $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
-
- $this->click("_qf_Confirm_next-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Log in using webtestLogin() method
- $this->webtestLogin();
-
- //Find member
- $endDate = date('F jS, Y', strtotime(" +2 year -1 day"));
- $this->openCiviPage("member/search", "reset=1", "member_end_date_high");
-
- $this->type("sort_name", "$organisationName");
- $this->click("xpath=//tr/td[1]/p/label[contains(text(),'Membership is a Test?')]/../label[contains(text(),'Yes')]/preceding-sibling::input[1]");
- $this->clickLink("_qf_Search_refresh", 'css=#memberSearch table tbody tr td a.action-item:first-child');
- $this->click('css=#memberSearch table tbody tr td a.action-item:first-child');
- $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
-
- //View Membership Record
- $verifyMembershipData = array(
- 'Member' => $organisationName,
- 'Membership Type' => $membershipTypeTitle,
- 'End date' => $endDate,
- );
-
- foreach ($verifyMembershipData as $label => $value) {
- $this->verifyText("xpath=//form[@id='MembershipView']//table/tbody/tr/td[text()='{$label}']/following-sibling::td",
- preg_quote($value)
- );
- }
-
- $this->openCiviPage("member/search", "reset=1", "member_end_date_high");
-
- $this->type("sort_name", "$lastName, $firstName");
- $this->click("xpath=//tr/td[1]/p/label[contains(text(),'Membership is a Test?')]/../label[contains(text(),'Yes')]/preceding-sibling::input[1]");
- $this->clickLink("_qf_Search_refresh", 'css=#memberSearch table tbody tr td a.action-item:first-child');
- $this->click('css=#memberSearch table tbody tr td a.action-item:first-child');
- $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
-
- //View Membership Record
- $verifyMembershipData = array(
- 'Member' => $name,
- 'Membership Type' => $membershipTypeTitle,
- 'End date' => $endDate,
- );
-
- foreach ($verifyMembershipData as $label => $value) {
- $this->verifyText("xpath=//form[@id='MembershipView']//table/tbody/tr/td[text()='{$label}']/following-sibling::td",
- preg_quote($value)
- );
- }
- }
-
- /**
- * CRM-16165
- */
- public function testOnRecurringContributionAndMembershipRenewal() {
- // Log in as admin
- $this->webtestLogin('admin');
-
- $this->enableComponents('CiviMember');
-
- // Log in as normal user
- $this->webtestLogin();
-
- // Add membership Type
- $this->openCiviPage("admin/member/membershipType", "reset=1&action=browse");
-
- $this->click('link=Add Membership Type');
- $this->waitForElementPresent('_qf_MembershipType_cancel-bottom');
-
- $title = substr(sha1(rand()), 0, 7);
- $membershipTypeTitle = "Membership Type $title";
- $this->type('name', "Membership Type $title");
- $this->waitForAjaxContent();
- $this->select2('member_of_contact_id', 'Default Organization');
-
- $this->type('minimum_fee', '100');
- $this->select('financial_type_id', 'value=2');
- $this->type('duration_interval', 1);
- $this->select('duration_unit', 'label=year');
- $this->select('period_type', 'value=rolling');
- $this->click('CIVICRM_QFID_1_auto_renew');
-
- $this->click('_qf_MembershipType_upload-bottom');
- $this->waitForElementPresent('link=Add Membership Type');
- $this->waitForText('crm-notification-container', "The membership type 'Membership Type $title' has been saved.");
-
- $this->waitForElementPresent("xpath=//div[@id='membership_type']/table/tbody//tr/td[1]/div[text()='{$membershipTypeTitle}']/../../td[12]/span/a[3][text()='Delete']/@href");
- $url = $this->getAttribute("xpath=//div[@id='membership_type']/table/tbody//tr/td[1]/div[text()='{$membershipTypeTitle}']/../../td[12]/span/a[3][text()='Delete']/@href");
- $matches = array();
- preg_match('/id=([0-9]+)/', $url, $matches);
- $membershipTypeId = $matches[1];
-
- // Use default payment processor
- $processorName = 'Test Processor';
-
- // create contribution page with randomized title and default params
- $hash = substr(sha1(rand()), 0, 7);
- $rand = 2 * rand(2, 50);
- $amountSection = FALSE;
- $payLater = FALSE;
- $onBehalf = FALSE;
- $pledges = FALSE;
- $recurring = FALSE;
- $memberships = FALSE;
- $memPriceSetId = NULL;
- $friend = FALSE;
- $profilePreId = NULL;
- $profilePostId = NULL;
- $premiums = FALSE;
- $widget = FALSE;
- $pcp = FALSE;
-
- $contributionTitle = "Title $hash";
- $pageId = $this->webtestAddContributionPage($hash,
- $rand,
- $contributionTitle,
- array($processorName => 'Dummy'),
- $amountSection,
- $payLater,
- $onBehalf,
- $pledges,
- $recurring,
- $memberships,
- $memPriceSetId,
- $friend,
- $profilePreId,
- $profilePostId,
- $premiums,
- $widget,
- $pcp,
- TRUE
- );
-
- $this->openCiviPage("admin/contribute/amount", "reset=1&action=update&id=$pageId", '_qf_Amount_next');
-
- //this contribution page for membership signup
- $xpath = "xpath=//label[text() = '{$processorName}']/preceding-sibling::input[1]";
- $this->waitForText('css=.crm-contribution-contributionpage-amount-form-block-payment_processor', $processorName);
- $this->check($xpath);
-
- //enable contribution amaount
- $this->click('amount_block_is_active');
- $this->waitForElementPresent('amount_label');
- $this->type('amount_label', 'Additional Contribution');
- $this->click('is_allow_other_amount');
- $this->type('min_amount', '10');
- $this->type('max_amount', '1000');
-
- // save
- $this->waitForElementPresent('_qf_Amount_submit_savenext');
- $this->click('_qf_Amount_submit_savenext');
- $this->waitForPageToLoad();
-
- //enable membership block
- $this->waitForElementPresent("member_is_active");
- $this->check("member_is_active");
- $this->waitForElementPresent("new_title");
- $this->type('new_title', 'Membership Levels');
- $this->type('membership_type_label', 'Membership Levels');
- $this->check("membership_type_$membershipTypeId");
- $this->check("is_required");
- $this->clickLink('_qf_MembershipBlock_next', '_qf_MembershipBlock_next-bottom');
-
- //Scenario 1(a) - (is_separate_payment=FALSE + recurring contribution + non-renewal membership) on Amount page
- $this->click('link=Amounts');
- $this->waitForElementPresent("is_recur");
- $this->click('is_recur');
- $this->clickLink('_qf_Amount_next', '_qf_Amount_next-bottom');
- $this->waitForElementPresent("is_recur");
- $this->assertTrue($this->isTextPresent("You need to enable Separate Membership Payment when online contribution page is configured for both Membership and Recurring Contribution."));
-
- //Scenario 1(b) - (is_separate_payment=FALSE + recurring contribution + non-renewal membership) on MembershipBlock page
- $this->click('link=Memberships');
- $this->waitForElementPresent("is_separate_payment");
- $this->click('is_separate_payment');//enable is_separate_payment
- $this->clickLink('_qf_MembershipBlock_next', '_qf_MembershipBlock_next-bottom');
- $this->click('link=Amounts');//switch back to amount page
- $this->waitForElementPresent("is_recur");
- $this->click('is_recur');//enable recurring contribution
- $this->clickLink('_qf_Amount_next', '_qf_Amount_next-bottom');
- $this->click('link=Memberships');//switch back to MembershipBlock page
- $this->waitForElementPresent("is_separate_payment");
- $this->uncheck('is_separate_payment');//disable is_separate_payment
- $this->clickLink('_qf_MembershipBlock_next', '_qf_MembershipBlock_next-bottom');
- $this->waitForElementPresent("is_separate_payment");
- $this->assertTrue($this->isTextPresent("You need to enable Separate Membership Payment when online contribution page is configured for both Membership and Recurring Contribution"));
-
- //Scenario 2(a) - (is_separate_payment=TRUE + recurring contribution + auto-renewal membership) on MembershipBlock page
- $this->click('is_separate_payment');//enable is_separate_payment
- $this->select("auto_renew_$membershipTypeId", 'value=1');//choose auto-renew as optional
- $this->clickLink('_qf_MembershipBlock_next', '_qf_MembershipBlock_next-bottom');
- $this->assertTrue($this->isTextPresent("You cannot enable both Recurring Contributions and Auto-renew memberships on the same online contribution page"));
-
- //Scenario 2(b) - (is_separate_payment=TRUE + recurring contribution + auto-renewal membership) on Amount page
- $this->click('link=Amounts');//switch back to amount page
- $this->waitForElementPresent("is_recur");
- $this->uncheck('is_recur');//disable recurring contribution
- $this->clickLink('_qf_Amount_next', '_qf_Amount_next-bottom');
- $this->click('link=Memberships');//switch back to MembershipBlock page
- $this->waitForElementPresent("auto_renew_$membershipTypeId");
- $this->select("auto_renew_$membershipTypeId", 'value=1');//choose auto-renew as optional
- $this->clickLink('_qf_MembershipBlock_next', '_qf_MembershipBlock_next-bottom');
- $this->click('link=Amounts');//switch back to amount page
- $this->waitForElementPresent("is_recur");
- $this->click('is_recur');//enable recurring contribution
- $this->clickLink('_qf_Amount_next', '_qf_Amount_next-bottom');
- $this->waitForElementPresent("is_recur");
- $this->assertTrue($this->isTextPresent("You cannot enable both Recurring Contributions and Auto-renew memberships on the same online contribution page"));
-
- //Scenario 3 - Online Registration on
- // (is_separate_payment=TRUE + non-recurring Additional contribution + auto-renewal membership) setting
- $firstName = 'Eia' . substr(sha1(rand()), 0, 4);
- $lastName = 'Ande' . substr(sha1(rand()), 0, 4);
- $email = $firstName . '@test.com';
-
- $this->openCiviPage("contribute/transact", "reset=1&id=$pageId&action=preview", "_qf_Main_upload-bottom");
-
- $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]/div/span/label/span[1][contains(text(),'$membershipTypeTitle')]");
- $this->waitForElementPresent("auto_renew");
- $this->type("xpath=//div[@class='content other_amount-content']/input[@type='text']", '20');
- $this->click("auto_renew");
-
- //fill email
- $this->type('email-5', $email);
-
- //Credit Card Info
- $this->select("credit_card_type", "value=Visa");
- $this->select("credit_card_type", "label=Visa");
- $this->type("credit_card_number", "4111111111111111");
- $this->type("cvv2", "000");
- $this->select("credit_card_exp_date[M]", "value=1");
- $this->select("credit_card_exp_date[Y]", "value=2020");
-
- //Billing Info
- $this->type("billing_first_name", $firstName . "billing");
- $this->type("billing_last_name", $lastName . "billing");
- $this->type("billing_street_address-5", "15 Main St.");
- $this->type(" billing_city-5", "San Jose");
- $this->select("billing_country_id-5", "value=1228");
- $this->select("billing_state_province_id-5", "value=1004");
- $this->type("billing_postal_code-5", "94129");
-
- $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
- $this->assertTrue($this->isTextPresent("I want this membership to be renewed automatically every 1 year(s)."));
- $this->click("_qf_Confirm_next-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $expectedParams = array(
- 'Pending' => array(
- 'total_amount' => 100.00),
- 'Completed' => array(
- 'total_amount' => 20.00,
- ),
- );
-
- //Assert that additional contribution and auto-renewal membrship
- $membership = $this->webtest_civicrm_api("Membership", "get", array('membership_type_id' => $membershipTypeId));
- $this->assertEquals($membership['count'], 1);
- $membershipId = $membership['id'];
- $this->assertEquals($membership['values'][$membershipId]['membership_name'], $membershipTypeTitle);
- //CRM-16165: if membership contribution status is pending then membership status should be pending
- $pendingStatus = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipStatus', 'Pending', 'id', 'name');
- $this->assertEquals($membership['values'][$membershipId]['status_id'], $pendingStatus);
-
- //check if the membership created is set to reccuring
- $recurringContributionId = $membership['values'][$membershipId]['contribution_recur_id'];
- $recurringContribution = $this->webtest_civicrm_api("ContributionRecur", "get", array('id' => $recurringContributionId));
- $this->assertEquals($recurringContribution['count'], 1);
- $this->assertEquals($recurringContribution['values'][$recurringContributionId]['auto_renew'], 1);
- $this->assertEquals($recurringContribution['values'][$recurringContributionId]['frequency_unit'], 'year');
- $this->assertEquals($recurringContribution['values'][$recurringContributionId]['frequency_interval'], 1);
-
- $results = $this->webtest_civicrm_api("Contribution", "get", array('source' => array('LIKE' => "%$contributionTitle%")));
- foreach ($results['values'] as $value) {
- $status = $value['contribution_status'];
- $this->assertEquals($value['total_amount'], $expectedParams[$status]['total_amount']);
- $this->webtest_civicrm_api("Contribution", "delete", array('id' => $value['contribution_id']));
- }
-
- //Cleanup data before trying next combination
- $this->webtest_civicrm_api("Membership", "delete", array('id' => $membershipId));
- $this->webtest_civicrm_api("ContributionRecur", "delete", array('id' => $recurringContributionId));
-
- //Scenario 4 - Online Registration on
- // (is_separate_payment=TRUE + recurring Additional contribution + non auto-renewal membership) setting
- $this->openCiviPage("admin/contribute/membership", "reset=1&action=update&id=$pageId");
- $this->waitForElementPresent("auto_renew_$membershipTypeId");
- $this->select("auto_renew_$membershipTypeId", 'value=0');
- $this->clickLink('_qf_MembershipBlock_next', '_qf_MembershipBlock_next-bottom');
- $this->click('link=Amounts');//switch back to amount page
- $this->waitForElementPresent("is_recur");
- $this->click('is_recur');//disable recurring contribution
- $this->clickLink('_qf_Amount_next', '_qf_Amount_next-bottom');
-
- $this->openCiviPage("contribute/transact", "reset=1&id=$pageId&action=preview", "_qf_Main_upload-bottom");
- $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]/div/span/label/span[1][contains(text(),'$membershipTypeTitle')]");
- $this->type("xpath=//div[@class='content other_amount-content']/input[@type='text']", '30');
- $this->click("is_recur");
-
- //Credit Card Info
- $this->select("credit_card_type", "value=Visa");
- $this->select("credit_card_type", "label=Visa");
- $this->type("credit_card_number", "4111111111111111");
- $this->type("cvv2", "000");
- $this->select("credit_card_exp_date[M]", "value=1");
- $this->select("credit_card_exp_date[Y]", "value=2020");
-
- $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
- $this->assertTrue($this->isTextPresent("I want to contribute this amount every month."));
- $this->click("_qf_Confirm_next-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $expectedParams = array(
- 'Pending' => array(
- 'total_amount' => 30.00),
- 'Completed' => array(
- 'total_amount' => 100.00,
- ),
- );
-
- //Assert that additional contribution and auto-renewal membrship
- $membership = $this->webtest_civicrm_api("Membership", "get", array('membership_type_id' => $membershipTypeId));
- $this->assertEquals($membership['count'], 1);
- $membershipId = $membership['id'];
- $this->assertEquals($membership['values'][$membershipId]['membership_name'], $membershipTypeTitle);
- $this->assertEquals($membership['values'][$membershipId]['status_id'], 1);
- $this->assertEquals($membership['values'][$membershipId]['source'], "Online Contribution: $contributionTitle");
-
- $results = $this->webtest_civicrm_api("Contribution", "get", array('source' => array('LIKE' => "%$contributionTitle%")));
- foreach ($results['values'] as $value) {
- $status = $value['contribution_status'];
- $this->assertEquals($value['total_amount'], $expectedParams[$status]['total_amount']);
- if ($status == 'Pending') {
- $recurringContributionId = $value['contribution_recur_id'];
- $recurringContribution = $this->webtest_civicrm_api("ContributionRecur", "get", array('id' => $recurringContributionId));
- $this->assertEquals($recurringContribution['count'], 1);
- $this->assertEquals($recurringContribution['values'][$recurringContributionId]['frequency_unit'], 'month');
- $this->assertEquals($recurringContribution['values'][$recurringContributionId]['frequency_interval'], 1);
- }
- $this->webtest_civicrm_api("Contribution", "delete", array('id' => $value['contribution_id']));
- }
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Member_SeperateMembershipPaymentTest
- */
-class WebTest_Member_SeperateMembershipPaymentTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testSeperateMembershipCreate() {
- // a random 7-char string and an even number to make this pass unique
- $hash = substr(sha1(rand()), 0, 7);
- $rand = 2 * rand(2, 50);
- // Log in using webtestLogin() method
- $this->webtestLogin();
-
- $firstName1 = 'Ma_' . substr(sha1(rand()), 0, 7);
- $lastName1 = 'An_' . substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName1, $lastName1, TRUE);
- $this->waitForText('crm-notification-container', "$firstName1 $lastName1 has been created.");
- $cid = $this->urlArg('cid');
-
- // create contribution page with randomized title and default params
- $amountSection = TRUE;
- $payLater = TRUE;
- $onBehalf = FALSE;
- $pledges = FALSE;
- $recurring = FALSE;
- $memberships = TRUE;
- $memPriceSetId = NULL;
- $friend = TRUE;
- $profilePreId = NULL;
- $profilePostId = NULL;
- $premiums = FALSE;
- $widget = FALSE;
- $pcp = FALSE;
- $isAddPaymentProcessor = FALSE;
- $isSeparatePayment = TRUE;
-
- $contributionTitle = "Title $hash";
- $pageId = $this->webtestAddContributionPage($hash,
- $rand,
- $contributionTitle,
- NULL,
- $amountSection,
- $payLater,
- $onBehalf,
- $pledges,
- $recurring,
- $memberships,
- $memPriceSetId,
- $friend,
- $profilePreId,
- $profilePostId,
- $premiums,
- $widget,
- $pcp,
- $isAddPaymentProcessor,
- FALSE,
- $isSeparatePayment,
- FALSE
- );
-
- // create new membership types
- $memTypeParams1 = $this->webtestAddMembershipType();
- $memTypeTitle1 = $memTypeParams1['membership_type'];
- $memTypeId1 = explode('&id=', $this->getAttribute("xpath=//div[@id='membership_type']/table/tbody//tr/td/div[text()='{$memTypeTitle1}']/../../td[12]/span/a[3]@href"));
- $memTypeId1 = $memTypeId1[1];
-
- $memTypeParams2 = $this->webtestAddMembershipType();
- $memTypeTitle2 = $memTypeParams2['membership_type'];
- $memTypeId2 = explode('&id=', $this->getAttribute("xpath=//div[@id='membership_type']/table/tbody//tr/td/div[text()='{$memTypeTitle2}']/../../td[12]/span/a[3]@href"));
- $memTypeId2 = $memTypeId2[1];
-
- // edit contribution page memberships tab to add two new membership types
- $this->openCiviPage('admin/contribute/membership', "reset=1&action=update&id={$pageId}", "_qf_MembershipBlock_next-bottom");
- $this->click("membership_type_$memTypeId1");
- $this->click("membership_type_$memTypeId2");
- $this->clickLink('_qf_MembershipBlock_next', '_qf_MembershipBlock_next-bottom');
- $text = "'MembershipBlock' information has been saved.";
- $this->waitForText('crm-notification-container', $text);
- $this->_testOnlineMembershipSignup($pageId, $memTypeTitle1, $cid);
-
- //Find Member
- $this->openCiviPage('member/search', 'reset=1', 'member_end_date_high');
- $this->type("sort_name", "$lastName1 $firstName1");
- $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='memberSearch']/table/tbody/tr");
- $this->click("xpath=//div[@id='memberSearch']/table/tbody/tr/td[11]/span/a[text()='View']");
- $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
-
- //View Membership Record
- $verifyData = array(
- 'Member' => $firstName1 . ' ' . $lastName1,
- 'Membership Type' => $memTypeTitle1,
- 'Status' => 'Pending',
- 'Source' => 'Online Contribution:' . ' ' . $contributionTitle,
- );
-
- $this->webtestVerifyTabularData($verifyData);
-
- // Click View action link on associated contribution record
-
- $this->waitForElementPresent("xpath=//form[@id='MembershipView']/div[2]/div/div[@class='crm-accordion-wrapper']/div/table/tbody/tr[1]/td[8]/span/a[1][text()='View']");
- $this->click("xpath=//form[@id='MembershipView']/div[2]/div/div[@class='crm-accordion-wrapper']/div/table/tbody/tr[1]/td[8]/span/a[1][text()='View']");
- $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']/button[3]/span[2]");
-
- //View Contribution Record
- $verifyData = array(
- 'From' => $firstName1 . ' ' . $lastName1,
- 'Total Amount' => '$ 100.00',
- );
- $this->webtestVerifyTabularData($verifyData);
-
- $this->click("_qf_ContributionView_cancel-bottom");
- $this->waitForElementPresent("xpath=//form[@id='MembershipView']/div[2]/div/div[@class='crm-accordion-wrapper']/div/table/tbody/tr[1]/td[8]/span/a[1][text()='View']");
- }
-
- /**
- * @param int $pageId
- * @param int $memTypeId
- * @param int $cid
- */
- public function _testOnlineMembershipSignup($pageId, $memTypeId, $cid = NULL) {
- //Open Live Contribution Page
- $args = array('reset' => 1, 'id' => $pageId);
- if ($cid) {
- $args['cid'] = $cid;
- }
- $this->openCiviPage("contribute/transact", $args, '_qf_Main_upload-bottom');
-
- // Select membership type 1
- $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]//div/span/label/span[1][contains(text(),'$memTypeId')]");
- $this->type("xpath=//div[@class='crm-section other_amount-section']//div[2]/input", 60);
- $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
- $this->clickLink("_qf_Confirm_next-bottom", NULL);
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Member_StandaloneAddTest
- */
-class WebTest_Member_StandaloneAddTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testStandaloneMemberAdd() {
-
- $this->webtestLogin();
-
- // create contact
- $firstName = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName, "Memberson", "Memberson{$firstName}@memberson.name");
- $contactName = "Memberson, $firstName";
-
- // add membership type
- $membershipTypes = $this->webtestAddMembershipType();
-
- // now add membership
- $this->openCiviPage("member/add", "reset=1&action=add&context=standalone", "_qf_Membership_upload");
-
- // select contact
- $this->webtestFillAutocomplete($firstName);
-
- // fill in Membership Organization
- $this->select("membership_type_id[0]", "label={$membershipTypes['member_of_contact']}");
-
- // select membership type
- $this->select("membership_type_id[1]", "label={$membershipTypes['membership_type']}");
-
- // fill in Source
- $this->type("source", "Membership StandaloneAddTest Webtest");
-
- // Let Join Date stay default
-
- // fill in Start Date
- $this->webtestFillDate('start_date');
-
- // Let End Date be auto computed
-
- // fill in Status Override?
- // fill in Record Membership Payment?
- $this->click("send_receipt");
- $this->assertTrue($this->isChecked("send_receipt"), 'Send Confirmation and Receipt checkbox should be checked.');
- $this->click("_qf_Membership_upload");
-
- //View Membership
- $this->waitForElementPresent("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']");
- $this->click("xpath=//div[@id='memberships']//table/tbody/tr[1]/td[9]/span/a[text()='View']");
- $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
-
- $expected = array(
- 'Membership Type' => $membershipTypes['membership_type'],
- 'Status' => 'New',
- 'Source' => 'Membership StandaloneAddTest Webtest',
- );
- $this->webtestVerifyTabularData($expected);
- }
-
- public function testStandaloneGiftMembership() {
-
- $this->webtestLogin();
-
- // create contact
- $firstName = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName, "Memberson", "Memberson{$firstName}@memberson.name");
- $contactName = "Memberson, $firstName";
-
- $giftMemberfirstName = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($giftMemberfirstName, "Memberson", "Memberson{$giftMemberfirstName}@memberson.name");
- $giftMembercontactName = "Memberson, $giftMemberfirstName";
-
- // add membership type
- $membershipTypes = $this->webtestAddMembershipType();
-
- // now add membership
- $this->openCiviPage("member/add", "reset=1&action=add&context=standalone", "_qf_Membership_upload");
-
- // select contact
- $this->webtestFillAutocomplete($firstName);
-
- // fill in Membership Organization
- $this->select("membership_type_id[0]", "label={$membershipTypes['member_of_contact']}");
-
- // select membership type
- $this->select("membership_type_id[1]", "label={$membershipTypes['membership_type']}");
-
- // fill in Source
- $this->type("source", "Membership StandaloneAddTest Webtest");
-
- // fill in Start Date
- $this->webtestFillDate('start_date');
-
- // add softcredit details
- $totalAmount = 100;
- $financialType = 'Donation';
- $this->clickLink('is_different_contribution_contact', 'total_amount', FALSE);
-
- $this->select('soft_credit_type_id', 'Gift');
- $this->select2('soft_credit_contact_id', $giftMembercontactName);
- $this->select('financial_type_id', 'Donation');
- $this->type('total_amount', $totalAmount);
- $this->select('payment_instrument_id', 'Check');
- $this->select('contribution_status_id', 'Completed');
-
- $this->clickLink("_qf_Membership_upload");
-
- //View Membership
- $this->waitForElementPresent("xpath=//table[@class='display dataTable no-footer']/tbody/tr[1]/td[9]/span/a[text()='View']");
- $this->click("xpath=//table[@class='display dataTable no-footer']/tbody/tr[1]/td[9]/span/a[text()='View']");
- $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
-
- // verify soft credit data
- $expected = array(
- '1' => $giftMemberfirstName . ' Memberson',
- '2' => $totalAmount,
- '3' => 'Gift',
- '4' => 'Donation',
- '6' => 'Completed',
- );
-
- foreach ($expected as $key => $value) {
- $this->verifyText("xpath=//div[@class='crm-accordion-wrapper']//table/tbody//tr/td[$key]", $value);
- }
-
- }
-
- public function testStandaloneMemberOverrideAdd() {
-
- $this->webtestLogin();
-
- // add contact
- $firstName = substr(sha1(rand()), 0, 7);
- $this->webtestAddContact($firstName, "Memberson", "Memberson{$firstName}@memberson.name");
- $contactName = "Memberson, $firstName";
-
- // add membership type
- $membershipTypes = $this->webtestAddMembershipType();
-
- // add membership
- $this->openCiviPage("member/add", "reset=1&action=add&context=standalone", "_qf_Membership_upload");
-
- // select contact
- $this->webtestFillAutocomplete($firstName);
-
- // fill in Membership Organization
- $this->select("membership_type_id[0]", "label={$membershipTypes['member_of_contact']}");
-
- // select membership type
- $this->select("membership_type_id[1]", "label={$membershipTypes['membership_type']}");
-
- // fill in Source
- $this->type("source", "Membership StandaloneAddTest Webtest");
-
- // Let Join Date stay default
-
- // fill in Start Date
- $this->webtestFillDate('start_date');
-
- // Let End Date be auto computed
-
- // fill in Status Override?
- $this->click("is_override", "value=1");
- $this->waitForElementPresent("status_id");
- $this->select("status_id", "value=3");
-
- // fill in Record Membership Payment?
- $this->click("record_contribution", "value=1");
- $this->waitForElementPresent("contribution_status_id");
- // let financial type be default
-
- // let the amount be default
-
- // select payment instrument type = Check and enter chk number
- $this->select("payment_instrument_id", "value=4");
- $this->waitForElementPresent("check_number");
- $this->type("check_number", "check #12345");
- $this->type("trxn_id", "P5476785" . rand(100, 10000));
-
- // fill the payment status be default
- $this->select("contribution_status_id", "value=2");
-
- //----
-
- // Clicking save.
- $this->click("_qf_Membership_upload");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // page was loaded
- $this->waitForTextPresent("Membership StandaloneAddTest Webtest");
-
- // verify if Membership is created
- $this->waitForElementPresent("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']");
-
- //click through to the Membership view screen
- $this->click("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']");
- $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
-
- $expected = array(
- 'Membership Type' => $membershipTypes['membership_type'],
- 'Status' => 'Grace',
- 'Source' => 'Membership StandaloneAddTest Webtest',
- );
- $this->webtestVerifyTabularData($expected);
- }
-
- public function testAjaxCustomGroupLoad() {
- $this->webtestLogin();
- $triggerElement = array('name' => 'membership_type_id_1', 'type' => 'select');
- $customSets = array(
- array('entity' => 'Membership', 'subEntity' => 'General', 'triggerElement' => $triggerElement),
- array('entity' => 'Membership', 'subEntity' => 'Student', 'triggerElement' => $triggerElement),
- );
-
- $pageUrl = array('url' => 'member/add', 'args' => 'reset=1&action=add&context=standalone');
-
- //case where we should fire certain
- //ui actions which helps triggering possible
- $test = $this;
- $this->customFieldSetLoadOnTheFlyCheck($customSets, $pageUrl,
- function () use ($test) {
- $test->select('membership_type_id_0', 'value=1');
- }
- );
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Member_UpdateMembershipScriptTest
- */
-class WebTest_Member_UpdateMembershipScriptTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testAddMembership() {
- // Log in using webtestLogin() method
- $this->webtestLogin();
-
- // Add a new membership type
- $memTypeParams = $this->addMembershipType();
-
- $firstName = substr(sha1(rand()), 0, 7);
- $email = "$firstName.Anderson@example.com";
- $this->webtestAddContact($firstName, 'Anderson', $email);
-
- $this->waitForElementPresent('css=li#tab_member a');
- $this->click('css=li#tab_member a');
- $this->waitForElementPresent('link=Add Membership');
- $this->click('link=Add Membership');
-
- $this->waitForElementPresent('_qf_Membership_cancel-bottom');
- $this->select('membership_type_id[0]', "label={$memTypeParams['member_of_contact']}");
- $this->select('membership_type_id[1]', "label={$memTypeParams['membership_type']}");
-
- // Fill join date
- $this->webtestFillDate('join_date', "1 March 2008");
-
- // Override status
- $this->check('is_override');
- $this->select('status_id', "label=Current");
-
- // Clicking save.
- $this->click('_qf_Membership_upload');
-
- // Is status message correct?
- $this->waitForText('crm-notification-container', "{$memTypeParams['membership_type']} membership for $firstName Anderson has been added.");
-
- // click through to the membership view screen
- $this->waitForElementPresent("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]");
- $this->click("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']");
- $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
-
- $this->webtestVerifyTabularData(
- array(
- 'Membership Type' => "{$memTypeParams['membership_type']}",
- 'Status' => 'Current',
- 'Member Since' => 'March 1st, 2008',
- 'Start date' => 'March 1st, 2008',
- 'End date' => 'February 28th, 2009',
- )
- );
- }
-
- /**
- * @return array
- */
- public function addMembershipType() {
- $membershipTitle = substr(sha1(rand()), 0, 7);
- $membershipOrg = $membershipTitle . ' memorg';
- $this->webtestAddOrganization($membershipOrg, TRUE);
-
- $title = "Membership Type " . substr(sha1(rand()), 0, 7);
- $memTypeParams = array(
- 'membership_type' => $title,
- 'member_of_contact' => $membershipOrg,
- 'financial_type' => 2,
- 'relationship_type' => '4_b_a',
- );
-
- $this->openCiviPage('admin/member/membershipType', 'reset=1&action=browse');
-
- $this->click("link=Add Membership Type");
- $this->waitForElementPresent('_qf_MembershipType_cancel-bottom');
-
- // New membership type
- $this->type('name', $memTypeParams['membership_type']);
- $this->select2('member_of_contact_id', $membershipTitle);
-
- // Membership fees
- $this->type('minimum_fee', '100');
- $this->select('financial_type_id', "value={$memTypeParams['financial_type']}");
-
- // Duration for which the membership will be active
- $this->type('duration_interval', 1);
- $this->select('duration_unit', "label=year");
-
- // Membership period type
- $this->select('period_type', "value=rolling");
- $this->click('relationship_type_id', "value={$memTypeParams['relationship_type']}");
-
- // Clicking save
- $this->click('_qf_MembershipType_upload-bottom');
- $this->waitForElementPresent('link=Add Membership Type');
- $this->waitForText('crm-notification-container', "The membership type '$title' has been saved.");
-
- return $memTypeParams;
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Pledge_AddCancelPaymentTest
- */
-class WebTest_Pledge_AddCancelPaymentTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testAddCancelPayment() {
- $this->webtestLogin();
-
- $this->openCiviPage('pledge/add', 'reset=1&context=standalone', '_qf_Pledge_upload');
-
- // create new contact using dialog
- $contact = $this->createDialogContact();
-
- $this->type('amount', '1200');
- $this->type('installments', '12');
- $this->select('frequency_unit', 'value=month');
- $this->type('frequency_day', '1');
- $this->webtestFillDate('acknowledge_date', 'now');
- $this->select('contribution_page_id', 'value=3');
- $this->click('_qf_Pledge_upload-bottom');
- $this->waitForPageToLoad("30000");
-
- $this->waitForText('crm-notification-container', "Pledge has been recorded and the payment schedule has been created.");
-
- // verify if Pledge is created
- $this->waitForElementPresent("xpath=//div[@class='view-content']//table//tbody/tr[1]/td[10]/span/a[text()='View']");
-
- //click through to the Pledge view screen
- $this->click("xpath=//div[@class='view-content']//table//tbody/tr[1]/td[10]/span/a[text()='View']");
- $this->waitForElementPresent('_qf_PledgeView_next-bottom');
- $pledgeDate = date('F jS, Y', strtotime('now'));
-
- $this->webtestVerifyTabularData(array(
- 'Pledge By' => $contact['display_name'],
- 'Total Pledge Amount' => '$ 1,200.00',
- 'To be paid in' => '12 installments of $ 100.00 every 1 month(s)',
- 'Payments are due on the' => '1 day of the period',
- 'Pledge Made' => $pledgeDate,
- 'Financial Type' => 'Donation',
- 'Pledge Status' => 'Pending',
- )
- );
- //Edit and add the first payment for 300.00
- $this->click('_qf_PledgeView_next-bottom');
- $this->waitForElementPresent("xpath=//div[@class='view-content']//table//tbody/tr[1]/td[10]/span/a[text()='View']");
- $this->waitForAjaxContent();
- $this->click("xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[1]/a");
- $this->waitForElementPresent("xpath=//div[@class='view-content']//table//tbody//tr//td/div/table/tbody/tr[2]/td[8]/a[text()='Record Payment']");
- $this->click("xpath=//div[@class='view-content']//table//tbody//tr//td/div/table/tbody/tr[2]/td[8]/a");
- $this->waitForElementPresent("xpath=//form[@id='Contribution']//div[2]/table/tbody/tr[3]/td[2]/a");
- $this->click("xpath=//form[@id='Contribution']//div[2]/table/tbody/tr[3]/td[2]/a");
- $this->type('total_amount', '300.00');
- $this->click('_qf_Contribution_upload-bottom');
- $this->waitForText('crm-notification-container', "The contribution record has been saved.");
-
- $this->waitForElementPresent("xpath=//div[@class='view-content']//table//tbody/tr[1]/td[10]/span/a[text()='View']");
-
- //Check whether the next two payments are done or not
- $this->waitForAjaxContent();
- $this->waitForElementPresent("xpath=//form[@class='CRM_Pledge_Form_Search crm-search-form']//div/table/tbody//tr//td/div/table/tbody/tr[2]/td[8]/a[text()='View Payment']");
- $this->verifyText("xpath=//div[@class='view-content']//table/tbody/tr/td/div/table/tbody/tr[3]/td[7]", "Completed");
- $this->verifyText("xpath=//div[@class='view-content']//table/tbody/tr/td/div/table/tbody/tr[4]/td[7]", "Completed");
-
- //Cancel the contribution made for amount of 300.00
- $this->waitForElementPresent("xpath=//form[@class='CRM_Pledge_Form_Search crm-search-form']//div/table/tbody//tr//td/div/table/tbody/tr[2]/td[8]/a[text()='View Payment']");
- $this->click("xpath=//div[@class='view-content']//table/tbody/tr/td/div/table/tbody/tr[2]/td[8]/a");
- $this->waitForElementPresent("xpath=//form[@id='ContributionView']//div[2]/div/div/a");
- $this->click("xpath=//form[@id='ContributionView']//div[2]/div/div/a");
- $this->waitForElementPresent("_qf_Contribution_upload-bottom");
- $this->select('contribution_status_id', 'value=3');
- $this->click("_qf_Contribution_upload-bottom");
- $this->waitForAjaxContent();
- $this->waitForElementPresent("_qf_ContributionView_cancel-bottom");
- $this->click("_qf_ContributionView_cancel-bottom");
-
- $this->waitForElementPresent("xpath=//div[@class='view-content']//table//tbody/tr[1]/td[10]/span/a[text()='View']");
- $this->waitForAjaxContent();
- $this->waitForElementPresent("xpath=//div[@class='view-content']//table/tbody/tr/td/div/table/tbody/tr[3]/td[7]");
-
- // verify that first paayment is cancelled and the rest two payments are revert back to the pending status
- $this->verifyText("xpath=//div[@class='view-content']//table/tbody/tr/td/div/table/tbody/tr[2]/td[7]", "Cancelled");
- $this->verifyText("xpath=//div[@class='view-content']//table/tbody/tr/td/div/table/tbody/tr[3]/td[7]", "Pending");
- $this->verifyText("xpath=//div[@class='view-content']//table/tbody/tr/td/div/table/tbody/tr[4]/td[7]", "Pending");
-
- // Check whether a new payment with pending status is added at the last or not
- $this->verifyText("xpath=//div[@class='view-content']//table/tbody/tr/td/div/table/tbody/tr[14]/td[7]", "Pending");
-
- // verify that Balance sum is correct
- $this->verifyText("xpath=//form[@class='CRM_Pledge_Form_Search crm-search-form']//div[@class='view-content']//table//tbody/tr[1]/td[4]", "1,200.00");
-
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Pledge_ContactContextAddTest
- */
-class WebTest_Pledge_ContactContextAddTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testContactContextAddTest() {
- $this->webtestLogin();
- // Disable pop-ups for this test. Running test w/ pop-ups causes a spurious failure. dgg
- $this->enableDisablePopups(FALSE);
-
- // create unique name
- $name = substr(sha1(rand()), 0, 7);
- $firstName = 'Adam' . $name;
- $lastName = 'Jones' . $name;
-
- // create new contact
- $this->webtestAddContact($firstName, $lastName, $firstName . "@example.com");
-
- // wait for action element
- $this->waitForElementPresent('crm-contact-actions-link');
-
- // now add pledge from contact summary
- $this->click("xpath=//div[@class='crm-actions-ribbon']/ul[@id='actions']/li[@class='crm-contact-activity crm-summary-block']/div/a[@id='crm-contact-actions-link']");
- $this->waitForElementPresent('crm-contact-actions-list');
-
- // wait for add plegde link
- $this->waitForElementPresent('link=Add Pledge');
-
- $this->click('link=Add Pledge');
-
- // wait for pledge form to load completely
- $this->waitForElementPresent('_qf_Pledge_upload-bottom');
-
- // check contact name on pledge form
- $this->assertElementContainsText('css=tr.crm-pledge-form-block-displayName', "$firstName $lastName");
-
- $this->type("amount", "100");
- $this->type("installments", "10");
- $this->select("frequency_unit", "value=week");
- $this->type("frequency_day", "2");
-
- $this->webtestFillDate('acknowledge_date', 'now');
-
- $this->select("contribution_page_id", "value=3");
-
- //PaymentReminders
- $this->click("PaymentReminders");
- $this->waitForElementPresent("additional_reminder_day");
- $this->type("initial_reminder_day", "4");
- $this->type("max_reminders", "2");
- $this->type("additional_reminder_day", "4");
-
- $this->click("_qf_Pledge_upload-bottom");
-
- $this->waitForText('crm-notification-container', "Pledge has been recorded and the payment schedule has been created.");
-
- $this->waitForElementPresent("xpath=//div[@class='view-content']//table//tbody/tr[1]/td[10]/span[1]/a[text()='View']");
- //click through to the Pledge view screen
- $this->click("xpath=//div[@class='view-content']//table//tbody/tr[1]/td[10]/span[1]/a[text()='View']");
- $this->waitForElementPresent("_qf_PledgeView_next-bottom");
- $pledgeDate = date('F jS, Y', strtotime('now'));
-
- $verifyData = array(
- 'Pledge By' => $firstName . ' ' . $lastName,
- 'Total Pledge Amount' => '$ 100.00',
- 'To be paid in' => '10 installments of $ 10.00 every 1 week(s)',
- 'Payments are due on the' => '2 day of the period',
- 'Pledge Made' => $pledgeDate,
- 'Financial Type' => 'Donation',
- 'Pledge Status' => 'Pending',
- 'Initial Reminder Day' => '4 days prior to schedule date',
- 'Maximum Reminders Send' => 2,
- 'Send additional reminders' => '4 days after the last one sent',
- );
-
- foreach ($verifyData as $label => $value) {
- $this->verifyText("xpath=//form[@id='PledgeView']//table/tbody/tr/td[text()='{$label}']/following-sibling::td", preg_quote($value));
- }
-
- $this->clickLink("_qf_PledgeView_next-bottom", "xpath=//form[@class='CRM_Pledge_Form_Search crm-search-form']/div/table/tbody/tr[1]/td[10]/span[1]/a[text()='View']", FALSE);
-
- $this->waitForElementPresent("xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[1]/a");
- $this->click("xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[1]/a");
- $this->waitForElementPresent("xpath=//div[@class='view-content']//table//tbody//tr//td/div/table/tbody/tr[2]/td[8]/a[text()='Record Payment']");
- // Re-enable pop-ups to leave things in the same state
- $this->enableDisablePopups(TRUE);
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Pledge_ContactContextPledgePaymentAddTest
- */
-class WebTest_Pledge_ContactContextPledgePaymentAddTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testAddPledgePaymentWithAdjustPledgePaymentSchedule() {
- $this->webtestLogin();
- $this->openCiviPage('admin/setting/localization', 'reset=1');
- $this->select("currencyLimit", "value=FJD");
- $this->click("add");
- $this->click("_qf_Localization_next-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // create unique name
- $name = substr(sha1(rand()), 0, 7);
- $firstName = 'Adam' . $name;
- $lastName = 'Jones' . $name;
-
- // create new contact
- $this->webtestAddContact($firstName, $lastName, $firstName . "@example.com");
-
- // wait for action element
- $this->waitForElementPresent('crm-contact-actions-link');
-
- // now add pledge from contact summary
- $this->click("xpath=//div[@class='crm-actions-ribbon']/ul[@id='actions']/li[@class='crm-contact-activity crm-summary-block']/div/a[@id='crm-contact-actions-link']");
- $this->waitForElementPresent('crm-contact-actions-list');
-
- // wait for add pledge link
- $this->waitForElementPresent('link=Add Pledge');
-
- $this->click('link=Add Pledge');
-
- // wait for pledge form to load completely
- $this->waitForElementPresent('_qf_Pledge_upload-bottom');
-
- // check contact name on pledge form
- $this->assertElementContainsText('css=tr.crm-pledge-form-block-displayName', "$firstName $lastName");
-
- $this->select("currency", "value=FJD");
- $this->type("amount", "30");
- $this->type("installments", "3");
- $this->select("frequency_unit", "value=week");
- $this->type("frequency_day", "2");
-
- $this->webtestFillDate('acknowledge_date', 'now');
- $this->select("financial_type_id", "label=Donation");
-
- $this->select("contribution_page_id", "value=3");
-
- //PaymentReminders
- $this->click("PaymentReminders");
- $this->waitForElementPresent("additional_reminder_day");
- $this->type("initial_reminder_day", "4");
- $this->type("max_reminders", "2");
- $this->type("additional_reminder_day", "4");
-
- $this->click("_qf_Pledge_upload-bottom");
- $this->waitForElementPresent('link=Add Pledge');
-
- $this->waitForText('crm-notification-container', "Pledge has been recorded and the payment schedule has been created.");
- $this->waitForElementPresent("xpath=//table[@class='selector row-highlight']//tbody/tr[1]/td[10]/span/a[text()='View']");
- //click through to the Pledge view screen
- $this->click("xpath=//div[@class='view-content']//table//tbody/tr[1]/td[10]/span/a[text()='View']");
- $this->waitForElementPresent("_qf_PledgeView_next-bottom");
- $pledgeDate = date('F jS, Y', strtotime('now'));
-
- $this->webtestVerifyTabularData(array(
- 'Pledge By' => $firstName . ' ' . $lastName,
- 'Total Pledge Amount' => '$ 30.00',
- 'To be paid in' => '3 installments of $ 10.00 every 1 week(s)',
- 'Payments are due on the' => '2 day of the period',
- 'Pledge Made' => $pledgeDate,
- 'Financial Type' => 'Donation',
- 'Pledge Status' => 'Pending',
- 'Initial Reminder Day' => '4 days prior to schedule date',
- 'Maximum Reminders Send' => 2,
- 'Send additional reminders' => '4 days after the last one sent',
- )
- );
-
- $this->clickLink("_qf_PledgeView_next-bottom", "xpath=//div[@class='view-content']//table//tbody/tr[1]/td[10]/span/a[text()='View']", FALSE);
- $this->waitForAjaxContent();
- $this->click("xpath=//form[@class='CRM_Pledge_Form_Search crm-search-form']/div[2]/table[@class='selector row-highlight']/tbody/tr[1]/td[1]/a");
- $this->waitForElementPresent("xpath=//form[@class='CRM_Pledge_Form_Search crm-search-form']/div[2]/table/tbody/tr[2]/td/div/table/tbody/tr[2]/td[8]/a[text()='Record Payment']");
- $this->click("xpath=//form[@class='CRM_Pledge_Form_Search crm-search-form']/div[2]/table/tbody/tr[2]/td/div/table/tbody/tr[2]/td[8]/a[text()='Record Payment']");
- $this->waitForElementPresent("xpath=//form[@id='Contribution']//table//tbody/tr[3]/td[2]/a[text()='adjust payment amount']");
- $this->click("xpath=//form[@id='Contribution']//table//tbody/tr[3]/td[2]/a[text()='adjust payment amount']");
- $this->waitForElementPresent("adjust-option-type");
- $this->type("total_amount", "5");
- $this->click("_qf_Contribution_upload");
- $this->waitForText('crm-notification-container', "The contribution record has been saved.");
-
- $this->waitForElementPresent("xpath=//div[@class='view-content']//table//tbody/tr[1]/td[10]/span/a[text()='View']");
- $this->waitForAjaxContent();
- $this->click("xpath=//form[@class='CRM_Pledge_Form_Search crm-search-form']/div[2]/table/tbody/tr[1]/td[1]/a");
-
- $this->waitForElementPresent("xpath=//table[@class='selector row-highlight']/tbody/tr[2]/td/div/table/tbody/tr[3]/td[8]/a[text()='Record Payment']");
- $this->click("xpath=//form[@class='CRM_Pledge_Form_Search crm-search-form']/div[2]/table/tbody/tr[2]/td/div/table/tbody/tr[3]/td[8]/a[text()='Record Payment']");
- $this->waitForElementPresent("xpath=//form[@id='Contribution']//table//tbody/tr[3]/td[2]/a[text()='adjust payment amount']");
- $this->click("xpath=//form[@id='Contribution']//table//tbody/tr[3]/td[2]/a[text()='adjust payment amount']");
- $this->waitForElementPresent("adjust-option-type");
- $this->type("total_amount", "10");
-
- $this->click("_qf_Contribution_upload");
- $this->waitForText('crm-notification-container', "The contribution record has been saved.");
-
- $this->waitForElementPresent("xpath=//div[@class='view-content']//table//tbody/tr[1]/td[10]/span/a[text()='View']");
- //click through to the Pledge view screen
- $this->click("xpath=//div[@class='view-content']//table//tbody/tr[1]/td[10]/span/a[text()='View']");
- $this->waitForElementPresent("_qf_PledgeView_next-bottom");
- $pledgeDate = date('F jS, Y', strtotime('now'));
-
- $this->webtestVerifyTabularData(array(
- 'Pledge By' => $firstName . ' ' . $lastName,
- 'Total Pledge Amount' => '$ 30.00',
- 'To be paid in' => '3 installments of $ 10.00 every 1 week(s)',
- 'Payments are due on the' => '2 day of the period',
- 'Pledge Made' => $pledgeDate,
- 'Financial Type' => 'Donation',
- 'Pledge Status' => 'In Progress',
- 'Initial Reminder Day' => '4 days prior to schedule date',
- 'Maximum Reminders Send' => 2,
- 'Send additional reminders' => '4 days after the last one sent',
- )
- );
-
- $this->clickLink("_qf_PledgeView_next-bottom", "xpath=//div[@class='view-content']//table//tbody/tr[1]/td[10]/span/a[text()='View']", FALSE);
- $this->waitForAjaxContent();
- $this->click("xpath=//form[@class='CRM_Pledge_Form_Search crm-search-form']/div[2]/table/tbody/tr[1]/td[1]/a");
- $this->waitForElementPresent("xpath=//form[@class='CRM_Pledge_Form_Search crm-search-form']/div[2]/table/tbody/tr[2]/td/div/table/tbody/tr[4]/td[8]/a[text()='Record Payment']");
- $this->click("xpath=//form[@class='CRM_Pledge_Form_Search crm-search-form']/div[2]/table/tbody/tr[2]/td/div/table/tbody/tr[4]/td[8]/a[text()='Record Payment']");
- $this->waitForElementPresent("xpath=//form[@id='Contribution']//table//tbody/tr[3]/td[2]/a[text()='adjust payment amount']");
-
- $this->waitForElementPresent("xpath=//form[@id='Contribution']//table//tbody/tr[3]/td[2]/a[text()='adjust payment amount']");
- $this->click("xpath=//form[@id='Contribution']//table//tbody/tr[3]/td[2]/a[text()='adjust payment amount']");
- $this->waitForElementPresent("adjust-option-type");
- $this->type("total_amount", "10");
-
- $this->waitForElementPresent("_qf_Contribution_upload");
- $this->click("_qf_Contribution_upload");
- $this->waitForText('crm-notification-container', "The contribution record has been saved.");
-
- $this->waitForElementPresent("xpath=//div[@class='view-content']//table//tbody/tr[1]/td[10]/span/a[text()='View']");
- $this->waitForAjaxContent();
- $this->click("xpath=//table[@class='selector row-highlight']/tbody/tr[1]/td[1]/a");
- $this->waitForAjaxContent();
- $this->waitForElementPresent("xpath=//form[@class='CRM_Pledge_Form_Search crm-search-form']/div[2]/table/tbody/tr[2]/td/div/table/tbody/tr[5]/td[8]/a[text()='Record Payment']");
- $this->click("xpath=//form[@class='CRM_Pledge_Form_Search crm-search-form']/div[2]/table/tbody/tr[2]/td/div/table/tbody/tr[5]/td[8]/a[text()='Record Payment']");
-
- $this->waitForElementPresent("_qf_Contribution_upload");
- $this->click("_qf_Contribution_upload");
- $this->waitForText('crm-notification-container', "The contribution record has been saved.");
-
- $this->waitForElementPresent("xpath=//form[@class='CRM_Pledge_Form_Search crm-search-form']/div[@class='view-content']//table//tbody/tr[1]/td[10]/span/a[text()='View']");
- $this->click("xpath=//form[@class='CRM_Pledge_Form_Search crm-search-form']/div[2]/table/tbody/tr[1]/td[10]/span/a[text()='View']");
-
- $this->waitForElementPresent("_qf_PledgeView_next-bottom");
- $this->webtestVerifyTabularData(array(
- 'Pledge By' => $firstName . ' ' . $lastName,
- 'Total Pledge Amount' => '$ 30.00',
- 'To be paid in' => '3 installments of $ 10.00 every 1 week(s)',
- 'Payments are due on the' => '2 day of the period',
- 'Pledge Made' => $pledgeDate,
- 'Financial Type' => 'Donation',
- 'Pledge Status' => 'Completed',
- 'Initial Reminder Day' => '4 days prior to schedule date',
- 'Maximum Reminders Send' => 2,
- 'Send additional reminders' => '4 days after the last one sent',
- )
- );
- $this->openCiviPage('admin/setting/localization', 'reset=1');
- $this->waitForElementPresent("currencyLimit");
- $this->select("currencyLimit", "value=FJD");
- $this->click("remove");
- $this->click("_qf_Localization_next-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- }
-
- public function testAddPledgePaymentWithAdjustTotalPledgeAmount() {
- $this->webtestLogin();
- // Disable pop-ups for this test. Running test w/ pop-ups causes a spurious failure. dgg
- $this->enableDisablePopups(FALSE);
-
- // create unique name
- $name = substr(sha1(rand()), 0, 7);
- $firstName = 'Adam' . $name;
- $lastName = 'Jones' . $name;
-
- // create new contact
- $this->webtestAddContact($firstName, $lastName, $firstName . "@example.com");
-
- // wait for action element
- $this->waitForElementPresent('crm-contact-actions-link');
-
- // now add pledge from contact summary
- $this->click("xpath=//div[@class='crm-actions-ribbon']/ul[@id='actions']/li[@class='crm-contact-activity crm-summary-block']/div/a[@id='crm-contact-actions-link']");
- $this->waitForElementPresent('crm-contact-actions-list');
-
- // wait for add plegde link
- $this->waitForElementPresent('link=Add Pledge');
-
- $this->click('link=Add Pledge');
-
- // wait for pledge form to load completely
- $this->waitForElementPresent('_qf_Pledge_upload-bottom');
-
- // check contact name on pledge form
- $this->assertElementContainsText('css=tr.crm-pledge-form-block-displayName', "$firstName $lastName");
-
- $this->type("amount", "30");
- $this->type("installments", "3");
- $this->select("frequency_unit", "value=week");
- $this->type("frequency_day", "2");
-
- $this->webtestFillDate('acknowledge_date', 'now');
-
- $this->select("contribution_page_id", "value=3");
-
- //PaymentReminders
- $this->click("PaymentReminders");
- $this->waitForElementPresent("additional_reminder_day");
- $this->type("initial_reminder_day", "4");
- $this->type("max_reminders", "2");
- $this->type("additional_reminder_day", "4");
-
- $this->click("_qf_Pledge_upload-bottom");
-
- $this->waitForText('crm-notification-container', "Pledge has been recorded and the payment schedule has been created.");
-
- $this->waitForElementPresent("xpath=//div[@class='view-content']//table//tbody/tr[1]/td[10]/span/a[text()='View']");
- //click through to the Pledge view screen
- $this->click("xpath=//div[@class='view-content']//table//tbody/tr[1]/td[10]/span/a[text()='View']");
- $this->waitForElementPresent("_qf_PledgeView_next-bottom");
- $pledgeDate = date('F jS, Y', strtotime('now'));
-
- $this->webtestVerifyTabularData(array(
- 'Pledge By' => $firstName . ' ' . $lastName,
- 'Total Pledge Amount' => '$ 30.00',
- 'To be paid in' => '3 installments of $ 10.00 every 1 week(s)',
- 'Payments are due on the' => '2 day of the period',
- 'Pledge Made' => $pledgeDate,
- 'Financial Type' => 'Donation',
- 'Pledge Status' => 'Pending',
- 'Initial Reminder Day' => '4 days prior to schedule date',
- 'Maximum Reminders Send' => 2,
- 'Send additional reminders' => '4 days after the last one sent',
- )
- );
- $this->clickLink("_qf_PledgeView_next-bottom", "xpath=//div[@class='view-content']//table//tbody/tr[1]/td[10]/span/a[text()='View']", FALSE);
- $this->click("xpath=//table[@class='selector row-highlight']/tbody/tr[1]/td[1]/a");
- $this->waitForElementPresent("xpath=//table/tbody/tr[2]/td/div/table/tbody/tr[2]/td[8]/a[text()='Record Payment']");
- $this->click("xpath=//table/tbody/tr[2]/td/div/table/tbody/tr[2]/td[8]/a[text()='Record Payment']");
- $this->waitForElementPresent("xpath=//form[@id='Contribution']//table//tbody/tr[3]/td[2]/a[text()='adjust payment amount']");
- $this->click("xpath=//form[@id='Contribution']//table//tbody/tr[3]/td[2]/a[text()='adjust payment amount']");
- $this->waitForElementPresent("adjust-option-type");
- $this->waitForElementPresent("CIVICRM_QFID_2_option_type");
- $this->click("CIVICRM_QFID_2_option_type");
- $this->type("total_amount", "15");
- $this->click("_qf_Contribution_upload");
-
- $this->waitForElementPresent("xpath=//form[@class='CRM_Pledge_Form_Search crm-search-form']/div[2]/table/tbody/tr[1]/td[10]/span/a[text()='View']");
- $this->click("xpath=//form[@class='CRM_Pledge_Form_Search crm-search-form']/div[2]/table/tbody/tr[1]/td[1]/a");
- $this->waitForElementPresent("xpath=//form[@class='CRM_Pledge_Form_Search crm-search-form']/div[2]/table/tbody/tr[2]/td/div/table/tbody/tr[3]/td[8]/a[text()='Record Payment']");
- $this->click("xpath=//div[@class='view-content']//table//tbody/tr[2]/td/div/table/tbody/tr[3]/td[8]/a[text()='Record Payment']");
- $this->waitForElementPresent("xpath=//form[@id='Contribution']//table//tbody/tr[3]/td[2]/a[text()='adjust payment amount']");
- $this->click("xpath=//form[@id='Contribution']//table//tbody/tr[3]/td[2]/a[text()='adjust payment amount']");
- $this->waitForElementPresent("adjust-option-type");
- $this->waitForElementPresent("CIVICRM_QFID_2_option_type");
- $this->click("CIVICRM_QFID_2_option_type");
- $this->type("total_amount", "15");
-
- $this->click("_qf_Contribution_upload");
-
- $this->waitForElementPresent("xpath=//div[@class='view-content']//table//tbody/tr[1]/td[10]/span/a[text()='View']");
- //click through to the Pledge view screen
- $this->click("xpath=//div[@class='view-content']//table//tbody/tr[1]/td[10]/span/a[text()='View']");
- $this->waitForElementPresent("_qf_PledgeView_next-bottom");
- $pledgeDate = date('F jS, Y', strtotime('now'));
-
- $this->webtestVerifyTabularData(array(
- 'Pledge By' => $firstName . ' ' . $lastName,
- 'Total Pledge Amount' => '$ 40.00',
- 'To be paid in' => '3 installments of $ 10.00 every 1 week(s)',
- 'Payments are due on the' => '2 day of the period',
- 'Pledge Made' => $pledgeDate,
- 'Financial Type' => 'Donation',
- 'Pledge Status' => 'In Progress',
- 'Initial Reminder Day' => '4 days prior to schedule date',
- 'Maximum Reminders Send' => 2,
- 'Send additional reminders' => '4 days after the last one sent',
- )
- );
-
- $this->clickLink("_qf_PledgeView_next-bottom", "xpath=//div[@class='view-content']//table//tbody/tr[1]/td[10]/span/a[text()='View']", FALSE);
- $this->waitForAjaxContent();
- $this->click("xpath=//form[@class='CRM_Pledge_Form_Search crm-search-form']/div[2]/table/tbody/tr[1]/td[1]/a");
- $this->waitForElementPresent("xpath=//form[@class='CRM_Pledge_Form_Search crm-search-form']/div[2]/table/tbody/tr[2]/td/div/table/tbody/tr[4]/td[8]/a[text()='Record Payment']");
- $this->click("xpath=//form[@class='CRM_Pledge_Form_Search crm-search-form']/div[2]/table/tbody/tr[2]/td/div/table/tbody/tr[4]/td[8]/a[text()='Record Payment']");
-
- $this->waitForElementPresent("_qf_Contribution_upload");
- $this->click("_qf_Contribution_upload");
-
- $this->waitForElementPresent("xpath=//div[@class='view-content']//table//tbody/tr[1]/td[10]/span/a[text()='View']");
- $this->click("xpath=//div[@class='view-content']//table//tbody/tr[1]/td[10]/span/a[text()='View']");
-
- $this->waitForElementPresent("_qf_PledgeView_next-bottom");
- $this->webtestVerifyTabularData(array(
- 'Pledge By' => $firstName . ' ' . $lastName,
- 'Total Pledge Amount' => '$ 40.00',
- 'To be paid in' => '3 installments of $ 10.00 every 1 week(s)',
- 'Payments are due on the' => '2 day of the period',
- 'Pledge Made' => $pledgeDate,
- 'Financial Type' => 'Donation',
- 'Pledge Status' => 'Completed',
- 'Initial Reminder Day' => '4 days prior to schedule date',
- 'Maximum Reminders Send' => 2,
- 'Send additional reminders' => '4 days after the last one sent',
- )
- );
- // Re-enable pop-ups to leave things in the same state
- $this->enableDisablePopups(TRUE);
- }
-
- public function testAddPledgePayment() {
- $this->webtestLogin();
-
- // create unique name
- $name = substr(sha1(rand()), 0, 7);
- $firstName = 'Adam' . $name;
- $lastName = 'Jones' . $name;
-
- // create new contact
- $this->webtestAddContact($firstName, $lastName, $firstName . "@example.com");
-
- // wait for action element
- $this->waitForElementPresent('crm-contact-actions-link');
-
- // now add pledge from contact summary
- $this->click("xpath=//div[@class='crm-actions-ribbon']/ul[@id='actions']/li[@class='crm-contact-activity crm-summary-block']/div/a[@id='crm-contact-actions-link']");
- $this->waitForElementPresent('crm-contact-actions-list');
-
- // wait for add plegde link
- $this->waitForElementPresent('link=Add Pledge');
-
- $this->click('link=Add Pledge');
-
- // wait for pledge form to load completely
- $this->waitForElementPresent('_qf_Pledge_upload-bottom');
-
- // check contact name on pledge form
- $this->assertElementContainsText('css=tr.crm-pledge-form-block-displayName', "$firstName $lastName");
-
- $this->type("amount", "30");
- $this->type("installments", "3");
- $this->select("frequency_unit", "value=week");
- $this->type("frequency_day", "2");
-
- $this->webtestFillDate('acknowledge_date', 'now');
-
- $this->select("contribution_page_id", "value=3");
-
- //PaymentReminders
- $this->click("PaymentReminders");
- $this->waitForElementPresent("additional_reminder_day");
- $this->type("initial_reminder_day", "4");
- $this->type("max_reminders", "2");
- $this->type("additional_reminder_day", "4");
-
- $this->click("_qf_Pledge_upload-bottom");
-
- $this->waitForText('crm-notification-container', "Pledge has been recorded and the payment schedule has been created.");
-
- //Add payments
- $this->waitForElementPresent("xpath=//div[@class='view-content']//table//tbody/tr[1]/td[10]/span/a[text()='View']");
- $this->click("xpath=//form[@class='CRM_Pledge_Form_Search crm-search-form']/div[2]/table[@class='selector row-highlight']/tbody/tr[1]/td[1]/a");
- $this->waitForElementPresent("xpath=//form[@class='CRM_Pledge_Form_Search crm-search-form']/div[2]/table/tbody/tr[2]/td/div/table/tbody/tr[2]/td[8]/a[text()='Record Payment']");
- $this->click("xpath=//form[@class='CRM_Pledge_Form_Search crm-search-form']/div[2]/table/tbody/tr[2]/td/div/table/tbody/tr[2]/td[8]/a[text()='Record Payment']");
- $this->waitForElementPresent("_qf_Contribution_upload");
- $this->click("_qf_Contribution_upload");
- $this->waitForText('crm-notification-container', "The contribution record has been saved.");
-
- $this->waitForElementPresent("xpath=//div[@class='view-content']//table//tbody/tr[1]/td[10]/span/a[text()='View']");
- $this->waitForAjaxContent();
- $this->click("xpath=//table[@class='selector row-highlight']/tbody/tr[1]/td[1]/a");
- $this->waitForElementPresent("xpath=//form[@class='CRM_Pledge_Form_Search crm-search-form']/div[2]/table/tbody/tr[2]/td/div/table/tbody/tr[3]/td[8]/a[text()='Record Payment']");
- $this->click("xpath=//form[@class='CRM_Pledge_Form_Search crm-search-form']/div[2]/table/tbody/tr[2]/td/div/table/tbody/tr[3]/td[8]/a[text()='Record Payment']");
- $this->waitForElementPresent("_qf_Contribution_upload");
- $this->click("_qf_Contribution_upload");
-
- $this->waitForText('crm-notification-container', "The contribution record has been saved.");
- $this->waitForElementPresent("xpath=//div[@class='view-content']//table//tbody/tr[1]/td[10]/span/a[text()='View']");
- $this->waitForAjaxContent();
- $this->click("xpath=//table[@class='selector row-highlight']/tbody/tr[1]/td[1]/a");
- $this->waitForElementPresent("xpath=//form[@class='CRM_Pledge_Form_Search crm-search-form']/div[2]/table/tbody/tr[2]/td/div/table/tbody/tr[4]/td[8]/a[text()='Record Payment']");
- $this->click("xpath=//form[@class='CRM_Pledge_Form_Search crm-search-form']/div[2]/table/tbody/tr[2]/td/div/table/tbody/tr[4]/td[8]/a[text()='Record Payment']");
- $this->waitForElementPresent("_qf_Contribution_upload");
- $this->click("_qf_Contribution_upload");
-
- $this->waitForElementPresent("xpath=//form[@class='CRM_Pledge_Form_Search crm-search-form']/div[2]/table/tbody/tr[1]/td[10]/span/a[text()='View']");
- //click through to the Pledge view screen
- $this->click("xpath=//form[@class='CRM_Pledge_Form_Search crm-search-form']/div[2]/table/tbody/tr[1]/td[10]/span/a[text()='View']");
- $this->waitForElementPresent("_qf_PledgeView_next-bottom");
- $pledgeDate = date('F jS, Y', strtotime('now'));
-
- $this->webtestVerifyTabularData(array(
- 'Pledge By' => $firstName . ' ' . $lastName,
- 'Total Pledge Amount' => '$ 30.00',
- 'To be paid in' => '3 installments of $ 10.00 every 1 week(s)',
- 'Payments are due on the' => '2 day of the period',
- 'Pledge Made' => $pledgeDate,
- 'Financial Type' => 'Donation',
- 'Pledge Status' => 'Completed',
- 'Initial Reminder Day' => '4 days prior to schedule date',
- 'Maximum Reminders Send' => 2,
- 'Send additional reminders' => '4 days after the last one sent',
- )
- );
- // Re-enable pop-ups to leave things in the same state
- $this->enableDisablePopups(TRUE);
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Pledge_StandaloneAddDeleteTest
- */
-class WebTest_Pledge_StandaloneAddDeleteTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testStandalonePledgeAddDelete() {
- $this->webtestLogin();
-
- $this->openCiviPage('pledge/add', 'reset=1&context=standalone', '_qf_Pledge_upload');
-
- // create new contact using dialog
- $contact = $this->createDialogContact();
-
- $this->type('amount', '2400');
- $this->type('installments', '10');
- $this->select('frequency_unit', 'value=month');
- $this->type('frequency_day', '2');
- $this->webtestFillDate('acknowledge_date', 'now');
- $this->select('contribution_page_id', 'value=3');
- $this->click('_qf_Pledge_upload-bottom');
- $this->waitForPageToLoad("30000");
-
- $this->waitForText('crm-notification-container', "Pledge has been recorded and the payment schedule has been created.");
-
- // verify if Pledge is created
- $this->waitForElementPresent("xpath=//div[@class='view-content']//table//tbody/tr[1]/td[10]/span/a[text()='View']");
-
- //click through to the Pledge view screen
- $this->click("xpath=//div[@class='view-content']//table//tbody/tr[1]/td[10]/span/a[text()='View']");
- $this->waitForElementPresent('_qf_PledgeView_next-bottom');
- $pledgeDate = date('F jS, Y', strtotime('now'));
-
- $this->webtestVerifyTabularData(array(
- 'Pledge By' => $contact['display_name'],
- 'Total Pledge Amount' => '$ 2,400.00',
- 'To be paid in' => '10 installments of $ 240.00 every 1 month(s)',
- 'Payments are due on the' => '2 day of the period',
- 'Pledge Made' => $pledgeDate,
- 'Financial Type' => 'Donation',
- 'Pledge Status' => 'Pending',
- )
- );
- $this->click('_qf_PledgeView_next-bottom');
- $this->waitForElementPresent("xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[1]/a");
- $this->waitForAjaxContent();
- $this->click("xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[1]/a");
- $this->waitForElementPresent("xpath=//div[@class='view-content']//table//tbody/tr[2]/td/div/table/tbody/tr[2]/td[8]/a[text()='Record Payment']");
- $this->click("xpath=//div[@class='view-content']//table//tbody/tr[2]/td/div/table/tbody/tr[2]/td[8]/a");
- $this->waitForElementPresent("xpath=//form[@id='Contribution']//div[2]/table/tbody/tr[3]/td[2]/a");
- $this->click("xpath=//form[@id='Contribution']//div[2]/table/tbody/tr[3]/td[2]/a");
- $this->type('total_amount', '300.00');
- $this->click('_qf_Contribution_upload-bottom');
-
- $this->waitForText('crm-notification-container', "The contribution record has been saved.");
-
- $this->waitForElementPresent("xpath=//div[@class='view-content']//table//tbody/tr[1]/td[10]/span/a[text()='View']");
- $this->waitForAjaxContent();
- $this->click("xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[1]/a");
- $this->waitForElementPresent("xpath=//div[@class='view-content']//table/tbody/tr[2]/td/div/table/tbody/tr[3]/td[8]/a[text()='Record Payment']");
- $this->click("xpath=//div[@class='view-content']//table/tbody/tr[2]/td/div/table/tbody/tr[3]/td[8]/a");
- $this->waitForElementPresent("xpath=//form[@id='Contribution']//div[2]/table/tbody/tr[3]/td[2]/a");
- $this->click("xpath=//form[@id='Contribution']//div[2]/table/tbody/tr[3]/td[2]/a");
- $this->type('total_amount', '250.00');
- $this->click('_qf_Contribution_upload-bottom');
- $this->waitForText('crm-notification-container', "The contribution record has been saved.");
-
- $this->waitForElementPresent("xpath=//div[@class='view-content']//table//tbody/tr[1]/td[10]/span/a[text()='View']");
- $this->waitForAjaxContent();
- $this->click("xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[1]/a");
- $this->waitForElementPresent("xpath=//div[@class='view-content']//table/tbody/tr[2]/td/div/table/tbody/tr[4]/td[8]/a[text()='Record Payment']");
- $this->click("xpath=//div[@class='view-content']//table/tbody/tr[2]/td/div/table/tbody/tr[4]/td[8]/a");
- $this->waitForElementPresent("xpath=//form[@id='Contribution']//div[2]/table/tbody/tr[3]/td[2]/a");
- $this->click("xpath=//form[@id='Contribution']//div[2]/table/tbody/tr[3]/td[2]/a");
-
- $this->type('total_amount', '170.00');
- $this->click('_qf_Contribution_upload-bottom');
- $this->waitForText('crm-notification-container', "The contribution record has been saved.");
-
- // delete the contribution associated with the 2nd payment
- $this->waitForElementPresent("xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[10]/span/a[text()='View']");
- $this->waitForAjaxContent();
- $this->click("xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[1]/a");
- $this->waitForElementPresent("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[2]/td/div/table[@class='nestedSelector']/tbody/tr[3]/td[8]/a[text()='View Payment']");
- $this->click("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[2]/td/div/table[@class='nestedSelector']/tbody/tr[3]/td[8]/a");
- $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']/button[2]");
- $this->click("xpath=//div[@class='ui-dialog-buttonset']/button[2]");
- $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']//button/span[text()='Delete']");
- $this->waitForAjaxContent();
- $this->click("xpath=//div[@class='ui-dialog-buttonset']//button/span[text()='Delete']");
- $this->waitForAjaxContent();
- $this->waitForElementPresent("xpath=//li[@id='tab_pledge']/a");
- $this->click("xpath=//li[@id='tab_pledge']/a");
- $this->waitForElementPresent("xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[10]/span/a[text()='View']");
- $this->waitForAjaxContent();
- $this->click("xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[1]/a");
- $this->waitForElementPresent("xpath=//div[@class='view-content']//table/tbody/tr[2]/td/div/table/tbody/tr[3]/td[7]");
-
- $this->waitForAjaxContent();
- $this->verifyText("xpath=//div[@class='view-content']//table/tbody/tr[2]/td/div/table/tbody/tr[3]/td[7]", "Pending");
- $this->waitForElementPresent("xpath=//div[@class='view-content']//table/tbody/tr[2]/td/div/table/tbody/tr[3]/td");
-
- // verify that payment owed amount is correct (250.00)
- $this->waitForAjaxContent();
- $this->verifyText("xpath=//div[@class='view-content']//table/tbody/tr[2]/td/div/table/tbody/tr[3]/td", "250.00");
- // verify that Total Paid and Balance sums are correct
- $this->waitForAjaxContent();
- $this->verifyText("xpath=//div[@class='view-content']/table[@class='selector row-highlight']//tbody/tr[1]/td[3]", "470.00");
- $this->verifyText("xpath=//div[@class='view-content' and contains(., 'view pledge payments')]/table[@class='selector row-highlight']//tbody/tr[1]/td[4]", "1,930.00");
-
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Pledge_StandaloneAddTest
- */
-class WebTest_Pledge_StandaloneAddTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- /**
- * Add pledge
- */
- public function testStandalonePledgeAdd() {
- $this->webtestStandalonePledgeAdd();
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Profile_BatchUpdateTest
- */
-class WebTest_Profile_BatchUpdateTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testBatchUpdateWithContactSubtypes() {
- // Log in using webtestLogin() method
- $this->webtestLogin();
-
- // Add new individual using Quick Add block on the main page
- $firstName1 = "John_" . substr(sha1(rand()), 0, 7);
- $lastName1 = "Smiths_x" . substr(sha1(rand()), 0, 7);
- $Name1 = $lastName1 . ', ' . $firstName1;
- $this->webtestAddContact($firstName1, $lastName1, "$firstName1.$lastName1@example.com");
-
- // Add new individual using Quick Add block on the main page
- $firstName2 = "James_" . substr(sha1(rand()), 0, 7);
- $lastName2 = "Smiths_x" . substr(sha1(rand()), 0, 7);
- $Name2 = $lastName2 . ', ' . $firstName2;
-
- $firstName3 = "James_" . substr(sha1(rand()), 0, 7);
- $lastName3 = "Smiths_x" . substr(sha1(rand()), 0, 7);
- $Name3 = $lastName3 . ', ' . $firstName3;
-
- $this->webtestAddContact($firstName2, $lastName2, "$firstName2.$lastName2@example.com", "Student");
- $this->webtestAddContact($firstName3, $lastName3, "$firstName3.$lastName3@example.com", "Staff");
-
- $profileTitle = 'Batch Profile test_' . substr(sha1(rand()), 0, 7);
- $profileFields = array(
- array(
- 'type' => 'Individual',
- 'name' => 'Last Name',
- 'label' => 'Last Name',
- ),
- );
- $this->addProfile($profileTitle, $profileFields);
- $this->openCiviPage('contact/search', 'reset=1', '_qf_Basic_refresh');
- $this->type('sort_name', "Smiths_x");
- $this->click('_qf_Basic_refresh');
-
- // Update multiple contacts
- $this->waitForElementPresent('CIVICRM_QFID_ts_all_4');
- $this->click('CIVICRM_QFID_ts_all_4');
-
- $this->select('task', "label=Update multiple contacts");
- $this->waitForElementPresent('_qf_PickProfile_next');
- $this->waitForElementPresent('uf_group_id');
- $this->select('uf_group_id', "label={$profileTitle}");
- $this->click('_qf_PickProfile_next');
-
- $this->waitForElementPresent('_qf_Batch_next');
-
- $this->isElementPresent("xpath=//form[@id='Batch']/div[2]/table/tbody//tr/td[text()='{$Name2}']");
- $this->isElementPresent("xpath=//form[@id='Batch']/div[2]/table/tbody//tr/td[text()='{$Name1}']");
- $this->isElementPresent("xpath=//form[@id='Batch']/div[2]/table/tbody//tr/td[text()='{$Name3}']");
- // selecting first check of profile
- $this->click("xpath=//form[@id='Batch']/div[2]/table/tbody/tr/td[2]/input");
-
- $this->waitForElementPresent('_qf_Batch_next');
- $this->click("xpath=//table[@class='crm-copy-fields']/thead/tr/td[2]/img");
- // Because it tends to cause problems, all uses of sleep() must be justified in comments
- // Sleep should never be used for wait for anything to load from the server
- // Justification for this instance: FIXME
- sleep(5);
- //$this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForElementPresent('_qf_Batch_next');
- $this->click('_qf_Batch_next');
- $this->waitForElementPresent('_qf_Result_done');
- $this->click('_qf_Result_done');
-
- // Find contact and assert for contact sub type
- $this->openCiviPage('contact/search', 'reset=1', '_qf_Basic_refresh');
- $this->type('sort_name', $firstName2);
- $this->click('_qf_Basic_refresh');
- $this->waitForElementPresent("xpath=//div[@class='crm-search-results']/table/tbody//td/span/a[text()='View']");
- $this->click("xpath=//div[@class='crm-search-results']/table/tbody//td/span/a[text()='View']");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $xpath = "xpath=//div[@id='contact-summary']/div/div[2]/div/div/div[2]/div[@class='crm-content crm-contact_type_label']";
- $this->verifyText($xpath, preg_quote("Student"));
-
- $this->openCiviPage('contact/search', 'reset=1', '_qf_Basic_refresh');
- $this->type('sort_name', $firstName3);
- $this->click('_qf_Basic_refresh');
- $this->waitForElementPresent("xpath=//div[@class='crm-search-results']/table/tbody//td/span/a[text()='View']");
- $this->click("xpath=//div[@class='crm-search-results']/table/tbody//td/span/a[text()='View']");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $xpath = "xpath=//div[@id='contact-summary']/div/div[2]/div/div/div[2]/div[@class='crm-content crm-contact_type_label']";
- $this->verifyText($xpath, preg_quote("Staff"));
- }
-
- public function testBatchUpdate() {
- $this->markTestSkipped('Skipping for now as it works fine locally.');
- // Log in using webtestLogin() method
- $this->webtestLogin();
-
- // Add new individual using Quick Add block on the main page
- $firstName1 = "John_" . substr(sha1(rand()), 0, 7);
- $lastName = "Smith_" . substr(sha1(rand()), 0, 7);
- $Name1 = $lastName . ', ' . $firstName1;
- $this->webtestAddContact($firstName1, $lastName, "$firstName1.$lastName@example.com");
-
- // Add new individual using Quick Add block on the main page
- $firstName1 = "James_" . substr(sha1(rand()), 0, 7);
- $Name2 = $lastName . ', ' . $firstName1;
- $this->webtestAddContact($firstName1, $lastName, "$firstName1.$lastName@example.com");
- $profileTitle = 'Batch Profile test for contacts ' . substr(sha1(rand()), 0, 7);
- $profileFor = 'Contacts';
- $customDataArr = $this->_addCustomData($profileFor);
- $this->_addProfile($profileTitle, $customDataArr, $profileFor);
-
- //setting ckeditor as WYSIWYG
- $this->openCiviPage('admin/setting/preferences/display', 'reset=1', '_qf_Display_next-bottom');
- $this->select('editor_id', 'CKEditor');
- $this->click('_qf_Display_next-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Find Contact
- $this->openCiviPage('contact/search', 'reset=1', '_qf_Basic_refresh');
- $this->type('sort_name', $lastName);
- $this->click('_qf_Basic_refresh');
-
- // Update multiple contacts
- $this->waitForElementPresent('CIVICRM_QFID_ts_all_4');
- $this->click('CIVICRM_QFID_ts_all_4');
-
- $this->select('task', "label=Update multiple contacts");
- $this->waitForElementPresent('_qf_PickProfile_next');
-
- $this->select('uf_group_id', "label={$profileTitle}");
- $this->click('_qf_PickProfile_next');
-
- $this->waitForElementPresent('_qf_Batch_next');
-
- $this->isElementPresent("xpath=//form[@id='Batch']/div[2]/table/tbody//tr/td[text()='{$Name2}']");
- $this->isElementPresent("xpath=//form[@id='Batch']/div[2]/table/tbody//tr/td[text()='{$Name1}']");
-
- // selecting first check of profile
- $this->click("xpath=//form[@id='Batch']/div[2]/table/tbody/tr/td[2]/table/tbody/tr/td/input[2]");
-
- // selecting second check of profile
- $this->click("xpath=//form[@id='Batch']/div[2]/table/tbody/tr/td[3]/input[2]");
- // clicking copy values to rows of first check and verifying
- // if other check Profile Field check box are affected
-
- $this->click("xpath=//table[@class='crm-copy-fields']/thead/tr/td[2]/img");
- // Because it tends to cause problems, all uses of sleep() must be justified in comments
- // Sleep should never be used for wait for anything to load from the server
- // Justification for this instance: FIXME
- sleep(5);
- if ($this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr/td[3]/input[2]") &&
- !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr/td[3]/input[4]") &&
- !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr/td[3]/input[6]") &&
- //verification for second field first row
- !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr[2]/td[3]/input[2]") &&
- !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr[2]/td[3]/input[4]") &&
- !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr[2]/td[3]/input[6]") &&
- //verification for first field second row
- $this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr[2]/td[2]/table/tbody/tr/td/input[2]") &&
- !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr[2]/td[2]/table/tbody/tr/td[2]/input[2]") &&
- !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr[2]/td[2]/table/tbody/tr[2]/td/input[2]")
- ) {
- $assertCheck = TRUE;
- }
- else {
- $assertCheck = FALSE;
- }
-
- $this->assertTrue($assertCheck, 'copy rows for field one failed');
-
- $this->click("xpath=//table[@class='crm-copy-fields']/thead/tr/td[3]/img");
- // Because it tends to cause problems, all uses of sleep() must be justified in comments
- // Sleep should never be used for wait for anything to load from the server
- // Justification for this instance: FIXME
- sleep(5);
- if ($this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr/td[3]/input[2]") &&
- !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr/td[3]/input[4]") &&
- !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr/td[3]/input[6]") &&
- //verification for second field first row
- $this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr[2]/td[3]/input[2]") &&
- !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr[2]/td[3]/input[4]") &&
- !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr[2]/td[3]/input[6]") &&
- //verification for first field second row
- $this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr[2]/td[2]/table/tbody/tr/td/input[2]") &&
- !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr[2]/td[2]/table/tbody/tr/td[2]/input[2]") &&
- !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr[2]/td[2]/table/tbody/tr[2]/td/input[2]")
- ) {
- $assertCheck = TRUE;
- }
- else {
- $assertCheck = FALSE;
- }
-
- $this->assertTrue($assertCheck, 'copy rows for field two failed');
-
- $dateElementIdFirstRow = $this->getAttribute("xpath=//form[@id='Batch']/div[2]/table/tbody/tr/td[4]/input/@id");
- $dateElementIdSecondRow = $this->getAttribute("xpath=//form[@id='Batch']/div[2]/table/tbody/tr[2]/td[4]/input/@id");
-
- $this->webtestFillDateTime($dateElementIdFirstRow, "+1 week");
- $this->click("xpath=//table[@class='crm-copy-fields']/thead/tr/td[4]/img");
- // Because it tends to cause problems, all uses of sleep() must be justified in comments
- // Sleep should never be used for wait for anything to load from the server
- // Justification for this instance: FIXME
- sleep(5);
-
- if ($this->getValue("{$dateElementIdFirstRow}_time") == $this->getValue("{$dateElementIdSecondRow}_time") && $this->getValue("{$dateElementIdFirstRow}") == $this->getValue("{$dateElementIdSecondRow}")) {
- $assertCheck = TRUE;
- }
- else {
- $assertCheck = FALSE;
- }
-
- $this->assertTrue($assertCheck, 'date / time coping failed');
-
- $richTextAreaIdOne = $this->getAttribute("xpath=//form[@id='Batch']/div[2]/table/tbody/tr/td[5]/textarea/@id");
- $richTextAreaIdTwo = $this->getAttribute("xpath=//form[@id='Batch']/div[2]/table/tbody/tr[2]/td[5]/textarea/@id");
-
- $this->fillRichTextField($richTextAreaIdOne, 'This is Test Introductory Message', 'CKEditor');
- $this->click("xpath=//table[@class='crm-copy-fields']/thead/tr/td[5]/img");
- // Because it tends to cause problems, all uses of sleep() must be justified in comments
- // Sleep should never be used for wait for anything to load from the server
- // Justification for this instance: FIXME
- sleep(5);
-
- if ($this->getValue($richTextAreaIdOne) == $this->getValue($richTextAreaIdTwo)) {
- $assertCheck = TRUE;
- }
- else {
- $assertCheck = FALSE;
- }
-
- $this->assertTrue($assertCheck, 'Rich Text Area coping failed');
-
- // selecting first check of profile
- $this->click("xpath=//form[@id='Batch']/div[2]/table/tbody/tr/td[6]/input");
- // selecting second check of profile
- $this->click("xpath=//form[@id='Batch']/div[2]/table/tbody/tr/td[7]/input");
- // clicking copy values to rows of first check and verifying
- // if other radio Profile Field radio buttons are affected
-
- $this->click("xpath=//table[@class='crm-copy-fields']/thead/tr/td[6]/img");
- // Because it tends to cause problems, all uses of sleep() must be justified in comments
- // Sleep should never be used for wait for anything to load from the server
- // Justification for this instance: FIXME
- sleep(5);
- if ($this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr/td[7]/input") &&
- !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr/td[7]/input[2]") &&
- !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr/td[7]/input[3]") &&
- //verification for second field first row
- !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr[2]/td[7]/input") &&
- !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr[2]/td[7]/input[2]") &&
- !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr[2]/td[7]/input[3]") &&
- //verification for first field second row
- $this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr[2]/td[6]/input") &&
- !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr[2]/td[6]/input[2]") &&
- !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr[2]/td[6]/input[3]")
- ) {
- $assertCheck = TRUE;
- }
- else {
- $assertCheck = FALSE;
- }
-
- $this->assertTrue($assertCheck, 'copy rows for field one failed[radio button]');
-
- $this->click("xpath=//table[@class='crm-copy-fields']/thead/tr/td[7]/img");
- // Because it tends to cause problems, all uses of sleep() must be justified in comments
- // Sleep should never be used for wait for anything to load from the server
- // Justification for this instance: FIXME
- sleep(5);
- if ($this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr/td[7]/input") &&
- !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr/td[7]/input[2]") &&
- !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr/td[7]/input[3]") &&
- //verification for second field first row
- $this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr[2]/td[7]/input") &&
- !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr[2]/td[7]/input[2]") &&
- !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr[2]/td[7]/input[3]") &&
- //verification for first field second row
- $this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr[2]/td[6]/input") &&
- !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr[2]/td[6]/input[2]") &&
- !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr[2]/td[6]/input[3]")
- ) {
- $assertCheck = TRUE;
- }
- else {
- $assertCheck = FALSE;
- }
-
- $this->assertTrue($assertCheck, 'copy rows for field two failed[radio button]');
-
- //campaign test for interview
- //enable CiviCampaign module if necessary
- $this->enableComponents("CiviCampaign");
-
- //Adding a survey
- $this->openCiviPage('survey/add', 'reset=1', '_qf_Main_upload-bottom');
- $surveyTitle = "BatchUpdateTest Survey" . substr(sha1(rand()), 0, 7);
- $this->type("title", $surveyTitle);
- $this->select('activity_type_id', 'label=Survey');
- $this->click('_qf_Main_upload-bottom');
- $this->waitForElementPresent('_qf_Questions_cancel-bottom');
- $this->select("//form[@id='Questions']/div[2]/table/tbody/tr[1]/td[2]/div/div/span/select", "label={$profileTitle}");
- $this->click('_qf_Questions_upload_next-bottom');
- $this->waitForElementPresent('_qf_Results_cancel-bottom');
- $this->click('CIVICRM_QFID_1_option_type');
- $this->type('option_label_1', 'option1');
- $this->type('option_value_1', 'option1');
- $this->type('option_label_2', 'option2');
- $this->type('option_value_2', 'option2');
- $this->click('_qf_Results_upload_done-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- //Reserve and interview respondents
- $this->openCiviPage('campaign', 'reset=1&subPage=survey');
- $this->waitForElementPresent("xpath=//table[@class='surveys dataTable no-footer']/tbody//tr/td[2]/div/a[text()='{$surveyTitle}']/../../following-sibling::td[@class=' crm-campaign-voterLinks']/span/ul/li/a");
- $this->click("xpath=//table[@class='surveys dataTable no-footer']/tbody//tr/td[2]/div/a[text()='{$surveyTitle}']/../../following-sibling::td[@class=' crm-campaign-voterLinks']/span/ul/li/a");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->click("xpath=//div[@id='search_form_reserve']/div");
- $this->waitForElementPresent('sort_name');
- $this->type('sort_name', $lastName);
- $this->waitForElementPresent('_qf_Search_refresh');
- $this->clickLink('_qf_Search_refresh', 'toggleSelect');
- $this->click('toggleSelect');
- $this->select('task', "value=2");
- $this->waitForElementPresent('_qf_Reserve_next_reserveToInterview-top');
- $this->clickLink('_qf_Reserve_next_reserveToInterview-top', '_qf_Interview_cancel_interview');
-
- $this->isElementPresent("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody//tr/td[2][text()='{$Name2}']");
- $this->isElementPresent("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody//tr/td[2][text()='{$Name1}']");
-
- //edition to be done here
- // selecting first check of profile
- $this->click("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[3]/input[2]");
- // selecting second check of profile
- $this->click("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[4]/input[2]");
- // clicking copy values to rows of first check and verifying
- // if other check Profile Field check box are affected
-
- $this->click("xpath=//div[@class='dataTables_wrapper no-footer']/table/thead/tr/th[3]/div/img");
- // Because it tends to cause problems, all uses of sleep() must be justified in comments
- // Sleep should never be used for wait for anything to load from the server
- // Justification for this instance: FIXME
- sleep(5);
- if ($this->isChecked("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[4]/input[2]") &&
- !$this->isChecked("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[4]/input[4]") &&
- !$this->isChecked("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[4]/input[6]") &&
- //verification for second field first row
- !$this->isChecked("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[2]/td[4]/input[2]") &&
- !$this->isChecked("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[2]/td[4]/input[4]") &&
- !$this->isChecked("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[2]/td[4]/input[6]") &&
- //verification for first field second row
- $this->isChecked("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[2]/td[3]/input[2]") &&
- !$this->isChecked("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[2]/td[3]/input[4]") &&
- !$this->isChecked("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[2]/td[3]/input[6]")
- ) {
- $assertCheck = TRUE;
- }
- else {
- $assertCheck = FALSE;
- }
-
- $this->assertTrue($assertCheck, 'copy rows for field one failed for inteview (campaign)');
-
- $this->click("xpath=//div[@class='dataTables_wrapper no-footer']/table/thead/tr/th[4]/div/img");
- // Because it tends to cause problems, all uses of sleep() must be justified in comments
- // Sleep should never be used for wait for anything to load from the server
- // Justification for this instance: FIXME
- sleep(5);
- if ($this->isChecked("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[4]/input[2]") &&
- !$this->isChecked("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[4]/input[4]") &&
- !$this->isChecked("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[4]/input[6]") &&
- //verification for second field first row
- $this->isChecked("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[2]/td[4]/input[2]") &&
- !$this->isChecked("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[2]/td[4]/input[4]") &&
- !$this->isChecked("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[2]/td[4]/input[6]") &&
- //verification for first field second row
- $this->isChecked("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[2]/td[3]/input[2]") &&
- !$this->isChecked("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[2]/td[3]/input[4]") &&
- !$this->isChecked("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[2]/td[3]/input[6]")
- ) {
- $assertCheck = TRUE;
- }
- else {
- $assertCheck = FALSE;
- }
-
- $this->assertTrue($assertCheck, 'copy rows for field two failed for inteview (campaign)');
-
- $dateElementIdFirstRow = $this->getAttribute("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[5]/input/@id");
- $dateElementIdSecondRow = $this->getAttribute("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[2]/td[5]/input/@id");
-
- $this->webtestFillDateTime($dateElementIdFirstRow, "+1 week");
- $this->click("xpath=//div[@class='dataTables_wrapper no-footer']/table/thead/tr/th[5]/div/img");
- // Because it tends to cause problems, all uses of sleep() must be justified in comments
- // Sleep should never be used for wait for anything to load from the server
- // Justification for this instance: FIXME
- sleep(5);
-
- if ($this->getValue("{$dateElementIdFirstRow}_time") == $this->getValue("{$dateElementIdSecondRow}_time") && $this->getValue("{$dateElementIdFirstRow}") == $this->getValue("{$dateElementIdSecondRow}")) {
- $assertCheck = TRUE;
- }
- else {
- $assertCheck = FALSE;
- }
-
- $this->assertTrue($assertCheck, 'date / time coping failed for inteview (campaign)');
-
- $this->type("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[@class='note']/input", 'This is Test Introductory Message');
- $this->click("xpath=//div[@class='dataTables_wrapper no-footer']/table/thead/tr/th[8]/div/img");
- // Because it tends to cause problems, all uses of sleep() must be justified in comments
- // Sleep should never be used for wait for anything to load from the server
- // Justification for this instance: FIXME
- sleep(5);
-
- if ($this->getValue("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[@class='note']/input") == $this->getValue("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[2]/td[@class='note']/input")) {
- $assertCheck = TRUE;
- }
- else {
- $assertCheck = FALSE;
- }
-
- $this->assertTrue($assertCheck, 'Note Custom field coping failed');
-
- $this->click("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[6]/input");
- // selecting second check of profile
- $this->click("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[7]/input");
- // clicking copy values to rows of first check and verifying
- // if other radio Profile Field radio buttons are affected
-
- $this->click("xpath=//div[@class='dataTables_wrapper no-footer']/table/thead/tr/th[6]/div/img");
- // Because it tends to cause problems, all uses of sleep() must be justified in comments
- // Sleep should never be used for wait for anything to load from the server
- // Justification for this instance: FIXME
- sleep(5);
- if ($this->isChecked("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[7]/input") &&
- !$this->isChecked("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[7]/input[2]") &&
- !$this->isChecked("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[7]/input[3]") &&
- //verification for second field first row
- !$this->isChecked("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[2]/td[7]/input") &&
- !$this->isChecked("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[2]/td[7]/input[2]") &&
- !$this->isChecked("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[2]/td[7]/input[3]") &&
- //verification for first field second row
- $this->isChecked("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[2]/td[6]/input") &&
- !$this->isChecked("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[2]/td[6]/input[2]") &&
- !$this->isChecked("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[2]/td[6]/input[3]")
- ) {
- $assertCheck = TRUE;
- }
- else {
- $assertCheck = FALSE;
- }
-
- $this->assertTrue($assertCheck, 'copy rows for field one failed for inteview (campaign)[radio button]');
-
- $this->click("xpath=//div[@class='dataTables_wrapper no-footer']/table/thead/tr/th[7]/div/img");
- // Because it tends to cause problems, all uses of sleep() must be justified in comments
- // Sleep should never be used for wait for anything to load from the server
- // Justification for this instance: FIXME
- sleep(5);
- if ($this->isChecked("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[7]/input") &&
- !$this->isChecked("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[7]/input[2]") &&
- !$this->isChecked("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[7]/input[3]") &&
- //verification for second field first row
- $this->isChecked("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[2]/td[7]/input") &&
- !$this->isChecked("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[2]/td[7]/input[2]") &&
- !$this->isChecked("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[2]/td[7]/input[3]") &&
- //verification for first field second row
- $this->isChecked("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[2]/td[6]/input") &&
- !$this->isChecked("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[2]/td[6]/input[2]") &&
- !$this->isChecked("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[2]/td[6]/input[3]")
- ) {
- $assertCheck = TRUE;
- }
- else {
- $assertCheck = FALSE;
- }
-
- $this->assertTrue($assertCheck, 'copy rows for field two failed for inteview (campaign)[radio button]');
- $this->clickLink("_qf_Interview_cancel_interview");
-
- //change the editor back to ckeditor
- $this->openCiviPage('admin/setting/preferences/display', 'reset=1', '_qf_Display_next-bottom');
- $this->select('editor_id', 'CKEditor');
- $this->click('_qf_Display_next-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- }
-
- /**
- * @param $profileTitle
- * @param $customDataArr
- * @param $profileFor
- */
- public function _addProfile($profileTitle, $customDataArr, $profileFor) {
-
- $this->openCiviPage('admin/uf/group', 'reset=1');
-
- $this->clickLink('link=Add Profile', '_qf_Group_cancel-bottom');
-
- // Add membership custom data field to profile
- $this->type('title', $profileTitle);
-
- // Standalone form or directory
- $this->click('uf_group_type_Profile');
-
- $this->clickLink('_qf_Group_next-bottom');
-
- $this->waitForText('crm-notification-container', "Your CiviCRM Profile '{$profileTitle}' has been added. You can add fields to this profile now.");
-
- $this->waitForElementPresent("field_name[0]");
- foreach ($customDataArr as $customDataParams) {
- $this->select('field_name[0]', "label={$profileFor}");
- $this->select('field_name[1]', "label={$customDataParams[1]} :: {$customDataParams[0]}");
- $this->click('field_name[1]');
- $this->click('label');
-
- // Clicking save and new
- $this->click('_qf_Field_next_new-bottom');
- $this->waitForText('crm-notification-container', "Your CiviCRM Profile Field '{$customDataParams[1]}' has been saved to '{$profileTitle}'.");
- $this->waitForElementPresent("xpath=//select[@id='field_name_1'][@style='display: none;']");
- }
- }
-
- /**
- * @param $profileFor
- *
- * @return array
- */
- public function _addCustomData($profileFor) {
- $returnArray = array();
- $customGroupTitle = 'Custom_' . substr(sha1(rand()), 0, 4);
-
- $this->openCiviPage('admin/custom/group', 'reset=1');
-
- //add new custom data
- $this->clickLink("//a[@id='newCustomDataGroup']/span");
-
- //fill custom group title
- $this->click("title");
- $this->type("title", $customGroupTitle);
-
- //custom group extends
- $this->click("extends[0]");
- $this->select("extends[0]", "label={$profileFor}");
- if ($this->isElementPresent('//option')) {
- $this->click("//option[@value='']");
- }
-
- $this->clickLink('_qf_Group_next-bottom');
-
- //Is custom group created?
- $this->waitForText('crm-notification-container', "Your custom field set '{$customGroupTitle}' has been added. You can add custom fields now.");
-
- //for checkbox 1
- $this->waitForElementPresent("label");
- $checkLabel1 = 'Custom Check One Text_' . substr(sha1(rand()), 0, 4);
- $this->waitForAjaxContent();
- $this->type('label', $checkLabel1);
- $this->click('data_type[0]');
- $this->select('data_type[0]', "label=Alphanumeric");
- $this->select('data_type[1]', "label=CheckBox");
-
- // enter checkbox options
- $checkOneOptionLabel1 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
- $this->type('option_label_1', $checkOneOptionLabel1);
- $this->type('option_value_1', 1);
- $checkOneOptionLabel2 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
- $this->type('option_label_2', $checkOneOptionLabel2);
- $this->type('option_value_2', 2);
- $this->click("link=another choice");
- $checkOneOptionLabel3 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
- $this->type('option_label_3', $checkOneOptionLabel3);
- $this->type('option_value_3', 3);
-
- //setting options per line to check CRM-9938
- $this->type("options_per_line", 2);
-
- //clicking save
- $this->clickLink('_qf_Field_next_new-top', '_qf_Field_done-bottom', FALSE);
-
- //Is custom field created
- $this->waitForText('crm-notification-container', "Custom field '$checkLabel1' has been saved.");
- $this->waitForElementPresent("label");
- $returnArray[1] = array($customGroupTitle, $checkLabel1);
-
- // create another custom field - Integer Radio
- //for checkbox 2
- $checkLabel2 = 'Custom Check Two Text_' . substr(sha1(rand()), 0, 4);
- $this->waitForAjaxContent();
- $this->type('label', $checkLabel2);
- $this->click('data_type[0]');
- $this->select('data_type[0]', "label=Alphanumeric");
- $this->select('data_type[1]', "label=CheckBox");
-
- // enter checkbox options
- $checkTwoOptionLabel1 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
- $this->type('option_label_1', $checkTwoOptionLabel1);
- $this->type('option_value_1', 1);
- $checkTwoOptionLabel2 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
- $this->type('option_label_2', $checkTwoOptionLabel2);
- $this->type('option_value_2', 2);
- $this->click("link=another choice");
- $checkTwoOptionLabel3 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
- $this->type('option_label_3', $checkTwoOptionLabel3);
- $this->type('option_value_3', 3);
-
- //clicking save
- $this->clickLink('_qf_Field_next_new-top', '_qf_Field_done-bottom', FALSE);
-
- //Is custom field created
- $this->waitForText('crm-notification-container', "Custom field '$checkLabel2' has been saved.");
- $returnArray[2] = array($customGroupTitle, $checkLabel2);
-
- // create another custom field - Date
- $this->waitForElementPresent("label");
- $dateFieldLabel = 'Custom Date Field' . substr(sha1(rand()), 0, 4);
- $this->waitForAjaxContent();
- $this->type('label', $dateFieldLabel);
- $this->click('data_type[0]');
- $this->select('data_type[0]', "label=Date");
- $this->waitForElementPresent('start_date_years');
-
- // enter years prior to current date
- $this->type('start_date_years', 3);
-
- // enter years up to the end year
- $this->type('end_date_years', 3);
-
- // select the date and time format
- $this->select('date_format', "value=yy-mm-dd");
- $this->select('time_format', "value=2");
-
- //clicking save
- $this->clickLink('_qf_Field_next_new-top', '_qf_Field_done-bottom', FALSE);
- //Is custom field created
- $this->waitForText('crm-notification-container', "Custom field '$dateFieldLabel' has been saved.");
- $returnArray[3] = array($customGroupTitle, $dateFieldLabel);
-
- //create rich text editor field
- $this->waitForElementPresent("label");
- $richTextField = 'Custom Rich TextField_' . substr(sha1(rand()), 0, 4);
- $this->waitForAjaxContent();
- $this->type('label', $richTextField);
- $this->click('data_type[0]');
- $this->select('data_type[0]', "label=Note");
- $this->select('data_type[1]', "value=RichTextEditor");
-
- //clicking save
- $this->clickLink('_qf_Field_next_new-top', '_qf_Field_done-bottom', FALSE);
-
- //Is custom field created
- $this->waitForText('crm-notification-container', "Custom field '$richTextField' has been saved.");
- $returnArray[4] = array($customGroupTitle, $richTextField);
-
- //create radio button field
- //for radio 1
- $this->waitForElementPresent("label");
- $radioLabel1 = 'Custom Radio One Text_' . substr(sha1(rand()), 0, 4);
- $this->waitForAjaxContent();
- $this->type('label', $radioLabel1);
- $this->click('data_type[0]');
- $this->select('data_type[0]', "label=Alphanumeric");
- $this->select('data_type[1]', "label=Radio");
-
- // enter radio options
- $radioOneOptionLabel1 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
- $this->type('option_label_1', $radioOneOptionLabel1);
- $this->type('option_value_1', 1);
- $radioOneOptionLabel2 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
- $this->type('option_label_2', $radioOneOptionLabel2);
- $this->type('option_value_2', 2);
- $this->click("link=another choice");
- $radioOneOptionLabel3 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
- $this->type('option_label_3', $radioOneOptionLabel3);
- $this->type('option_value_3', 3);
-
- //clicking save
- $this->clickLink('_qf_Field_next_new-top', '_qf_Field_done-bottom', FALSE);
-
- //Is custom field created
- $this->waitForText('crm-notification-container', "Custom field '$radioLabel1' has been saved.");
- $returnArray[5] = array($customGroupTitle, $radioLabel1);
-
- // create another custom field - Alpha Radio
- //for radio 2
- $this->waitForElementPresent("label");
- $radioLabel2 = 'Custom Radio Two Text_' . substr(sha1(rand()), 0, 4);
- $this->waitForAjaxContent();
- $this->type('label', $radioLabel2);
- $this->click('data_type[0]');
- $this->select('data_type[0]', "label=Alphanumeric");
- $this->select('data_type[1]', "label=Radio");
-
- // enter radio options
- $radioTwoOptionLabel1 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
- $this->type('option_label_1', $radioTwoOptionLabel1);
- $this->type('option_value_1', 1);
- $radioTwoOptionLabel2 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
- $this->type('option_label_2', $radioTwoOptionLabel2);
- $this->type('option_value_2', 2);
- $this->click("link=another choice");
- $radioTwoOptionLabel3 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
- $this->type('option_label_3', $radioTwoOptionLabel3);
- $this->type('option_value_3', 3);
-
- //clicking save
- $this->clickLink('_qf_Field_done', 'newCustomField', FALSE);
-
- //Is custom field created
- $this->waitForText('crm-notification-container', "Custom field '$radioLabel2' has been saved.");
- $returnArray[6] = array($customGroupTitle, $radioLabel2);
-
- return $returnArray;
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Profile_DedupeTest
- */
-class WebTest_Profile_DedupeTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testProfileCreateDupeStrictDefault() {
- // lets give profile related permision to anonymous user.
- $permission = array(
- 'edit-1-profile-create',
- 'edit-1-profile-edit',
- 'edit-1-profile-listings',
- 'edit-1-profile-view',
- );
- $this->changePermissions($permission);
-
- // Log in as normal user
- $this->webtestLogin();
-
- $this->openCiviPage('contact/add', 'reset=1&ct=Individual');
-
- $firstName = "John" . substr(sha1(rand()), 0, 7);
- $lastName = "Smith" . substr(sha1(rand()), 0, 7);
- $email = $firstName . "@" . $lastName . ".com";
- // fill in first name
- $this->type("first_name", $firstName);
-
- // fill in last name
- $this->type("last_name", $lastName);
-
- // fill in email
- $this->type("email_1_email", $email);
-
- // Clicking save.
- $this->click("_qf_Contact_upload_view");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $individualName = $this->getText("xpath=//div[@class='crm-summary-display_name']");
- $this->waitForText('crm-notification-container', "$individualName has been created.");
-
- // submit dupe using profile/create as anonymous
- $this->openCiviPage('profile/create', 'gid=4&reset=1', '_qf_Edit_next');
-
- $firstName = "John" . substr(sha1(rand()), 0, 7);
- $lastName = "Smith" . substr(sha1(rand()), 0, 7);
-
- // fill in first name
- $this->type("first_name", $firstName);
-
- // fill in last name
- $this->type("last_name", $lastName);
-
- // fill in email
- $this->type("email-Primary", $email);
-
- // click save
- $this->click("_qf_Edit_next");
- $this->waitForTextPresent("A record already exists with the same information.");
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Profile_MultiRecordProfileAddTest
- */
-class WebTest_Profile_MultiRecordProfileAddTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testAdminAddNewProfile() {
- $this->webtestLogin();
- list($id, $profileTitle) = $this->_addNewProfile();
- $this->_deleteProfile($id, $profileTitle);
- }
-
- public function testUserAddNewProfile() {
- //add the required permission
- $permissions = array(
- 'edit-2-profile-listings-and-forms',
- 'edit-2-access-all-custom-data',
- 'edit-2-access-civicrm',
- );
- $this->changePermissions($permissions);
- list($id, $profileTitle) = $this->_addNewProfile(TRUE, FALSE, TRUE);
- $this->_deleteProfile($id, $profileTitle);
- }
-
- public function testAddNewNonMultiProfile() {
- $this->webtestLogin();
- list($id, $profileTitle) = $this->_addNewProfile(FALSE);
- $this->_deleteProfile($id, $profileTitle);
- }
-
- public function testNonSearchableMultiProfile() {
- $this->webtestLogin();
- list($id, $profileTitle) = $this->_addNewProfile(TRUE, TRUE);
- $this->_deleteProfile($id, $profileTitle);
- }
-
- /**
- * @param bool $checkMultiRecord
- * @param bool $checkSearchable
- * @param bool $userCheck
- *
- * @return array
- */
- public function _addNewProfile($checkMultiRecord = TRUE, $checkSearchable = FALSE, $userCheck = FALSE) {
- $params = $this->_testCustomAdd($checkSearchable);
-
- $this->openCiviPage('admin/uf/group', 'reset=1');
-
- $this->click('newCiviCRMProfile-top');
- $this->waitForElementPresent('_qf_Group_next-bottom');
-
- //Name of profile
- $profileTitle = 'profile_' . substr(sha1(rand()), 0, 7);
- $this->type('title', $profileTitle);
-
- $this->click('uf_group_type_Profile');
- //profile Used for
- $this->click('uf_group_type_User Account');
-
- //Profile Advance Settings
- $this->click("//form[@id='Group']/div[2]/div[2]/div[1]");
-
- //Drupal user account registration option
- $this->click('CIVICRM_QFID_0_8');
-
- //What to do upon duplicate match
- $this->click('CIVICRM_QFID_1_4');
-
- //Proximity search options
- $this->click('CIVICRM_QFID_0_14');
-
- // enable maping for contact
- $this->click('is_map');
-
- // include a link in the listings to Edit profile fields
- $this->click('is_edit_link');
-
- //to view contacts' Drupal user account information
- $this->click('is_uf_link');
-
- //click on save
- $this->clickLink('_qf_Group_next', NULL, TRUE);
-
- //check for profile create
- $this->waitForText('crm-notification-container', "Your CiviCRM Profile '{$profileTitle}' has been added. You can add fields to this profile now.");
-
- $gid = $this->urlArg('gid');
-
- $this->openCiviPage('admin/uf/group/field/add', array(
- 'action' => 'add',
- 'reset' => 1,
- 'gid' => $gid,
- ), 'field_name[0]');
-
- //Add field to profile
- $this->click('field_name[0]');
- $this->select('field_name[0]', 'value=Contact');
- $this->click("//option[@value='Contact']");
- $this->click('field_name_1');
- $this->select('field_name_1', 'label=' . $params['textFieldLabel'] . ' :: ' . $params['customGroupTitle']);
- if ($checkMultiRecord) {
- $this->click('is_multi_summary');
- }
- if (!$checkSearchable) {
- $this->click('is_searchable');
- $this->select('visibility', 'value=Public Pages and Listings');
- }
- else {
- $this->select('visibility', 'value=User and User Admin Only');
- }
- $this->click('in_selector');
- $this->click('is_required');
- $this->type('help_post', 'This is help for profile field');
- $this->click('_qf_Field_next_new-top');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->click('field_name[0]');
- $this->select('field_name[0]', 'value=Contact');
- $this->click("//option[@value='Contact']");
- $this->click('field_name_1');
- $this->select('field_name_1', 'label=' . $params['selectFieldLabel'] . ' :: ' . $params['customGroupTitle']);
- if ($checkMultiRecord) {
- $this->click('is_multi_summary');
- }
- $this->select('visibility', 'value=Public Pages and Listings');
- $this->click('is_searchable');
- $this->click('in_selector');
- $this->type('help_post', 'This is help for profile field');
- $this->click('_qf_Field_next_new-top');
-
- // Add Contact
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->click('field_name[0]');
- $this->select('field_name[0]', 'value=Student');
- $this->click("//option[@value='Student']");
-
- $this->click('field_name_1');
- $this->select('field_name_1', 'value=first_name');
- $this->click('is_multi_summary');
- $this->select('visibility', 'value=Public Pages and Listings');
- $this->click('is_searchable');
- $this->click('in_selector');
- $this->type('help_post', 'This is help for profile field');
- $this->click('_qf_Field_next_new-top');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->click('field_name[0]');
- $this->select('field_name[0]', 'value=Student');
- $this->click("//option[@value='Student']");
- $this->click('field_name_1');
- $this->select('field_name_1', 'value=last_name');
- $this->select('visibility', 'value=Public Pages and Listings');
- $this->click('is_searchable');
- $this->click('in_selector');
- $this->type('help_post', 'This is help for profile field');
- $this->clickLink('_qf_Field_next_new-top');
-
- $this->click('field_name[0]');
- $this->select('field_name[0]', 'value=Contact');
- $this->click("//option[@value='Contact']");
- $this->click('field_name_1');
- $this->select('field_name_1', 'value=email');
- $this->select('visibility', 'value=Public Pages and Listings');
- $this->click('is_searchable');
- $this->type('help_post', 'This is help for profile field');
- $this->clickLink('_qf_Field_next');
-
- $uselink = explode('?', $this->getAttribute("xpath=//*[@id='field_page']/div[1]/a[4]@href"));
- $this->openCiviPage('profile/create', "$uselink[1]", '_qf_Edit_next');
- $recordNew = $this->_addRecords('Create');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $id = $this->urlArg('id');
-
- if ($userCheck) {
- //add drupal user
- $this->openCiviPage('contact/view/useradd', "reset=1&action=add&cid=$id", 'cms_name');
- $this->type('cms_name', $recordNew['firstname']);
- $this->type('cms_pass', $recordNew['firstname']);
- $this->type('cms_confirm_pass', $recordNew['firstname']);
- $this->click('_qf_Useradd_next-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->webtestLogout();
-
- $this->webtestLogin($recordNew['firstname'], $recordNew['firstname']);
- }
- $this->openCiviPage('profile/edit', "reset=1&id=$id&gid=$gid", NULL);
- if (!$checkMultiRecord) {
- $this->assertElementContainsText('crm-container', 'No records');
- return array($gid, $profileTitle);
- }
- $this->waitForElementPresent("//a/span[contains(text(), 'Add New Record')]");
- $this->click("//a/span[contains(text(), 'Add New Record')]");
- $this->waitForElementPresent("_qf_Edit_next");
- $record1 = $this->_addRecords('Edit', TRUE);
- $this->waitForElementPresent("//div[@id='custom--table-wrapper']/div/div/table/tbody/tr[2]/td[1]");
- $alertText = $this->getAlert();
- $this->assertEquals("Thank you. Your information has been saved.", $alertText);
- $this->waitForElementPresent("//a/span[contains(text(), 'Add New Record')]");
- $this->verifyText("//div[@id='custom--table-wrapper']/div/div/table/thead/tr/th[1]", preg_quote($params['textFieldLabel']));
- $this->verifyText("//div[@id='custom--table-wrapper']/div/div/table/tbody/tr[2]/td[1]", preg_quote($record1['text']));
- $this->click("//a/span[contains(text(), 'Add New Record')]");
- $this->waitForElementPresent("_qf_Edit_next");
- $record2 = $this->_addRecords('Edit', TRUE);
- $this->waitForElementPresent("//div[@id='custom--table-wrapper']/div/div/table/tbody/tr[3]/td[1]");
- $alertText = $this->getAlert();
- $this->assertEquals("Thank you. Your information has been saved.", $alertText);
- $this->waitForElementPresent("//div[@id='custom--table-wrapper']/div/div/table/tbody/tr[3]/td[1]");
- $this->verifyText("//div[@id='custom--table-wrapper']/div/div/table/tbody/tr[3]/td[1]", preg_quote($record2['text']));
-
- // Check Max Record Limit
- $this->verifyElementNotPresent("//a/span[contains(text(), 'Add New Record')]");
-
- //Check for edit functionality
- $this->click("//div[@id='custom--table-wrapper']/div/div/table/tbody/tr/td[3]/span/a[text()='Edit']");
- $this->waitForElementPresent("xpath=//div[@class='ui-dialog-content ui-widget-content modal-dialog crm-ajax-container']/form/div[2]//div[@id='crm-profile-block']");
- $this->verifyText("//div[@id='custom--table-wrapper']/div/div/table/thead/tr/th[1]", preg_quote($params['textFieldLabel']));
- $this->type("//div[@id='crm-profile-block']/div/div[2]/input[@class='crm-form-text required']", $recordNew['text'] . 'edit');
- $this->click("css=.ui-dialog-buttonset button[data-identifier=_qf_Edit_next]");
- $this->waitForText("//div[@id='custom--table-wrapper']/div/div/table/tbody/tr[1]/td[1]", $recordNew['text'] . 'edit');
- $editalertText = $this->getAlert();
- $this->assertEquals("Thank you. Your information has been saved.", $editalertText);
- $this->verifyText("//div[@id='custom--table-wrapper']/div/div/table/tbody/tr[1]/td[1]", preg_quote($recordNew['text'] . 'edit'));
-
- // Check the delete functionality
- $this->click("//div[@id='custom--table-wrapper']/div/div/table/tbody/tr/td[3]/span/a[text()='Delete']");
- $this->waitForText("css=.ui-dialog-content.crm-ajax-container", 'Are you sure you want to delete this record?');
- $this->click('_qf_Edit_upload_delete');
-
- $this->waitForElementPresent("//a/span[contains(text(), 'Add New Record')]");
- $delText = $this->getAlert();
- $this->assertEquals("Deleted Your record has been deleted.", $delText);
-
- $this->click("//div[@id='custom--table-wrapper']/div/div/table/tbody/tr/td[3]/span/a[text()='View']");
- $this->waitForText("css=.ui-dialog-title", 'View ' . $params['customGroupTitle'] . ' Record');
- $this->assertElementContainsText("css=.ui-dialog-content.crm-ajax-container", $params['textFieldLabel']);
- if ($checkSearchable) {
- $this->verifyElementNotPresent("//div[@id='profile-dialog']/div/div/div/div/div[1]/div[2]/a");
- return array($gid, $profileTitle);
- }
-
- // Check Search Functionality
- if (!$userCheck) {
- $this->click("//div[@class='ui-dialog-content ui-widget-content modal-dialog crm-ajax-container']/div/div/div/div/div[2]/a");
- $this->waitForElementPresent("//form[@id='Search']");
- $this->verifyText("//form[@id='Search']/div[2]/div[2]/div[2]/table/tbody/tr[2]/td[2]", preg_quote($recordNew['firstname']));
- $this->openCiviPage('profile/view', "reset=1&id=$id&gid=$gid", "//div[@id='row-first_name']/div[2]/a");
- $this->click("//div[@id='row-first_name']/div[2]/a");
- $this->waitForElementPresent("//form[@id='Search']");
- // Check that Email column is not present in selector results
- $this->verifyElementNotPresent("//form[@id='Search']/div[2]/div[2]/div[2]/table/tbody/tr/th[7]/a[@label='Email (Primary)']");
- $this->verifyText("//form[@id='Search']/div[2]/div[2]/div[2]/table/tbody/tr/th[3]/a", preg_quote($params['textFieldLabel']));
- $this->verifyText("//form[@id='Search']/div[2]/div[2]/div[2]/table/tbody/tr[2]/td[3]", preg_quote($record1['text']));
- $this->verifyText("//form[@id='Search']/div[2]/div[2]/div[2]/table/tbody/tr[3]/td[3]", preg_quote($record2['text']));
- }
- return array($gid, $profileTitle);
- }
-
- /**
- * @param int $gid
- * @param $profileTitle
- */
- public function _deleteProfile($gid, $profileTitle) {
- $this->webtestLogin();
- $this->openCiviPage("admin/uf/group", "action=delete&id={$gid}", '_qf_Group_next-bottom');
- $this->click('_qf_Group_next-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->assertElementContainsText('crm-container', "Your CiviCRM Profile '{$profileTitle}' has been deleted.");
- }
-
- /**
- * @param $checkSearchable
- *
- * @return mixed
- */
- public function _testCustomAdd($checkSearchable) {
-
- $this->openCiviPage('admin/custom/group', 'action=add&reset=1');
-
- //fill custom group title
- $params['customGroupTitle'] = 'custom_group' . substr(sha1(rand()), 0, 3);
- $this->click("title");
- $this->type("title", $params['customGroupTitle']);
-
- //custom group extends
- $this->click("extends[0]");
- $this->select("extends[0]", "label=Contacts");
- $this->click("//option[@value='Contact']");
- $this->waitForElementPresent("//input[@id='is_multiple']");
- $this->click("//input[@id='is_multiple']");
- $this->type("max_multiple", 3);
- $this->clickLink("//form[@id='Group']/div[2]/div[3]/span[1]/input");
-
- //Is custom group created?
- $this->assertElementContainsText('crm-container', $params['customGroupTitle']);
-
- $gid = $this->urlArg('gid');
- $this->openCiviPage('admin/custom/group/field/add', 'reset=1&action=add&gid=' . $gid);
-
- //add custom field - alphanumeric text
- $params['textFieldLabel'] = 'test_text_field' . substr(sha1(rand()), 0, 3);
- $this->click("header");
- $this->type("label", $params['textFieldLabel']);
- //Is searchable?
- if (!$checkSearchable) {
- $this->click("is_searchable");
- }
- $this->click("_qf_Field_next_new-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->click("data_type[0]");
- $this->select("data_type[0]", "value=0");
- $this->click("//option[@value='0']");
- $this->click("data_type[1]");
- $this->select("data_type[1]", "label=Select");
- $this->click("//option[@value='Select']");
-
- $params['selectFieldLabel'] = 'test_select' . substr(sha1(rand()), 0, 5);
- $this->type("label", $params['selectFieldLabel']);
- $selectOptionLabel1 = 'option1' . substr(sha1(rand()), 0, 3);
- $this->type("option_label_1", $selectOptionLabel1);
- $this->type("option_value_1", "1");
- $selectOptionLabel2 = 'option2' . substr(sha1(rand()), 0, 3);
- $this->type("option_label_2", $selectOptionLabel2);
- $this->type("option_value_2", "2");
- $this->click("link=another choice");
-
- //enter pre help message
- $this->type("help_pre", "this is field pre help");
-
- //enter post help message
- $this->type("help_post", "this field post help");
-
- //Is searchable?
- $this->click("is_searchable");
-
- //clicking save
- $this->click("_qf_Field_done-bottom");
-
- //Is custom field created?
- $this->waitForText('crm-notification-container', $params['selectFieldLabel']);
- return $params;
- }
-
- /**
- * @param string $context
- * @param bool $dialog
- * @return mixed
- *
- */
- public function _addRecords($context = 'Edit', $dialog = FALSE) {
- $params['text'] = 'text' . substr(sha1(rand()), 0, 3);
- $this->waitForElementPresent("//div[@id='crm-profile-block']/div/div[2]/input[@class='crm-form-text required']");
- $this->type("//div[@id='crm-profile-block']/div/div[2]/input[@class='crm-form-text required']", $params['text']);
- if ($context == 'Create') {
- $params['firstname'] = 'John' . substr(sha1(rand()), 0, 3);
- $this->type('first_name', $params['firstname']);
- $params['lastname'] = 'Anderson' . substr(sha1(rand()), 0, 3);
- $this->type('last_name', $params['lastname']);
- $params['email'] = $params['firstname'] . $params['lastname'] . '@exa.com';
- $this->type('email-Primary', $params['email']);
- $this->waitForElementPresent("//div[@id='crm-profile-block']//div/div[2]/select");
- $this->select("//div[@id='crm-profile-block']//div/div[2]/select", 'value=1');
- }
- else {
- $this->waitForElementPresent("//div[@id='crm-profile-block']//div/div[2]/select");
- $this->select("//div[@id='crm-profile-block']//div/div[2]/select", 'value=1');
-
- }
- if ($dialog) {
- $this->click("css=.ui-dialog-buttonset button[data-identifier=_qf_Edit_next]");
- }
- else {
- $this->click("_qf_Edit_next");
- }
- return $params;
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Profile_ProfileAddTest
- */
-class WebTest_Profile_ProfileAddTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testAddNewProfile() {
- $this->webtestLogin();
-
- // Add new profile.
- $this->openCiviPage('admin/uf/group', 'reset=1');
-
- $this->click('newCiviCRMProfile-top');
-
- $this->waitForElementPresent('_qf_Group_next-bottom');
-
- //Name of profile
- $profileTitle = 'profile_' . substr(sha1(rand()), 0, 7);
- $this->type('title', $profileTitle);
-
- //profile Used for
- $this->click('uf_group_type_User Registration');
- $this->click('uf_group_type_User Account');
-
- //Profile Advance Settings
- $this->click("//form[@id='Group']/div[2]/div[2]/div[1]");
-
- //Select a group if you are using this profile for search and listings.
- $this->select('group', 'value=1');
-
- //Select a group if you are using this profile for adding new contacts.
- $this->select('add_contact_to_group', 'value=1');
-
- //If you want member(s) of your organization to receive a
- //notification email whenever this Profile
- //form is used to enter or update contact information, enter one or more email addresses here.
- $this->type('notify', 'This is notify email');
-
- //If you are using this profile as a contact signup or edit
- //form, and want to redirec the user to a static URL after
- //they've submitted the form - enter the complete URL here.
- $this->type('post_URL', 'This is Post Url');
-
- // If you are using this profile as a contact signup or edit
- // form, and want to redirect the user to a
- //static URL if they click the Cancel button - enter the complete URL here.
- $this->type('cancel_URL', 'This is cancle Url');
-
- //reCaptcha settings
- $this->click('add_captcha');
-
- //Drupal user account registration option
- $this->click('CIVICRM_QFID_0_8');
-
- //What to do upon duplicate match
- $this->click('CIVICRM_QFID_0_2');
-
- //Proximity search options
- $this->click('CIVICRM_QFID_0_14');
-
- // enable maping for contact
- $this->click('is_map');
-
- // include a link in the listings to Edit profile fields
- $this->click('is_edit_link');
-
- //to view contacts' Drupal user account information
- $this->click('is_uf_link');
-
- //click on save
- $this->clickLink('_qf_Group_next');
-
- $gid = $this->urlArg('gid');
-
- //Add field to profile
- $this->waitForElementPresent("field_name[0]");
- $this->click('field_name[0]');
- $this->select('field_name[0]', 'value=Contact');
- $this->click("//option[@value='Contact']");
- $this->click('is_required');
- $this->type('help_post', 'This is help for profile field');
-
- //click on save
- $this->click('_qf_Field_next');
- sleep(1);
-
- // delete the profile
- $this->openCiviPage('admin/uf/group', 'reset=1');
- $this->_testdeleteProfile($profileTitle);
- }
-
- public function testProfileAddContactstoGroup() {
- $this->webtestLogin();
-
- $permissions = array("edit-1-profile-listings-and-forms");
- $this->changePermissions($permissions);
- // take group name and create group
- $groupName = 'group_' . substr(sha1(rand()), 0, 7);
- $this->WebtestAddGroup($groupName);
-
- // Add new profile.
- $this->openCiviPage('admin/uf/group', 'reset=1');
-
- $this->click('newCiviCRMProfile-top');
-
- $this->waitForElementPresent('_qf_Group_next-bottom');
-
- //Name of profile
- $profileTitle = 'profile_' . substr(sha1(rand()), 0, 7);
- $this->type('title', $profileTitle);
-
- $this->click('uf_group_type_Profile');
- //Profile Advance Settings
- $this->click("//form[@id='Group']/div[2]/div[2]/div[1]");
-
- //Select the newly created group for adding new contacts into it.
- $this->select('add_contact_to_group', "label=$groupName");
-
- //click on save
- $this->clickLink('_qf_Group_next');
-
- //check for profile create
- $this->waitForText('crm-notification-container', "Your CiviCRM Profile '{$profileTitle}' has been added. You can add fields to this profile now.");
-
- //Add fields to profile
- $fields = array(
- 'first_name' => 'Individual',
- 'last_name' => 'Individual',
- 'email' => 'Contact',
- );
- $this->waitForElementPresent("field_name_0");
- foreach ($fields as $field => $type) {
- $this->click('field_name_0');
- $this->select('field_name_0', "value=$type");
- $this->click("//option[@value='$type']");
- $this->click('field_name_1');
- $this->select('field_name_1', "value=$field");
- $this->clickLink('_qf_Field_next_new-top', 'field_name_0', FALSE);
- $this->waitForElementPresent("xpath=//select[@id='field_name_1'][@style='display: none;']");
- }
-
- // create mode
- $gid = $this->urlArg('gid');
- $this->openCiviPage('profile/create', "gid=$gid&reset=1", NULL);
- $firstName1 = "John_" . substr(sha1(rand()), 0, 7);
- $lastName1 = "Smiths_x" . substr(sha1(rand()), 0, 7);
- $this->type('first_name', $firstName1);
- $this->type('last_name', $lastName1);
- $this->type('email-Primary', "$firstName1.$lastName1@example.com");
- $this->clickLink('_qf_Edit_next', NULL);
-
- //anonymous contact
- $this->webtestLogout();
- $this->openCiviPage('profile/create', "gid=$gid&reset=1", NULL);
- $firstName2 = "John12_" . substr(sha1(rand()), 0, 7);
- $lastName2 = "Smiths34_x" . substr(sha1(rand()), 0, 7);
- $this->type('first_name', $firstName2);
- $this->type('last_name', $lastName2);
- $this->type('email-Primary', "$firstName2.$lastName2@example.com");
- $this->clickLink('_qf_Edit_next', NULL);
-
- $this->webtestLogin();
- //check the existence of the two contacts in the group
- $this->openCiviPage('group', 'reset=1');
- $this->type('title', $groupName);
- $this->click('title');
- $this->waitForElementPresent("xpath=//div[text() = '$groupName']/parent::td/following-sibling::td[@class='crm-group-group_links']/span/a");
- $this->clickLink("xpath=//div[text() = '$groupName']/parent::td/following-sibling::td[@class='crm-group-group_links']/span/a");
- $contactEmails = array(
- 1 => "$lastName1, $firstName1",
- 2 => "$lastName2, $firstName2",
- );
- foreach ($contactEmails as $row => $name) {
- $this->assertTrue($this->isElementPresent("xpath=//div[@class='crm-search-results']/table/tbody/tr[$row]/td[4]/a[contains(text(), '$name')]"));
- }
-
- //add the api keys in the recaptcha settings
- $this->openCiviPage('admin/setting/misc', 'reset=1');
- $this->type('recaptchaPublicKey', '6Lcexd8SAAAAAOwcoLCRALkyRrmPX7jY7b4V5iju');
- $this->type('recaptchaPrivateKey', '6Lcexd8SAAAAANZXtyU5SVrnl9-_ckwFxUAZgxQp');
- $this->clickLink('_qf_Miscellaneous_next-bottom');
-
- //enable recaptcha in the profile
- $this->openCiviPage('admin/uf/group', 'reset=1');
- $this->clickLink("xpath=//div[@id='user-profiles']/div/div/table/tbody//tr/td[1]/div[text()= '$profileTitle']/../following-sibling::td[6]/span/a[2]");
- $this->click("//form[@id='Group']/div[2]/div[2]/div[1]");
- //reCaptcha settings
- $this->click('add_captcha');
- $this->clickLink('_qf_Group_next-bottom');
-
- //check if recaptcha loads for anonymous profile
- $this->webtestLogout();
- $this->openCiviPage('profile/create', "gid=$gid&reset=1", NULL);
- $this->waitForElementPresent('recaptcha_widget_div');
- $this->assertTrue($this->isElementPresent('recaptcha_area'));
-
- // delete the profile
- $this->webtestLogin();
- $this->openCiviPage('admin/uf/group', 'reset=1');
- $this->_testdeleteProfile($profileTitle);
- }
-
- /**
- * @param $profileTitle
- */
- public function _testdeleteProfile($profileTitle) {
- //$this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForElementPresent("xpath=//div[@id='user-profiles']/div/div/table/tbody//tr/td/div[text() = '$profileTitle']/../../td[7]/span[2][text()='more']/ul//li/a[text()='Delete']");
- $this->click("xpath=//div[@id='user-profiles']/div/div/table/tbody//tr/td/div[text() = '$profileTitle']/../../td[7]/span[2][text()='more']/ul//li/a[text()='Delete']");
-
- $this->waitForElementPresent('_qf_Group_next-bottom');
- $this->click('_qf_Group_next-bottom');
- $this->waitForElementPresent('newCiviCRMProfile-bottom');
- $this->waitForText('crm-notification-container', "Your CiviCRM Profile '{$profileTitle}' has been deleted.");
- }
-
- /**
- * CRM-12439
- * Test to check profile description field
- * which has a rich text editor (CKEditor)
- */
- public function testCheckDescAndCreatedIdFields() {
- // Log in using webtestLogin() method
- $this->webtestLogin();
-
- // open Add Profile page
- $this->openCiviPage("admin/uf/group/add", "action=add&reset=1");
-
- $this->waitForElementPresent('_qf_Group_next-bottom');
- $profileTitle = 'Test Profile' . substr(sha1(rand()), 0, 7);
- $this->type('title', $profileTitle);
-
- // check if description field is present
- $this->waitForElementPresent('description');
-
- $profileDescription = "Test Profile description" . substr(sha1(rand()), 0, 7);
- $this->type('description', $profileDescription);
- $this->check('uf_group_type_Search Profile');
-
- // click save button
- $this->clickLink('_qf_Group_next-bottom');
-
- // Wait for "saved" status msg
- $this->waitForText('crm-notification-container', 'Profile Added');
-
- $this->waitForElementPresent("field_name_0");
-
- // select field(s) to be added in profile
- $this->select("field_name_0", "value=Contact");
- $this->select("field_name_1", "value=email");
- $this->select("field_name_2", "value=2");
-
- // click on Save buttonProfile Field Saved
- $this->clickLink("xpath=//button/span[text()='Save']", "xpath=//a/span/i[@class='crm-i fa-plus-circle']", FALSE);
-
- // Wait for "saved" status msg
- $this->waitForText('crm-notification-container', "Profile Field Saved");
-
- $this->waitForElementPresent("xpath=//div[@id='field_page']/table/tbody/tr[1]/td[9]/span/a[text()='Edit']");
- // extract profile Id
- $id = explode("gid=", $this->getAttribute("xpath=//div[@id='field_page']/table/tbody/tr/td[9]/span/a[text()='Edit']/@href"));
- $id = $id[1];
-
- // click on Edit Settings
- $this->clickLink("xpath=//a/span/i[@class='crm-i fa-wrench']", '_qf_Group_next-bottom', FALSE);
-
- // check for description field
- $this->waitForElementPresent('description');
- // check value of description field is retrieved correctly
- $this->assertEquals($this->getValue('description'), $profileDescription);
-
- // click on save button
- $this->clickLink('_qf_Group_next-bottom', "xpath=//a/span/i[@class='crm-i fa-wrench']", FALSE);
-
- // Wait for "saved" status msg
- $this->waitForText('crm-notification-container', 'Profile Saved');
-
- $this->openCiviPage("admin/uf/group", "reset=1");
- $this->waitForElementPresent("xpath=//div[@class='crm-submit-buttons']/a[@id='newCiviCRMProfile-bottom']");
- $this->waitForElementPresent("xpath=//div[@id='user-profiles']/div/div/table/tbody/tr[@id='UFGroup-$id']/td[2]/a");
- $this->waitForElementPresent("xpath=//div[@id='user-profiles']/div/div/table/tbody/tr[@id='UFGroup-$id']/td[3]");
-
- // check description is displayed on profile listing page
- $this->assertEquals(
- $this->getText("xpath=//div[@id='user-profiles']/div/div/table/tbody/tr[@id='UFGroup-$id']/td[3]"),
- $profileDescription);
-
- // fetch created by
- $createdBy = $this->getText("xpath=//div[@id='user-profiles']/div/div/table/tbody/tr[@id='UFGroup-$id']/td[2]/a");
-
- // click on created by
- $this->click("xpath=id('UFGroup-$id')/td[2]/a");
-
- // Is contact present?
- $this->assertTrue($this->isTextPresent("$createdBy"), "Contact did not find!");
-
- $this->openCiviPage('admin/uf/group', 'reset=1');
- // delete created profile
- $this->_testdeleteProfile($profileTitle);
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Profile_ProfileCountryState
- */
-class WebTest_Profile_ProfileCountryState extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testStateCountry() {
- $this->webtestLogin();
- $config = CRM_Core_Config::singleton();
- // Add new profile.
- $this->openCiviPage('admin/uf/group', 'reset=1');
- $this->click('newCiviCRMProfile-top');
- $this->waitForElementPresent('_qf_Group_next-bottom');
-
- //Name of profile
- $profileTitle = 'Country state province web test temp';
- $this->type('title', $profileTitle);
-
- // Standalone form or directory
- $this->click('uf_group_type_Profile');
-
- //click on save
- $this->click('_qf_Group_next');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- //check for profile create
- $this->waitForText('crm-notification-container', "Profile '{$profileTitle}' has been added. You can add fields to this profile now.");
- $gid = $this->urlArg('gid');
-
- //Add Country field to profile
- $this->openCiviPage('admin/uf/group/field/add', array(
- 'action' => 'add',
- 'reset' => 1,
- 'gid' => $gid,
- ), 'field_name[0]');
- $this->click('field_name[0]');
- $this->select('field_name[0]', 'value=Contact');
- $this->click("//option[@value='Contact']");
- $this->click('field_name[1]');
- $this->select('field_name[1]', 'value=country');
- $this->click("//option[@value='country']");
- $this->click('is_required');
-
- $this->click('_qf_Field_next_new');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- //Add State field to profile
- $this->click('field_name[0]');
- $this->select('field_name[0]', 'value=Contact');
- $this->click("//option[@value='Contact']");
- $this->click('field_name[1]');
- $this->select('field_name[1]', 'value=state_province');
- $this->click("xpath=//select[@id='field_name_1']/option[@value='state_province']");
- $this->click('is_required');
- //click on save
- $this->click('_qf_Field_next');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- if ($gid) {
- $this->openCiviPage('admin/setting/localization', 'reset=1', '_qf_Localization_next-bottom');
- $country = array(1001 => 'Afghanistan', 1013 => 'Australia', 1039 => 'Canada', 1101 => 'India');
- $enabledCountries = $this->getSelectOptions("countryLimit-t");
- $enabledStates = $this->getSelectOptions("provinceLimit-t");
- $newCountry = array();
- foreach ($country as $countryID => $countryName) {
- if (!in_array($countryName, $enabledCountries)) {
- $newCountry[$countryID] = $countryName;
- $this->addSelection("countryLimit-f", "label=$countryName");
- $this->click("xpath=//select[@id='countryLimit-f']/option[@value='$countryID']");
- $this->click("xpath=//tr[@class='crm-localization-form-block-countryLimit']/td[2]/table//tbody/tr/td[2]/input[@name='add']");
- }
- if (!in_array($countryName, $enabledStates)) {
- $this->addSelection("provinceLimit-f", "label=$countryName");
- $this->click("//option[@value='$countryID']");
- $this->click("xpath=//tr[@class='crm-localization-form-block-provinceLimit']/td[2]/table//tbody/tr/td[2]/input[@name='add']");
- }
- $added = TRUE;
- }
- if ($added) {
- $this->click("_qf_Localization_next-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForText('crm-notification-container', "Saved");
- }
- $this->openCiviPage("profile/create", "gid=$gid&reset=1", NULL);
-
- $this->waitForElementPresent("xpath=//form[@id='Edit']/div[2]/div/div/div[2]/select");
- $this->click("xpath=//form[@id='Edit']/div[2]/div/div/div[2]/select");
- $countryID = array_rand($country);
- $states = CRM_Core_PseudoConstant::stateProvinceForCountry($countryID, 'id');
- $stateID = array_rand($states);
- $this->select("xpath=//form[@id='Edit']/div[2]/div/div/div[2]/select", "value=$countryID");
- $this->waitForElementPresent("xpath=//form[@id='Edit']/div[2]/div/div[2]/div[2]/select/option[@value=$stateID]");
- $this->click("xpath=//form[@id='Edit']/div[2]/div/div[2]/div[2]/select");
- $this->select("xpath=//form[@id='Edit']/div[2]/div/div[2]/div[2]/select", "value=$stateID");
- $this->clickLink('_qf_Edit_next', NULL);
-
- // Delete profile
- $this->openCiviPage('admin/uf/group', 'action=delete&id=' . $gid, '_qf_Group_next-bottom');
- $this->clickLink('_qf_Group_next-bottom', 'newCiviCRMProfile-bottom');
- $this->waitForText('crm-notification-container', "Profile '{$profileTitle}' has been deleted.");
-
- $this->openCiviPage("admin/setting/localization", "reset=1", "_qf_Localization_next-bottom");
- $enabledCountries = $this->getSelectOptions("countryLimit-t");
- $enabledStates = $this->getSelectOptions("provinceLimit-t");
- $removed = FALSE;
- foreach ($newCountry as $countryID => $countryName) {
- $this->addSelection("countryLimit-t", "label=$countryName");
- $this->click("xpath=//select[@id='countryLimit-t']/option[@value='$countryID']");
- $this->click("xpath=//tr[@class='crm-localization-form-block-countryLimit']/td[2]/table//tbody/tr/td[2]/input[@name='remove']");
-
- $this->addSelection("provinceLimit-t", "label=$countryName");
- $this->click("//option[@value='$countryID']");
- $this->click("xpath=//tr[@class='crm-localization-form-block-provinceLimit']/td[2]/table//tbody/tr/td[2]/input[@name='remove']");
- $removed = TRUE;
- }
- if ($removed) {
- $this->click("_qf_Localization_next-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForText('crm-notification-container', "Saved");
- }
- }
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Profile_ProfileGroupSubscriptionTest
- */
-class WebTest_Profile_ProfileGroupSubscriptionTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testProfileGroupSubscription() {
- $this->webtestLogin();
-
- // Add new profile.
- $this->openCiviPage('admin/uf/group', 'reset=1');
-
- $this->click('newCiviCRMProfile-top');
-
- $this->waitForElementPresent('_qf_Group_next-bottom');
-
- //Name of profile
- $profileTitle = 'profile_' . substr(sha1(rand()), 0, 7);
- $this->type('title', $profileTitle);
- $this->click('uf_group_type_Profile');
-
- //Drupal user account registration option
- $this->click('CIVICRM_QFID_0_8');
-
- //What to do upon duplicate match
- $this->click('CIVICRM_QFID_0_2');
-
- //Proximity search options
- $this->click('CIVICRM_QFID_0_14');
-
- // enable mapping for contact
- $this->click('is_map');
-
- // include a link in the listings to Edit profile fields
- $this->click('is_edit_link');
-
- //to view contacts' Drupal user account information
- $this->click('is_uf_link');
-
- //click on save
- $this->click('_qf_Group_next');
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- //check for profile create
- $this->waitForText('crm-notification-container', "Your CiviCRM Profile '{$profileTitle}' has been added. You can add fields to this profile now.");
-
- //Add email field to profile
- $this->waitForElementPresent("field_name[0]");
- $this->click('field_name[0]');
- $this->select('field_name[0]', 'value=Contact');
- $this->click("//option[@value='Contact']");
-
- $this->select('field_name[1]', 'value=email');
- $this->click("//option[@value='email']");
-
- //click on save
- $this->click('_qf_Field_next_new-top');
- $this->waitForText('crm-notification-container', "Your CiviCRM Profile Field 'Email' has been saved to '$profileTitle'.");
-
- //Add email field to profile
- $this->click('field_name[0]');
- $this->select('field_name[0]', 'value=Contact');
- $this->click("//option[@value='Contact']");
-
- $this->waitForElementPresent("field_name[1]");
- $this->select('field_name[1]', 'value=group');
- $this->click("//option[@value='group']");
-
- //click on save
- $this->click('_qf_Field_next');
-
- $this->waitForElementPresent("xpath=//div[@id='field_page']/div/a[4]/span");
-
- //now use profile create mode for group subscription
- $this->click("xpath=//div[@id='field_page']/div/a[4]/span");
-
- $this->waitForElementPresent('email-Primary');
-
- //check for group field
- $this->assertElementContainsText('crm-profile-block', 'Group(s)', "Groups field was not found.");
-
- //fill the subscription form
- $randomEmail = substr(sha1(rand()), 0, 7) . "@example.com";
-
- $this->type("email-Primary", $randomEmail);
-
- // check advisory group ( may be we should create a separate group to test this)
- $this->click("group_3");
-
- $this->click('_qf_Edit_next');
-
- // assert for subscription message
-
- $this->isTextPresent("Your subscription request has been submitted for");
- //check if profile is saved
- $this->isTextPresent("Your information has been saved.");
-
- // delete the profile
- $this->openCiviPage('admin/uf/group', 'reset=1');
- $this->_testdeleteProfile($profileTitle);
- }
-
- /**
- * @param $profileTitle
- */
- public function _testdeleteProfile($profileTitle) {
- $this->waitForElementPresent("xpath=//div[@id='user-profiles']/div/div[1]/table/tbody//tr/td[1]/div[text() = '$profileTitle']/../../td[7]/span[2][text()='more']/ul//li/a[text()='Delete']");
- $this->click("xpath=//div[@id='user-profiles']/div/div[1]/table/tbody//tr/td[1]/div[text() = '$profileTitle']/../../td[7]/span[2][text()='more']/ul//li/a[text()='Delete']");
- $this->waitForElementPresent('_qf_Group_next-bottom');
- $this->click('_qf_Group_next-bottom');
- $this->waitForElementPresent('newCiviCRMProfile-bottom');
- $this->waitForText('crm-notification-container', "Your CiviCRM Profile '{$profileTitle}' has been deleted.");
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Profile_SearchTest
- */
-class WebTest_Profile_SearchTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testSearchProfile() {
- $this->webtestLogin();
-
- // enable county field
- $this->openCiviPage('admin/setting/preferences/address', 'reset=1');
- $this->check('address_options[7]');
- $this->clickLink('_qf_Address_next-bottom');
-
- // Add new profile.
- $this->openCiviPage('admin/uf/group', 'reset=1');
-
- $this->click('newCiviCRMProfile-bottom');
-
- $this->waitForElementPresent('_qf_Group_next-bottom');
-
- //Name of profile
- $profileTitle = 'profile_' . substr(sha1(rand()), 0, 7);
- $this->type('title', $profileTitle);
-
- $this->click('uf_group_type_Profile');
- //click on save
- $this->click('_qf_Group_next-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForElementPresent("_qf_Field_next-bottom");
-
- //check for profile create
- $this->waitForText('crm-notification-container', "Your CiviCRM Profile '{$profileTitle}' has been added. You can add fields to this profile now.");
-
- // Get profile id (gid) from URL
- $profileId = $this->urlArg('gid');
-
- // Add Last Name field.
- $this->waitForElementPresent("field_name[0]");
- $this->click('field_name[0]');
- $this->select('field_name[0]', 'value=Individual');
- $this->click('field_name[1]');
- $this->select('field_name[1]', 'value=last_name');
- $this->click("//option[@value='Individual']");
- $this->click('visibility');
- $this->select('visibility', 'value=Public Pages');
- $this->click('is_searchable');
- $this->click('in_selector');
- // click on save
- $this->click('_qf_Field_next_new-bottom');
- //check for field add
- $this->waitForText('crm-notification-container', "Your CiviCRM Profile Field 'Last Name' has been saved to '$profileTitle'.");
-
- // Add Email field.
- $this->waitForElementPresent("field_name[0]");
- $this->click('field_name[0]');
- $this->select('field_name[0]', 'value=Contact');
- $this->waitForElementPresent('field_name[1]');
- $this->click('field_name[1]');
- $this->select('field_name[1]', 'value=email');
- $this->click("//option[@value='Contact']");
- $this->click('visibility');
- $this->select('visibility', 'value=Public Pages');
- $this->click('is_searchable');
- $this->click('in_selector');
- // click on save
- $this->click('_qf_Field_next_new-bottom');
- //check for field add
- $this->waitForText('crm-notification-container', "Your CiviCRM Profile Field 'Email' has been saved to '$profileTitle'.");
-
- // Add Sample Custom Field.
- $this->click('field_name[0]');
- $this->select('field_name[0]', 'value=Individual');
- $this->click('field_name[1]');
- $this->select('field_name[1]', 'value=custom_1');
- $this->click("//option[@value='Individual']");
- $this->click('visibility');
- $this->select('visibility', 'value=Public Pages');
- $this->click('is_searchable');
- $this->click('in_selector');
- $this->clickLink('_qf_Field_next_new-bottom', 'field_name[0]', FALSE);
- $this->waitForElementPresent("xpath=//select[@id='field_name_1'][@style='display: none;']");
-
- // Add state, country and county field
- $this->click('field_name[0]');
- $this->select('field_name[0]', 'value=Contact');
- $this->click('field_name[1]');
- $this->select('field_name[1]', 'value=country');
- $this->select('field_name[2]', 'Primary');
- $this->click('visibility');
- $this->select('visibility', 'value=Public Pages and Listings');
- $this->click('is_searchable');
- $this->click('in_selector');
- // click on save and new
- $this->clickLink('_qf_Field_next_new-bottom', 'field_name[0]', FALSE);
- $this->waitForElementPresent("xpath=//select[@id='field_name_1'][@style='display: none;']");
-
- $this->click('field_name[0]');
- $this->select('field_name[0]', 'value=Contact');
- $this->click('field_name[1]');
- $this->select('field_name[1]', 'value=state_province');
- $this->select('field_name[2]', 'Primary');
- $this->click('visibility');
- $this->select('visibility', 'value=Public Pages and Listings');
- $this->click('is_searchable');
- $this->click('in_selector');
- // click on save and new
- $this->clickLink('_qf_Field_next_new-bottom', 'field_name[0]', FALSE);
- $this->waitForElementPresent("xpath=//select[@id='field_name_1'][@style='display: none;']");
-
- $this->click('field_name[0]');
- $this->select('field_name[0]', 'value=Contact');
- $this->click('field_name[1]');
- $this->select('field_name[1]', 'value=county');
- $this->select('field_name[2]', 'Primary');
- $this->click('visibility');
- $this->select('visibility', 'value=Public Pages and Listings');
- $this->click('is_searchable');
- $this->click('in_selector');
-
- // click on save and new
- $this->clickLink('_qf_Field_next_new-bottom', 'field_name[0]', FALSE);
- $this->waitForElementPresent("xpath=//select[@id='field_name_1'][@style='display: none;']");
-
- $this->select('field_name[0]', 'value=Individual');
- $this->select('field_name[1]', 'value=current_employer');
- $this->select('visibility', 'value=Public Pages and Listings');
- $this->click('is_searchable');
- $this->click('in_selector');
-
- // click on save
- $this->clickLink('_qf_Field_next-bottom', "xpath=//div[@id='field_page']/div[1]/a[4]/span", FALSE);
-
- $uselink = explode('?', $this->getAttribute("xpath=//*[@id='field_page']/div[1]/a[4]@href"));
- $this->openCiviPage('profile/create', "$uselink[1]", '_qf_Edit_next');
- $lastName = substr(sha1(rand()), 0, 7);
- $orgName = 'Organisation' . substr(sha1(rand()), 0, 7);
-
- // Fill Last Name
- $this->type('last_name', $lastName);
- // Fill Email
- $this->type('email-Primary', "jhon@$lastName.com");
- // Select Custom option
- $this->click('CIVICRM_QFID_Edu_2');
-
- // fill country, state, county
- $this->select('country-Primary', "UNITED STATES");
-
- // wait for state data to be populated
- $this->waitForElementPresent("xpath=//select[@id='state_province-Primary']/option[text()='California']");
- $this->select('state_province-Primary', "California");
-
- // wait for county data to be populated
- $this->waitForElementPresent("xpath=//select[@id='county-Primary']/option[text()='Alameda']");
- $this->select('county-Primary', "Alameda");
-
- $this->type('current_employer', $orgName);
-
- $this->clickLink('_qf_Edit_next', NULL);
-
- $this->assertElementContainsText("css=span.msg-text", 'Your information has been saved.');
-
- // Search Contact via profile.
- $this->waitForElementPresent("xpath=//div[@id='crm-container']//div/a[text()='» Back to Listings']");
- $this->click("xpath=//div[@id='crm-container']//div/a[text()='» Back to Listings']");
- $this->waitForElementPresent("xpath=//div[@class='crm-block crm-form-block']");
- $this->click("xpath=//div[@class='crm-block crm-form-block']");
- // Fill Last Name
- $this->type('last_name', $lastName);
- // Fill Email
- $this->type('email-Primary', "jhon@$lastName.com");
-
- // Fill state, county, country
- $this->select('country-Primary', "UNITED STATES");
-
- // wait for state data to be populated
- $this->waitForElementPresent("xpath=//select[@id='state_province-Primary']/option[text()='California']");
- $this->select('state_province-Primary', "California");
-
- // wait for county data to be populated
- $this->waitForElementPresent("xpath=//select[@id='county-Primary']/option[text()='Alameda']");
- $this->select('county-Primary', "Alameda");
-
- // Select Custom option
- $this->select('custom_1', 'Education');
- $this->clickLink('_qf_Search_refresh', NULL);
-
- // Verify Data.
- $this->assertTrue($this->isElementPresent("xpath=//table/tbody/tr[2]/td[2][text()='$lastName']"));
- $this->assertTrue($this->isElementPresent("xpath=//table/tbody/tr[2]/td[3][text()='$lastName']"));
- $this->assertTrue($this->isElementPresent("xpath=//table/tbody/tr[2]/td[4][text()='jhon@$lastName.com']"));
- $this->assertTrue($this->isElementPresent("xpath=//table/tbody/tr[2]/td[5][text()='Education']"));
- $this->assertTrue($this->isElementPresent("xpath=//table/tbody/tr[2]/td[6][text()='UNITED STATES']"));
- $this->assertTrue($this->isElementPresent("xpath=//table/tbody/tr[2]/td[7][text()='CA']"));
- $this->assertTrue($this->isElementPresent("xpath=//table/tbody/tr[2]/td[8][text()='Alameda']"));
-
- // verify if the organization has been created -- CRM-15368
- $this->click("css=input#sort_name_navigation");
- $this->type("css=input#sort_name_navigation", "$orgName");
- $this->typeKeys("css=input#sort_name_navigation", "$orgName");
- $this->waitForElementPresent("css=ul.ui-autocomplete li");
-
- // visit contact summary page
- $this->click("css=ul.ui-autocomplete li");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Go back to Profile fields admin
- $this->openCiviPage('admin/uf/group/field', "reset=1&action=browse&gid=$profileId", "xpath=//table/tbody/tr[1]/td[9]");
-
- // Edit first profile field
- $this->clickLink("xpath=//table/tbody/tr[1]/td[9]/span[1]/a[1]", '_qf_Field_next-bottom', FALSE);
-
- $this->waitForElementPresent("visibility");
- $this->click("xpath=//tr[@id='profile_visibility']/td[1]/a");
- $this->waitForElementPresent("xpath=//div[@id='crm-notification-container']/div/div[2]/p[2]");
- $this->waitForText('crm-notification-container', 'Is this field hidden from public search');
- $this->select('visibility', 'value=Public Pages and Listings');
- }
-
-}
+++ /dev/null
-Please name your tests by scenario that you're testing, e.g.
-if you are testing the process of adding new activity, put it in
-Activity subdirectory in WebTest and name the file NewActivityTest.php.
-The class name in such case should be: WebTest_Activity_NewActivityTest
\ No newline at end of file
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'ReleaseTestCase.php';
-
-/**
- * name of the class doesn't end with Test on purpose - this way this
- * webtest is not picked up by the suite, since it needs to run
- * on specially prepare sandbox
- * more details: http://wiki.civicrm.org/confluence/display/CRMDOC/Release+testing+script
- * Class WebTest_Release_InstallScript
- */
-class WebTest_Release_InstallScript extends WebTest_Release_ReleaseTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testInstall() {
- $this->webtestLogin();
- $this->open($this->settings->installURL);
-
- $this->waitForTextPresent("Thanks for choosing to use CiviCRM! Please follow the instructions below to get CiviCRM installed.");
- $this->type("mysql_server", $this->settings->civiDBServer);
- $this->type("mysql_username", $this->settings->civiDBUser);
- $this->type("mysql_password", $this->settings->civiDBPass);
- $this->type("mysql_database", $this->settings->civiDBName);
-
- $this->type("drupal_server", $this->settings->drupalDBServer);
- $this->type("drupal_username", $this->settings->drupalDBUser);
- $this->type("drupal_password", $this->settings->drupalDBPass);
- $this->type("drupal_database", $this->settings->drupalDBName);
-
- $this->click("xpath=//input[@value='Re-check requirements']");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->click("install_button");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- // $this->assertTrue($this->isTextPresent("this will take a few minutes"));
- $this->waitForTextPresent("CiviCRM has been successfully installed");
- $this->openCiviPage("dashboard", "reset=1");
- $this->assertTrue($this->isTextPresent("CiviCRM Home"));
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * name of the class doesn't end with Test on purpose - this way this
- * webtest is not picked up by the suite, since it needs to run
- * on specially prepare sandbox
- * more details: http://wiki.civicrm.org/confluence/display/CRMDOC/Release+testing+script
- * Class WebTest_Release_ReleaseTestCase
- */
-class WebTest_Release_ReleaseTestCase extends CiviSeleniumTestCase {
-
- /**
- * Constructor.
- *
- * Because we are overriding the parent class constructor, we
- * need to show the same arguments as exist in the constructor of
- * PHPUnit_Framework_TestCase, since
- * PHPUnit_Framework_TestSuite::createTest() creates a
- * ReflectionClass of the Test class and checks the constructor
- * of that class to decide how to set up the test.
- *
- * @param string $name
- * @param array $data
- * @param string $dataName
- * @param array $browser
- */
- public function __construct($name = NULL, array$data = array(), $dataName = '', array$browser = array()) {
- parent::__construct($name, $data, $dataName, $browser);
-
- require_once 'CiviTest/ReleaseTestSettings.php';
- $this->settings = new ReleaseTestSettings();
- }
-
- protected function setUp() {
- parent::setUp();
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'ReleaseTestCase.php';
-
-/**
- * name of the class doesn't end with Test on purpose - this way this
- * webtest is not picked up by the suite, since it needs to run
- * on specially prepare sandbox
- * more details: http://wiki.civicrm.org/confluence/display/CRMDOC/Release+testing+script
- * Class WebTest_Release_UpgradeScript
- */
-class WebTest_Release_UpgradeScript extends WebTest_Release_ReleaseTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testUpgrade() {
- $this->webtestLogin();
- $this->open($this->settings->upgradeURL);
- $this->waitForTextPresent("Upgrade CiviCRM to Version");
- $this->clickAndWait("css=input[type=submit]");
-
- $this->waitForTextPresent("CiviCRM upgrade was successful.");
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Report_AddTest
- */
-class WebTest_Report_AddTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testAddReport() {
- $this->webtestLogin();
-
- // create contact
- $firstName = 'reportuser_' . substr(sha1(rand()), 0, 7);
- $displayName = "Anderson, $firstName";
- $emailId = "$firstName.anderson@example.org";
- $this->webtestAddContact($firstName, "Anderson", $emailId);
-
- $this->openCiviPage('report/contact/summary', 'reset=1', '_qf_Summary_submit');
-
- // enable email field
- $this->click("fields[email]");
-
- // enable phone field
- $this->click("fields[phone]");
-
- // apply Contact Name filter
- $this->select("sort_name_op", "value=has");
- $this->type("sort_name_value", $firstName);
-
- // preview result
- $this->click("_qf_Summary_submit");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Is filter statistics present?
- $this->assertElementContainsText("xpath=//tr/th[@class='statistics'][text()='Contact Name']/../td", "Contains $firstName", "Statistics did not found!");
-
- // Is Contact Name present in result?
- $this->assertElementContainsText('css=td.crm-report-civicrm_contact_sort_name', $displayName, "Contact Name did not found!");
-
- // Is email Id present on result?
- $this->assertElementContainsText('css=td.crm-report-civicrm_email_email', $emailId, "Email did not found!");
-
- // check criteria
- $this->click("xpath=//div[@class='crm-report-criteria']/div[@id='mainTabContainer']/ul//li/a[text()='Filters']");
- $this->waitForElementPresent("xpath=//div[@class='crm-submit-buttons']");
-
- // Is Contact Name filter?
- $this->assertContains($firstName, $this->getValue("sort_name_value"), "Filter Contact Name expected $firstName");
-
- // Is Email Field?
- $this->assertEquals("on", $this->getValue("fields[email]"));
-
- // Is Phone Field?
- $this->assertEquals("on", $this->getValue("fields[phone]"));
-
- // Create report
-
- $reportName = 'ContactSummary_' . substr(sha1(rand()), 0, 7);
- $reportDescription = "New Contact Summary Report";
- $emaiSubject = "Contact Summary Report";
- $emailCC = "tesmail@example.org";
- $this->click("xpath=//div[@class='crm-report-criteria']/div[@id='mainTabContainer']/ul//li/a[text()='Developer']");
- $this->waitForElementPresent("xpath=//div[@class='crm-submit-buttons']");
- $this->click("_qf_Summary_submit_save");
-
- // Fill Report Title
- $this->waitForElementPresent("xpath=//div[@class='crm-confirm-dialog ui-dialog-content ui-widget-content modal-dialog']/table/tbody/tr[1]/td[2]/input[@type='text']");
- $this->type("xpath=//div[@class='crm-confirm-dialog ui-dialog-content ui-widget-content modal-dialog']/table/tbody/tr[1]/td[2]/input[@type='text']", $reportName);
-
- // Fill Report Description
- $this->waitForElementPresent("xpath=//div[@class='crm-confirm-dialog ui-dialog-content ui-widget-content modal-dialog']/table/tbody/tr[2]/td[2]/input[@type='text']");
- $this->type("xpath=//div[@class='crm-confirm-dialog ui-dialog-content ui-widget-content modal-dialog']/table/tbody/tr[2]/td[2]/input[@type='text']", $reportDescription);
- $this->click("xpath=//div[@class='ui-dialog-buttonset']/button[1]/span[2]");
- $this->waitForElementPresent('_qf_Summary_submit_save');
-
- // Fill Email Subject
- $this->click("xpath=//div[@class='crm-report-criteria']/div[@id='mainTabContainer']/ul//li/a[text()='Email Delivery']");
- $this->waitForAjaxContent();
- $this->type("email_subject", $emaiSubject);
-
- // Fill Email To
- $this->waitForElementPresent('email_to');
- $this->type("email_to", $emailId);
-
- // Fill Email CC
- $this->waitForElementPresent('email_cc');
- $this->type("email_cc", $emailCC);
-
- // We want navigation menu
- $this->click("xpath=//div[@class='crm-report-criteria']/div[@id='mainTabContainer']/ul//li/a[text()='Access']");
- $this->waitForAjaxContent();
- $this->click("is_navigation");
-
- // Navigation menu under Reports section
- $this->waitForElementPresent("parent_id");
- $this->select("parent_id", "label=Reports");
-
- // Set permission as access CiviCRM
- $this->waitForElementPresent("permission");
- $this->select("permission", "value=access CiviCRM");
-
- // click to create report
- $this->click("_qf_Summary_submit_save");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Open report list
- $this->openCiviPage('report/list', 'reset=1');
-
- // Is report is resent in list?
- $this->assertElementContainsText('css=table.report-layout', $reportName);
-
- // Visit report
- $this->click("xpath=//div[@id='Contact']//table/tbody//tr/td/a/strong[text() = '$reportName']");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->click("_qf_Summary_submit");
- $this->waitForAjaxContent();
- // Is filter statistics present?
- $this->assertElementContainsText("xpath=//tr/th[@class='statistics'][text()='Contact Name']/../td", "Contains $firstName", "Statistics did not found!");
-
- // Is Contact Name present in result?
- $this->assertElementContainsText('css=td.crm-report-civicrm_contact_sort_name', $displayName, "Contact Name did not found!");
-
- // Is email Id present on result?
- $this->assertElementContainsText('css=td.crm-report-civicrm_email_email', $emailId, "Email did not found!");
-
- // check report criteria
- $this->click("xpath=//div[@id='mainTabContainer']/ul/li[3]/a");
- $this->waitForElementPresent("sort_name_value");
-
- // Is Contact Name filter?
- $this->assertContains($firstName, $this->getValue("sort_name_value"), "Filter Contact Name expected $firstName");
-
- // Is Email Field?
- $this->assertEquals("on", $this->getValue("fields[email]"));
-
- // Is Phone Field?
- $this->assertEquals("on", $this->getValue("fields[phone]"));
-
- // Check Report settings
- $this->click("xpath=//div[@class='crm-report-criteria']/div[@id='mainTabContainer']/ul/li[4]/a");
- $this->waitForElementPresent("title");
-
- // Is correct Report Title?
- $this->assertContains($reportName, $this->getValue("title"), "Report Title expected $reportName");
-
- // Is correct Report Description?
- $this->assertContains($reportDescription, $this->getValue("description"), "Report Description expected $reportDescription");
-
- // Is correct email Subject?
- $this->waitForElementPresent("mainTabContainer");
- $this->click("xpath=//div[@class='crm-report-criteria']/div[@id='mainTabContainer']/ul/li[5]/a");
- $this->waitForAjaxContent();
- $this->assertContains($emaiSubject, $this->getValue("email_subject"), "Email Subject expected $emaiSubject");
-
- // Is correct email to?
- $this->assertContains($emailId, $this->getValue("email_to"), "Email To expected $emailId");
-
- // Is correct email cc?
- $this->assertContains($emailCC, $this->getValue("email_cc"), "Email CC expected $emailCC");
-
- // Is Navigation?
- $this->click("xpath=//div[@class='crm-report-criteria']/div[@id='mainTabContainer']/ul/li[6]/a");
- $this->waitForAjaxContent();
- $this->assertEquals("on", $this->getValue("is_navigation"));
-
- // Is correct Navigation Parent?
- $this->assertSelectedLabel("parent_id", "Reports");
-
- // Is correct access permission?
- $this->assertSelectedLabel("permission", "access CiviCRM");
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Report_DonarReportTest
- */
-class WebTest_Report_DonarReportTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testDonarReportPager() {
- $this->webtestLogin();
-
- // now create new donar detail report instance
- $this->openCiviPage('report/contribute/detail', 'reset=1', '_qf_Detail_submit');
-
- // preview result
- $this->click("_qf_Detail_submit");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Create report
-
- $reportName = 'ContributeDetail_' . substr(sha1(rand()), 0, 7);
- $reportDescription = "New Contribute Detail Report";
-
- $this->click("xpath=//div[@id='mainTabContainer']/ul/li[4]/a");
- $this->waitForElementPresent("xpath=//div[@class='crm-submit-buttons']");
- $this->click("xpath=//div[@class='crm-submit-buttons']/input[@name='_qf_Detail_submit_save']");
-
- // Fill Report Title
- $this->waitForElementPresent("xpath=//div[@class='crm-confirm-dialog ui-dialog-content ui-widget-content modal-dialog']/table/tbody/tr[1]/td[2]/input[@type='text']");
- $this->type("xpath=//div[@class='crm-confirm-dialog ui-dialog-content ui-widget-content modal-dialog']/table/tbody/tr[1]/td[2]/input[@type='text']", $reportName);
-
- // Fill Report Description
- $this->waitForElementPresent("xpath=//div[@class='crm-confirm-dialog ui-dialog-content ui-widget-content modal-dialog']/table/tbody/tr[2]/td[2]/input[@type='text']");
- $this->type("xpath=//div[@class='crm-confirm-dialog ui-dialog-content ui-widget-content modal-dialog']/table/tbody/tr[2]/td[2]/input[@type='text']", $reportDescription);
- $this->click("xpath=//div[@class='ui-dialog-buttonset']/button[1]/span[2]");
-
- // We want navigation menu
- $this->waitForElementPresent('_qf_Detail_submit_next');
- $this->click("xpath=//div[@id='mainTabContainer']/ul/li[6]/a");
- $this->click("is_navigation");
- $this->waitForElementPresent("parent_id");
-
- // Navigation menu under Reports section
- $this->select("parent_id", "label=Reports");
-
- // Set permission as access CiviCRM
- $this->select("permission", "value=access CiviCRM");
-
- // click to create report
- $this->click("_qf_Detail_submit_save");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // Open report list
- $this->openCiviPage('report/list', 'reset=1');
-
- // Is report is resent in list?
- $this->assertElementContainsText('css=div#Contribute > table.report-layout', $reportName);
-
- // Visit report
- $this->click("xpath=//div[@id='Contribute']//table/tbody//tr/td/a/strong[text() = '$reportName']");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- //now select the criteria
- //click report criteria accordion
- $this->click("xpath=//div[@id='mainTabContainer']/ul/li[3]/a");
- $this->waitForElementPresent('_qf_Detail_submit_next');
-
- //enter contribution amount
- $this->waitForAjaxContent();
- $this->select('total_amount_op', "value=gte");
- $this->type('total_amount_value', "10");
-
- // click preview
- $this->click("_qf_Detail_submit");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- //Is greater than or equal to 100
- //check for criteria
- $this->verifyText("xpath=//table[@class='report-layout statistics-table']/tbody/tr[3]/td", "Is greater than or equal to 10");
-
- //click on next link
- $this->click("_qf_Detail_submit");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- // check if criteria still exits
- $this->verifyText("xpath=//table[@class='report-layout statistics-table']/tbody/tr[3]/td", "Is greater than or equal to 10");
- }
-
- /**
- * CRM-18484: To check the filter criteria 'is between'
- */
- public function testCheckIsBetweenFilter() {
- $this->webtestLogin();
-
- //add contact
- $this->openCiviPage('contact/add', 'reset=1&ct=Individual', '_qf_Contact_cancel-bottom');
- $firstName = 'Jo' . substr(sha1(rand()), 0, 4);
- $lastName = 'Ad' . substr(sha1(rand()), 0, 7);
- $this->type('first_name', $firstName);
- $this->type('last_name', $lastName);
-
- //address section
- $this->click("xpath=//div[@id='addressBlockId']/div");
- $this->waitForElementPresent("address_1_street_address");
- $this->type("address_1_street_address", "902C El Camino Way SW");
- $this->type("address_1_city", "Dumfries");
- $this->type("address_1_postal_code", "1234");
- $this->click("address_1_country_id");
- $this->select("address_1_country_id", "value=" . $this->webtestGetValidCountryID());
- $this->click("_qf_Contact_upload_view-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->openCiviPage('report/instance/1', 'reset=1&output=criteria', '_qf_Summary_submit_csv');
- $this->click("fields_postal_code");
- $this->click("xpath=//div[@class='crm-report-criteria']/div[@id='mainTabContainer']/ul//li/a[text()='Filters']");
- $this->waitForElementPresent('gid_value');
- $this->select('postal_code_op', "value=bw");
- $this->waitForElementPresent('postal_code_max');
- $this->type('postal_code_max', '1234');
- $this->click("_qf_Summary_submit");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->assertElementContainsText("xpath=//table[@class='report-layout display']/tbody//tr/td[1]/a", "{$lastName}, {$firstName}");
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Report_LoggingReportTest
- */
-class WebTest_Report_LoggingReportTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testLoggingReport() {
- $this->webtestLogin();
-
- //enable the logging
- $this->openCiviPage('admin/setting/misc', 'reset=1');
- $this->click("xpath=//tr[@class='crm-miscellaneous-form-block-logging']/td[2]/label[text()='Yes']");
- $this->click("_qf_Miscellaneous_next-top");
- $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
- // FIXME: good to do waitForText here but enabling log is time consuming and status may fade out by the time we do the check.
-
- //enable CiviCase component
- $this->enableComponents("CiviCase");
-
- //add new contact
- $originalFirstName = $firstName = 'Anthony' . substr(sha1(rand()), 0, 7);
- $lastName = 'Anderson' . substr(sha1(rand()), 0, 7);
-
- $this->webtestAddContact($firstName, $lastName);
- $cid = $this->urlArg('cid');
-
- //add contact to group
- $this->waitForElementPresent("xpath=//li[@id='tab_group']/a");
- $this->click("xpath=//li[@id='tab_group']/a");
- // Because it tends to cause problems, all uses of sleep() must be justified in comments
- // Sleep should never be used for wait for anything to load from the server
- // Justification for this instance: FIXME
- $this->waitForElementPresent("group_id");
- $this->select("group_id", "label=Case Resources");
- $this->click("_qf_GroupContact_next");
- $this->waitForElementPresent("xpath=//form[@id='GroupContact']//div[@class='view-content view-contact-groups']//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[4]/a");
- $this->click("xpath=//form[@id='GroupContact']//div[@class='view-content view-contact-groups']//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[4]/a");
-
- // Check confirmation alert.
- $this->waitForText("xpath=//div[@class='crm-confirm-dialog ui-dialog-content ui-widget-content modal-dialog']", "Remove $firstName $lastName from Case Resources?");
- $this->click("xpath=//div[@class='ui-dialog-buttonset']//button//span[text()='Continue']");
-
- //tag addition
- $this->waitForElementPresent("xpath=//li[@id='tab_tag']/a");
- $this->click("xpath=//li[@id='tab_tag']/a");
- // Because it tends to cause problems, all uses of sleep() must be justified in comments
- // Sleep should never be used for wait for anything to load from the server
- // Justification for this instance: FIXME
- $this->waitForElementPresent("tagtree");
- $this->click("xpath=//div[@id='tagtree']/ul//li/span/label[text()='Company']");
- $this->waitForTextPresent("Saved");
- $this->click("xpath=//div[@id='tagtree']/ul//li/span/label[text()='Government Entity']");
- $this->waitForTextPresent("Saved");
- $this->click("xpath=//div[@id='tagtree']/ul//li/span/label[text()='Company']");
- $this->waitForTextPresent("Saved");
-
- //add new note
- $this->waitForElementPresent("xpath=//li[@id='tab_note']/a");
- $this->click("xpath=//li[@id='tab_note']/a");
- $this->waitForAjaxContent();
- $this->click("xpath=//div[@class='view-content']//div[@class='action-link']/a[@class='button medium-popup']");
-
- $this->waitForElementPresent("_qf_Note_upload-top");
- $noteSubject = "test note" . substr(sha1(rand()), 0, 7);
- $noteText = "test note text" . substr(sha1(rand()), 0, 7);
- $this->type('subject', $noteSubject);
- $this->type('note', $noteText);
- $this->click("_qf_Note_upload-top");
- $this->waitForElementPresent("xpath=//div[@id='notes']/div/table/tbody/tr/td[7]/span[1]/a[2][text()='Edit']");
- $this->click("xpath=//div[@id='notes']/div/table/tbody/tr/td[7]/span[1]/a[2][text()='Edit']");
- $this->waitForElementPresent("_qf_Note_upload-top");
- $this->type('subject', $noteSubject . "_edited");
- $this->type('note', $noteText . "_edited");
- $this->clickLink("_qf_Note_upload-top", "xpath=//div[@class='crm-results-block']/div[@id='notes']/div/table/tbody/tr//td/span[2]/ul/li[2]/a[text()='Delete']", FALSE);
-
- $this->click("xpath=//div[@id='notes']/div/table/tbody/tr/td[7]/span[2]/ul/li[2]/a[text()='Delete']");
- // Check confirmation alert.
- $this->waitForText("xpath=//form[@id='Note']/div[@class='view-content']/div[@class='status']", "Are you sure you want to delete the note ''?");
- $this->click("xpath=//input[@id='_qf_Note_next']");
- $this->waitForText('crm-notification-container', "Selected Note has been deleted successfully.");
-
- //add new relationship , disable it , delete it
- $this->waitForElementPresent("xpath=//li[@id='tab_rel']/a");
- $this->click("css=li#tab_rel a");
- $this->waitForElementPresent("link=Add Relationship");
- $this->click("link=Add Relationship");
- $this->waitForElementPresent("_qf_Relationship_cancel");
- $this->select("relationship_type_id", "label=Employee of");
- $this->select2('related_contact_id', 'Default', TRUE);
- $this->click('_qf_Relationship_upload-bottom');
- $this->waitForElementPresent("xpath=//div[@id='contact-summary-relationship-tab']/div[2]/div/table/tbody/tr/td[9]/span[2][text()='more']/ul/li[1]/a[text()='Disable']");
-
- $this->click("xpath=//div[@id='contact-summary-relationship-tab']/div[2]/div/table/tbody/tr/td[9]/span[2][text()='more']/ul/li[1]/a[text()='Disable']");
- $this->waitForText("xpath=//div[@class='crm-confirm-dialog ui-dialog-content ui-widget-content modal-dialog crm-ajax-container']", 'Are you sure you want to disable this relationship?');
- $this->click("xpath=//div[@class='ui-dialog-buttonset']//button//span[text()='Yes']");
- $this->waitForElementPresent("xpath=//div[@class='crm-contact-relationship-past']/div//table/tbody//tr/td[9]/span[2][text()='more']/ul/li[2]/a[text()='Delete']");
- $this->click("xpath=//div[@class='crm-contact-relationship-past']/div//table/tbody//tr/td[9]/span[2][text()='more']/ul/li[2]/a[text()='Delete']");
- $this->waitForText("xpath=//form[@id='Relationship']/div[@class='status']", "Are you sure you want to delete this Relationship?");
- $this->click("_qf_Relationship_next-bottom");
- $this->waitForElementPresent("link=Add Relationship");
-
- //update existing contact
- $this->click("xpath=//ul[@id='actions']/li[2]/a");
- $this->waitForElementPresent("_qf_Contact_upload_view-top");
- $firstName = "{$firstName}_edited";
- $this->type("first_name", $firstName);
- $this->click("_qf_Contact_upload_view-top");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- //add an activity
- $this->click("xpath=//li[@id='tab_activity']/a");
- $this->waitForElementPresent("other_activity");
- $this->select("other_activity", "label=Interview");
- $this->waitForElementPresent("_qf_Activity_cancel-bottom");
- $this->click('_qf_Activity_upload-bottom');
- $this->waitForElementPresent("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr//td//span/a[text()='Edit']");
- $this->click("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr//td//span/a[text()='Edit']");
- $this->waitForElementPresent("_qf_Activity_cancel-bottom");
- $this->select("status_id", "value=2");
- $this->waitForAjaxContent();
- $this->click('_qf_Activity_upload-bottom');
- $this->waitForText("crm-notification-container", "Activity has been saved.");
- $this->waitForElementPresent("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[7]/div");
- $this->verifyText("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[7]/div", 'Completed');
-
- //add a case
- $this->click("xpath=//li[@id='tab_case']/a");
- $this->waitForElementPresent("xpath=//form[@id='Search']//div/div//div[@class='action-link']/a");
- $this->click("xpath=//form[@id='Search']//div/div//div[@class='action-link']/a");
- $this->waitForElementPresent("_qf_Case_cancel-bottom");
- $this->type('activity_subject', "subject" . rand());
- $this->select('case_type_id', 'value=1');
- $this->click('_qf_Case_upload-bottom');
- $this->waitForElementPresent("xpath=//table[@class='caseSelector']/tbody//tr/td[9]//span/a[1][text()='Manage']");
- $this->click("xpath=//table[@class='caseSelector']/tbody//tr/td[9]//span/a[1][text()='Manage']");
- $this->waitForElementPresent("xpath=//form[@id='CaseView']/div[2]/table/tbody/tr/td[4]/a");
- $this->click("xpath=//form[@id='CaseView']/div[2]/table/tbody/tr/td[4]/a");
- $this->waitForElementPresent("_qf_Activity_cancel-bottom");
- $this->select("case_status_id", "value=2");
- $this->click("_qf_Activity_upload-top");
- $this->waitForElementPresent("_qf_CaseView_cancel-bottom");
- $this->click("_qf_CaseView_cancel-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- //visit the logging contact summary report
- $this->openCiviPage('report/logging/contact/summary', 'reset=1');
- $this->waitForElementPresent('altered_contact_value');
- $this->type('altered_contact_value', $firstName);
- $this->click("_qf_LoggingSummary_submit");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $data = array(
- //contact data check
- array("log_type" => "Contact", "altered_contact" => "{$firstName} {$lastName}", "action" => "Update"),
- array("log_type" => "Contact", "altered_contact" => "{$firstName} {$lastName}", "action" => "Insert"),
- //relationship data check
- array(
- "log_type" => "Relationship",
- "altered_contact" => "{$firstName} {$lastName} [Employee of]",
- "action" => "Update",
- ),
- array(
- "log_type" => "Relationship",
- "altered_contact" => "{$firstName} {$lastName} [Employee of]",
- "action" => "Insert",
- ),
- array(
- "log_type" => "Relationship",
- "altered_contact" => "{$firstName} {$lastName} [Employee of]",
- "action" => "Delete",
- ),
- //group data check
- array(
- "log_type" => "Group",
- "altered_contact" => "{$firstName} {$lastName} [Case Resources]",
- "action" => "Added",
- ),
- array(
- "log_type" => "Group",
- "altered_contact" => "{$firstName} {$lastName} [Case Resources]",
- "action" => "Removed",
- ),
- //note data check
- array("log_type" => "Note", "altered_contact" => "{$firstName} {$lastName}", "action" => "Update"),
- array("log_type" => "Note", "altered_contact" => "{$firstName} {$lastName}", "action" => "Insert"),
- array("log_type" => "Note", "altered_contact" => "{$firstName} {$lastName}", "action" => "Delete"),
- //tags data check
- array("log_type" => "Tag", "altered_contact" => "{$firstName} {$lastName} [Company]", "action" => "Insert"),
- array(
- "log_type" => "Tag",
- "altered_contact" => "{$firstName} {$lastName} [Government Entity]",
- "action" => "Insert",
- ),
- array("log_type" => "Tag", "altered_contact" => "{$firstName} {$lastName} [Company]", "action" => "Delete"),
- //case data check
- array(
- "log_type" => "Case",
- "altered_contact" => "{$firstName} {$lastName} [Housing Support]",
- "action" => "Update",
- ),
- array(
- "log_type" => "Case",
- "altered_contact" => "{$firstName} {$lastName} [Housing Support]",
- "action" => "Insert",
- ),
- //case activity check
- array(
- "log_type" => "Activity",
- "altered_contact" => "{$firstName} {$lastName} [Interview]",
- "action" => "Update",
- ),
- array(
- "log_type" => "Activity",
- "altered_contact" => "{$firstName} {$lastName} [Interview]",
- "action" => "Insert",
- ),
- );
- $this->verifyReportData($data);
-
- //update link (logging details report check)
- $contactInfo = array();
- $contactInfo['data'] = array(
- array(
- 'field' => 'Sort Name',
- 'changed_from' => "{$lastName}, {$originalFirstName}",
- 'changed_to' => "{$lastName}, {$firstName}",
- ),
- array(
- 'field' => 'Display Name',
- 'changed_from' => "{$originalFirstName} {$lastName}",
- 'changed_to' => "{$firstName} {$lastName}",
- ),
- array('field' => 'First Name', 'changed_from' => $originalFirstName, 'changed_to' => $firstName),
- // array('field' => 'Email Greeting', 'changed_from' => "Dear {$originalFirstName}", 'changed_to' => "Dear {$firstName}"),
- // array('field' => 'Postal Greeting', 'changed_from' => "Dear {$originalFirstName}", 'changed_to' => "Dear {$firstName}"),
- // array('field' => 'Addressee', 'changed_from' => "{$originalFirstName} {$lastName}", 'changed_to' => "{$firstName} {$lastName}"),
- );
- $contactInfo = array_merge($contactInfo, $data[0]);
-
- $relationshipInfo = array();
- $relationshipInfo['data'] = array(
- array('field' => 'Relationship Is Active', 'changed_from' => 'true', 'changed_to' => 'false'),
- );
- $relationshipInfo = array_merge($relationshipInfo, $data[2]);
-
- $noteInfo = array();
- $noteInfo['data'] = array(
- array('field' => 'Note', 'changed_from' => $noteText, 'changed_to' => "{$noteText}_edited"),
- array('field' => 'Subject', 'changed_from' => $noteSubject, 'changed_to' => "{$noteSubject}_edited"),
- );
- $noteInfo = array_merge($noteInfo, $data[7]);
-
- $caseInfo = array();
- $caseInfo['data'] = array(
- array('field' => 'Case Status Id', 'changed_from' => 'Ongoing', 'changed_to' => "Resolved"),
- );
- $caseInfo = array_merge($caseInfo, $data[13]);
-
- $activityInfo = array();
- $activityInfo['data'] = array(
- array('field' => 'Activity Status Id', 'changed_from' => 'Scheduled', 'changed_to' => 'Completed'),
- );
- $activityInfo = array_merge($activityInfo, $data[15]);
-
- $dataForReportDetail = array($contactInfo, $relationshipInfo, $noteInfo, $caseInfo, $activityInfo);
- $filters = array(
- 'text' => array('altered_contact_value' => "{$firstName} {$lastName}"),
- );
- $this->detailReportCheck($dataForReportDetail, $filters);
-
- //delete contact check
- $this->openCiviPage('contact/view/delete', "reset=1&delete=1&cid=$cid");
- $this->click("_qf_Delete_done");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->openCiviPage('report/logging/contact/summary', 'reset=1');
- $this->click("_qf_LoggingSummary_submit");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $contactDataDelete = array(
- array(
- "log_type" => "Contact",
- "altered_contact" => "{$firstName} {$lastName}",
- "action" => "Delete (to trash)",
- ),
- );
- $this->verifyReportData($contactDataDelete);
-
- //disable the logging
- $this->openCiviPage('admin/setting/misc', 'reset=1');
- $this->waitForElementPresent("xpath=//tr[@class='crm-miscellaneous-form-block-logging']/td[2]/label[text()='No']");
- $this->click("xpath=//tr[@class='crm-miscellaneous-form-block-logging']/td[2]/label[text()='No']");
- $this->click("_qf_Miscellaneous_next-top");
- $this->waitForTextPresent("Changes Saved");
- }
-
- /**
- * @param $data
- */
- public function verifyReportData($data) {
- foreach ($data as $value) {
- // check for the row contains proper data
- $actionPath = ($value['action'] == 'Update') ? "td[1]/a[2]" : "td[1][contains(text(), '{$value['action']}')]";
- $contactCheck = ($value['action'] == 'Delete (to trash)') ? "td[4][contains(text(), '{$value['altered_contact']}')]" : "td[4]/a[contains(text(), '{$value['altered_contact']}')]/..";
-
- $this->assertTrue($this->isElementPresent("xpath=//table/tbody//tr/td[2][contains(text(), '{$value['log_type']}')]/../{$contactCheck}/../{$actionPath}"), "The proper record not present for (log type : {$value['log_type']}, altered contact : {$value['altered_contact']}, action as {$value['action']})");
-
- if ($value['action'] == 'Update') {
- $this->assertTrue(($value['action'] == $this->getText("xpath=//table/tbody//tr/td[2][contains(text(), '{$value['log_type']}')]/../td[4]/a[contains(text(), '{$value['altered_contact']}')]/../../{$actionPath}")), "The proper record action {$value['action']} not present for (log type : {$value['log_type']}, altered contact : {$value['altered_contact']} record)");
- }
- }
- }
-
- /**
- * @param $dataForReportDetail
- * @param array $filters
- */
- public function detailReportCheck($dataForReportDetail, $filters = array()) {
- foreach ($dataForReportDetail as $value) {
- $this->waitForElementPresent("xpath=//table/tbody//tr/td[2][contains(text(), '{$value['log_type']}')]/../td[4]/a[contains(text(), '{$value['altered_contact']}')]/../../td[1]/a[2]");
- $this->click("xpath=//table/tbody//tr/td[2][contains(text(), '{$value['log_type']}')]/../td[4]/a[contains(text(), '{$value['altered_contact']}')]/../../td[1]/a[2]");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- foreach ($value['data'] as $key => $data) {
- $rowCount = $this->getXpathCount("//table[@class='report-layout display']/tbody/tr");
- for ($i = 1; $i <= $rowCount; $i++) {
- $field = $data['field'];
- if ($this->isElementPresent("xpath=//form[@id='LoggingDetail']//table/tbody/tr[{$i}]/td[@class='crm-report-field'][text()='$field']")) {
- $this->verifyText("xpath=//form[@id='LoggingDetail']//table/tbody/tr[{$i}]/td[@class='crm-report-field']", preg_quote($data['field']));
- $this->verifyText("xpath=//form[@id='LoggingDetail']//table/tbody/tr[{$i}]/td[@class='crm-report-from']", preg_quote($data['changed_from']));
- $this->verifyText("xpath=//form[@id='LoggingDetail']//table/tbody/tr[{$i}]/td[@class='crm-report-to']", preg_quote($data['changed_to']));
- }
- }
- }
-
- //visit the logging contact summary report
- $this->openCiviPage('report/logging/contact/summary', 'reset=1');
- foreach ($filters as $type => $filter) {
- if ($type == 'text') {
- foreach ($filter as $filterName => $filterValue) {
- $this->type($filterName, $filterValue);
- }
- }
- }
- $this->click("_qf_LoggingSummary_submit");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- }
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-require_once 'CiviTest/CiviSeleniumTestCase.php';
-
-/**
- * Class WebTest_Report_RolePermissionReportTest
- */
-class WebTest_Report_RolePermissionReportTest extends CiviSeleniumTestCase {
-
- protected function setUp() {
- parent::setUp();
- }
-
- public function testRolePermissionReport() {
- $this->webtestLogin('admin');
-
- //create new roles
- $role1 = 'role1' . substr(sha1(rand()), 0, 7);
- $role2 = 'role2' . substr(sha1(rand()), 0, 7);
- $this->open($this->sboxPath . "admin/people/permissions/roles");
- $this->waitForElementPresent("edit-add");
- $this->type("edit-name", $role1);
- $this->click("edit-add");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->open($this->sboxPath . "admin/people/permissions/roles");
- $this->waitForElementPresent("edit-add");
- $this->type("edit-name", $role2);
- $this->click("edit-add");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->open($this->sboxPath . "admin/people/permissions/roles");
-
- $this->waitForElementPresent("xpath=//table[@id='user-roles']/tbody//tr/td[1][text()='{$role1}']");
- $roleid = explode('/', $this->getAttribute("xpath=//table[@id='user-roles']/tbody//tr/td[1][text()='{$role1}']/../td[4]/a[text()='edit permissions']/@href"));
- $roleId1 = end($roleid);
- $this->waitForElementPresent("xpath=//table[@id='user-roles']/tbody//tr/td[1][text()='{$role2}']");
- $roleid = explode('/', $this->getAttribute("xpath=//table[@id='user-roles']/tbody//tr/td[1][text()='{$role2}']/../td[4]/a[text()='edit permissions']/@href"));
- $roleId2 = end($roleid);
-
- $user1 = $this->_testCreateUser($roleId1);
- $user2 = $this->_testCreateUser($roleId2);
-
- // let's give full CiviReport permissions.
- $permissions = array(
- "edit-2-access-civireport",
- "edit-2-view-all-contacts",
- "edit-2-administer-civicrm",
- "edit-2-access-civicrm",
- );
- $this->changePermissions($permissions);
-
- // change report setting to for a particular role
- $this->openCiviPage('report/instance/1', 'reset=1');
- $this->click("xpath=//div[@id='mainTabContainer']/ul/li[6]/a");
- $this->waitForElementPresent("_qf_Summary_submit_save");
- $this->select("permission", "value=access CiviCRM");
- $this->select("grouprole-f", "value=$role1");
- $this->click("add");
- $this->click("_qf_Summary_submit_save");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->webtestLogin($user2, 'Test12345');
- $this->openCiviPage('report/instance/1', 'reset=1');
- $this->assertElementContainsText('crm-container', 'You do not have permission to access this report.');
- $this->openCiviPage('report/list', 'reset=1');
-
- //delete roles
- $this->webtestLogin('admin');
- $this->open($this->sboxPath . "admin/people/permissions/roles");
- $this->_roleDelete($role1);
- $this->_roleDelete($role2);
- }
-
- /**
- * Check for CRM-10148.
- */
- public function testReservedReportPermission() {
- $this->webtestLogin('admin');
-
- //create new role
- $role = 'role' . substr(sha1(rand()), 0, 7);
- $this->open($this->sboxPath . "admin/people/permissions/roles");
-
- $this->waitForElementPresent("edit-add");
- $this->type("edit-name", $role);
- $this->click("edit-add");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->open($this->sboxPath . "admin/people/permissions/roles");
- $this->waitForElementPresent("xpath=//table[@id='user-roles']/tbody//tr/td[1][text()='{$role}']");
- $roleId = explode('/', $this->getAttribute("xpath=//table[@id='user-roles']/tbody//tr/td[1][text()='{$role}']/../td[4]/a[text()='edit permissions']/@href"));
- $roleId = end($roleId);
- $user = $this->_testCreateUser($roleId);
- $this->openCiviPage('report/instance/1', 'reset=1');
- if ($this->isChecked("is_reserved")) {
- $this->click("is_reserved");
- $this->click("_qf_Summary_submit_save");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- }
- $permissions = array(
- "edit-{$roleId}-access-civireport",
- "edit-{$roleId}-view-all-contacts",
- "edit-{$roleId}-administer-reports",
- "edit-{$roleId}-access-civicrm",
- );
- $this->changePermissions($permissions);
-
- $this->webtestLogin($user, 'Test12345');
- $this->openCiviPage('report/instance/1', 'reset=1');
-
- //check if the reserved report field is frozen
- $this->assertTrue($this->isElementPresent("xpath=//div[@id='report-tab-access']/table/tbody//tr/td[2]/span/tt[text()='[ ]']"));
-
- // let's give full CiviReport permissions.
- $permissions = array(
- "edit-{$roleId}-access-civireport",
- "edit-{$roleId}-view-all-contacts",
- "edit-{$roleId}-administer-reports",
- "edit-{$roleId}-access-civicrm",
- "edit-{$roleId}-administer-reserved-reports",
- );
- $this->changePermissions($permissions);
-
- $this->openCiviPage('report/instance/1', 'reset=1');
-
- //make the report reserved
- $this->click("is_reserved");
- $this->click("_qf_Summary_submit_save");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->webtestLogin($user, 'Test12345');
- $this->openCiviPage('report/instance/1', 'reset=1');
-
- //check if the report criteria and settings is accessible
- $this->assertTrue($this->isElementPresent("xpath=//div[@id='report-tab-col-groups']/table/tbody//tr/td[1]/input[@id='fields_email']"));
- $this->assertTrue($this->isElementPresent("xpath=//div[@id='report-tab-format']/table/tbody//tr/td[2]/input[@id='title']"));
-
- //login as admin and remove reserved permission
- $this->webtestLogin('admin');
- $this->open($this->sboxPath . "admin/people/permissions");
- $this->waitForElementPresent("edit-submit");
-
- if ($this->isChecked("edit-2-administer-reserved-reports")) {
- $this->click("edit-2-administer-reserved-reports");
- }
- else {
- $this->click("edit-{$roleId}-administer-reserved-reports");
- }
- $this->click("edit-submit");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- //login as user and check for absence of report criteria and settings
- $this->webtestLogin($user, 'Test12345');
- $this->openCiviPage('report/instance/1', 'reset=1');
-
- if ($this->isElementPresent("xpath=//div[@id='mainTabContainer']/ul/li")) {
- $this->verifyNotText("xpath=//div[@id='mainTabContainer']/ul/li/a", "Columns");
- }
- if ($this->isElementPresent("xpath=//li[@id='tab_settings']")) {
- $this->verifyNotText("xpath=//li[@id='tab_settings']/a", "Title and Format");
- }
-
- $this->assertFalse($this->isElementPresent("xpath=//div[@id='report-tab-format']/table/tbody//tr/td[2]/input[@id='title']"));
-
- //login as admin and turn the is_reserved flag off for the instance
- $this->webtestLogin('admin');
- $this->openCiviPage('report/instance/1', 'reset=1');
- $this->click("is_reserved");
- $this->click("_qf_Summary_submit_save");
- $this->waitForPageToLoad($this->getTimeoutMsec());
-
- $this->webtestLogin($user, 'Test12345');
- $this->openCiviPage('report/instance/1', 'reset=1');
-
- $this->assertTrue($this->isElementPresent("xpath=//div[@id='report-tab-col-groups']/table/tbody//tr/td[1]/input[@id='fields_email']"));
- $this->assertTrue($this->isElementPresent("xpath=//div[@id='report-tab-format']/table/tbody//tr/td[2]/input[@id='title']"));
-
- //login as admin and delete the role
- $this->webtestLogin('admin');
- $this->open($this->sboxPath . "admin/people/permissions/roles");
- $this->_roleDelete($role);
- }
-
- /**
- * @param $role
- */
- public function _roleDelete($role) {
- $this->waitForElementPresent("xpath=//table[@id='user-roles']/tbody//tr/td[text()='{$role}']/..//td/a[text()='edit role']");
- $this->click("xpath=//table[@id='user-roles']/tbody//tr/td[text()='{$role}']/..//td/a[text()='edit role']");
- $this->waitForElementPresent('edit-delete');
- $this->click('edit-delete');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->click("edit-submit");
- $this->waitForTextPresent("The role has been deleted.");
- }
-
- /**
- * @param int $roleid
- *
- * @return string
- */
- public function _testCreateUser($roleid) {
-
- $this->open($this->sboxPath . "admin/people/create");
-
- $this->waitForElementPresent("edit-submit");
-
- $name = "TestUser" . substr(sha1(rand()), 0, 4);
- $this->type("edit-name", $name);
-
- $emailId = substr(sha1(rand()), 0, 7) . '@web.com';
- $this->type("edit-mail", $emailId);
- $this->type("edit-pass-pass1", "Test12345");
- $this->type("edit-pass-pass2", "Test12345");
- $role = "edit-roles-" . $roleid;
- $this->check("name=roles[$roleid] value={$roleid}");
-
- //Add profile Details
- $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
- $lastName = 'An' . substr(sha1(rand()), 0, 7);
-
- $this->type("first_name", $firstName);
- $this->type("last_name", $lastName);
-
- //Address Details
- $this->type("street_address-1", "902C El Camino Way SW");
- $this->type("city-1", "Dumfries");
- $this->type("postal_code-1", "1234");
- $this->select("state_province-1", "value=1019");
-
- $this->click("edit-submit");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- return $name;
- }
-
-}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License along with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
- */
-
-define('CIVICRM_WEBTEST', 1);
-
-/**
- * Check that we handle redirects appropriately.
- */
-class WebTest_Utils_RedirectTest extends PHPUnit_Framework_TestCase {
- protected $url;
- protected $ch;
-
- /**
- * @param string|null $name
- */
- public function __construct($name = NULL) {
- parent::__construct($name);
-
- // TODO: Just use $GLOBALS['_CV'] and don't bother with CiviSeleniumSettings.
- $this->settings = new CiviSeleniumSettings();
- if (property_exists($this->settings, 'serverStartupTimeOut') && $this->settings->serverStartupTimeOut) {
- global $CiviSeleniumTestCase_polled;
- if (!$CiviSeleniumTestCase_polled) {
- $CiviSeleniumTestCase_polled = TRUE;
- CRM_Utils_Network::waitForServiceStartup(
- $this->drivers[0]->getHost(),
- $this->drivers[0]->getPort(),
- $this->settings->serverStartupTimeOut
- );
- }
- }
- }
-
- protected function setUp() {
- parent::setUp();
- //URL should eventually be adapted for multisite
- $this->url = $this->settings->sandboxURL;
-
- $this->ch = curl_init();
- curl_setopt($this->ch, CURLOPT_HEADER, FALSE);
- curl_setopt($this->ch, CURLOPT_FOLLOWLOCATION, FALSE);
- // curl_setopt($this->ch, CURLOPT_ENCODING, 'gzip');
- // curl_setopt($this->ch, CURLOPT_VERBOSE, 0);
- }
-
- /**
- * Try redirect.
- *
- * @param string $input_url
- * @param string $expected_url
- */
- private function tryRedirect($input_url, $expected_url) {
- // file_put_contents('php://stderr', $input_url . "\n", FILE_APPEND);
- $url = $this->url . '/' . $input_url;
- $expected_url = $this->url . '/' . $expected_url;
- curl_setopt($this->ch, CURLOPT_URL, $url);
- $req = curl_exec($this->ch);
- $this->assertEquals(0, curl_errno($this->ch), 'cURL error: ' . curl_error($this->ch));
- if (!curl_errno($this->ch)) {
- $info = curl_getinfo($this->ch);
- // file_put_contents('php://stderr', print_r($info,1), FILE_APPEND);
- $this->assertEquals($expected_url, $info['redirect_url']);
- $this->assertEquals('302', $info['http_code']);
- }
- }
-
- /**
- * Handle onsite redirects with absolute URL.
- */
- public function testAbsoluteOnsiteRedirect() {
- $this->tryRedirect("civicrm/contribute/transact?qfKey=xxx&entryURL={$this->url}/civicrm/contribute/transact%3Fid%3D1", 'civicrm/contribute/transact?id=1');
- }
-
- /**
- * Handle onsite redirects with slash prefix and query params.
- */
- public function testOnsiteRedirectWithSlashPrefixAndQueryParams() {
- $this->tryRedirect('civicrm/contribute/transact?qfKey=xxx&entryURL=/civicrm/contribute/transact%3Fid%3D1', 'civicrm/contribute/transact?id=1');
- }
-
- /**
- * Handle onsite redirects with non-CiviCRM paths.
- */
- public function testOtherpathRedirect() {
- $this->tryRedirect('civicrm/contribute/transact?qfKey=xxx&entryURL=asdf', 'asdf');
- }
-
- /**
- * Handle offsite redirects without path as onsite redirects.
- */
- public function testOffsiteRedirectNoPath() {
- $this->tryRedirect('civicrm/contribute/transact?qfKey=xxx&entryURL=http://evil.example.com/', '');
- }
-
- /**
- * Handle offsite redirects with paths as onsite redirects.
- */
- public function testOffsiteRedirectWithPath() {
- $this->tryRedirect('civicrm/contribute/transact?qfKey=xxx&entryURL=http://evil.example.com/civicrm', 'civicrm');
- }
-
-}
+++ /dev/null
-Contact ID,Type,Activity Date,Subject,Status,Duration (minutes),Location,Details\r69,Phone Call,20071111 10:30,Volunteer solicitation,Completed,60,,Not interested\r90,Meeting,20070915 14:30,Fall fund-raiser,Cancelled,15,,\r29,Interview,20090209 08:30,New staff hiring,Scheduled,45,Room 200,\r102,Meeting,20071215,Volunteer orientation,Completed,120,Janet's office,20 attendees. Great session\r90,Email,20091111 18:30,Volunteer solicitation,Completed,5,,
\ No newline at end of file
+++ /dev/null
-Title,First Name,Middle Name,Last Name,Nick Name,Email,Street,City,State,Zip,Zip + 4,ID,Web Site,Gender,D.O.B.,Last Voted Date,Do Not Call,Preferred Comm,Important Issue,District,Suffix,External ID,Location Name,Employer\rMS,Paula,A,Smarts,,psmarts@gmail.com,20 Main St.,Portland,OR,97092,4112,23,http://www.foobar.org/psmarts.htm,Other,19560511,20041111,1,EMAIL,Education,District 1,JR,N101,Main Home,CiviCRM LLC\rMr,Peter,William,Smarts,Pete,petesmarts@gmail.com,20 Main St.,Portland,OR,97092,4112,34,http://www.foobar.org/psmarts.htm,MALE,19511010,20041003,1,email,Edu,1,sr,N102,Main Home,Tahoe Donner\rDR,Dan,,Foobar,,dan.foobar@foo.org,,San Mateo,CA,90192-1449,,45,,male,19721105,20041003,1,Postal Mail,Environment,2,SR,N103,College Address,Northstar\rMrs,Pat,April,Foobar,Petunia,pat.foobar@sos.org,,San Mateo,CA,90192,1611,56,,Female,19510927,20041003,1,phone,Env,District 2,,N105,Summer Home,\rms,Jackie,,Johnson,,jackie@example.org,10 Main #3,Newton,MA,1924,,66,,Female,19650102,20041003,0,Phone,Env,1,Jr,N110,,
\ No newline at end of file
+++ /dev/null
-Contact ID,External ID,Contribution Type,Amount,Date,Payment Method,Source,Transaction ID,Fee Amount,Non-deductible,Check #\r2,22,Campaign Contribution,125,20081011,Check,Oct 2005 Mailer 1,,,125,109\r4,44,Donation,50,20080921,Credit Card,Online: Save the Penguins,P20901X9,1.75,,\r6,66,Campaign Contribution,25,20081029,Check,Oct 2005 Mailer 1,,,25,2309\r55,55abc,Campaign Contribution,2175,20081011,Check,Oct 2005 Mailer 1,,,175,1902\r32,3232abc,Donation,50,20080927,Credit Card,Online: Save the Penguins,P20193L235,1.75,,\r92,9292,Donation,10,20080908,Credit Card,Online: Save the Penguins,P40232Y256,0.27,,\r34,3434,Donation,250,20081022,Credit Card,Online: Save the Penguins,P20193SSS092,3.55,,\r199,199199,Donation,250,20081022,Credit Card,Online: Save the Penguins,XJA090322,3.55,,
\ No newline at end of file
+++ /dev/null
-Email,Contribution Type,Amount,Receive Date,Payment Method,Source,Transaction ID,Invoice ID,Status,Comments\rjake@foo.org,Donation,125,,,Oct 2005 Mailer 1,,,Completed,Coming in by mail.\rdggreenberg@gmail.com,Donation,50,20060111,Check,Dec 2005 Mailer,,,Pending,\radamspeter@hotmail.com,Member Dues,25,20051029,Check,Oct 2005 Mailer 1,check #2095,10924,Completed,\r,Member Dues,50,20051011,Check,Oct 2005 Mailer 1,check #10552,10925,Completed,
\ No newline at end of file
+++ /dev/null
-External ID,Contribution Type,Amount,Date,Payment Method,Source,Transaction ID,Fee Amount,Non-deductible\rN101,Campaign Contribution,125,20051011,Check,Oct 2005 Mailer 1,check #1066,,125\rN102,Donation,50,20050921,Credit Card,Online: Save the Penguins,P20901X9,1.75,\rN103,Campaign Contribution,25,20051029,Check,Oct 2005 Mailer 1,Acct 2099002 check #2098,,25\rN105,Campaign Contribution,50,20051011,Cash,Oct 2005 Mailer 1,,,50\rN110,Campaign Contribution,500,20051015,Check,Oct 2005 Mailer 1,10909131 #09022,,500
\ No newline at end of file
+++ /dev/null
-Contact ID,Contribution Type,Amount,Date,Payment Method,Source,Transaction ID,Fee Amount,Non-deductible,Region-Alpha,Region-Int,External ID\r103,Campaign Contribution,33,20070111,Check,Mar 2007 Mailer 1,check #1066,,125,East,1,N101\r104,Donation,33,20070521,Credit Card,Online: Save the Penguins,P20901X9,1.75,,East Region,East Region,N110\r105,Campaign Contribution,33,20070129,Check,Mar 2007 Mailer 1,Acct 2099002 check #2098,,25,West,2,N102\r105,Campaign Contribution,33,20070411,Cash,Mar 2007 Mailer 1,,,50,West Region,West Region,N105\r107,Donation,33,20070315,Check,Mar 2007 Mailer 1,10909131 #09022,,500,Foo,3,N105
\ No newline at end of file
+++ /dev/null
-Internal Contact ID,Source of Contact Data\r13,Export\r16,Export\r17,Export\r23,Export\r27,Export\r33,Export\r34,Export\r35,Export\r36,Export\r50,\r53,\r56,\r70,\r88,Export\r89,Export
\ No newline at end of file
+++ /dev/null
-Household,Census ID,Household Email,Street Address,City,State,Zip,House Phone,Head of Household First Name,Last Name,Email,Mobile Phone\rGranville Clan,2022,carol@granvilleclan.org,12 Texas NE,Washington,DC,10952,301-222-2200,Carol,Granville,cgranville@gmail.com,301-222-2212\rThe Handlers,2022,pamh@hosf.org,22 Roosevelt Way,San Francisco,CA,97092,415 229-0920,Pam,Handler,pamh@hosf.org,415 209-0109\rAdler Household,5092,,411 Buena Vista Terrace,San Francisco,CA,94117,415 242-1095,Alvin,Adler,,415 409-2044\rThe Chipster Family,,,25 Aguilar St.,San Jose,CA,92051,408 555-0942,Gary,Chipster,gchipster@baynet.com,
\ No newline at end of file
+++ /dev/null
-Internal Contact ID,Source of Contact Data\r31,Export 2\r69,Export 2\r55,Export 2\r6,Export 2\r25,Export 2\r67,Export 2\r32,Export 2\r40,Export 2\r3,Export 2\r54,Export 2\r42,Export 2\r5,Export 2\r8,Export 2\r14,Export 2\r15,Export 2\r19,Export 2\r30,Export 2\r12,Export 2\r101,Export 2\r48,Export 2\r93,Export 2\r68,Export 2\r46,Export 2\r85,Export 2\r66,Export 2
\ No newline at end of file
+++ /dev/null
-Internal Contact ID,Org Name,Sic Code,Note(s)\r1,Inner City Arts,SIC1,\r21,Magic Bus ,SIC41,Send reminder for annual dinner\r41,Red Cross,SIC41,Connect for presentation\r112,Compasspoint ,,Send newsletter for April 2005
\ No newline at end of file
+++ /dev/null
-Organization Name,SIC Code,Legal Name,EIN,Main Email,Main Address,City,State,Zip,Main Phone,Web Site,Primary Contact First Name,Last Name,Email,Phone\rFairness Network,2022,Fairness Inc.,930023341,info@fairness.org,20 Main St.,Washington,DC,10222-3332,301-222-2200,http://www.example.org,James,Brown,jbrownr@fairness.org,301-222-2212\rHOSF,2022,Hands On San Francisco,950221111,info@hosf.org,1 Market St.,San Francisco,CA,97092,415 229-0920,http://www.hosf.org,Pam,Handler,pamh@hosf.org,\rPeet's Cofee,5092,Peet's Coffee and Spices Inc.,940115233,sales@peets.com,255 Mission St.,San Francisco,CA,94110-4022,415 991-0000,http://www.peets.com,,,,\rFairness Network,,Fairness Ltd.,,info@fairness.uk,,London,,B1251,,,Gary,Chipster,gary@fairness.org.uk,011 2522322
\ No newline at end of file
+++ /dev/null
-External ID,Event,Status,Role,Fee Level,Fee Amount,Email\r108ex,Summer Solstice Festival Day Concert,Registered,Attendee,Bass,22.5,jake@foo.org\r102ex,Rain-forest Cup Youth Soccer Tournament,Cancelled,Volunteer,Tiny-tots (ages 5-8),800,dggreenberg@gmail.com\rabcNo,Summer Solstice Festival Day Concert,Registered,Volunteer,,,adamspeter@hotmail.com\r7,Rain-forest Cup Youth Soccer Tournament,Registered,Attendee,,,
\ No newline at end of file