$activityIcons[$type['value']] = $type['icon'];
}
}
- CRM_Utils_Date::convertFormDateToApiFormat($params, 'activity_date_time', FALSE);
+ CRM_Utils_Date::convertFormDateToApiFormat($params, 'activity_date_time');
// Get contact activities.
$activities = CRM_Activity_BAO_Activity::getActivities($params);
$activityOptions = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE);
asort($activityOptions);
- $this->add('select', 'activity_type_filter_id', ts('Include'), array('' => ts('- all activity type(s) -')) + $activityOptions);
- $this->add('select', 'activity_type_exclude_filter_id', ts('Exclude'), array('' => ts('- select activity type -')) + $activityOptions);
- CRM_Core_Form_Date::buildDateRange(
- $this, 'activity_date_time', 1,
- '_low', '_high', ts('From:'),
- FALSE, array(), 'searchDate',
- FALSE, array('class' => 'crm-select2 medium')
- );
+ $this->add('select', 'activity_type_filter_id', ts('Include'), $activityOptions, FALSE, ['class' => 'crm-select2', 'multiple' => TRUE, 'placeholder' => ts('- all activity type(s) -')]);
+ $this->add('select', 'activity_type_exclude_filter_id', ts('Exclude'), $activityOptions, FALSE, ['class' => 'crm-select2', 'multiple' => TRUE, 'placeholder' => ts('- no types excluded -')]);
+ $this->addDatePickerRange('activity_date_time', ts('Date'));
$this->addSelect('status_id',
array('entity' => 'activity', 'multiple' => 'multiple', 'option_url' => NULL, 'placeholder' => ts('- any -'))
);
$formSearchField = 'activity_type_exclude_filter_id';
}
if (!empty($params[$searchField])) {
- $activityFilter[$formSearchField] = CRM_Utils_Type::escape($params[$searchField], $dataType);
- if (in_array($searchField, array('activity_date_low', 'activity_date_high'))) {
- $activityFilter['activity_date_relative'] = 0;
+ $activityFilter[$formSearchField] = $params[$searchField];
+ if (in_array($searchField, array('activity_date_time_low', 'activity_date_time_high'))) {
+ $activityFilter['activity_date_time_relative'] = 0;
}
elseif ($searchField == 'activity_status_id') {
$activityFilter['status_id'] = explode(',', $activityFilter[$searchField]);
}
}
- elseif (in_array($searchField, array('activity_type_id', 'activity_type_exclude_id'))) {
- $activityFilter[$formSearchField] = '';
- }
}
Civi::contactSettings()->set('activity_tab_filter', $activityFilter);
while ($dao->fetch()) {
$paymentProcessor[$dao->id] = array();
CRM_Core_DAO::storeValues($dao, $paymentProcessor[$dao->id]);
- $paymentProcessor[$dao->id]['payment_processor_type'] = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_PaymentProcessorType',
- $paymentProcessor[$dao->id]['payment_processor_type_id']);
+ $paymentProcessor[$dao->id]['payment_processor_type'] = CRM_Core_PseudoConstant::getLabel(
+ 'CRM_Financial_DAO_PaymentProcessor', 'payment_processor_type_id', $dao->payment_processor_type_id
+ );
// form all action links
$action = array_sum(array_keys($this->links()));
$dao->id
);
$paymentProcessor[$dao->id]['financialAccount'] = CRM_Contribute_PseudoConstant::getRelationalFinancialAccount($dao->id, NULL, 'civicrm_payment_processor', 'financial_account_id.name');
+ $paymentProcessor[$dao->id]['test_id'] = CRM_Financial_BAO_PaymentProcessor::getTestProcessorId($dao->id);
}
$this->assign('rows', $paymentProcessor);
$xmlFile .= "</CaseRoles>\n";
}
+ if (array_key_exists('restrictActivityAsgmtToCmsUser', $definition)) {
+ $xmlFile .= "<RestrictActivityAsgmtToCmsUser>" . $definition['restrictActivityAsgmtToCmsUser'] . "</RestrictActivityAsgmtToCmsUser>\n";
+ }
+
+ if (!empty($definition['activityAsgmtGrps'])) {
+ $xmlFile .= "<ActivityAsgmtGrps>\n";
+ foreach ($definition['activityAsgmtGrps'] as $value) {
+ $xmlFile .= "<Group>$value</Group>\n";
+ }
+ $xmlFile .= "</ActivityAsgmtGrps>\n";
+ }
+
$xmlFile .= '</CaseType>';
+
return $xmlFile;
}
$definition['forkable'] = (int) $xml->forkable;
}
+ if (isset($xml->RestrictActivityAsgmtToCmsUser)) {
+ $definition['restrictActivityAsgmtToCmsUser'] = (int) $xml->RestrictActivityAsgmtToCmsUser;
+ }
+
+ if (isset($xml->ActivityAsgmtGrps)) {
+ $definition['activityAsgmtGrps'] = (array) $xml->ActivityAsgmtGrps->Group;
+ }
+
// set activity types
if (isset($xml->ActivityTypes)) {
$definition['activityTypes'] = array();
class CRM_Case_Form_Activity extends CRM_Activity_Form_Activity {
/**
- * The default variable defined.
+ * Cases this activity belongs to.
*
- * @var int
+ * @var []int
*/
public $_caseId;
/**
* The default case type variable defined.
*
- * @var int
+ * @var []int
*/
public $_caseType;
*/
public $_relatedContacts;
+ /**
+ * The case type definition column info
+ * for the caseId;
+ *
+ * @var array
+ */
+ public $_caseTypeDefinition;
+
/**
* Build the form object.
*/
public function preProcess() {
- $caseIds = CRM_Utils_Request::retrieve('caseid', 'String', $this);
- $this->_caseId = explode(',', $caseIds);
+ $caseIds = CRM_Utils_Request::retrieve('caseid', 'CommaSeparatedIntegers', $this);
+ $this->_caseId = $caseIds ? explode(',', $caseIds) : [];
$this->_context = CRM_Utils_Request::retrieve('context', 'Alphanumeric', $this);
if (!$this->_context) {
$this->_context = 'caseActivity';
$this->assign('scheduleStatusId', $scheduleStatusId);
if (!$this->_caseId && $this->_activityId) {
- $this->_caseId = CRM_Core_DAO::getFieldValue('CRM_Case_DAO_CaseActivity', $this->_activityId,
+ $this->_caseId = (array) CRM_Core_DAO::getFieldValue('CRM_Case_DAO_CaseActivity', $this->_activityId,
'case_id', 'activity_id'
);
}
}
$this->assign('caseType', $this->_caseType);
+ $this->_caseTypeDefinition = $this->getCaseTypeDefinition();
+
$xmlProcessorProcess = new CRM_Case_XMLProcessor_Process();
$isMultiClient = $xmlProcessorProcess->getAllowMultipleCaseClients();
$this->assign('multiClient', $isMultiClient);
$this->_fields['source_contact_id']['label'] = ts('Reported By');
unset($this->_fields['status_id']['attributes']['required']);
+ if ($this->restrictAssignmentByUserAccount()) {
+ $assigneeParameters['uf_user'] = 1;
+ }
+
+ $activityAssignmentGroups = $this->getActivityAssignmentGroups();
+ if (!empty($activityAssignmentGroups)) {
+ $assigneeParameters['group'] = ['IN' => $activityAssignmentGroups];
+ }
+
+ if (!empty($assigneeParameters)) {
+ $this->_fields['assignee_contact_id']['attributes']['api']['params']
+ = array_merge($this->_fields['assignee_contact_id']['attributes']['api']['params'], $assigneeParameters);
+
+ $this->_fields['followup_assignee_contact_id']['attributes']['api']['params']
+ = array_merge($this->_fields['followup_assignee_contact_id']['attributes']['api']['params'], $assigneeParameters);
+
+ //Disallow creating a contact from the assignee field UI.
+ $this->_fields['assignee_contact_id']['attributes']['create'] = FALSE;
+ $this->_fields['followup_assignee_contact_id']['attributes']['create'] = FALSE;
+ }
+
if ($this->_caseType) {
$xmlProcessor = new CRM_Case_XMLProcessor_Process();
$aTypes = array();
- foreach ($this->_caseType as $key => $val) {
+ foreach (array_unique($this->_caseType) as $val) {
$activityTypes = $xmlProcessor->get($val, 'ActivityTypes', TRUE);
$aTypes = $aTypes + $activityTypes;
}
}
}
+ /**
+ * Returns the groups that contacts must belong to in order to be assigned
+ * an activity for this case. It returns an empty array if no groups are found for
+ * the case type linked to the caseId.
+ *
+ * @return array
+ */
+ private function getActivityAssignmentGroups() {
+ if (!$this->_caseTypeDefinition) {
+ return [];
+ }
+
+ $assignmentGroups = [];
+ foreach ($this->_caseTypeDefinition as $caseId => $definition) {
+ if (!empty($definition['activityAsgmtGrps'])) {
+ $assignmentGroups = array_merge($assignmentGroups, $definition['activityAsgmtGrps']);
+ }
+ }
+
+ return $assignmentGroups;
+ }
+
+ /**
+ * Returns whether contacts must have a user account in order to be
+ * assigned an activity for this case.
+ *
+ * @return bool
+ */
+ private function restrictAssignmentByUserAccount() {
+ if (!$this->_caseTypeDefinition) {
+ return FALSE;
+ }
+
+ foreach ($this->_caseTypeDefinition as $caseId => $definition) {
+ if (!empty($definition['restrictActivityAsgmtToCmsUser'])) {
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+ }
+
+ /**
+ * Returns the case type definition column value for the case type linked to the caseId.
+ *
+ * @return array
+ */
+ private function getCaseTypeDefinition() {
+ if (!$this->_caseId) {
+ return [];
+ }
+
+ $definitions = civicrm_api3('CaseType', 'get', [
+ 'return' => ['name', 'definition'],
+ 'name' => ['IN' => array_unique($this->_caseType)],
+ ]);
+
+ return array_column($definitions['values'], 'definition', 'name');
+ }
+
}
$params['contact_sub_type'] = 'null';
}
- // Fixed contact source.
- if (isset($params['contact_source'])) {
- $params['source'] = $params['contact_source'];
- }
-
if (isset($params['preferred_communication_method']) && is_array($params['preferred_communication_method'])) {
CRM_Utils_Array::formatArrayKeys($params['preferred_communication_method']);
$contact->preferred_communication_method = CRM_Utils_Array::implodePadded($params['preferred_communication_method']);
unset($params['preferred_communication_method']);
}
+ $defaults = ['source' => CRM_Utils_Array::value('contact_source', $params)];
+ if ($params['contact_type'] === 'Organization' && isset($params['organization_name'])) {
+ $defaults['display_name'] = $params['organization_name'];
+ $defaults['sort_name'] = $params['organization_name'];
+ }
+ if ($params['contact_type'] === 'Household' && isset($params['household_name'])) {
+ $defaults['display_name'] = $params['household_name'];
+ $defaults['sort_name'] = $params['household_name'];
+ }
+ $params = array_merge($defaults, $params);
+
$allNull = $contact->copyValues($params);
$contact->id = CRM_Utils_Array::value('contact_id', $params);
if ($contact->contact_type == 'Individual') {
$allNull = FALSE;
-
+ // @todo allow the lines below to be overridden by input or hooks & add tests,
+ // as has been done for households and organizations.
// Format individual fields.
CRM_Contact_BAO_Individual::format($params, $contact);
}
- elseif ($contact->contact_type == 'Household') {
- if (isset($params['household_name'])) {
- $allNull = FALSE;
- $contact->display_name = $contact->sort_name = CRM_Utils_Array::value('household_name', $params, '');
- }
- }
- elseif ($contact->contact_type == 'Organization') {
- if (isset($params['organization_name'])) {
- $allNull = FALSE;
- $contact->display_name = $contact->sort_name = CRM_Utils_Array::value('organization_name', $params, '');
- }
- }
+
if (strlen($contact->display_name) > 128) {
$contact->display_name = substr($contact->display_name, 0, 128);
}
* @param bool $checkPermissions
* @param int $ruleGroupID
* ID of the rule group to be used if an override is desirable.
+ * @param array $contextParams
+ * The context if relevant, eg. ['event_id' => X]
*
* @return array
*/
- public static function getDuplicateContacts($input, $contactType, $rule = 'Unsupervised', $excludedContactIDs = array(), $checkPermissions = TRUE, $ruleGroupID = NULL) {
+ public static function getDuplicateContacts($input, $contactType, $rule = 'Unsupervised', $excludedContactIDs = [], $checkPermissions = TRUE, $ruleGroupID = NULL, $contextParams = []) {
$dedupeParams = CRM_Dedupe_Finder::formatParams($input, $contactType);
$dedupeParams['check_permission'] = $checkPermissions;
- $ids = CRM_Dedupe_Finder::dupesByParams($dedupeParams, $contactType, $rule, $excludedContactIDs, $ruleGroupID);
- return $ids;
+ $dedupeParams['contact_type'] = $contactType;
+ $dedupeParams['rule'] = $rule;
+ $dedupeParams['rule_group_id'] = $ruleGroupID;
+ $dedupeParams['excluded_contact_ids'] = $excludedContactIDs;
+ $dedupeResults['ids'] = [];
+ $dedupeResults['handled'] = FALSE;
+ CRM_Utils_Hook::findDuplicates($dedupeParams, $dedupeResults, $contextParams);
+ if (!$dedupeResults['handled']) {
+ $dedupeResults['ids'] = CRM_Dedupe_Finder::dupesByParams($dedupeParams, $contactType, $rule, $excludedContactIDs, $ruleGroupID);
+ }
+ return $dedupeResults['ids'];
}
/**
* @param bool $checkPermissions
* @param int $ruleGroupID
* ID of the rule group to be used if an override is desirable.
+ * @param array $contextParams
+ * The context if relevant, eg. ['event_id' => X]
*
* @return int|NULL
*/
- public static function getFirstDuplicateContact($input, $contactType, $rule = 'Unsupervised', $excludedContactIDs = array(), $checkPermissions = TRUE, $ruleGroupID = NULL) {
- $ids = self::getDuplicateContacts($input, $contactType, $rule, $excludedContactIDs, $checkPermissions, $ruleGroupID);
+ public static function getFirstDuplicateContact($input, $contactType, $rule = 'Unsupervised', $excludedContactIDs = [], $checkPermissions = TRUE, $ruleGroupID = NULL, $contextParams = []) {
+ $ids = self::getDuplicateContacts($input, $contactType, $rule, $excludedContactIDs, $checkPermissions, $ruleGroupID, $contextParams);
if (empty($ids)) {
return NULL;
}
foreach ($this->_returnProperties['location'] as $name => $elements) {
$lCond = self::getPrimaryCondition($name);
+ $locationTypeId = is_numeric($name) ? NULL : array_search($name, $locationTypes);
if (!$lCond) {
- $locationTypeId = array_search($name, $locationTypes);
if ($locationTypeId === FALSE) {
continue;
}
}
$name = str_replace(' ', '_', $name);
-
$tName = "$name-location_type";
$ltName = "`$name-location_type`";
$this->_select["{$tName}_id"] = "`$tName`.id as `{$tName}_id`";
$locationTypeName = $tName;
$locationTypeJoin = array();
- $addAddress = FALSE;
$addWhereCount = 0;
foreach ($elements as $elementFullName => $dontCare) {
$index++;
$addressCustomFieldIds[$cfID][$name] = 1;
}
}
- //add address table only once
+ // add address table - doesn't matter if we do it mutliple times - it's the same data
+ // @todo ditch the double processing of addressJoin
if ((in_array($elementCmpName, self::$_locationSpecificFields) || !empty($addressCustomFieldIds))
- && !$addAddress
&& !in_array($elementCmpName, array('email', 'phone', 'im', 'openid'))
) {
- $tName = "$name-address";
- $aName = "`$name-address`";
- $this->_select["{$tName}_id"] = "`$tName`.id as `{$tName}_id`";
- $this->_element["{$tName}_id"] = 1;
- $addressJoin = "\nLEFT JOIN civicrm_address $aName ON ($aName.contact_id = contact_a.id AND $aName.$lCond)";
- $this->_tables[$tName] = $addressJoin;
+ list($aName, $addressJoin) = $this->addAddressTable($name, $lCond);
$locationTypeJoin[$tName] = " ( $aName.location_type_id = $ltName.id ) ";
$processed[$aName] = 1;
- $addAddress = TRUE;
}
$cond = $elementType = '';
}
}
elseif ($sortByChar) {
+ // @fixme add the deprecated warning back in (it breaks CRM_Contact_SelectorTest::testSelectorQuery)
+ // CRM_Core_Error::deprecatedFunctionWarning('sort by char is deprecated - use alphabetQuery method');
$select = 'SELECT DISTINCT LEFT(contact_a.sort_name, 1) as sort_name';
$from = $this->_simpleFromClause;
}
}
/**
- * Create and query the db for a contact search.
+ * Create and query the db for the list of all first letters used by contacts
*
* @return CRM_Core_DAO
*/
public function alphabetQuery() {
- $query = $this->getSearchSQL(NULL, NULL, NULL, FALSE, FALSE, TRUE);
-
+ $sqlParts = $this->getSearchSQLParts(NULL, NULL, NULL, FALSE, FALSE, TRUE);
+ $query = "SELECT DISTINCT LEFT(contact_a.sort_name, 1) as sort_name
+ {$this->_simpleFromClause}
+ {$sqlParts['where']}
+ {$sqlParts['having']}
+ GROUP BY sort_name
+ ORDER BY sort_name asc";
$dao = CRM_Core_DAO::executeQuery($query);
-
- // We can always call this - it will only re-enable if it was originally enabled.
- CRM_Core_DAO::reenableFullGroupByMode();
-
return $dao;
}
*
* @param string|CRM_Utils_Sort $sort
* The order by string.
- * @param bool $sortByChar
- * If true returns the distinct array of first characters for search results.
* @param null $sortOrder
* Who knows? Hu knows. He who knows Hu knows who.
- * @param string $additionalFromClause
- * Should be clause with proper joins, effective to reduce where clause load.
+ *
* @return array
* list(string $orderByClause, string $additionalFromClause).
*/
- protected function prepareOrderBy($sort, $sortByChar, $sortOrder, $additionalFromClause) {
+ protected function prepareOrderBy($sort, $sortOrder) {
$orderByArray = [];
$orderBy = '';
}
}
}
- elseif ($sortByChar) {
- $orderBy = " sort_name asc";
- }
else {
$orderBy = " contact_a.sort_name ASC, contact_a.id";
}
}
if (!$orderBy) {
- return [NULL, $additionalFromClause];
+ return NULL;
}
// Remove this here & add it at the end for simplicity.
$order = trim($orderBy);
$direction = isset($orderByClauseParts[1]) ? $orderByClauseParts[1] : 'asc';
$fieldSpec = $this->getMetadataForRealField($field);
+ // This is a hacky add-in for primary address joins. Feel free to iterate as it is unit tested.
+ // @todo much more cleanup on location handling in addHierarchical elements. Potentially
+ // add keys to $this->fields to represent the actual keys for locations.
+ if (empty($fieldSpec) && substr($field, 0, 2) === '1-') {
+ $fieldSpec = $this->getMetadataForField(substr($field, 2));
+ $this->addAddressTable('1-' . str_replace('civicrm_', '', $fieldSpec['table_name']), 'is_primary = 1');
+ }
+
if ($this->_returnProperties === []) {
if (!empty($fieldSpec['table_name']) && !isset($this->_tables[$fieldSpec['table_name']])) {
$this->_tables[$fieldSpec['table_name']] = 1;
}
}
- switch ($field) {
-
- case 'placeholder-will-remove-next-pr-but-jenkins-will-not-accept-without-and-removing-switch-will-make-hard-to-read':
- break;
-
- default:
- $cfID = CRM_Core_BAO_CustomField::getKeyID($field);
- // add to cfIDs array if not present
- if (!empty($cfID) && !array_key_exists($cfID, $this->_cfIDs)) {
- $this->_cfIDs[$cfID] = array();
- $this->_customQuery = new CRM_Core_BAO_CustomQuery($this->_cfIDs, TRUE, $this->_locationSpecificCustomFields);
- $this->_customQuery->query();
- $this->_select = array_merge($this->_select, $this->_customQuery->_select);
- $this->_tables = array_merge($this->_tables, $this->_customQuery->_tables);
- }
-
- // By replacing the join to the option value table with the mysql construct
- // ORDER BY field('contribution_status_id', 2,1,4)
- // we can remove a join. In the case of the option value join it is
- /// a join known to cause slow queries.
- // @todo cover other pseudoconstant types. Limited to option group ones & Foreign keys
- // matching an id+name parrern in the
- // first instance for scope reasons. They require slightly different handling as the column (label)
- // is not declared for them.
- // @todo so far only integer fields are being handled. If we add string fields we need to look at
- // escaping.
- $pseudoConstantMetadata = CRM_Utils_Array::value('pseudoconstant', $fieldSpec, FALSE);
- if (!empty($pseudoConstantMetadata)
- ) {
- if (!empty($pseudoConstantMetadata['optionGroupName'])
- || $this->isPseudoFieldAnFK($fieldSpec)
- ) {
- $sortedOptions = $fieldSpec['bao']::buildOptions($fieldSpec['name'], NULL, [
- 'orderColumn' => CRM_Utils_Array::value('labelColumn', $pseudoConstantMetadata, 'label'),
- ]);
- $fieldIDsInOrder = implode(',', array_keys($sortedOptions));
- // Pretty sure this validation ALSO happens in the order clause & this can't be reached but...
- // this might give some early warning.
- CRM_Utils_Type::validate($fieldIDsInOrder, 'CommaSeparatedIntegers');
- $order = str_replace("$field", "field({$fieldSpec['name']},$fieldIDsInOrder)", $order);
- }
- //CRM-12565 add "`" around $field if it is a pseudo constant
- // This appears to be for 'special' fields like locations with appended numbers or hyphens .. maybe.
- if (!empty($pseudoConstantMetadata['element']) && $pseudoConstantMetadata['element'] == $field) {
- $order = str_replace($field, "`{$field}`", $order);
- }
- }
+ $cfID = CRM_Core_BAO_CustomField::getKeyID($field);
+ // add to cfIDs array if not present
+ if (!empty($cfID) && !array_key_exists($cfID, $this->_cfIDs)) {
+ $this->_cfIDs[$cfID] = array();
+ $this->_customQuery = new CRM_Core_BAO_CustomQuery($this->_cfIDs, TRUE, $this->_locationSpecificCustomFields);
+ $this->_customQuery->query();
+ $this->_select = array_merge($this->_select, $this->_customQuery->_select);
+ $this->_tables = array_merge($this->_tables, $this->_customQuery->_tables);
+ }
+
+ // By replacing the join to the option value table with the mysql construct
+ // ORDER BY field('contribution_status_id', 2,1,4)
+ // we can remove a join. In the case of the option value join it is
+ /// a join known to cause slow queries.
+ // @todo cover other pseudoconstant types. Limited to option group ones & Foreign keys
+ // matching an id+name parrern in the
+ // first instance for scope reasons. They require slightly different handling as the column (label)
+ // is not declared for them.
+ // @todo so far only integer fields are being handled. If we add string fields we need to look at
+ // escaping.
+ $pseudoConstantMetadata = CRM_Utils_Array::value('pseudoconstant', $fieldSpec, FALSE);
+ if (!empty($pseudoConstantMetadata)
+ ) {
+ if (!empty($pseudoConstantMetadata['optionGroupName'])
+ || $this->isPseudoFieldAnFK($fieldSpec)
+ ) {
+ $sortedOptions = $fieldSpec['bao']::buildOptions($fieldSpec['name'], NULL, [
+ 'orderColumn' => CRM_Utils_Array::value('labelColumn', $pseudoConstantMetadata, 'label'),
+ ]);
+ $fieldIDsInOrder = implode(',', array_keys($sortedOptions));
+ // Pretty sure this validation ALSO happens in the order clause & this can't be reached but...
+ // this might give some early warning.
+ CRM_Utils_Type::validate($fieldIDsInOrder, 'CommaSeparatedIntegers');
+ $order = str_replace("$field", "field({$fieldSpec['name']},$fieldIDsInOrder)", $order);
+ }
+ //CRM-12565 add "`" around $field if it is a pseudo constant
+ // This appears to be for 'special' fields like locations with appended numbers or hyphens .. maybe.
+ if (!empty($pseudoConstantMetadata['element']) && $pseudoConstantMetadata['element'] == $field) {
+ $order = str_replace($field, "`{$field}`", $order);
+ }
}
}
// The above code relies on crazy brittle string manipulation of a peculiarly-encoded ORDER BY
// clause. But this magic helper which forgivingly reescapes ORDER BY.
- // Note: $sortByChar implies that $order was hard-coded/trusted, so it can do funky things.
- if ($sortByChar) {
- return array(' ORDER BY ' . $order, $additionalFromClause);
- }
if ($order) {
$order = CRM_Utils_Type::escape($order, 'MysqlOrderBy');
- return array(' ORDER BY ' . $order, $additionalFromClause);
+ return ' ORDER BY ' . $order;
}
}
$sqlParts = $this->getSearchSQLParts($offset, $rowCount, $sort, $count, $includeContactIds, $sortByChar, $groupContacts, $additionalWhereClause, $sortOrder, $additionalFromClause);
+ if ($sortByChar) {
+ CRM_Core_Error::deprecatedFunctionWarning('sort by char is deprecated - use alphabetQuery method');
+ $sqlParts['order_by'] = 'ORDER BY sort_name asc';
+ }
+
if ($skipOrderAndLimit) {
CRM_Core_Error::deprecatedFunctionWarning('skipOrderAndLimit is deprected - call getSearchSQLParts & construct it in the calling function');
$query = "{$sqlParts['select']} {$sqlParts['from']} {$sqlParts['where']} {$sqlParts['having']} {$sqlParts['group_by']}";
$order = $orderBy = '';
if (!$count) {
- list($order, $additionalFromClause) = $this->prepareOrderBy($sort, $sortByChar, $sortOrder, $additionalFromClause);
+ if (!$sortByChar) {
+ $order = $this->prepareOrderBy($sort, $sortOrder);
+ }
}
- // Two cases where we are disabling FGB (FULL_GROUP_BY_MODE):
- // 1. Expecting the search query to return all the first single letter characters of contacts ONLY, but when FGB is enabled
- // MySQL expect the columns present in GROUP BY, must be present in SELECT clause and that results into error, needless to have other columns.
- // 2. When GROUP BY columns are present then disable FGB otherwise it demands to add ORDER BY columns in GROUP BY and eventually in SELECT
+ // Cases where we are disabling FGB (FULL_GROUP_BY_MODE):
+ // 1. When GROUP BY columns are present then disable FGB otherwise it demands to add ORDER BY columns in GROUP BY and eventually in SELECT
// clause. This will impact the search query output.
- $disableFullGroupByMode = ($sortByChar || !empty($groupBy) || $groupContacts);
+ $disableFullGroupByMode = (!empty($groupBy) || $groupContacts);
if ($disableFullGroupByMode) {
CRM_Core_DAO::disableFullGroupByMode();
}
}
+ /**
+ * Add the address table into the query.
+ *
+ * @param string $tableKey
+ * @param string $joinCondition
+ *
+ * @return array
+ * - alias name
+ * - address join.
+ */
+ protected function addAddressTable($tableKey, $joinCondition) {
+ $tName = "$tableKey-address";
+ $aName = "`$tableKey-address`";
+ $this->_select["{$tName}_id"] = "`$tName`.id as `{$tName}_id`";
+ $this->_element["{$tName}_id"] = 1;
+ $addressJoin = "\nLEFT JOIN civicrm_address $aName ON ($aName.contact_id = contact_a.id AND $aName.$joinCondition)";
+ $this->_tables[$tName] = $addressJoin;
+
+ return [
+ $aName,
+ $addressJoin
+ ];
+ }
+
}
$this->bounceIfInvalid($this->_cid, $this->_oid);
- $this->_contactType = civicrm_api3('Contact', 'getvalue', array(
- 'id' => $this->_cid,
- 'return' => 'contact_type',
- ));
+ $contacts = civicrm_api3('Contact', 'get', [
+ 'id' => ['IN' => [$this->_cid, $this->_oid]],
+ 'return' => ['contact_type', 'modified_date', 'created_date', 'contact_sub_type'],
+ ])['values'];
+
+ $this->_contactType = $contacts[$this->_cid]['contact_type'];
$browseUrl = CRM_Utils_System::url('civicrm/contact/dedupefind', array_merge($urlParams, ['action' => 'browse']));
$this->assign('main_cid', $main['contact_id']);
$this->assign('other_cid', $other['contact_id']);
$this->assign('rgid', $this->_rgid);
+ $this->assignSummaryRowsToTemplate($contacts);
$this->addElement('checkbox', 'toggleSelect', NULL, NULL, array('class' => 'select-rows'));
$this->assign('mainLocBlock', json_encode($rowsElementsAndInfo['main_details']['location_blocks']));
$this->assign('locationBlockInfo', json_encode(CRM_Dedupe_Merger::getLocationBlockInfo()));
+ $this->assign('mainContactTypeIcon', CRM_Contact_BAO_Contact_Utils::getImage($contacts[$this->_cid]['contact_sub_type'] ? $contacts[$this->_cid]['contact_sub_type'] : $contacts[$this->_cid]['contact_type'],
+ FALSE,
+ $this->_cid
+ ));
+ $this->assign('otherContactTypeIcon', CRM_Contact_BAO_Contact_Utils::getImage($contacts[$this->_oid]['contact_sub_type'] ? $contacts[$this->_oid]['contact_sub_type'] : $contacts[$this->_oid]['contact_type'],
+ FALSE,
+ $this->_oid
+ ));
+
+ if (isset($rowsElementsAndInfo['rows']['move_contact_type'])) {
+ // We don't permit merging contacts of different types so this is just clutter - putting
+ // the icon next to the contact name is consistent with elsewhere and permits hover-info
+ // https://lab.civicrm.org/dev/core/issues/824
+ unset($rowsElementsAndInfo['rows']['move_contact_type']);
+ }
+
$this->assign('rows', $rowsElementsAndInfo['rows']);
// add elements
}
}
+ /**
+ * Assign the summary_rows variable to the tpl.
+ *
+ * This adds rows to the beginning of the block that will help in making merge choices.
+ *
+ * It can be modified by a hook by altering what is assigned. Although not technically supported this
+ * is an easy tweak with no earth-shattering impacts if later changes stop if from working.
+ *
+ * https://lab.civicrm.org/dev/core/issues/824
+ *
+ * @param array $contacts
+ */
+ protected function assignSummaryRowsToTemplate($contacts) {
+ $mostRecent = ($contacts[$this->_cid]['modified_date'] < $contacts[$this->_oid]['modified_date']) ? $this->_oid : $this->_cid;
+ $this->assign('summary_rows', [
+ [
+ 'name' => 'created_date',
+ 'label' => ts('Created'),
+ 'main_contact_value' => CRM_Utils_Date::customFormat($contacts[$this->_cid]['created_date']),
+ 'other_contact_value' => CRM_Utils_Date::customFormat($contacts[$this->_oid]['created_date']),
+ ],
+ [
+ 'name' => 'modified_date',
+ 'label' => ts('Last Modified'),
+ 'main_contact_value' => CRM_Utils_Date::customFormat($contacts[$this->_cid]['modified_date']) . ($mostRecent == $this->_cid ? ' (' . ts('Most Recent') . ')' : ''),
+ 'other_contact_value' => CRM_Utils_Date::customFormat($contacts[$this->_oid]['modified_date']) . ($mostRecent == $this->_oid ? ' (' . ts('Most Recent') . ')' : ''),
+ ],
+ ]);
+ }
+
}
}
public function buildTempTable() {
- $randomNum = md5(uniqid());
- $this->_tableName = "civicrm_temp_custom_details_{$randomNum}";
+ $table = CRM_Utils_SQL_TempTable::build()->setCategory('custom')->setMemory()->setUtf8();
+ $this->_tableName = $table->getName();
$this->_tableFields = array(
'id' => 'int unsigned NOT NULL AUTO_INCREMENT',
);
$sql = "
-CREATE TEMPORARY TABLE {$this->_tableName} (
";
foreach ($this->_tableFields as $name => $desc) {
$sql .= "
PRIMARY KEY ( id )
-) ENGINE=HEAP DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci
";
- CRM_Core_DAO::executeQuery($sql);
+ $table->createWithColumns($sql);
- $this->_entityIDTableName = "civicrm_temp_custom_entityID_{$randomNum}";
+ $entityIdTable = CRM_Utils_SQL_TempTable::build()->setCategory('custom')->setMemory()->setUtf8();
+ $this->_entityIDTableName = $entityIdTable->getName();
$sql = "
-CREATE TEMPORARY TABLE {$this->_entityIDTableName} (
id int unsigned NOT NULL AUTO_INCREMENT,
entity_id int unsigned NOT NULL,
UNIQUE INDEX unique_entity_id ( entity_id ),
PRIMARY KEY ( id )
-) ENGINE=HEAP DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci
";
- CRM_Core_DAO::executeQuery($sql);
+ $entityIdTable->createWithColumns($sql);
if (!empty($this->_formValues['is_unit_test'])) {
$this->_tableNameForTest = $this->_tableName;
/**
* This class provides the common functionality for creating PDF letter for one or a group of contact ids.
*/
-class CRM_Contact_Form_Task_PDFLetterCommon {
+class CRM_Contact_Form_Task_PDFLetterCommon extends CRM_Core_Form_Task_PDFLetterCommon {
protected static $tokenCategories;
$form->assign('message', $messageText);
$form->assign('messageSubject', $messageSubject);
- CRM_Utils_System::setTitle('Print/Merge Document');
+ parent::preProcess($form);
}
/**
}
}
- /**
- * Build the form object.
- *
- * @var CRM_Core_Form $form
- */
- public static function buildQuickForm(&$form) {
- // This form outputs a file so should never be submitted via ajax
- $form->preventAjaxSubmit();
-
- //Added for CRM-12682: Add activity subject and campaign fields
- CRM_Campaign_BAO_Campaign::addCampaign($form);
- $form->add(
- 'text',
- 'subject',
- ts('Activity Subject'),
- array('size' => 45, 'maxlength' => 255),
- FALSE
- );
-
- $form->add('static', 'pdf_format_header', NULL, ts('Page Format: %1', array(1 => '<span class="pdf-format-header-label"></span>')));
- $form->addSelect('format_id', array(
- 'label' => ts('Select Format'),
- 'placeholder' => ts('Default'),
- 'entity' => 'message_template',
- 'field' => 'pdf_format_id',
- 'option_url' => 'civicrm/admin/pdfFormats',
- ));
- $form->add(
- 'select',
- 'paper_size',
- ts('Paper Size'),
- array(0 => ts('- default -')) + CRM_Core_BAO_PaperSize::getList(TRUE),
- FALSE,
- array('onChange' => "selectPaper( this.value ); showUpdateFormatChkBox();")
- );
- $form->add('static', 'paper_dimensions', NULL, ts('Width x Height'));
- $form->add(
- 'select',
- 'orientation',
- ts('Orientation'),
- CRM_Core_BAO_PdfFormat::getPageOrientations(),
- FALSE,
- array('onChange' => "updatePaperDimensions(); showUpdateFormatChkBox();")
- );
- $form->add(
- 'select',
- 'metric',
- ts('Unit of Measure'),
- CRM_Core_BAO_PdfFormat::getUnits(),
- FALSE,
- array('onChange' => "selectMetric( this.value );")
- );
- $form->add(
- 'text',
- 'margin_left',
- ts('Left Margin'),
- array('size' => 8, 'maxlength' => 8, 'onkeyup' => "showUpdateFormatChkBox();"),
- TRUE
- );
- $form->add(
- 'text',
- 'margin_right',
- ts('Right Margin'),
- array('size' => 8, 'maxlength' => 8, 'onkeyup' => "showUpdateFormatChkBox();"),
- TRUE
- );
- $form->add(
- 'text',
- 'margin_top',
- ts('Top Margin'),
- array('size' => 8, 'maxlength' => 8, 'onkeyup' => "showUpdateFormatChkBox();"),
- TRUE
- );
- $form->add(
- 'text',
- 'margin_bottom',
- ts('Bottom Margin'),
- array('size' => 8, 'maxlength' => 8, 'onkeyup' => "showUpdateFormatChkBox();"),
- TRUE
- );
-
- $config = CRM_Core_Config::singleton();
- /** CRM-15883 Suppressing Stationery path field until we switch from DOMPDF to a library that supports it.
- if ($config->wkhtmltopdfPath == FALSE) {
- $form->add(
- 'text',
- 'stationery',
- ts('Stationery (relative path to PDF you wish to use as the background)'),
- array('size' => 25, 'maxlength' => 900, 'onkeyup' => "showUpdateFormatChkBox();"),
- FALSE
- );
- }
- */
- $form->add('checkbox', 'bind_format', ts('Always use this Page Format with the selected Template'));
- $form->add('checkbox', 'update_format', ts('Update Page Format (this will affect all templates that use this format)'));
-
- $form->assign('useThisPageFormat', ts('Always use this Page Format with the new template?'));
- $form->assign('useSelectedPageFormat', ts('Should the new template always use the selected Page Format?'));
- $form->assign('totalSelectedContacts', count($form->_contactIds));
-
- $form->add('select', 'document_type', ts('Document Type'), CRM_Core_SelectValues::documentFormat());
-
- $documentTypes = implode(',', CRM_Core_SelectValues::documentApplicationType());
- $form->addElement('file', "document_file", 'Upload Document', 'size=30 maxlength=255 accept="' . $documentTypes . '"');
- $form->addUploadElement("document_file");
-
- CRM_Mailing_BAO_Mailing::commonCompose($form);
-
- $buttons = array();
- if ($form->get('action') != CRM_Core_Action::VIEW) {
- $buttons[] = array(
- 'type' => 'upload',
- 'name' => ts('Download Document'),
- 'isDefault' => TRUE,
- 'icon' => 'fa-download',
- );
- $buttons[] = array(
- 'type' => 'submit',
- 'name' => ts('Preview'),
- 'subName' => 'preview',
- 'icon' => 'fa-search',
- 'isDefault' => FALSE,
- );
- }
- $buttons[] = array(
- 'type' => 'cancel',
- 'name' => $form->get('action') == CRM_Core_Action::VIEW ? ts('Done') : ts('Cancel'),
- );
- $form->addButtons($buttons);
-
- $form->addFormRule(array('CRM_Contact_Form_Task_PDFLetterCommon', 'formRule'), $form);
- }
-
- /**
- * Set default values.
- */
- public static function setDefaultValues() {
- $defaultFormat = CRM_Core_BAO_PdfFormat::getDefaultValues();
- $defaultFormat['format_id'] = $defaultFormat['id'];
- return $defaultFormat;
- }
-
- /**
- * Form rule.
- *
- * @param array $fields
- * The input form values.
- * @param array $files
- * @param array $self
- * Additional values form 'this'.
- *
- * @return bool
- * TRUE if no errors, else array of errors.
- */
- public static function formRule($fields, $files, $self) {
- $errors = array();
- $template = CRM_Core_Smarty::singleton();
-
- // If user uploads non-document file other than odt/docx
- if (empty($fields['template']) &&
- !empty($files['document_file']['tmp_name']) &&
- array_search($files['document_file']['type'], CRM_Core_SelectValues::documentApplicationType()) == NULL
- ) {
- $errors['document_file'] = ts('Invalid document file format');
- }
- //Added for CRM-1393
- if (!empty($fields['saveTemplate']) && empty($fields['saveTemplateName'])) {
- $errors['saveTemplateName'] = ts("Enter name to save message template");
- }
- if (!is_numeric($fields['margin_left'])) {
- $errors['margin_left'] = 'Margin must be numeric';
- }
- if (!is_numeric($fields['margin_right'])) {
- $errors['margin_right'] = 'Margin must be numeric';
- }
- if (!is_numeric($fields['margin_top'])) {
- $errors['margin_top'] = 'Margin must be numeric';
- }
- if (!is_numeric($fields['margin_bottom'])) {
- $errors['margin_bottom'] = 'Margin must be numeric';
- }
- return empty($errors) ? TRUE : $errors;
- }
-
/**
* Part of the post process which prepare and extract information from the template.
*
* [$categories, $html_message, $messageToken, $returnProperties]
*/
public static function processMessageTemplate($formValues) {
- $html_message = CRM_Utils_Array::value('html_message', $formValues);
-
- // process message template
- if (!empty($formValues['saveTemplate']) || !empty($formValues['updateTemplate'])) {
- $messageTemplate = array(
- 'msg_text' => NULL,
- 'msg_html' => $formValues['html_message'],
- 'msg_subject' => NULL,
- 'is_active' => TRUE,
- );
-
- $messageTemplate['pdf_format_id'] = 'null';
- if (!empty($formValues['bind_format']) && $formValues['format_id']) {
- $messageTemplate['pdf_format_id'] = $formValues['format_id'];
- }
- if (!empty($formValues['saveTemplate']) && $formValues['saveTemplate']) {
- $messageTemplate['msg_title'] = $formValues['saveTemplateName'];
- CRM_Core_BAO_MessageTemplate::add($messageTemplate);
- }
-
- if (!empty($formValues['updateTemplate']) && $formValues['template'] && $formValues['updateTemplate']) {
- $messageTemplate['id'] = $formValues['template'];
-
- unset($messageTemplate['msg_title']);
- CRM_Core_BAO_MessageTemplate::add($messageTemplate);
- }
- }
- elseif (CRM_Utils_Array::value('template', $formValues) > 0) {
- if (!empty($formValues['bind_format']) && $formValues['format_id']) {
- $query = "UPDATE civicrm_msg_template SET pdf_format_id = {$formValues['format_id']} WHERE id = {$formValues['template']}";
- }
- else {
- $query = "UPDATE civicrm_msg_template SET pdf_format_id = NULL WHERE id = {$formValues['template']}";
- }
- CRM_Core_DAO::executeQuery($query);
-
- $documentInfo = CRM_Core_BAO_File::getEntityFile('civicrm_msg_template', $formValues['template']);
- foreach ((array) $documentInfo as $info) {
- list($html_message, $formValues['document_type']) = CRM_Utils_PDF_Document::docReader($info['fullPath'], $info['mime_type']);
- $formValues['document_file_path'] = $info['fullPath'];
- }
- }
- // extract the content of uploaded document file
- elseif (!empty($formValues['document_file'])) {
- list($html_message, $formValues['document_type']) = CRM_Utils_PDF_Document::docReader($formValues['document_file']['name'], $formValues['document_file']['type']);
- $formValues['document_file_path'] = $formValues['document_file']['name'];
- }
-
- if (!empty($formValues['update_format'])) {
- $bao = new CRM_Core_BAO_PdfFormat();
- $bao->savePdfFormat($formValues, $formValues['format_id']);
- }
+ $html_message = self::processTemplate($formValues);
$categories = self::getTokenCategories();
return $activityIds;
}
- /**
- * @param $message
- */
- public static function formatMessage(&$message) {
- $newLineOperators = array(
- 'p' => array(
- 'oper' => '<p>',
- 'pattern' => '/<(\s+)?p(\s+)?>/m',
- ),
- 'br' => array(
- 'oper' => '<br />',
- 'pattern' => '/<(\s+)?br(\s+)?\/>/m',
- ),
- );
-
- $htmlMsg = preg_split($newLineOperators['p']['pattern'], $message);
- foreach ($htmlMsg as $k => & $m) {
- $messages = preg_split($newLineOperators['br']['pattern'], $m);
- foreach ($messages as $key => & $msg) {
- $msg = trim($msg);
- $matches = array();
- if (preg_match('/^( )+/', $msg, $matches)) {
- $spaceLen = strlen($matches[0]) / 6;
- $trimMsg = ltrim($msg, ' ');
- $charLen = strlen($trimMsg);
- $totalLen = $charLen + $spaceLen;
- if ($totalLen > 100) {
- $spacesCount = 10;
- if ($spaceLen > 50) {
- $spacesCount = 20;
- }
- if ($charLen > 100) {
- $spacesCount = 1;
- }
- $msg = str_repeat(' ', $spacesCount) . $trimMsg;
- }
- }
- }
- $m = implode($newLineOperators['br']['oper'], $messages);
- }
- $message = implode($newLineOperators['p']['oper'], $htmlMsg);
- }
-
/**
* Convert from a vague-type/file-extension to mime-type.
*
}
}
- if ($this->_newTagName || count($this->_tag)) {
+ if ($this->_newTagName || !empty($this->_tag)) {
$tagAdditions = $this->_tagImportedContactsWithNewTag($contactIds,
$this->_newTagName,
$this->_newTagDesc
*/
public function run() {
if (!preg_match('/^[^\/]+\.(jpg|jpeg|png|gif)$/i', $_GET['photo'])) {
- CRM_Core_Error::fatal('Malformed photo name');
+ throw new CRM_Core_Exception(ts('Malformed photo name'));
}
// FIXME Optimize performance of image_url query
CRM_Utils_System::civiExit();
}
else {
- CRM_Core_Error::fatal('Photo does not exist');
+ throw new CRM_Core_Exception(ts('Photo does not exist'));
}
}
'Note',
$note->id
);
- $contact = new CRM_Contact_DAO_Contact();
- $contact->id = $note->contact_id;
- $contact->find();
- $contact->fetch();
- $values[$note->id]['createdBy'] = $contact->display_name;
+ if (!empty($note->contact_id)) {
+ $contact = new CRM_Contact_DAO_Contact();
+ $contact->id = $note->contact_id;
+ $contact->find();
+ $contact->fetch();
+ $values[$note->id]['createdBy'] = $contact->display_name;
+ }
$values[$note->id]['comment_count'] = CRM_Core_BAO_Note::getChildCount($note->id);
// paper icon view for attachments part
$queryOperator
);
}
- $value = $query->searchQuery(0, 0, $sort,
- FALSE, FALSE, FALSE,
- FALSE, FALSE
- );
- return $value;
+ return $query->searchQuery(0, 0, $sort);
}
/**
$form->addElement('text', 'contribution_recur_processor_id', ts('Processor ID'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_ContributionRecur', 'processor_id'));
$form->addElement('text', 'contribution_recur_trxn_id', ts('Transaction ID'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_ContributionRecur', 'trxn_id'));
- $paymentProcessorParams = [
- 'return' => ["id", "name", 'is_test'],
- ];
- $paymentProcessors = civicrm_api3('PaymentProcessor', 'get', $paymentProcessorParams);
- $paymentProcessorOpts = [];
- foreach ($paymentProcessors['values'] as $key => $value) {
- $paymentProcessorOpts[$key] = $value['name'] . ($value['is_test'] ? ' (Test)' : '');
- }
+ $paymentProcessorOpts = CRM_Contribute_BAO_ContributionRecur::buildOptions('payment_processor_id', 'get');
$form->add('select', 'contribution_recur_payment_processor_id', ts('Payment Processor ID'), $paymentProcessorOpts, FALSE, ['class' => 'crm-select2', 'multiple' => 'multiple']);
CRM_Core_BAO_Query::addCustomFormFields($form, array('ContributionRecur'));
*/
protected static function isComplete($recurringContributionID, $installments) {
$paidInstallments = CRM_Core_DAO::singleValueQuery(
- 'SELECT count(*) FROM civicrm_contribution
+ 'SELECT count(*) FROM civicrm_contribution
WHERE contribution_recur_id = %1
AND contribution_status_id = ' . CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Completed'),
array(1 => array($recurringContributionID, 'Integer'))
$priceField = new CRM_Price_DAO_PriceField();
$priceField->id = $lineItem['price_field_id'];
$priceField->find(TRUE);
- $lineSets[$priceField->price_set_id][] = $lineItem;
+ $lineSets[$priceField->price_set_id][$lineItem['price_field_id']] = $lineItem;
}
}
// CRM-19309 if more than one then just pass them through:
elseif (count($lineItems) > 1) {
foreach ($lineItems as $index => $lineItem) {
- $lineSets[$index][] = $lineItem;
+ $lineSets[$index][$lineItem['price_field_id']] = $lineItem;
}
}
return self::$inactiveStatuses;
}
+ /**
+ * Get options for the called BAO object's field.
+ *
+ * This function can be overridden by each BAO to add more logic related to context.
+ * The overriding function will generally call the lower-level CRM_Core_PseudoConstant::get
+ *
+ * @param string $fieldName
+ * @param string $context
+ * @see CRM_Core_DAO::buildOptionsContext
+ * @param array $props
+ * whatever is known about this bao object.
+ *
+ * @return array|bool
+ */
+ public static function buildOptions($fieldName, $context = NULL, $props = array()) {
+
+ switch ($fieldName) {
+ case 'payment_processor_id':
+ if (isset(\Civi::$statics[__CLASS__]['buildoptions_payment_processor_id'])) {
+ return \Civi::$statics[__CLASS__]['buildoptions_payment_processor_id'];
+ }
+ $baoName = 'CRM_Contribute_BAO_ContributionRecur';
+ $props['condition']['test'] = "is_test = 0";
+ $liveProcessors = CRM_Core_PseudoConstant::get($baoName, $fieldName, $props, $context);
+ $props['condition']['test'] = "is_test != 0";
+ $testProcessors = CRM_Core_PseudoConstant::get($baoName, $fieldName, $props, $context);
+ foreach ($testProcessors as $key => $value) {
+ if ($context === 'validate') {
+ // @fixme: Ideally the names would be different in the civicrm_payment_processor table but they are not.
+ // So we append '_test' to the test one so that we can select the correct processor by name using the ContributionRecur.create API.
+ $testProcessors[$key] = $value . '_test';
+ }
+ else {
+ $testProcessors[$key] = CRM_Core_TestEntity::appendTestText($value);
+ }
+ }
+ $allProcessors = $liveProcessors + $testProcessors;
+ ksort($allProcessors);
+ \Civi::$statics[__CLASS__]['buildoptions_payment_processor_id'] = $allProcessors;
+ return $allProcessors;
+ }
+ return parent::buildOptions($fieldName, $context, $props);
+ }
+
}
$query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("civicrm_contribution.$name", $op, $value, $dataType);
list($op, $value) = CRM_Contact_BAO_Query::buildQillForFieldValue('CRM_Contribute_DAO_Contribution', $name, $value, $op, $pseudoExtraParam);
- $query->_qill[$grouping][] = ts('%1 %2 %3', array(1 => $fields[$qillName]['title'], 2 => $op, 3 => $value));
+ if (!($name == 'id' && $value == 0)) {
+ $query->_qill[$grouping][] = ts('%1 %2 %3', array(1 => $fields[$qillName]['title'], 2 => $op, 3 => $value));
+ }
$query->_tables['civicrm_contribution'] = $query->_whereTables['civicrm_contribution'] = 1;
return;
if (!CRM_Core_Permission::check('edit contributions')) {
if ($this->_subscriptionDetails->contact_id != $this->getContactID()) {
- CRM_Core_Error::fatal(ts('You do not have permission to cancel this recurring contribution.'));
+ CRM_Core_Error::statusBounce(ts('You do not have permission to cancel this recurring contribution.'));
}
$this->_selfService = TRUE;
}
$amount_block_is_active = $this->get('amount_block_is_active');
$this->assign('amount_block_is_active', $amount_block_is_active);
- $invoiceSettings = Civi::settings()->get('contribution_invoice_settings');
- $invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings);
// Make a copy of line items array to use for display only
$tplLineItems = $this->_lineItem;
- if ($invoicing) {
- $getTaxDetails = FALSE;
- $taxTerm = CRM_Utils_Array::value('tax_term', $invoiceSettings);
+ if (CRM_Invoicing_Utils::isInvoicingEnabled()) {
list($getTaxDetails, $tplLineItems) = $this->alterLineItemsForTemplate($tplLineItems);
$this->assign('getTaxDetails', $getTaxDetails);
- $this->assign('taxTerm', $taxTerm);
+ $this->assign('taxTerm', CRM_Invoicing_Utils::getTaxTerm());
$this->assign('totalTaxAmount', $params['tax_amount']);
}
+ if ($this->_priceSetId && !CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $this->_priceSetId, 'is_quick_config')) {
+ $this->assign('lineItem', $tplLineItems);
+ }
+ else {
+ $this->assign('is_quick_config', 1);
+ $this->_params['is_quick_config'] = 1;
+ }
+
if (!empty($params['selectProduct']) && $params['selectProduct'] != 'no_thanks') {
$option = CRM_Utils_Array::value('options_' . $params['selectProduct'], $params);
$productID = $params['selectProduct'];
$this->_separateMembershipPayment = $this->get('separateMembershipPayment');
$this->assign('is_separate_payment', $this->_separateMembershipPayment);
- if ($this->_priceSetId && !CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $this->_priceSetId, 'is_quick_config')) {
- $this->assign('lineItem', $tplLineItems);
- }
- else {
- $this->assign('is_quick_config', 1);
- $this->_params['is_quick_config'] = 1;
- }
+
$this->assign('priceSetID', $this->_priceSetId);
// The concept of contributeMode is deprecated.
$contribButton = ts('Make Contribution');
}
$this->assign('button', $contribButton);
+
+ $this->assign('continueText',
+ $this->getPaymentProcessorObject()->getText('contributionPageContinueText', [
+ 'is_payment_to_existing' => !empty($this->_ccid),
+ 'amount' => $this->_amount,
+ ]
+ )
+ );
+
$this->addButtons(array(
array(
'type' => 'next',
}
}
+
+ /**
+ * Get the payment processor object for the submission, returning the manual one for offline payments.
+ *
+ * @return CRM_Core_Payment
+ */
+ protected function getPaymentProcessorObject() {
+ if (!empty($this->_paymentProcessor)) {
+ return $this->_paymentProcessor['object'];
+ }
+ return new CRM_Core_Payment_Manual();
+ }
+
}
}
if (!CRM_Core_Permission::check('edit contributions')) {
if ($this->_subscriptionDetails->contact_id != $this->getContactID()) {
- CRM_Core_Error::fatal(ts('You do not have permission to cancel subscription.'));
+ CRM_Core_Error::statusBounce(ts('You do not have permission to cancel subscription.'));
}
$this->_selfService = TRUE;
}
*/
public function listContribution() {
$rows = civicrm_api3('Contribution', 'get', [
- 'options' => ['limit' => 12],
+ 'options' => [
+ 'limit' => 12,
+ 'sort' => 'receive_date DESC',
+ ],
'sequential' => 1,
'contact_id' => $this->_contactId,
'return' => [
],
])['values'];
+ // We want oldest first, just among the most recent contributions
+ $rows = array_reverse($rows);
+
foreach ($rows as $index => $row) {
// This is required for tpl logic. We should move away from hard-code this to adding an array of actions to the row
// which the tpl can iterate through - this should allow us to cope with competing attempts to add new buttons
$this->_action = $action;
$returnProperties = CRM_Contribute_BAO_Query::selectorReturnProperties($this->_queryParams);
$this->_includeSoftCredits = CRM_Contribute_BAO_Query::isSoftCreditOptionEnabled($this->_queryParams);
+ $this->_queryParams[] = ['contribution_id', '!=', 0, 0, 0];
$this->_query = new CRM_Contact_BAO_Query(
$this->_queryParams,
$returnProperties,
case 'state_province':
// change $fieldName to DB specific names.
$fieldName = 'state_province_id';
- if (empty($props['country_id'])) {
+ if (empty($props['country_id']) && $context !== 'validate') {
$config = CRM_Core_Config::singleton();
if (!empty($config->provinceLimit)) {
$props['country_id'] = $config->provinceLimit;
$props['country_id'] = $config->defaultContactCountry;
}
}
- if (!empty($props['country_id']) && $context !== 'validate') {
+ if (!empty($props['country_id'])) {
$params['condition'] = 'country_id IN (' . implode(',', (array) $props['country_id']) . ')';
}
break;
* Get custom field ID from field/group name/title.
*
* @param string $fieldName Field name or label
- * @param string|null $groupTitle (Optional) Group name or label
+ * @param string|null $groupName (Optional) Group name or label
* @param bool $fullString Whether to return "custom_123" or "123"
*
* @return string|int|null
* @throws \CiviCRM_API3_Exception
*/
- public static function getCustomFieldID($fieldName, $groupTitle = NULL, $fullString = FALSE) {
- if (!isset(Civi::$statics['CRM_Core_BAO_CustomField'][$fieldName])) {
+ public static function getCustomFieldID($fieldName, $groupName = NULL, $fullString = FALSE) {
+ $cacheKey = $groupName . '.' . $fieldName;
+ if (!isset(Civi::$statics['CRM_Core_BAO_CustomField'][$cacheKey])) {
$customFieldParams = [
'name' => $fieldName,
'label' => $fieldName,
'options' => ['or' => [["name", "label"]]],
];
- if ($groupTitle) {
- $customFieldParams['custom_group_id.name'] = $groupTitle;
- $customFieldParams['custom_group_id.title'] = $groupTitle;
+ if ($groupName) {
+ $customFieldParams['custom_group_id.name'] = $groupName;
+ $customFieldParams['custom_group_id.title'] = $groupName;
$customFieldParams['options'] = ['or' => [["name", "label"], ["custom_group_id.name", "custom_group_id.title"]]];
}
$field = civicrm_api3('CustomField', 'get', $customFieldParams);
if (empty($field['id'])) {
- Civi::$statics['CRM_Core_BAO_CustomField'][$fieldName]['id'] = NULL;
- Civi::$statics['CRM_Core_BAO_CustomField'][$fieldName]['string'] = NULL;
+ Civi::$statics['CRM_Core_BAO_CustomField'][$cacheKey]['id'] = NULL;
+ Civi::$statics['CRM_Core_BAO_CustomField'][$cacheKey]['string'] = NULL;
}
else {
- Civi::$statics['CRM_Core_BAO_CustomField'][$fieldName]['id'] = $field['id'];
- Civi::$statics['CRM_Core_BAO_CustomField'][$fieldName]['string'] = 'custom_' . $field['id'];
+ Civi::$statics['CRM_Core_BAO_CustomField'][$cacheKey]['id'] = $field['id'];
+ Civi::$statics['CRM_Core_BAO_CustomField'][$cacheKey]['string'] = 'custom_' . $field['id'];
}
}
if ($fullString) {
- return Civi::$statics['CRM_Core_BAO_CustomField'][$fieldName]['string'];
+ return Civi::$statics['CRM_Core_BAO_CustomField'][$cacheKey]['string'];
}
- return Civi::$statics['CRM_Core_BAO_CustomField'][$fieldName]['id'];
+ return Civi::$statics['CRM_Core_BAO_CustomField'][$cacheKey]['id'];
}
/**
// we do this to prevent a autoloader errors with joomla / 3rd party packages
// Use absolute path, since we don't know the content of include_path yet.
// CRM-11304
- $file = dirname(__FILE__) . '/../../packages/IDS/vendors/htmlpurifier/HTMLPurifier/Bootstrap.php';
+ $file = dirname(__FILE__) . '/../../vendor/ezyang/htmlpurifier/library/HTMLPurifier/Bootstrap.php';
if (file_exists($file)) {
return $file;
}
* @copyright CiviCRM LLC (c) 2004-2019
*/
+require_once 'Log.php';
require_once 'Mail.php';
require_once 'api/api.php';
require_once 'PEAR/Exception.php';
require_once 'CRM/Core/Exception.php';
+require_once 'Log.php';
+
/**
* Class CRM_Exception
*/
--- /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 |
+ +--------------------------------------------------------------------+
+ */
+
+/**
+ *
+ * @package CRM
+ * @copyright CiviCRM LLC (c) 2004-2019
+ */
+
+/**
+ * This is the base class for common PDF/Doc Merge functionality.
+ * Most CRM_*_Form_Task_PDFLetterCommon classes extend the Contact version
+ * but the assumptions there are not always appropriate for other classes
+ * resulting in code duplication and unexpected dependencies.
+ * The intention is that common functionality can be moved here and the other
+ * classes cleaned up.
+ * Keep old-style token handling out of this class.
+ */
+class CRM_Core_Form_Task_PDFLetterCommon {
+
+ /**
+ * @var CRM_Core_Form $form
+ */
+ public static function preProcess(&$form) {
+ CRM_Utils_System::setTitle('Print/Merge Document');
+ }
+
+ /**
+ * Build the form object.
+ *
+ * @var CRM_Core_Form $form
+ */
+ public static function buildQuickForm(&$form) {
+ // This form outputs a file so should never be submitted via ajax
+ $form->preventAjaxSubmit();
+
+ //Added for CRM-12682: Add activity subject and campaign fields
+ CRM_Campaign_BAO_Campaign::addCampaign($form);
+ $form->add(
+ 'text',
+ 'subject',
+ ts('Activity Subject'),
+ array('size' => 45, 'maxlength' => 255),
+ FALSE
+ );
+
+ $form->add('static', 'pdf_format_header', NULL, ts('Page Format: %1', array(1 => '<span class="pdf-format-header-label"></span>')));
+ $form->addSelect('format_id', array(
+ 'label' => ts('Select Format'),
+ 'placeholder' => ts('Default'),
+ 'entity' => 'message_template',
+ 'field' => 'pdf_format_id',
+ 'option_url' => 'civicrm/admin/pdfFormats',
+ ));
+ $form->add(
+ 'select',
+ 'paper_size',
+ ts('Paper Size'),
+ array(0 => ts('- default -')) + CRM_Core_BAO_PaperSize::getList(TRUE),
+ FALSE,
+ array('onChange' => "selectPaper( this.value ); showUpdateFormatChkBox();")
+ );
+ $form->add('static', 'paper_dimensions', NULL, ts('Width x Height'));
+ $form->add(
+ 'select',
+ 'orientation',
+ ts('Orientation'),
+ CRM_Core_BAO_PdfFormat::getPageOrientations(),
+ FALSE,
+ array('onChange' => "updatePaperDimensions(); showUpdateFormatChkBox();")
+ );
+ $form->add(
+ 'select',
+ 'metric',
+ ts('Unit of Measure'),
+ CRM_Core_BAO_PdfFormat::getUnits(),
+ FALSE,
+ array('onChange' => "selectMetric( this.value );")
+ );
+ $form->add(
+ 'text',
+ 'margin_left',
+ ts('Left Margin'),
+ array('size' => 8, 'maxlength' => 8, 'onkeyup' => "showUpdateFormatChkBox();"),
+ TRUE
+ );
+ $form->add(
+ 'text',
+ 'margin_right',
+ ts('Right Margin'),
+ array('size' => 8, 'maxlength' => 8, 'onkeyup' => "showUpdateFormatChkBox();"),
+ TRUE
+ );
+ $form->add(
+ 'text',
+ 'margin_top',
+ ts('Top Margin'),
+ array('size' => 8, 'maxlength' => 8, 'onkeyup' => "showUpdateFormatChkBox();"),
+ TRUE
+ );
+ $form->add(
+ 'text',
+ 'margin_bottom',
+ ts('Bottom Margin'),
+ array('size' => 8, 'maxlength' => 8, 'onkeyup' => "showUpdateFormatChkBox();"),
+ TRUE
+ );
+
+ $config = CRM_Core_Config::singleton();
+ /** CRM-15883 Suppressing Stationery path field until we switch from DOMPDF to a library that supports it.
+ if ($config->wkhtmltopdfPath == FALSE) {
+ $form->add(
+ 'text',
+ 'stationery',
+ ts('Stationery (relative path to PDF you wish to use as the background)'),
+ array('size' => 25, 'maxlength' => 900, 'onkeyup' => "showUpdateFormatChkBox();"),
+ FALSE
+ );
+ }
+ */
+ $form->add('checkbox', 'bind_format', ts('Always use this Page Format with the selected Template'));
+ $form->add('checkbox', 'update_format', ts('Update Page Format (this will affect all templates that use this format)'));
+
+ $form->assign('useThisPageFormat', ts('Always use this Page Format with the new template?'));
+ $form->assign('useSelectedPageFormat', ts('Should the new template always use the selected Page Format?'));
+ $form->assign('totalSelectedContacts', count($form->_contactIds));
+
+ $form->add('select', 'document_type', ts('Document Type'), CRM_Core_SelectValues::documentFormat());
+
+ $documentTypes = implode(',', CRM_Core_SelectValues::documentApplicationType());
+ $form->addElement('file', "document_file", 'Upload Document', 'size=30 maxlength=255 accept="' . $documentTypes . '"');
+ $form->addUploadElement("document_file");
+
+ CRM_Mailing_BAO_Mailing::commonCompose($form);
+
+ $buttons = array();
+ if ($form->get('action') != CRM_Core_Action::VIEW) {
+ $buttons[] = array(
+ 'type' => 'upload',
+ 'name' => ts('Download Document'),
+ 'isDefault' => TRUE,
+ 'icon' => 'fa-download',
+ );
+ $buttons[] = array(
+ 'type' => 'submit',
+ 'name' => ts('Preview'),
+ 'subName' => 'preview',
+ 'icon' => 'fa-search',
+ 'isDefault' => FALSE,
+ );
+ }
+ $buttons[] = array(
+ 'type' => 'cancel',
+ 'name' => $form->get('action') == CRM_Core_Action::VIEW ? ts('Done') : ts('Cancel'),
+ );
+ $form->addButtons($buttons);
+
+ $form->addFormRule(array('CRM_Core_Form_Task_PDFLetterCommon', 'formRule'), $form);
+ }
+
+ /**
+ * Set default values.
+ */
+ public static function setDefaultValues() {
+ $defaultFormat = CRM_Core_BAO_PdfFormat::getDefaultValues();
+ $defaultFormat['format_id'] = $defaultFormat['id'];
+ return $defaultFormat;
+ }
+
+ /**
+ * Form rule.
+ *
+ * @param array $fields
+ * The input form values.
+ * @param array $files
+ * @param array $self
+ * Additional values form 'this'.
+ *
+ * @return bool
+ * TRUE if no errors, else array of errors.
+ */
+ public static function formRule($fields, $files, $self) {
+ $errors = array();
+ $template = CRM_Core_Smarty::singleton();
+
+ // If user uploads non-document file other than odt/docx
+ if (empty($fields['template']) &&
+ !empty($files['document_file']['tmp_name']) &&
+ array_search($files['document_file']['type'], CRM_Core_SelectValues::documentApplicationType()) == NULL
+ ) {
+ $errors['document_file'] = ts('Invalid document file format');
+ }
+ //Added for CRM-1393
+ if (!empty($fields['saveTemplate']) && empty($fields['saveTemplateName'])) {
+ $errors['saveTemplateName'] = ts("Enter name to save message template");
+ }
+ if (!is_numeric($fields['margin_left'])) {
+ $errors['margin_left'] = 'Margin must be numeric';
+ }
+ if (!is_numeric($fields['margin_right'])) {
+ $errors['margin_right'] = 'Margin must be numeric';
+ }
+ if (!is_numeric($fields['margin_top'])) {
+ $errors['margin_top'] = 'Margin must be numeric';
+ }
+ if (!is_numeric($fields['margin_bottom'])) {
+ $errors['margin_bottom'] = 'Margin must be numeric';
+ }
+ return empty($errors) ? TRUE : $errors;
+ }
+
+ /**
+ * Handle the template processing part of the form
+ */
+ public static function processTemplate(&$formValues) {
+ $html_message = CRM_Utils_Array::value('html_message', $formValues);
+
+ // process message template
+ if (!empty($formValues['saveTemplate']) || !empty($formValues['updateTemplate'])) {
+ $messageTemplate = array(
+ 'msg_text' => NULL,
+ 'msg_html' => $formValues['html_message'],
+ 'msg_subject' => NULL,
+ 'is_active' => TRUE,
+ );
+
+ $messageTemplate['pdf_format_id'] = 'null';
+ if (!empty($formValues['bind_format']) && $formValues['format_id']) {
+ $messageTemplate['pdf_format_id'] = $formValues['format_id'];
+ }
+ if (!empty($formValues['saveTemplate']) && $formValues['saveTemplate']) {
+ $messageTemplate['msg_title'] = $formValues['saveTemplateName'];
+ CRM_Core_BAO_MessageTemplate::add($messageTemplate);
+ }
+
+ if (!empty($formValues['updateTemplate']) && $formValues['template'] && $formValues['updateTemplate']) {
+ $messageTemplate['id'] = $formValues['template'];
+
+ unset($messageTemplate['msg_title']);
+ CRM_Core_BAO_MessageTemplate::add($messageTemplate);
+ }
+ }
+ elseif (CRM_Utils_Array::value('template', $formValues) > 0) {
+ if (!empty($formValues['bind_format']) && $formValues['format_id']) {
+ $query = "UPDATE civicrm_msg_template SET pdf_format_id = {$formValues['format_id']} WHERE id = {$formValues['template']}";
+ }
+ else {
+ $query = "UPDATE civicrm_msg_template SET pdf_format_id = NULL WHERE id = {$formValues['template']}";
+ }
+ CRM_Core_DAO::executeQuery($query);
+
+ $documentInfo = CRM_Core_BAO_File::getEntityFile('civicrm_msg_template', $formValues['template']);
+ foreach ((array) $documentInfo as $info) {
+ list($html_message, $formValues['document_type']) = CRM_Utils_PDF_Document::docReader($info['fullPath'], $info['mime_type']);
+ $formValues['document_file_path'] = $info['fullPath'];
+ }
+ }
+ // extract the content of uploaded document file
+ elseif (!empty($formValues['document_file'])) {
+ list($html_message, $formValues['document_type']) = CRM_Utils_PDF_Document::docReader($formValues['document_file']['name'], $formValues['document_file']['type']);
+ $formValues['document_file_path'] = $formValues['document_file']['name'];
+ }
+
+ if (!empty($formValues['update_format'])) {
+ $bao = new CRM_Core_BAO_PdfFormat();
+ $bao->savePdfFormat($formValues, $formValues['format_id']);
+ }
+
+ return $html_message;
+ }
+
+ /**
+ * @param $message
+ */
+ public static function formatMessage(&$message) {
+ $newLineOperators = array(
+ 'p' => array(
+ 'oper' => '<p>',
+ 'pattern' => '/<(\s+)?p(\s+)?>/m',
+ ),
+ 'br' => array(
+ 'oper' => '<br />',
+ 'pattern' => '/<(\s+)?br(\s+)?\/>/m',
+ ),
+ );
+
+ $htmlMsg = preg_split($newLineOperators['p']['pattern'], $message);
+ foreach ($htmlMsg as $k => & $m) {
+ $messages = preg_split($newLineOperators['br']['pattern'], $m);
+ foreach ($messages as $key => & $msg) {
+ $msg = trim($msg);
+ $matches = array();
+ if (preg_match('/^( )+/', $msg, $matches)) {
+ $spaceLen = strlen($matches[0]) / 6;
+ $trimMsg = ltrim($msg, ' ');
+ $charLen = strlen($trimMsg);
+ $totalLen = $charLen + $spaceLen;
+ if ($totalLen > 100) {
+ $spacesCount = 10;
+ if ($spaceLen > 50) {
+ $spacesCount = 20;
+ }
+ if ($charLen > 100) {
+ $spacesCount = 1;
+ }
+ $msg = str_repeat(' ', $spacesCount) . $trimMsg;
+ }
+ }
+ }
+ $m = implode($newLineOperators['br']['oper'], $messages);
+ }
+ $message = implode($newLineOperators['p']['oper'], $htmlMsg);
+ }
+
+}
'filter_type' => 'xml',
'filter_path' => "{$civicrm_root}/packages/IDS/default_filter.xml",
'tmp_path' => $tmpDir,
- 'HTML_Purifier_Path' => 'IDS/vendors/htmlpurifier/HTMLPurifier.auto.php',
+ 'HTML_Purifier_Path' => $civicrm_root . '/vendor/ezyang/htmlpurifier/library/HTMLPurifier.auto.php',
'HTML_Purifier_Cache' => $tmpDir,
'scan_keys' => '',
'exceptions' => array('__utmz', '__utmc'),
foreach ($optionalParams as $param => $type) {
if (CRM_Utils_Array::value($param, $_GET)) {
- $params[$param] = CRM_Utils_Type::validate(CRM_Utils_Array::value($param, $_GET), $type);
+ if (!is_array($_GET[$param])) {
+ $params[$param] = CRM_Utils_Type::validate(CRM_Utils_Array::value($param, $_GET), $type);
+ }
+ else {
+ foreach ($_GET[$param] as $index => $value) {
+ $params[$param][$index] = CRM_Utils_Type::validate($value, $type);
+ }
+ }
}
}
}
}
+ $object_type = get_class($object);
+
if (!$forceAction) {
if (array_key_exists('is_reserved', $object) && $object->is_reserved) {
$values['class'] = 'reserved';
// check if object is relationship type
- $object_type = get_class($object);
$exceptions = array(
'CRM_Contact_BAO_RelationshipType',
// make sure we only allow those actions that the user is permissioned for
$newAction = $newAction & CRM_Core_Action::mask($permissions);
- $values['action'] = CRM_Core_Action::formLink($links, $newAction, array('id' => $object->id));
+ $values['action'] = CRM_Core_Action::formLink(
+ $links,
+ $newAction,
+ ['id' => $object->id],
+ 'more',
+ FALSE,
+ "basic.$object_type.page",
+ $object_type,
+ $object->id
+ );
}
/**
$gotText .= ' ' . ts('You will receive an email receipt for each recurring contribution.');
}
}
- break;
+ return $gotText;
+
+ case 'contributionPageContinueText':
+ if ($params['amount'] <= 0) {
+ return ts('To complete this transaction, click the <strong>Continue</strong> button below.');
+ }
+ if ($this->_paymentProcessor['billing_mode'] == 4) {
+ return ts('Click the <strong>Continue</strong> button to go to %1, where you will select your payment method and complete the contribution.', [$this->_paymentProcessor['payment_processor_type']]);
+ }
+ if ($params['is_payment_to_existing']) {
+ return ts('To complete this transaction, click the <strong>Make Payment</strong> button below.');
+ }
+ return ts('To complete your contribution, click the <strong>Continue</strong> button below.');
+
}
- return $gotText;
+ CRM_Core_Error::deprecatedFunctionWarning('Calls to getText must use a supported method');
+ return '';
}
/**
}
if ($participant) {
- $participantStatuses = CRM_Core_PseudoConstant::get('CRM_Event_DAO_Participant', 'status_id', array(
- 'labelColumn' => 'name',
- 'flip' => 1,
- ));
- $participant->status_id = $participantStatuses['Cancelled'];
- $participant->save();
+ $participantParams['id'] = $participant->id;
+ $participantParams['status_id'] = 'Cancelled';
+ civicrm_api3('Participant', 'create', $participantParams);
}
}
}
if ($participant) {
- $participantStatuses = CRM_Core_PseudoConstant::get('CRM_Event_DAO_Participant', 'status_id', array(
- 'labelColumn' => 'name',
- 'flip' => 1,
- ));
- $participant->status_id = $participantStatuses['Cancelled'];
- $participant->save();
+ $participantParams['id'] = $participant->id;
+ $participantParams['status_id'] = 'Cancelled';
+ civicrm_api3('Participant', 'create', $participantParams);
}
}
$transaction->commit();
return TRUE;
}
+ /**
+ * Get help text information (help, description, etc.) about this payment,
+ * to display to the user.
+ *
+ * @param string $context
+ * Context of the text.
+ * Only explicitly supported contexts are handled without error.
+ * Currently supported:
+ * - contributionPageRecurringHelp (params: is_recur_installments, is_email_receipt)
+ *
+ * @param array $params
+ * Parameters for the field, context specific.
+ *
+ * @return string
+ */
+ public function getText($context, $params) {
+ switch ($context) {
+ case 'contributionPageContinueText':
+ if ($params['amount'] <= 0) {
+ return ts('To complete this transaction, click the <strong>Continue</strong> button below.');
+ }
+ return ts('To complete your contribution, click the <strong>Continue</strong> button below.');
+
+ }
+ }
+
}
*/
var $noRules = FALSE;
+ protected $temporaryTables = [];
+
/**
* Return a structure holding the supported tables, fields and their titles
*
* @return array
* a table-keyed array of field-keyed arrays holding supported fields' titles
*/
- public static function &supportedFields($requestedType) {
+ public static function supportedFields($requestedType) {
static $fields = NULL;
if (!$fields) {
// this is needed, as we're piggy-backing importableFields() below
$fields[$ctype][$table][$field] = $iField['title'];
}
}
+ // Note that most of the fields available come from 'importable fields' -
+ // I thought about making this field 'importable' but it felt like there might be unknown consequences
+ // so I opted for just adding it in & securing it with a unit test.
+ // Example usage of sort_name - It is possible to alter sort name via hook so 2 organization names might differ as in
+ // Justice League vs The Justice League but these could have the same sort_name if 'the the'
+ // exension is installed (https://github.com/eileenmcnaughton/org.wikimedia.thethe)
+ $fields[$ctype]['civicrm_contact']['sort_name'] = ts('Sort Name');
// add custom data fields
foreach (CRM_Core_BAO_CustomGroup::getTree($ctype, NULL, NULL, -1) as $key => $cg) {
if (!is_int($key)) {
}
}
CRM_Utils_Hook::dupeQuery(CRM_Core_DAO::$_nullObject, 'supportedFields', $fields);
- return $fields[$requestedType];
+ return !empty($fields[$requestedType]) ? $fields[$requestedType] : [];
}
/**
$tableQueries = $this->tableQuery();
if ($this->params && !$this->noRules) {
- $tempTableQuery = "CREATE TEMPORARY TABLE dedupe (id1 int, weight int, UNIQUE UI_id1 (id1)) ENGINE=InnoDB";
- $insertClause = "INSERT INTO dedupe (id1, weight)";
+ $this->temporaryTables['dedupe'] = CRM_Utils_SQL_TempTable::build()
+ ->setCategory('dedupe')
+ ->createWithColumns("id1 int, weight int, UNIQUE UI_id1 (id1)")->getName();
+ $insertClause = "INSERT INTO {$this->temporaryTables['dedupe']} (id1, weight)";
$groupByClause = "GROUP BY id1, weight";
$dupeCopyJoin = " JOIN dedupe_copy ON dedupe_copy.id1 = t1.column WHERE ";
}
else {
- $tempTableQuery = "CREATE TEMPORARY TABLE dedupe (id1 int, id2 int, weight int, UNIQUE UI_id1_id2 (id1, id2)) ENGINE=InnoDB";
- $insertClause = "INSERT INTO dedupe (id1, id2, weight)";
+ $this->temporaryTables['dedupe'] = CRM_Utils_SQL_TempTable::build()
+ ->setCategory('dedupe')
+ ->createWithColumns("id1 int, id2 int, weight int, UNIQUE UI_id1_id2 (id1, id2)")->getName();
+ $insertClause = "INSERT INTO {$this->temporaryTables['dedupe']} (id1, id2, weight)";
$groupByClause = "GROUP BY id1, id2, weight";
$dupeCopyJoin = " JOIN dedupe_copy ON dedupe_copy.id1 = t1.column AND dedupe_copy.id2 = t2.column WHERE ";
}
$patternColumn = '/t1.(\w+)/';
$exclWeightSum = array();
- // create temp table
$dao = new CRM_Core_DAO();
- $dao->query($tempTableQuery);
-
CRM_Utils_Hook::dupeQuery($this, 'table', $tableQueries);
while (!empty($tableQueries)) {
if ($searchWithinDupes) {
// get prepared to search within already found dupes if $searchWithinDupes flag is set
$dao->query("DROP TEMPORARY TABLE IF EXISTS dedupe_copy");
- $dao->query("CREATE TEMPORARY TABLE dedupe_copy SELECT * FROM dedupe WHERE weight >= {$weightSum}");
+ $dao->query("CREATE TEMPORARY TABLE dedupe_copy SELECT * FROM {$this->temporaryTables['dedupe']} WHERE weight >= {$weightSum}");
$dao->free();
preg_match($patternColumn, $query, $matches);
if (preg_match('/dedupe_copy[\S\s]*(union)[\S\s]*dedupe_copy/i', $query, $matches, PREG_OFFSET_CAPTURE)) {
// Make a second temp table:
$dao->query("DROP TEMPORARY TABLE IF EXISTS dedupe_copy_2");
- $dao->query("CREATE TEMPORARY TABLE dedupe_copy_2 SELECT * FROM dedupe WHERE weight >= {$weightSum}");
+ $dao->query("CREATE TEMPORARY TABLE dedupe_copy_2 SELECT * FROM {$this->temporaryTables['dedupe']} WHERE weight >= {$weightSum}");
$dao->free();
// After the union, use that new temp table:
$part1 = substr($query, 0, $matches[1][1]);
list($this->_aclFrom, $this->_aclWhere) = CRM_Contact_BAO_Contact_Permission::cacheClause('civicrm_contact');
$this->_aclWhere = $this->_aclWhere ? "AND {$this->_aclWhere}" : '';
}
- $query = "SELECT dedupe.id1 as id
- FROM dedupe JOIN civicrm_contact ON dedupe.id1 = civicrm_contact.id {$this->_aclFrom}
+ $query = "SELECT {$this->temporaryTables['dedupe']}.id1 as id
+ FROM {$this->temporaryTables['dedupe']} JOIN civicrm_contact ON {$this->temporaryTables['dedupe']}.id1 = civicrm_contact.id {$this->_aclFrom}
WHERE contact_type = '{$this->contact_type}' {$this->_aclWhere}
AND weight >= {$this->threshold}";
}
list($this->_aclFrom, $this->_aclWhere) = CRM_Contact_BAO_Contact_Permission::cacheClause(array('c1', 'c2'));
$this->_aclWhere = $this->_aclWhere ? "AND {$this->_aclWhere}" : '';
}
- $query = "SELECT IF(dedupe.id1 < dedupe.id2, dedupe.id1, dedupe.id2) as id1,
- IF(dedupe.id1 < dedupe.id2, dedupe.id2, dedupe.id1) as id2, dedupe.weight
- FROM dedupe JOIN civicrm_contact c1 ON dedupe.id1 = c1.id
- JOIN civicrm_contact c2 ON dedupe.id2 = c2.id {$this->_aclFrom}
- LEFT JOIN civicrm_dedupe_exception exc ON dedupe.id1 = exc.contact_id1 AND dedupe.id2 = exc.contact_id2
+ $query = "SELECT IF({$this->temporaryTables['dedupe']}.id1 < {$this->temporaryTables['dedupe']}.id2, {$this->temporaryTables['dedupe']}.id1, {$this->temporaryTables['dedupe']}.id2) as id1,
+ IF({$this->temporaryTables['dedupe']}.id1 < {$this->temporaryTables['dedupe']}.id2, {$this->temporaryTables['dedupe']}.id2, {$this->temporaryTables['dedupe']}.id1) as id2, {$this->temporaryTables['dedupe']}.weight
+ FROM {$this->temporaryTables['dedupe']} JOIN civicrm_contact c1 ON {$this->temporaryTables['dedupe']}.id1 = c1.id
+ JOIN civicrm_contact c2 ON {$this->temporaryTables['dedupe']}.id2 = c2.id {$this->_aclFrom}
+ LEFT JOIN civicrm_dedupe_exception exc ON {$this->temporaryTables['dedupe']}.id1 = exc.contact_id1 AND {$this->temporaryTables['dedupe']}.id2 = exc.contact_id2
WHERE c1.contact_type = '{$this->contact_type}' AND
c2.contact_type = '{$this->contact_type}' {$this->_aclWhere}
AND weight >= {$this->threshold} AND exc.contact_id1 IS NULL";
$config = CRM_Core_Config::singleton();
if ($config->userSystem->is_drupal) {
$userRecordUrl = CRM_Utils_System::url('user/%ufid');
- $title = ts('%1 User: %2; user id: %3', array(1 => $config->userFramework, 2 => '$ufname', 3 => '$ufid'));
+ $title = ts('%1 User: %2; user id: %3', [
+ 1 => $config->userFramework,
+ 2 => '$ufname',
+ 3 => '$ufid',
+ ]);
}
elseif ($config->userFramework == 'Joomla') {
$userRecordUrl = $config->userSystem->getVersion() > 1.5 ? $config->userFrameworkBaseURL . "index.php?option=com_users&view=user&task=user.edit&id=" . '%ufid' : $config->userFrameworkBaseURL . "index2.php?option=com_users&view=user&task=edit&id[]=" . '%ufid';
- $title = ts('%1 User: %2; user id: %3', array(1 => $config->userFramework, 2 => '$ufname', 3 => '$ufid'));
+ $title = ts('%1 User: %2; user id: %3', [
+ 1 => $config->userFramework,
+ 2 => '$ufname',
+ 3 => '$ufid',
+ ]);
}
- $relTables = array(
- 'rel_table_contributions' => array(
+ $relTables = [
+ 'rel_table_contributions' => [
'title' => ts('Contributions'),
- 'tables' => array('civicrm_contribution', 'civicrm_contribution_recur', 'civicrm_contribution_soft'),
+ 'tables' => [
+ 'civicrm_contribution',
+ 'civicrm_contribution_recur',
+ 'civicrm_contribution_soft',
+ ],
'url' => CRM_Utils_System::url('civicrm/contact/view', 'reset=1&force=1&cid=$cid&selectedChild=contribute'),
- ),
- 'rel_table_contribution_page' => array(
+ ],
+ 'rel_table_contribution_page' => [
'title' => ts('Contribution Pages'),
- 'tables' => array('civicrm_contribution_page'),
+ 'tables' => ['civicrm_contribution_page'],
'url' => CRM_Utils_System::url('civicrm/admin/contribute', 'reset=1&cid=$cid'),
- ),
- 'rel_table_memberships' => array(
+ ],
+ 'rel_table_memberships' => [
'title' => ts('Memberships'),
- 'tables' => array('civicrm_membership', 'civicrm_membership_log', 'civicrm_membership_type'),
+ 'tables' => [
+ 'civicrm_membership',
+ 'civicrm_membership_log',
+ 'civicrm_membership_type',
+ ],
'url' => CRM_Utils_System::url('civicrm/contact/view', 'reset=1&force=1&cid=$cid&selectedChild=member'),
- ),
- 'rel_table_participants' => array(
+ ],
+ 'rel_table_participants' => [
'title' => ts('Participants'),
- 'tables' => array('civicrm_participant'),
+ 'tables' => ['civicrm_participant'],
'url' => CRM_Utils_System::url('civicrm/contact/view', 'reset=1&force=1&cid=$cid&selectedChild=participant'),
- ),
- 'rel_table_events' => array(
+ ],
+ 'rel_table_events' => [
'title' => ts('Events'),
- 'tables' => array('civicrm_event'),
+ 'tables' => ['civicrm_event'],
'url' => CRM_Utils_System::url('civicrm/event/manage', 'reset=1&cid=$cid'),
- ),
- 'rel_table_activities' => array(
+ ],
+ 'rel_table_activities' => [
'title' => ts('Activities'),
- 'tables' => array('civicrm_activity', 'civicrm_activity_contact'),
+ 'tables' => ['civicrm_activity', 'civicrm_activity_contact'],
'url' => CRM_Utils_System::url('civicrm/contact/view', 'reset=1&force=1&cid=$cid&selectedChild=activity'),
- ),
- 'rel_table_relationships' => array(
+ ],
+ 'rel_table_relationships' => [
'title' => ts('Relationships'),
- 'tables' => array('civicrm_relationship'),
+ 'tables' => ['civicrm_relationship'],
'url' => CRM_Utils_System::url('civicrm/contact/view', 'reset=1&force=1&cid=$cid&selectedChild=rel'),
- ),
- 'rel_table_custom_groups' => array(
+ ],
+ 'rel_table_custom_groups' => [
'title' => ts('Custom Groups'),
- 'tables' => array('civicrm_custom_group'),
+ 'tables' => ['civicrm_custom_group'],
'url' => CRM_Utils_System::url('civicrm/admin/custom/group', 'reset=1'),
- ),
- 'rel_table_uf_groups' => array(
+ ],
+ 'rel_table_uf_groups' => [
'title' => ts('Profiles'),
- 'tables' => array('civicrm_uf_group'),
+ 'tables' => ['civicrm_uf_group'],
'url' => CRM_Utils_System::url('civicrm/admin/uf/group', 'reset=1'),
- ),
- 'rel_table_groups' => array(
+ ],
+ 'rel_table_groups' => [
'title' => ts('Groups'),
- 'tables' => array('civicrm_group_contact'),
+ 'tables' => ['civicrm_group_contact'],
'url' => CRM_Utils_System::url('civicrm/contact/view', 'reset=1&force=1&cid=$cid&selectedChild=group'),
- ),
- 'rel_table_notes' => array(
+ ],
+ 'rel_table_notes' => [
'title' => ts('Notes'),
- 'tables' => array('civicrm_note'),
+ 'tables' => ['civicrm_note'],
'url' => CRM_Utils_System::url('civicrm/contact/view', 'reset=1&force=1&cid=$cid&selectedChild=note'),
- ),
- 'rel_table_tags' => array(
+ ],
+ 'rel_table_tags' => [
'title' => ts('Tags'),
- 'tables' => array('civicrm_entity_tag'),
+ 'tables' => ['civicrm_entity_tag'],
'url' => CRM_Utils_System::url('civicrm/contact/view', 'reset=1&force=1&cid=$cid&selectedChild=tag'),
- ),
- 'rel_table_mailings' => array(
+ ],
+ 'rel_table_mailings' => [
'title' => ts('Mailings'),
- 'tables' => array('civicrm_mailing', 'civicrm_mailing_event_queue', 'civicrm_mailing_event_subscribe'),
+ 'tables' => [
+ 'civicrm_mailing',
+ 'civicrm_mailing_event_queue',
+ 'civicrm_mailing_event_subscribe',
+ ],
'url' => CRM_Utils_System::url('civicrm/contact/view', 'reset=1&force=1&cid=$cid&selectedChild=mailing'),
- ),
- 'rel_table_cases' => array(
+ ],
+ 'rel_table_cases' => [
'title' => ts('Cases'),
- 'tables' => array('civicrm_case_contact'),
+ 'tables' => ['civicrm_case_contact'],
'url' => CRM_Utils_System::url('civicrm/contact/view', 'reset=1&force=1&cid=$cid&selectedChild=case'),
- ),
- 'rel_table_grants' => array(
+ ],
+ 'rel_table_grants' => [
'title' => ts('Grants'),
- 'tables' => array('civicrm_grant'),
+ 'tables' => ['civicrm_grant'],
'url' => CRM_Utils_System::url('civicrm/contact/view', 'reset=1&force=1&cid=$cid&selectedChild=grant'),
- ),
- 'rel_table_pcp' => array(
+ ],
+ 'rel_table_pcp' => [
'title' => ts('PCPs'),
- 'tables' => array('civicrm_pcp'),
+ 'tables' => ['civicrm_pcp'],
'url' => CRM_Utils_System::url('civicrm/contribute/pcp/manage', 'reset=1'),
- ),
- 'rel_table_pledges' => array(
+ ],
+ 'rel_table_pledges' => [
'title' => ts('Pledges'),
- 'tables' => array('civicrm_pledge', 'civicrm_pledge_payment'),
+ 'tables' => ['civicrm_pledge', 'civicrm_pledge_payment'],
'url' => CRM_Utils_System::url('civicrm/contact/view', 'reset=1&force=1&cid=$cid&selectedChild=pledge'),
- ),
- 'rel_table_users' => array(
+ ],
+ 'rel_table_users' => [
'title' => $title,
- 'tables' => array('civicrm_uf_match'),
+ 'tables' => ['civicrm_uf_match'],
'url' => $userRecordUrl,
- ),
- );
+ ],
+ ];
$relTables += self::getMultiValueCustomSets('relTables');
*/
public static function getActiveRelTables($cid) {
$cid = (int) $cid;
- $groups = array();
+ $groups = [];
$relTables = self::relTables();
$cidRefs = self::cidRefs();
$eidRefs = self::eidRefs();
foreach ($relTables as $group => $params) {
- $sqls = array();
+ $sqls = [];
foreach ($params['tables'] as $table) {
if (isset($cidRefs[$table])) {
foreach ($cidRefs[$table] as $field) {
CRM_Utils_Hook::merge('cidRefs', $contactReferences);
if ($contactReferences !== $coreReferences) {
- Civi::log()->warning("Deprecated hook ::merge in context of 'cidRefs. Use entityTypes instead.", array('civi.tag' => 'deprecated'));
+ Civi::log()
+ ->warning("Deprecated hook ::merge in context of 'cidRefs. Use entityTypes instead.", ['civi.tag' => 'deprecated']);
}
\Civi::$statics[__CLASS__]['contact_references'] = $contactReferences;
return \Civi::$statics[__CLASS__]['contact_references'];
if (!$eidRefs) {
// FIXME: this should be generated dynamically from the schema
// tables that reference contacts with entity_{id,table}
- $eidRefs = array(
- 'civicrm_acl' => array('entity_table' => 'entity_id'),
- 'civicrm_acl_entity_role' => array('entity_table' => 'entity_id'),
- 'civicrm_entity_file' => array('entity_table' => 'entity_id'),
- 'civicrm_log' => array('entity_table' => 'entity_id'),
- 'civicrm_mailing_group' => array('entity_table' => 'entity_id'),
- 'civicrm_note' => array('entity_table' => 'entity_id'),
- );
+ $eidRefs = [
+ 'civicrm_acl' => ['entity_table' => 'entity_id'],
+ 'civicrm_acl_entity_role' => ['entity_table' => 'entity_id'],
+ 'civicrm_entity_file' => ['entity_table' => 'entity_id'],
+ 'civicrm_log' => ['entity_table' => 'entity_id'],
+ 'civicrm_mailing_group' => ['entity_table' => 'entity_id'],
+ 'civicrm_note' => ['entity_table' => 'entity_id'],
+ ];
// Allow hook_civicrm_merge() to adjust $eidRefs
CRM_Utils_Hook::merge('eidRefs', $eidRefs);
public static function locTables() {
static $locTables;
if (!$locTables) {
- $locTables = array('civicrm_email', 'civicrm_address', 'civicrm_phone');
+ $locTables = ['civicrm_email', 'civicrm_address', 'civicrm_phone'];
// Allow hook_civicrm_merge() to adjust $locTables
CRM_Utils_Hook::merge('locTables', $locTables);
public static function getMultiValueCustomSets($request) {
if (!isset(Civi::$statics[__CLASS__]['multiValueCustomSets'])) {
- $data = array(
- 'relTables' => array(),
- 'cidRefs' => array(),
- );
- $result = civicrm_api3('custom_group', 'get', array(
+ $data = [
+ 'relTables' => [],
+ 'cidRefs' => [],
+ ];
+ $result = civicrm_api3('custom_group', 'get', [
'is_multiple' => 1,
- 'extends' => array('IN' => array('Individual', 'Organization', 'Household', 'Contact')),
- 'return' => array('id', 'title', 'table_name', 'style'),
- ));
+ 'extends' => [
+ 'IN' => [
+ 'Individual',
+ 'Organization',
+ 'Household',
+ 'Contact',
+ ],
+ ],
+ 'return' => ['id', 'title', 'table_name', 'style'],
+ ]);
foreach ($result['values'] as $custom) {
- $data['cidRefs'][$custom['table_name']] = array('entity_id');
+ $data['cidRefs'][$custom['table_name']] = ['entity_id'];
$urlSuffix = $custom['style'] == 'Tab' ? '&selectedChild=custom_' . $custom['id'] : '';
- $data['relTables']['rel_table_custom_' . $custom['id']] = array(
+ $data['relTables']['rel_table_custom_' . $custom['id']] = [
'title' => $custom['title'],
- 'tables' => array($custom['table_name']),
+ 'tables' => [$custom['table_name']],
'url' => CRM_Utils_System::url('civicrm/contact/view', 'reset=1&force=1&cid=$cid' . $urlSuffix),
- );
+ ];
}
// Store the result in a static variable cache
public static function cpTables() {
static $tables;
if (!$tables) {
- $tables = array(
- 'civicrm_case_contact' => array('CRM_Case_BAO_Case' => 'mergeContacts'),
- 'civicrm_group_contact' => array('CRM_Contact_BAO_GroupContact' => 'mergeGroupContact'),
+ $tables = [
+ 'civicrm_case_contact' => ['CRM_Case_BAO_Case' => 'mergeContacts'],
+ 'civicrm_group_contact' => ['CRM_Contact_BAO_GroupContact' => 'mergeGroupContact'],
// Empty array == do nothing - this table is handled by mergeGroupContact
- 'civicrm_subscription_history' => array(),
- 'civicrm_relationship' => array('CRM_Contact_BAO_Relationship' => 'mergeRelationships'),
- 'civicrm_membership' => array('CRM_Member_BAO_Membership' => 'mergeMemberships'),
- );
+ 'civicrm_subscription_history' => [],
+ 'civicrm_relationship' => ['CRM_Contact_BAO_Relationship' => 'mergeRelationships'],
+ 'civicrm_membership' => ['CRM_Member_BAO_Membership' => 'mergeMemberships'],
+ ];
}
return $tables;
}
public static function paymentTables() {
static $tables;
if (!$tables) {
- $tables = array('civicrm_pledge', 'civicrm_membership', 'civicrm_participant');
+ $tables = ['civicrm_pledge', 'civicrm_membership', 'civicrm_participant'];
}
return $tables;
}
* @return array
*/
public static function paymentSql($tableName, $mainContactId, $otherContactId) {
- $sqls = array();
+ $sqls = [];
if (!$tableName || !$mainContactId || !$otherContactId) {
return $sqls;
}
*
* @return array
*/
- public static function operationSql($mainId, $otherId, $tableName, $tableOperations = array(), $mode = 'add') {
- $sqls = array();
+ public static function operationSql($mainId, $otherId, $tableName, $tableOperations = [], $mode = 'add') {
+ $sqls = [];
if (!$tableName || !$mainId || !$otherId) {
return $sqls;
}
if (in_array("civicrm_membership", $tables)) {
$membershipIDs = CRM_Utils_Array::collect('id',
CRM_Utils_Array::value('values',
- civicrm_api3("Membership", "get", array(
- "contact_id" => $otherID,
- "return" => "id",
- )
+ civicrm_api3("Membership", "get", [
+ "contact_id" => $otherID,
+ "return" => "id",
+ ]
)
));
if (!empty($membershipIDs)) {
- civicrm_api3("Membership", "get", array(
- 'owner_membership_id' => array('IN' => $membershipIDs),
- 'api.Membership.delete' => array('id' => '$value.id'),
- ));
+ civicrm_api3("Membership", "get", [
+ 'owner_membership_id' => ['IN' => $membershipIDs],
+ 'api.Membership.delete' => ['id' => '$value.id'],
+ ]);
}
}
}
* @param array $tableOperations
* @param array $customTableToCopyFrom
*/
- public static function moveContactBelongings($mainId, $otherId, $tables = FALSE, $tableOperations = array(), $customTableToCopyFrom = NULL) {
+ public static function moveContactBelongings($mainId, $otherId, $tables = FALSE, $tableOperations = [], $customTableToCopyFrom = NULL) {
$cidRefs = self::cidRefs();
$eidRefs = self::eidRefs();
$cpTables = self::cpTables();
$paymentTables = self::paymentTables();
// getting all custom tables
- $customTables = array();
+ $customTables = [];
if ($customTableToCopyFrom !== NULL) {
// @todo this duplicates cidRefs?
CRM_Core_DAO::appendCustomTablesExtendingContacts($customTables);
$otherId = (int) $otherId;
$multi_value_tables = array_keys(CRM_Dedupe_Merger::getMultiValueCustomSets('cidRefs'));
- $sqls = array();
+ $sqls = [];
foreach ($affected as $table) {
// skipping non selected single-value custom table's value migration
if (!in_array($table, $multi_value_tables)) {
// call the SQL queries in one transaction
$transaction = new CRM_Core_Transaction();
foreach ($sqls as $sql) {
- CRM_Core_DAO::executeQuery($sql, array(), TRUE, NULL, TRUE);
+ CRM_Core_DAO::executeQuery($sql, [], TRUE, NULL, TRUE);
}
CRM_Dedupe_Merger::addMembershipToRealtedContacts($mainId);
$transaction->commit();
* @return array
*/
public static function retrieveFields($main, $other) {
- $result = array(
- 'contact' => array(),
- 'custom' => array(),
- );
+ $result = [
+ 'contact' => [],
+ 'custom' => [],
+ ];
foreach (self::getContactFields() as $validField) {
// CRM-17556 Get all non-empty fields, to make comparison easier
if (!empty($main[$validField]) || !empty($other[$validField])) {
*
* @return array|bool
*/
- public static function batchMerge($rgid, $gid = NULL, $mode = 'safe', $batchLimit = 1, $isSelected = 2, $criteria = array(), $checkPermissions = TRUE, $reloadCacheIfEmpty = NULL) {
+ public static function batchMerge($rgid, $gid = NULL, $mode = 'safe', $batchLimit = 1, $isSelected = 2, $criteria = [], $checkPermissions = TRUE, $reloadCacheIfEmpty = NULL) {
$redirectForPerformance = ($batchLimit > 1) ? TRUE : FALSE;
if (!isset($reloadCacheIfEmpty)) {
}
$dupePairs = self::getDuplicatePairs($rgid, $gid, $reloadCacheIfEmpty, $batchLimit, $isSelected, '', ($mode == 'aggressive'), $criteria, $checkPermissions);
- $cacheParams = array(
+ $cacheParams = [
'cache_key_string' => self::getMergeCacheKeyString($rgid, $gid, $criteria, $checkPermissions),
// @todo stop passing these parameters in & instead calculate them in the merge function based
// on the 'real' params like $isRespectExclusions $batchLimit and $isSelected.
'join' => self::getJoinOnDedupeTable(),
'where' => self::getWhereString($isSelected),
'limit' => (int) $batchLimit,
- );
+ ];
return CRM_Dedupe_Merger::merge($dupePairs, $cacheParams, $mode, $redirectForPerformance, $checkPermissions);
}
* @param string $cacheKeyString
* @param array $result
*/
- public static function updateMergeStats($cacheKeyString, $result = array()) {
+ public static function updateMergeStats($cacheKeyString, $result = []) {
// gather latest stats
- $merged = count($result['merged']);
+ $merged = count($result['merged']);
$skipped = count($result['skipped']);
if ($merged <= 0 && $skipped <= 0) {
CRM_Dedupe_Merger::resetMergeStats($cacheKeyString);
// store the updated stats
- $data = array(
- 'merged' => $merged,
+ $data = [
+ 'merged' => $merged,
'skipped' => $skipped,
- );
+ ];
$data = CRM_Core_DAO::escapeString(serialize($data));
- $values = array();
+ $values = [];
$values[] = " ( 'civicrm_contact', 0, 0, '{$cacheKeyString}_stats', '$data' ) ";
CRM_Core_BAO_PrevNextCache::setItem($values);
}
public static function getMergeStatsMsg($stats) {
$msg = '';
if (!empty($stats['merged'])) {
- $msg = '<p>' . ts('One contact merged.', array('count' => $stats['merged'], 'plural' => '%count contacts merged.')) . '</p>';
+ $msg = '<p>' . ts('One contact merged.', [
+ 'count' => $stats['merged'],
+ 'plural' => '%count contacts merged.',
+ ]) . '</p>';
}
if (!empty($stats['skipped'])) {
- $msg .= '<p>' . ts('One contact was skipped.', array('count' => $stats['skipped'], 'plural' => '%count contacts were skipped.')) . '</p>';
+ $msg .= '<p>' . ts('One contact was skipped.', [
+ 'count' => $stats['skipped'],
+ 'plural' => '%count contacts were skipped.',
+ ]) . '</p>';
}
return $msg;
}
*
* @return array|bool
*/
- public static function merge($dupePairs = array(), $cacheParams = array(), $mode = 'safe',
- $redirectForPerformance = FALSE, $checkPermissions = TRUE
+ public static function merge($dupePairs = [], $cacheParams = [], $mode = 'safe',
+ $redirectForPerformance = FALSE, $checkPermissions = TRUE
) {
$cacheKeyString = CRM_Utils_Array::value('cache_key_string', $cacheParams);
- $resultStats = array('merged' => array(), 'skipped' => array());
+ $resultStats = ['merged' => [], 'skipped' => []];
// we don't want dupe caching to get reset after every-merge, and therefore set the
CRM_Core_Config::setPermitCacheFlushMode(FALSE);
- $deletedContacts = array();
+ $deletedContacts = [];
while (!empty($dupePairs)) {
foreach ($dupePairs as $index => $dupes) {
$cacheParams['where'],
0,
$cacheParams['limit'],
- array(),
+ [],
'',
FALSE
);
*
* @return bool
*/
- public static function skipMerge($mainId, $otherId, &$migrationInfo, $mode = 'safe', &$conflicts = array()) {
+ public static function skipMerge($mainId, $otherId, &$migrationInfo, $mode = 'safe', &$conflicts = []) {
$originalMigrationInfo = $migrationInfo;
foreach ($migrationInfo as $key => $val) {
// there's a conflict (to handle "gotchas"). fields_in_conflict could be modified here
// merge happens with new values filled in here. For a particular field / row not to be merged
// field should be unset from fields_in_conflict.
- $migrationData = array(
+ $migrationData = [
'old_migration_info' => $originalMigrationInfo,
'mode' => $mode,
'fields_in_conflict' => $conflicts,
'merge_mode' => $mode,
'migration_info' => $migrationInfo,
- );
+ ];
CRM_Utils_Hook::merge('batch', $migrationData, $mainId, $otherId);
$conflicts = $migrationData['fields_in_conflict'];
// allow hook to override / manipulate migrationInfo as well
* @return bool
*/
static public function locationIsSame($mainAddress, $comparisonAddress) {
- $keysToIgnore = array('id', 'is_primary', 'is_billing', 'manual_geo_code', 'contact_id', 'reset_date', 'hold_date');
+ $keysToIgnore = [
+ 'id',
+ 'is_primary',
+ 'is_billing',
+ 'manual_geo_code',
+ 'contact_id',
+ 'reset_date',
+ 'hold_date',
+ ];
foreach ($comparisonAddress as $field => $value) {
if (in_array($field, $keysToIgnore)) {
continue;
* @return array
*/
public static function getLocationBlockInfo() {
- $locationBlocks = array(
- 'address' => array(
+ $locationBlocks = [
+ 'address' => [
'label' => 'Address',
'displayField' => 'display',
'sortString' => 'location_type_id',
'hasLocation' => TRUE,
'hasType' => FALSE,
- ),
- 'email' => array(
+ ],
+ 'email' => [
'label' => 'Email',
'displayField' => 'display',
'sortString' => 'location_type_id',
'hasLocation' => TRUE,
'hasType' => FALSE,
- ),
- 'im' => array(
+ ],
+ 'im' => [
'label' => 'IM',
'displayField' => 'name',
'sortString' => 'location_type_id,provider_id',
'hasLocation' => TRUE,
'hasType' => 'provider_id',
- ),
- 'phone' => array(
+ ],
+ 'phone' => [
'label' => 'Phone',
'displayField' => 'phone',
'sortString' => 'location_type_id,phone_type_id',
'hasLocation' => TRUE,
'hasType' => 'phone_type_id',
- ),
- 'website' => array(
+ ],
+ 'website' => [
'label' => 'Website',
'displayField' => 'url',
'sortString' => 'website_type_id',
'hasLocation' => FALSE,
'hasType' => 'website_type_id',
- ),
- );
+ ],
+ ];
return $locationBlocks;
}
$compareFields = self::retrieveFields($main, $other);
- $rows = $elements = $relTableElements = $migrationInfo = array();
+ $rows = $elements = $relTableElements = $migrationInfo = [];
foreach ($compareFields['contact'] as $field) {
if ($field == 'contact_sub_type') {
// CRM-15681 don't display sub-types in UI
continue;
}
- foreach (array('main', 'other') as $moniker) {
+ foreach (['main', 'other'] as $moniker) {
$contact = &$$moniker;
$value = CRM_Utils_Array::value($field, $contact);
if (isset($specialValues[$moniker][$field]) && is_string($specialValues[$moniker][$field])) {
$label = CRM_Utils_Array::value('individual_suffix', $contact);
}
elseif ($field == 'gender_id' && !empty($value)) {
- $genderOptions = civicrm_api3('contact', 'getoptions', array('field' => 'gender_id'));
+ $genderOptions = civicrm_api3('contact', 'getoptions', ['field' => 'gender_id']);
$label = $genderOptions['values'][$value];
}
elseif ($field == 'current_employer_id' && !empty($value)) {
// Display a checkbox to migrate, only if the values are different
if ($value != $main[$field]) {
- $elements[] = array('advcheckbox', "move_$field", NULL, NULL, NULL, $value);
+ $elements[] = [
+ 'advcheckbox',
+ "move_$field",
+ NULL,
+ NULL,
+ NULL,
+ $value,
+ ];
}
$migrationInfo["move_$field"] = $value;
// Set up useful information about the location blocks
$locationBlocks = self::getLocationBlockInfo();
- $locations = array(
- 'main' => array(),
- 'other' => array(),
- );
+ $locations = [
+ 'main' => [],
+ 'other' => [],
+ ];
// @todo This could probably be defined and used earlier
- $mergeTargets = array(
+ $mergeTargets = [
'main' => $mainId,
'other' => $otherId,
- );
+ ];
foreach ($locationBlocks as $blockName => $blockInfo) {
// Collect existing fields from both 'main' and 'other' contacts first
// This allows us to match up location/types when building the table rows
foreach ($mergeTargets as $moniker => $cid) {
- $searchParams = array(
+ $searchParams = [
'contact_id' => $cid,
// CRM-17556 Order by field-specific criteria
- 'options' => array(
+ 'options' => [
'sort' => $blockInfo['sortString'],
- ),
- );
+ ],
+ ];
$values = civicrm_api3($blockName, 'get', $searchParams);
if ($values['count']) {
$cnt = 0;
// Set this value as the default against the 'other' contact value
$rows["move_location_{$blockName}_{$count}"]['main'] = $mainValueCheck[$blockInfo['displayField']];
$rows["move_location_{$blockName}_{$count}"]['main_is_primary'] = $mainValueCheck['is_primary'];
+ $rows["move_location_{$blockName}_{$count}"]['location_entity'] = $blockName;
$mainContactBlockId = $mainValueCheck['id'];
break;
}
}
// Add checkbox to migrate data from 'other' to 'main'
- $elements[] = array('advcheckbox', "move_location_{$blockName}_{$count}");
+ $elements[] = ['advcheckbox', "move_location_{$blockName}_{$count}"];
// Add checkbox to set the 'other' location as primary
- $elements[] = array('advcheckbox', "location_blocks[$blockName][$count][set_other_primary]", NULL, ts('Set as primary'));
+ $elements[] = [
+ 'advcheckbox',
+ "location_blocks[$blockName][$count][set_other_primary]",
+ NULL,
+ ts('Set as primary'),
+ ];
// Flag up this field to skipMerge function (@todo: do we need to?)
$migrationInfo["move_location_{$blockName}_{$count}"] = 1;
// Add a hidden field to store the ID of the target main contact block
- $elements[] = array('hidden', "location_blocks[$blockName][$count][mainContactBlockId]", $mainContactBlockId);
+ $elements[] = [
+ 'hidden',
+ "location_blocks[$blockName][$count][mainContactBlockId]",
+ $mainContactBlockId,
+ ];
// Setup variables
$thisTypeId = FALSE;
if ($blockInfo['hasLocation']) {
// Load the location options for this entity
- $locationOptions = civicrm_api3($blockName, 'getoptions', array('field' => 'location_type_id'));
+ $locationOptions = civicrm_api3($blockName, 'getoptions', ['field' => 'location_type_id']);
$thisLocId = $value['location_type_id'];
// Put this field's location type at the top of the list
$tmpIdList = $locationOptions['values'];
- $defaultLocId = array($thisLocId => $tmpIdList[$thisLocId]);
+ $defaultLocId = [$thisLocId => $tmpIdList[$thisLocId]];
unset($tmpIdList[$thisLocId]);
// Add the element
- $elements[] = array(
+ $elements[] = [
'select',
"location_blocks[$blockName][$count][locTypeId]",
NULL,
$defaultLocId + $tmpIdList,
- );
+ ];
// Add the relevant information to the $migrationInfo
// Keep location-type-id same as that of other-contact
// @todo Check this logic out
$migrationInfo['location_blocks'][$blockName][$count]['locTypeId'] = $thisLocId;
if ($blockName != 'address') {
- $elements[] = array('advcheckbox', "location_blocks[{$blockName}][$count][operation]", NULL, ts('Add new'));
+ $elements[] = [
+ 'advcheckbox',
+ "location_blocks[{$blockName}][$count][operation]",
+ NULL,
+ ts('Add new'),
+ ];
// always use add operation
$migrationInfo['location_blocks'][$blockName][$count]['operation'] = 1;
}
if ($blockInfo['hasType']) {
// Load the type options for this entity
- $typeOptions = civicrm_api3($blockName, 'getoptions', array('field' => $blockInfo['hasType']));
+ $typeOptions = civicrm_api3($blockName, 'getoptions', ['field' => $blockInfo['hasType']]);
$thisTypeId = CRM_Utils_Array::value($blockInfo['hasType'], $value);
// Put this field's location type at the top of the list
$tmpIdList = $typeOptions['values'];
- $defaultTypeId = array($thisTypeId => CRM_Utils_Array::value($thisTypeId, $tmpIdList));
+ $defaultTypeId = [$thisTypeId => CRM_Utils_Array::value($thisTypeId, $tmpIdList)];
unset($tmpIdList[$thisTypeId]);
// Add the element
- $elements[] = array(
+ $elements[] = [
'select',
"location_blocks[$blockName][$count][typeTypeId]",
NULL,
$defaultTypeId + $tmpIdList,
- );
+ ];
// Add the information to the migrationInfo
$migrationInfo['location_blocks'][$blockName][$count]['typeTypeId'] = $thisTypeId;
continue;
}
- $relTableElements[] = array('checkbox', "move_$name");
+ $relTableElements[] = ['checkbox', "move_$name"];
$migrationInfo["move_$name"] = 1;
$relTables[$name]['main_url'] = str_replace('$cid', $mainId, $relTables[$name]['url']);
if ($name == 'rel_table_users') {
$relTables[$name]['main_url'] = str_replace('%ufid', $mainUfId, $relTables[$name]['url']);
$relTables[$name]['other_url'] = str_replace('%ufid', $otherUfId, $relTables[$name]['url']);
- $find = array('$ufid', '$ufname');
+ $find = ['$ufid', '$ufname'];
if ($mainUser) {
- $replace = array($mainUfId, $mainUser->name);
+ $replace = [$mainUfId, $mainUser->name];
$relTables[$name]['main_title'] = str_replace($find, $replace, $relTables[$name]['title']);
}
if ($otherUser) {
- $replace = array($otherUfId, $otherUser->name);
+ $replace = [$otherUfId, $otherUser->name];
$relTables[$name]['other_title'] = str_replace($find, $replace, $relTables[$name]['title']);
}
}
$attributes = [];
}
}
- $elements[] = array('checkbox', "operation[move_{$name}][add]", NULL, ts('add new'), $attributes);
+ $elements[] = [
+ 'checkbox',
+ "operation[move_{$name}][add]",
+ NULL,
+ ts('add new'),
+ $attributes,
+ ];
$migrationInfo["operation"]["move_{$name}"]['add'] = 1;
}
}
}
$rows["move_custom_$fid"]['title'] = $field['label'];
- $elements[] = array('advcheckbox', "move_custom_$fid", NULL, NULL, NULL, $value);
+ $elements[] = [
+ 'advcheckbox',
+ "move_custom_$fid",
+ NULL,
+ NULL,
+ NULL,
+ $value,
+ ];
$migrationInfo["move_custom_$fid"] = $value;
}
}
}
- $result = array(
+ $result = [
'rows' => $rows,
'elements' => $elements,
'rel_table_elements' => $relTableElements,
'main_details' => $main,
'other_details' => $other,
'migration_info' => $migrationInfo,
- );
+ ];
$result['main_details']['location_blocks'] = $locations['main'];
$result['other_details']['location_blocks'] = $locations['other'];
$qfZeroBug = 'e8cddb72-a257-11dc-b9cc-0016d3330ee9';
$relTables = CRM_Dedupe_Merger::relTables();
- $submittedCustomFields = $moveTables = $locationMigrationInfo = $tableOperations = $removeTables = array();
+ $submittedCustomFields = $moveTables = $locationMigrationInfo = $tableOperations = $removeTables = [];
foreach ($migrationInfo as $key => $value) {
if ($value == $qfZeroBug) {
if (!empty($removeTables)) {
// **** CRM-20421
CRM_Dedupe_Merger::removeContactBelongings($otherId, $removeTables);
- $removeTables = array();
+ $removeTables = [];
}
// FIXME: fix gender, prefix and postfix, so they're edible by createProfileContact()
- $names['gender'] = array('newName' => 'gender_id', 'groupName' => 'gender');
- $names['individual_prefix'] = array('newName' => 'prefix_id', 'groupName' => 'individual_prefix');
- $names['individual_suffix'] = array('newName' => 'suffix_id', 'groupName' => 'individual_suffix');
- $names['communication_style'] = array('newName' => 'communication_style_id', 'groupName' => 'communication_style');
- $names['addressee'] = array('newName' => 'addressee_id', 'groupName' => 'addressee');
- $names['email_greeting'] = array('newName' => 'email_greeting_id', 'groupName' => 'email_greeting');
- $names['postal_greeting'] = array('newName' => 'postal_greeting_id', 'groupName' => 'postal_greeting');
+ $names['gender'] = ['newName' => 'gender_id', 'groupName' => 'gender'];
+ $names['individual_prefix'] = [
+ 'newName' => 'prefix_id',
+ 'groupName' => 'individual_prefix',
+ ];
+ $names['individual_suffix'] = [
+ 'newName' => 'suffix_id',
+ 'groupName' => 'individual_suffix',
+ ];
+ $names['communication_style'] = [
+ 'newName' => 'communication_style_id',
+ 'groupName' => 'communication_style',
+ ];
+ $names['addressee'] = [
+ 'newName' => 'addressee_id',
+ 'groupName' => 'addressee',
+ ];
+ $names['email_greeting'] = [
+ 'newName' => 'email_greeting_id',
+ 'groupName' => 'email_greeting',
+ ];
+ $names['postal_greeting'] = [
+ 'newName' => 'postal_greeting_id',
+ 'groupName' => 'postal_greeting',
+ ];
CRM_Core_OptionGroup::lookupValues($submitted, $names, TRUE);
// fix custom fields so they're edible by createProfileContact()
- $treeCache = array();
+ $treeCache = [];
if (!array_key_exists($migrationInfo['main_details']['contact_type'], $treeCache)) {
$treeCache[$migrationInfo['main_details']['contact_type']] = CRM_Core_BAO_CustomGroup::getTree(
$migrationInfo['main_details']['contact_type'],
NULL,
NULL,
-1,
- array(),
+ [],
NULL,
TRUE,
NULL,
);
}
- $cFields = array();
+ $cFields = [];
foreach ($treeCache[$migrationInfo['main_details']['contact_type']] as $key => $group) {
if (!isset($group['fields'])) {
continue;
}
if (!isset($submitted)) {
- $submitted = array();
+ $submitted = [];
}
foreach ($submitted as $key => $value) {
if (substr($key, 0, 7) == 'custom_') {
case 'Multi-Select State/Province':
// Merge values from both contacts for multivalue fields, CRM-4385
// get the existing custom values from db.
- $customParams = array('entityID' => $mainId, $key => TRUE);
+ $customParams = ['entityID' => $mainId, $key => TRUE];
$customfieldValues = CRM_Core_BAO_CustomValueTable::getValues($customParams);
if (!empty($customfieldValues[$key])) {
$existingValue = explode(CRM_Core_DAO::VALUE_SEPARATOR, $customfieldValues[$key]);
if (is_array($existingValue) && !empty($existingValue)) {
- $mergeValue = $submittedCustomFields = array();
+ $mergeValue = $submittedCustomFields = [];
if ($value == 'null') {
// CRM-19074 if someone has deliberately chosen to overwrite with 'null', respect it.
$submitted[$key] = $value;
//keep state and country as array format.
//for checkbox and m-select format w/ VALUE_SEPARATOR
- if (in_array($htmlType, array(
+ if (in_array($htmlType, [
'CheckBox',
'Multi-Select',
- ))) {
+ ])) {
$submitted[$key] = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR,
$mergeValue
) . CRM_Core_DAO::VALUE_SEPARATOR;
}
}
}
- elseif (in_array($htmlType, array(
+ elseif (in_array($htmlType, [
'Multi-Select Country',
'Multi-Select State/Province',
- ))) {
+ ])) {
//we require submitted values should be in array format
if ($value) {
$mergeValueArray = explode(CRM_Core_DAO::VALUE_SEPARATOR, $value);
//hack to remove null values from array.
- $mergeValue = array();
+ $mergeValue = [];
foreach ($mergeValueArray as $k => $v) {
if ($v != '') {
$mergeValue[] = $v;
// like, delete a file...
if (!isset($customFiles)) {
- $customFiles = array();
+ $customFiles = [];
}
foreach ($customFiles as $customId) {
list($tableName, $columnName, $groupID) = CRM_Core_BAO_CustomField::getTableColumnGroup($customId);
// get the contact_id -> file_id mapping
- $fileIds = array();
+ $fileIds = [];
$sql = "SELECT entity_id, {$columnName} AS file_id FROM {$tableName} WHERE entity_id IN ({$mainId}, {$otherId})";
$dao = CRM_Core_DAO::executeQuery($sql);
while ($dao->fetch()) {
}
// move view only custom fields CRM-5362
- $viewOnlyCustomFields = array();
+ $viewOnlyCustomFields = [];
foreach ($submitted as $key => $value) {
$fid = CRM_Core_BAO_CustomField::getKeyID($key);
if ($fid && array_key_exists($fid, $cFields) && !empty($cFields[$fid]['attributes']['is_view'])
}
if (!$checkPermissions || (CRM_Core_Permission::check('merge duplicate contacts') &&
- CRM_Core_Permission::check('delete contacts'))
+ CRM_Core_Permission::check('delete contacts'))
) {
// if ext id is submitted then set it null for contact to be deleted
if (!empty($submitted['external_identifier'])) {
$query = "UPDATE civicrm_contact SET external_identifier = null WHERE id = {$otherId}";
CRM_Core_DAO::executeQuery($query);
}
- civicrm_api3('contact', 'delete', array('id' => $otherId));
+ civicrm_api3('contact', 'delete', ['id' => $otherId]);
}
// CRM-15681 merge sub_types
* Array of custom table names
*/
private static function getAffectedCustomTables($customFieldIDs) {
- $customTableToCopyValues = array();
+ $customTableToCopyValues = [];
foreach ($customFieldIDs as $fieldID) {
if (!empty($fieldID)) {
- $customField = civicrm_api3('custom_field', 'getsingle', array(
+ $customField = civicrm_api3('custom_field', 'getsingle', [
'id' => $fieldID,
'is_active' => TRUE,
- ));
+ ]);
if (!civicrm_error($customField) && !empty($customField['custom_group_id'])) {
- $customGroup = civicrm_api3('custom_group', 'getsingle', array(
+ $customGroup = civicrm_api3('custom_group', 'getsingle', [
'id' => $customField['custom_group_id'],
'is_active' => TRUE,
- ));
+ ]);
if (!civicrm_error($customGroup) && !empty($customGroup['table_name'])) {
$customTableToCopyValues[] = $customGroup['table_name'];
*/
public static function getContactFields() {
$contactFields = CRM_Contact_DAO_Contact::fields();
- $invalidFields = array(
+ $invalidFields = [
'api_key',
'created_date',
'display_name',
'primary_contact_id',
'sort_name',
'user_unique_id',
- );
+ ];
foreach ($contactFields as $field => $value) {
if (in_array($field, $invalidFields)) {
unset($contactFields[$field]);
while ($dao->fetch()) {
$relationshipTypeId = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $dao->membership_type_id, 'relationship_type_id', 'id');
if ($relationshipTypeId) {
- $membershipParams = array(
+ $membershipParams = [
'id' => $dao->id,
'contact_id' => $dao->contact_id,
'membership_type_id' => $dao->membership_type_id,
'end_date' => CRM_Utils_Date::isoToMysql($dao->end_date),
'source' => $dao->source,
'status_id' => $dao->status_id,
- );
+ ];
// create/update membership(s) for related contact(s)
CRM_Member_BAO_Membership::createRelatedMemberships($membershipParams, $dao);
} // end of if relationshipTypeId
* @throws \CiviCRM_API3_Exception
*/
public static function createMergeActivities($mainId, $otherId) {
- $params = array(
+ $params = [
1 => $otherId,
2 => $mainId,
- );
- $activity = civicrm_api3('activity', 'create', array(
+ ];
+ $activity = civicrm_api3('activity', 'create', [
'source_contact_id' => CRM_Core_Session::getLoggedInContactID() ? CRM_Core_Session::getLoggedInContactID() :
$mainId,
'subject' => ts('Contact ID %1 has been merged and deleted.', $params),
'target_contact_id' => $mainId,
'activity_type_id' => 'Contact Merged',
'status_id' => 'Completed',
- ));
- if (civicrm_api3('Setting', 'getvalue', array('name' => 'contact_undelete', 'group' => 'CiviCRM Preferences'))) {
- civicrm_api3('activity', 'create', array(
+ ]);
+ if (civicrm_api3('Setting', 'getvalue', [
+ 'name' => 'contact_undelete',
+ 'group' => 'CiviCRM Preferences',
+ ])) {
+ civicrm_api3('activity', 'create', [
'source_contact_id' => CRM_Core_Session::getLoggedInContactID() ? CRM_Core_Session::getLoggedInContactID() :
$otherId,
'subject' => ts('Contact ID %1 has been merged into Contact ID %2 and deleted.', $params),
'activity_type_id' => 'Contact Deleted by Merge',
'parent_id' => $activity['id'],
'status_id' => 'Completed',
- ));
+ ]);
}
}
* @return array
* Array of matches meeting the criteria.
*/
- public static function getDuplicatePairs($rule_group_id, $group_id, $reloadCacheIfEmpty, $batchLimit, $isSelected, $orderByClause = '', $includeConflicts = TRUE, $criteria = array(), $checkPermissions = TRUE, $searchLimit = 0) {
+ public static function getDuplicatePairs($rule_group_id, $group_id, $reloadCacheIfEmpty, $batchLimit, $isSelected, $orderByClause = '', $includeConflicts = TRUE, $criteria = [], $checkPermissions = TRUE, $searchLimit = 0) {
$where = self::getWhereString($isSelected);
$cacheKeyString = self::getMergeCacheKeyString($rule_group_id, $group_id, $criteria, $checkPermissions);
$join = self::getJoinOnDedupeTable();
- $dupePairs = CRM_Core_BAO_PrevNextCache::retrieve($cacheKeyString, $join, $where, 0, $batchLimit, array(), $orderByClause, $includeConflicts);
+ $dupePairs = CRM_Core_BAO_PrevNextCache::retrieve($cacheKeyString, $join, $where, 0, $batchLimit, [], $orderByClause, $includeConflicts);
if (empty($dupePairs) && $reloadCacheIfEmpty) {
// If we haven't found any dupes, probably cache is empty.
// Try filling cache and give another try. We don't need to specify include conflicts here are there will not be any
// until we have done some processing.
CRM_Core_BAO_PrevNextCache::refillCache($rule_group_id, $group_id, $cacheKeyString, $criteria, $checkPermissions, $searchLimit);
- $dupePairs = CRM_Core_BAO_PrevNextCache::retrieve($cacheKeyString, $join, $where, 0, $batchLimit, array(), $orderByClause, $includeConflicts);
+ $dupePairs = CRM_Core_BAO_PrevNextCache::retrieve($cacheKeyString, $join, $where, 0, $batchLimit, [], $orderByClause, $includeConflicts);
return $dupePairs;
}
return $dupePairs;
*
* @return string
*/
- public static function getMergeCacheKeyString($rule_group_id, $group_id, $criteria = array(), $checkPermissions = TRUE) {
+ public static function getMergeCacheKeyString($rule_group_id, $group_id, $criteria = [], $checkPermissions = TRUE) {
$contactType = CRM_Dedupe_BAO_RuleGroup::getContactTypeForRuleGroup($rule_group_id);
$cacheKeyString = "merge_{$contactType}";
$cacheKeyString .= $rule_group_id ? "_{$rule_group_id}" : '_0';
*/
public static function getSpecialValues($contact) {
$preferred_communication_method = CRM_Utils_Array::value('preferred_communication_method', $contact);
- $value = empty($preferred_communication_method) ? array() : $preferred_communication_method;
- $specialValues = array(
+ $value = empty($preferred_communication_method) ? [] : $preferred_communication_method;
+ $specialValues = [
'preferred_communication_method' => $value,
'communication_style_id' => $value,
- );
+ ];
if (!empty($contact['preferred_communication_method'])) {
// api 3 returns pref_comm_method as an array, which breaks the lookup; so we reconstruct
$prefCommList = is_array($specialValues['preferred_communication_method']) ? implode(CRM_Core_DAO::VALUE_SEPARATOR, $specialValues['preferred_communication_method']) : $specialValues['preferred_communication_method'];
$specialValues['preferred_communication_method'] = CRM_Core_DAO::VALUE_SEPARATOR . $prefCommList . CRM_Core_DAO::VALUE_SEPARATOR;
}
- $names = array(
- 'preferred_communication_method' => array(
+ $names = [
+ 'preferred_communication_method' => [
'newName' => 'preferred_communication_method_display',
'groupName' => 'preferred_communication_method',
- ),
- );
+ ],
+ ];
CRM_Core_OptionGroup::lookupValues($specialValues, $names);
if (!empty($contact['communication_style'])) {
return \Civi::$statics[__CLASS__]['merge_fields_metadata'];
}
$fields = CRM_Contact_DAO_Contact::fields();
- static $optionValueFields = array();
+ static $optionValueFields = [];
if (empty($optionValueFields)) {
$optionValueFields = CRM_Core_OptionValue::getFields();
}
* @throws CRM_Core_Exception
*/
public static function getMergeContactDetails($contact_id) {
- $params = array(
+ $params = [
'contact_id' => $contact_id,
'version' => 3,
- 'return' => array_merge(array('display_name'), self::getContactFields()),
- );
+ 'return' => array_merge(['display_name'], self::getContactFields()),
+ ];
$result = civicrm_api('contact', 'get', $params);
// CRM-18480: Cancel the process if the contact is already deleted
if (isset($result['values'][$contact_id]['contact_is_deleted']) && !empty($result['values'][$contact_id]['contact_is_deleted'])) {
- throw new CRM_Core_Exception(ts('Cannot merge because one contact (ID %1) has been deleted.', array(
+ throw new CRM_Core_Exception(ts('Cannot merge because one contact (ID %1) has been deleted.', [
1 => $contact_id,
- )));
+ ]));
}
return $result['values'][$contact_id];
}
$locBlocks[$fieldName][$fieldCount]['operation'] = $operation;
}
- $blocksDAO = array();
+ $blocksDAO = [];
// @todo Handle OpenID (not currently in API).
if (!empty($locBlocks)) {
$locationBlocks = self::getLocationBlockInfo();
- $primaryBlockIds = CRM_Contact_BAO_Contact::getLocBlockIds($mainId, array('is_primary' => 1));
- $billingBlockIds = CRM_Contact_BAO_Contact::getLocBlockIds($mainId, array('is_billing' => 1));
+ $primaryBlockIds = CRM_Contact_BAO_Contact::getLocBlockIds($mainId, ['is_primary' => 1]);
+ $billingBlockIds = CRM_Contact_BAO_Contact::getLocBlockIds($mainId, ['is_billing' => 1]);
foreach ($locBlocks as $name => $block) {
- $blocksDAO[$name] = array('delete' => array(), 'update' => array());
+ $blocksDAO[$name] = ['delete' => [], 'update' => []];
if (!is_array($block) || CRM_Utils_System::isNull($block)) {
continue;
}
protected static function dedupePair(&$migrationInfo, &$resultStats, &$deletedContacts, $mode, $checkPermissions, $mainId, $otherId, $cacheKeyString) {
// go ahead with merge if there is no conflict
- $conflicts = array();
+ $conflicts = [];
if (!CRM_Dedupe_Merger::skipMerge($mainId, $otherId, $migrationInfo, $mode, $conflicts)) {
CRM_Dedupe_Merger::moveAllBelongings($mainId, $otherId, $migrationInfo, $checkPermissions);
- $resultStats['merged'][] = array(
+ $resultStats['merged'][] = [
'main_id' => $mainId,
'other_id' => $otherId,
- );
+ ];
$deletedContacts[] = $otherId;
}
else {
- $resultStats['skipped'][] = array(
+ $resultStats['skipped'][] = [
'main_id' => $mainId,
'other_id' => $otherId,
- );
+ ];
}
// store any conflicts
$participantBAO->save();
- $session = CRM_Core_Session::singleton();
-
CRM_Contact_BAO_GroupContactCache::opportunisticCacheFlush();
if (!empty($params['id'])) {
return $participant;
}
- if ((!CRM_Utils_Array::value('id', $params)) ||
+ // Log activity when creating new participant or changing status
+ if (empty($params['id']) ||
(isset($params['status_id']) && $params['status_id'] != $status)
) {
+ // Default status if not specified
+ $participant->status_id = $participant->status_id ?: self::fields()['participant_status_id']['default'];
CRM_Activity_BAO_Activity::addActivity($participant);
}
//participant note
if (!empty($query->_returnProperties['participant_note'])) {
- $query->_select['participant_note'] = "civicrm_note.note as participant_note";
+ $query->_select['participant_note'] = "participant_note.note as participant_note";
$query->_element['participant_note'] = 1;
$query->_tables['participant_note'] = 1;
- $query->_whereTables['civicrm_note'] = 1;
+ $query->_whereTables['participant_note'] = 1;
}
if (!empty($query->_returnProperties['participant_is_pay_later'])) {
list($op, $value) = CRM_Contact_BAO_Query::buildQillForFieldValue('CRM_Event_DAO_Event', $name, $value, $op, array('check_permission' => $checkPermission));
$query->_qill[$grouping][] = ts('%1 %2 %3', array(1 => $fields[$qillName]['title'], 2 => $op, 3 => $value));
return;
+
+ case 'participant_note':
+ $query->_tables['civicrm_participant'] = $query->_whereTables['civicrm_participant'] = 1;
+ $query->_tables['participant_note'] = $query->_whereTables['participant_note'] = 1;
+ $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause('participant_note.note', $op, $value, 'String');
+ $query->_qill[$grouping][] = ts('%1 %2 %3', array(1 => $fields[$name]['title'], 2 => $op, 3 => $value));
+ break;
}
}
break;
case 'participant_note':
- $from .= " $side JOIN civicrm_note ON ( civicrm_note.entity_table = 'civicrm_participant' AND
- civicrm_participant.id = civicrm_note.entity_id )";
+ $from .= " $side JOIN civicrm_note participant_note ON ( participant_note.entity_table = 'civicrm_participant' AND
+ civicrm_participant.id = participant_note.entity_id )";
break;
case 'participant_status':
$contactID = $form->getContactID();
}
if (!$contactID && is_array($fields) && $fields) {
- $contactID = CRM_Contact_BAO_Contact::getFirstDuplicateContact($fields, 'Individual', 'Unsupervised', array(), FALSE, CRM_Utils_Array::value('dedupe_rule_group_id', $form->_values['event']));
+ $contactID = CRM_Contact_BAO_Contact::getFirstDuplicateContact($fields, 'Individual', 'Unsupervised', [], FALSE, CRM_Utils_Array::value('dedupe_rule_group_id', $form->_values['event']), ['event_id' => CRM_Utils_Array::value('id', $form->_values['event'])]);
}
return $contactID;
}
}
else {
//cancel 'from' participant row
- $query = "select contact_id from civicrm_email where email = '" . $params['email'] . "'";
- $dao = CRM_Core_DAO::executeQuery($query);
- while ($dao->fetch()) {
- $contact_id = $dao->contact_id;
+ $contact_id_result = civicrm_api3('Contact', 'get', array(
+ 'sequential' => 1,
+ 'return' => array("id"),
+ 'email' => $params['email'],
+ 'options' => array('limit' => 1),
+ ));
+ $contact_id_result = $contact_id_result['values'][0];
+ $contact_id = $contact_id_result['contact_id'];
+ $contact_is_deleted = $contact_id_result['contact_is_deleted'];
+ if ($contact_is_deleted || !is_numeric($contact_id)) {
+ CRM_Core_Error::statusBounce(ts('Contact does not exist.'));
}
}
$from_participant = $params = array();
}
$sqlClause[] = '(' . implode(',', $valueString) . ')';
}
-
- $sqlColumnString = '(id, ' . implode(',', array_keys($sqlColumns)) . ')';
+ $sqlColumns = array_merge(['id' => 1], $sqlColumns);
+ $sqlColumnString = '(' . implode(',', array_keys($sqlColumns)) . ')';
$sqlValueString = implode(",\n", $sqlClause);
// also create the sql table
$exportTempTable->drop();
- $sql = "
- id int unsigned NOT NULL AUTO_INCREMENT,
-";
- $sql .= implode(",\n", array_values($sqlColumns));
+ $sql = " id int unsigned NOT NULL AUTO_INCREMENT, ";
+ if (!empty($sqlColumns)) {
+ $sql .= implode(",\n", array_values($sqlColumns)) . ',';
+ }
+
+ $sql .= "\n PRIMARY KEY ( id )";
- $sql .= ",
- PRIMARY KEY ( id )
-";
// add indexes for street_address and household_name if present
$addIndices = array(
'street_address',
$getTaxDetails = FALSE;
foreach ($tplLineItems as $key => $value) {
foreach ($value as $k => $v) {
- if (isset($v['tax_rate'])) {
- if ($v['tax_rate'] != '') {
- $getTaxDetails = TRUE;
- // Cast to float to display without trailing zero decimals
- $tplLineItems[$key][$k]['tax_rate'] = (float) $v['tax_rate'];
- }
+ if (isset($v['tax_rate']) && $v['tax_rate'] != '') {
+ $getTaxDetails = TRUE;
+ // Cast to float to display without trailing zero decimals
+ $tplLineItems[$key][$k]['tax_rate'] = (float) $v['tax_rate'];
}
}
}
* This function creates a table AND adds the details to the developer tab & $this->>temporary tables.
*
* @param string $identifier
- * @param $sql
+ * This is the key that will be used for the table in the temporaryTables property.
+ * @param string $sql
+ * Sql select statement or column description (the latter requires the columns flag)
+ * @param bool $isColumns
+ * Is the sql describing columns to create (rather than using a select query).
+ * @param bool $isMemory
+ * Create a memory table rather than a normal INNODB table.
*
* @return string
*/
- public function createTemporaryTable($identifier, $sql) {
- $tempTable = CRM_Utils_SQL_TempTable::build()->setUtf8(TRUE)->createWithQuery($sql);
+ public function createTemporaryTable($identifier, $sql, $isColumns = FALSE, $isMemory = FALSE) {
+ $tempTable = CRM_Utils_SQL_TempTable::build()->setUtf8();
+ if ($isMemory) {
+ $tempTable->setMemory();
+ }
+ if ($isColumns) {
+ $tempTable->createWithColumns($sql);
+ }
+ else {
+ $tempTable->createWithQuery($sql);
+ }
$name = $tempTable->getName();
// Developers may force tables to be durable to assist in debugging so lets check.
$isNotTrueTemporary = $tempTable->isDurable();
- // The TempTable build routine adds the next line - we output it to help developers see what has happened.
- $sql = 'CREATE ' . ($isNotTrueTemporary ? '' : 'TEMPORARY ') . "TABLE $name DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci " . $sql;
- $this->addToDeveloperTab($sql);
+ $this->addToDeveloperTab($tempTable->getCreateSql());
$this->temporaryTables[$identifier] = ['temporary' => !$isNotTrueTemporary, 'name' => $name];
return $name;
}
break;
}
+ //dev/core/544 Add report support for multiple contact subTypes
+ if ($field['name'] == 'contact_sub_type' && $clause) {
+ $clause = $this->whereSubtypeClause($field, $value, $op);
+ }
if (!empty($field['group']) && $clause) {
$clause = $this->whereGroupClause($field, $value, $op);
}
return $clause;
}
+ /**
+ * Get SQL where clause for contact subtypes
+ * @param string $field
+ * @param mixed $value
+ * @param string $op SQL Operator
+ *
+ * @return string
+ */
+ public function whereSubtypeClause($field, $value, $op) {
+ $clause = '( ';
+ $subtypeFilters = count($value);
+ for ($i = 0; $i < $subtypeFilters; $i++) {
+ $clause .= "{$field['dbAlias']} LIKE '%$value[$i]%'";
+ if ($i !== ($subtypeFilters - 1)) {
+ $clause .= " OR ";
+ }
+ }
+ $clause .= ' )';
+ return $clause;
+ }
+
/**
* Get SQL where clause for a date field.
*
list($from, $to) = $this->getFromTo($relative, $from, $to, $fromTime, $toTime);
if ($from) {
- $from = ($type == CRM_Utils_Type::T_DATE) ? substr($from, 0, 8) : $from;
$clauses[] = "( {$fieldName} >= $from )";
}
if ($to) {
- $to = ($type == CRM_Utils_Type::T_DATE) ? substr($to, 0, 8) : $to;
$clauses[] = "( {$fieldName} <= {$to} )";
}
}
CRM_Utils_Hook::alterReportVar('sql', $this, $this);
- // store the duration count in temp table
- $this->_tempTableName = CRM_Core_DAO::createTempTableName('civicrm_activity');
-
// build temporary table column names base on column headers of result
$dbColumns = array();
foreach ($this->_columnHeaders as $fieldName => $dontCare) {
}
// create temp table to store main result
- $tempQuery = "CREATE TEMPORARY TABLE {$this->_tempTableName} (
- id int unsigned NOT NULL AUTO_INCREMENT, " . implode(', ', $dbColumns) . ' , PRIMARY KEY (id))'
- . $this->_databaseAttributes;
- CRM_Core_DAO::executeQuery($tempQuery);
+ $this->_tempTableName = $this->createTemporaryTable('tempTable', "
+ id int unsigned NOT NULL AUTO_INCREMENT, " . implode(', ', $dbColumns) . ' , PRIMARY KEY (id)',
+ TRUE);
// build main report query
$sql = "{$this->_select} {$this->_from} {$this->_where} {$this->_groupBy} {$this->_having} {$this->_orderBy} {$this->_limit}";
$sql = "SELECT SUM(activity_civireport.duration) as civicrm_activity_duration_total {$this->_from} {$this->_where} {$this->_groupBy} {$this->_having} {$this->_orderBy} {$this->_limit}";
// create temp table to store duration
- $this->_tempDurationSumTableName = CRM_Core_DAO::createTempTableName('civicrm_activity');
- $tempQuery = "CREATE TEMPORARY TABLE {$this->_tempDurationSumTableName} (
- id int unsigned NOT NULL AUTO_INCREMENT, civicrm_activity_duration_total VARCHAR(128), PRIMARY KEY (id))"
- . $this->_databaseAttributes;
- CRM_Core_DAO::executeQuery($tempQuery);
+ $this->_tempDurationSumTableName = $this->createTemporaryTable('tempDurationSumTable', "
+ id int unsigned NOT NULL AUTO_INCREMENT, civicrm_activity_duration_total VARCHAR(128), PRIMARY KEY (id)",
+ TRUE);
// store the result in temporary table
$insertQuery = "INSERT INTO {$this->_tempDurationSumTableName} (civicrm_activity_duration_total)
{$from}
{$subWhere}
GROUP BY contribution2.{$this->contributionJoinTableColumn}, currency";
- $this->tempTableRepeat1 = 'civicrm_temp_civireport_repeat1' . uniqid();
- $sql = "
-CREATE TEMPORARY TABLE $this->tempTableRepeat1 (
+ $this->tempTableRepeat1 = $this->createTemporaryTable('tempTableRepeat1', "
{$create}
{$this->contributionJoinTableColumn} int unsigned,
total_amount_sum decimal(20,2),
total_amount_count int
-) ENGINE=HEAP {$this->_databaseAttributes}";
- $this->executeReportQuery($sql);
+", TRUE, TRUE);
$this->executeReportQuery("INSERT INTO $this->tempTableRepeat1 {$subContributionQuery1}");
$this->executeReportQuery("
ALTER TABLE $this->tempTableRepeat1 ADD INDEX ({$this->contributionJoinTableColumn})
");
- $this->tempTableRepeat2 = 'civicrm_temp_civireport_repeat2' . uniqid();
- $sql = "
-CREATE TEMPORARY TABLE $this->tempTableRepeat2 (
+ $this->tempTableRepeat2 = $this->createTemporaryTable('tempTableRepeat2', "
{$create}
{$this->contributionJoinTableColumn} int unsigned,
total_amount_sum decimal(20,2),
total_amount_count int,
currency varchar(3)
-) ENGINE=HEAP {$this->_databaseAttributes}";
- $this->executeReportQuery($sql);
+", TRUE, TRUE);
$sql = "INSERT INTO $this->tempTableRepeat2 {$subContributionQuery2}";
$this->executeReportQuery($sql);
class CRM_Report_Form_Grant_Detail extends CRM_Report_Form {
protected $_customGroupExtends = array(
+ 'Contact',
+ 'Individual',
+ 'Household',
+ 'Organization',
'Grant',
);
* Class constructor.
*/
public function __construct() {
- $this->_columns = array(
- 'civicrm_contact' => array(
- 'dao' => 'CRM_Contact_DAO_Contact',
+ $contactCols = $this->getColumns('Contact', array(
+ 'order_bys_defaults' => array('sort_name' => 'ASC '),
+ 'fields_defaults' => ['sort_name'],
+ 'fields_excluded' => ['id'],
+ 'fields_required' => ['id'],
+ 'filters_defaults' => array('is_deleted' => 0),
+ 'no_field_disambiguation' => TRUE,
+ ));
+ $specificCols = array(
+ 'civicrm_email' => array(
+ 'dao' => 'CRM_Core_DAO_Email',
'fields' => array(
- 'sort_name' => array(
- 'title' => ts('Contact Name'),
- 'required' => TRUE,
- 'no_repeat' => TRUE,
- ),
- 'id' => array(
- 'no_display' => TRUE,
- 'required' => TRUE,
+ 'email' => array(
+ 'title' => ts('Email'),
),
),
'grouping' => 'contact-fields',
- 'filters' => array(
- 'sort_name' => array(
- 'title' => ts('Contact Name'),
- 'operator' => 'like',
- ),
- 'gender_id' => array(
- 'title' => ts('Gender'),
- 'operatorType' => CRM_Report_Form::OP_MULTISELECT,
- 'options' => CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id'),
- ),
- 'id' => array(
- 'title' => ts('Contact ID'),
- 'no_display' => TRUE,
- ),
- ),
),
- 'civicrm_address' => array(
- 'dao' => 'CRM_Core_DAO_Address',
- 'filters' => array(
- 'country_id' => array(
- 'title' => ts('Country'),
- 'type' => CRM_Utils_Type::T_INT,
- 'operatorType' => CRM_Report_Form::OP_MULTISELECT,
- 'options' => CRM_Core_PseudoConstant::country(),
- ),
- 'state_province_id' => array(
- 'title' => ts('State/Province'),
- 'type' => CRM_Utils_Type::T_INT,
- 'operatorType' => CRM_Report_Form::OP_MULTISELECT,
- 'options' => CRM_Core_PseudoConstant::stateProvince(),
+ 'civicrm_phone' => array(
+ 'dao' => 'CRM_Core_DAO_Phone',
+ 'fields' => array(
+ 'phone' => array(
+ 'title' => ts('Phone'),
),
),
+ 'grouping' => 'contact-fields',
),
'civicrm_grant' => array(
'dao' => 'CRM_Grant_DAO_Grant',
'name' => 'application_received_date',
'title' => ts('Application Received'),
'default' => TRUE,
+ 'type' => CRM_Utils_Type::T_DATE,
),
'money_transfer_date' => array(
'name' => 'money_transfer_date',
),
),
'group_bys' => array(
+ 'grant_type_id' => array(
+ 'title' => ts('Grant Type'),
+ ),
+ 'status_id' => array(
+ 'title' => ts('Grant Status'),
+ ),
+ 'application_received_date' => array(
+ 'title' => ts('Application Received Date'),
+ ),
+ 'money_transfer_date' => array(
+ 'title' => ts('Money Transfer Date'),
+ ),
+ 'decision_date' => array(
+ 'title' => ts('Grant Decision Date'),
+ ),
+ ),
+ 'order_bys' => array(
'grant_type_id' => array(
'title' => ts('Grant Type'),
),
),
);
- parent::__construct();
- }
-
- public function select() {
- // @todo remove this override - seems to do nothing parent doesn't.
- $select = array();
+ $this->_columns = array_merge($contactCols, $specificCols, $this->addAddressFields(FALSE));
- $this->_columnHeaders = array();
- foreach ($this->_columns as $tableName => $table) {
- if (array_key_exists('fields', $table)) {
- foreach ($table['fields'] as $fieldName => $field) {
- if (!empty($field['required']) ||
- !empty($this->_params['fields'][$fieldName])
- ) {
-
- $select[] = "{$field['dbAlias']} as {$tableName}_{$fieldName}";
-
- $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = $field['title'];
- $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array::value('type', $field);
- }
- }
- }
- }
-
- $this->_select = "SELECT " . implode(', ', $select) . " ";
+ parent::__construct();
}
public function from() {
- $this->_from = "
- FROM civicrm_grant {$this->_aliases['civicrm_grant']}
- LEFT JOIN civicrm_contact {$this->_aliases['civicrm_contact']}
- ON ({$this->_aliases['civicrm_grant']}.contact_id = {$this->_aliases['civicrm_contact']}.id ) ";
- $this->joinAddressFromContact();
- }
-
- public function where() {
- // @todo this function appears to do nothing more than parent, test & remove
- $clauses = array();
- $this->_where = '';
- foreach ($this->_columns as $tableName => $table) {
- if (array_key_exists('filters', $table)) {
- foreach ($table['filters'] as $fieldName => $field) {
-
- $clause = NULL;
- if (CRM_Utils_Array::value('type', $field) & CRM_Utils_Type::T_DATE) {
- $relative = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params);
- $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params);
- $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params);
+ $this->setFromBase('civicrm_contact');
+ $this->_from .= <<<HERESQL
+ INNER JOIN civicrm_grant {$this->_aliases['civicrm_grant']}
+ ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_grant']}.contact_id
+HERESQL;
- if ($relative || $from || $to) {
- $clause = $this->dateClause($field['name'], $relative, $from, $to, $field['type']);
- }
- }
- else {
- $op = CRM_Utils_Array::value("{$fieldName}_op", $this->_params);
- if ($op) {
- $clause = $this->whereClause($field,
- $op,
- CRM_Utils_Array::value("{$fieldName}_value", $this->_params),
- CRM_Utils_Array::value("{$fieldName}_min", $this->_params),
- CRM_Utils_Array::value("{$fieldName}_max", $this->_params)
- );
- }
- }
- if (!empty($clause)) {
- $clauses[] = $clause;
- }
- }
- }
- }
- if (!empty($clauses)) {
- $this->_where = "WHERE " . implode(' AND ', $clauses);
- }
- }
-
- public function groupBy() {
- // @todo this function appears to do nothing more than parent, test & remove
- $this->_groupBy = "";
- if (!empty($this->_params['group_bys']) &&
- is_array($this->_params['group_bys']) &&
- !empty($this->_params['group_bys'])
- ) {
- foreach ($this->_columns as $tableName => $table) {
- if (array_key_exists('group_bys', $table)) {
- foreach ($table['group_bys'] as $fieldName => $field) {
- if (!empty($this->_params['group_bys'][$fieldName])) {
- $this->_groupBy[] = $field['dbAlias'];
- }
- }
- }
- }
- }
- if (!empty($this->_groupBy)) {
- $this->_groupBy = "ORDER BY " . implode(', ', $this->_groupBy) .
- ", {$this->_aliases['civicrm_contact']}.sort_name";
- }
- else {
- $this->_groupBy = "ORDER BY {$this->_aliases['civicrm_contact']}.sort_name";
- }
+ $this->joinEmailFromContact();
+ $this->joinPhoneFromContact();
+ $this->joinAddressFromContact();
}
/**
$this->_absoluteUrl
);
$rows[$rowNum]['civicrm_contact_sort_name_link'] = $url;
- $rows[$rowNum]['civicrm_contact_sort_name_hover'] = ts("View contact details for this record.");
+ $rows[$rowNum]['civicrm_contact_sort_name_hover'] = ts("View Contact Summary for this Contact.");
$entryFound = TRUE;
}
}
$entryFound = TRUE;
}
- if (array_key_exists('civicrm_grant_grant_report_received', $row)) {
- if ($value = $row['civicrm_grant_grant_report_received']) {
- if ($value == 1) {
- $value = 'Yes';
- }
- else {
- $value = 'No';
- }
- $rows[$rowNum]['civicrm_grant_grant_report_received'] = $value;
- }
- $entryFound = TRUE;
- }
if (!$entryFound) {
break;
}
*/
protected $groupFilterNotOptimised = TRUE;
+ protected $tableName;
+
/**
* Class constructor.
*/
public function from() {
$this->_from = "
- FROM civireport_membership_contribution_detail
+ FROM {$this->tableName}
INNER JOIN civicrm_contribution {$this->_aliases['civicrm_contribution']}
- ON (civireport_membership_contribution_detail.contribution_id = {$this->_aliases['civicrm_contribution']}.id)
+ ON ({$this->tableName}.contribution_id = {$this->_aliases['civicrm_contribution']}.id)
LEFT JOIN civicrm_membership {$this->_aliases['civicrm_membership']}
- ON (civireport_membership_contribution_detail.membership_id = {$this->_aliases['civicrm_membership']}.id)
+ ON ({$this->tableName}.membership_id = {$this->_aliases['civicrm_membership']}.id)
INNER JOIN civicrm_contact {$this->_aliases['civicrm_contact']}
- ON (civireport_membership_contribution_detail.contact_id = {$this->_aliases['civicrm_contact']}.id)
+ ON ({$this->tableName}.contact_id = {$this->_aliases['civicrm_contact']}.id)
LEFT JOIN civicrm_membership_status {$this->_aliases['civicrm_membership_status']}
ON {$this->_aliases['civicrm_membership_status']}.id =
{$this->_aliases['civicrm_membership']}.status_id
*/
public function tempTable($applyLimit = TRUE) {
// create temp table with contact ids,contribtuion id,membership id
- $dropTempTable = 'DROP TEMPORARY TABLE IF EXISTS civireport_membership_contribution_detail';
- CRM_Core_DAO::executeQuery($dropTempTable);
-
- $sql = 'CREATE TEMPORARY TABLE civireport_membership_contribution_detail
- (contribution_id int, INDEX USING HASH(contribution_id), contact_id int, INDEX USING HASH(contact_id),
- membership_id int, INDEX USING HASH(membership_id), payment_id int, INDEX USING HASH(payment_id)) ENGINE=MEMORY' . $this->_databaseAttributes;
- CRM_Core_DAO::executeQuery($sql);
+ $this->tableName = $this->createTemporaryTable('table', '
+ contribution_id int, INDEX USING HASH(contribution_id), contact_id int, INDEX USING HASH(contact_id),
+ membership_id int, INDEX USING HASH(membership_id), payment_id int, INDEX USING HASH(payment_id)', TRUE, TRUE);
$fillTemp = "
- INSERT INTO civireport_membership_contribution_detail (contribution_id, contact_id, membership_id)
+ INSERT INTO {$this->tableName} (contribution_id, contact_id, membership_id)
SELECT contribution.id, {$this->_aliases['civicrm_contact']}.id, m.id
FROM civicrm_contribution contribution
INNER JOIN civicrm_contact {$this->_aliases['civicrm_contact']}
{* file to handle db changes in 5.13.alpha1 during upgrade *}
+
+-- dev/core#829 Swaziland has changed its name to Eswatini
+UPDATE civicrm_country SET name = 'Eswatini' WHERE name = 'Swaziland';
+UPDATE civicrm_currency SET full_name = 'Eswatini Lilangeni' WHERE name = 'SZL';
);
}
+ /**
+ * Check for duplicate contacts
+ *
+ * @param array $dedupeParams
+ * Array of params for finding duplicates: [
+ * '{parameters returned by CRM_Dedupe_Finder::formatParams}
+ * 'check_permission' => TRUE/FALSE;
+ * 'contact_type' => $contactType;
+ * 'rule' = $rule;
+ * 'rule_group_id' => $ruleGroupID;
+ * 'excludedContactIDs' => $excludedContactIDs;
+ * @param array $dedupeResults
+ * Array of results ['handled' => TRUE/FALSE, 'ids' => array of IDs of duplicate contacts]
+ * @param array $contextParams
+ * The context if relevant, eg. ['event_id' => X]
+ *
+ * @return mixed
+ */
+ public static function findDuplicates($dedupeParams, &$dedupeResults, $contextParams) {
+ return self::singleton()
+ ->invoke(array('dedupeParams', 'dedupeResults', 'contextParams'), $dedupeParams, $dedupeResults, $contextParams, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_findDuplicates');
+ }
+
/**
* This hook is called AFTER EACH email has been processed by the script bin/EmailProcessor.php
*
* @inheritDoc
*/
protected function buildWhereClause() {
- $filters = array();
+ $filters = [];
foreach ($this->where as $key => $value) {
$table_name = NULL;
$column_name = NULL;
// Legacy support for old filter syntax per the test contract.
// (Convert the style to the later one & then deal with them).
$filterArray = explode('.', $key);
- $value = array($filterArray[1] => $value);
+ $value = [$filterArray[1] => $value];
$key = 'filters';
}
foreach ($value as $filterKey => $filterValue) {
if (substr($filterKey, -4, 4) == 'high') {
$key = substr($filterKey, 0, -5);
- $value = array('<=' => $filterValue);
+ $value = ['<=' => $filterValue];
}
if (substr($filterKey, -3, 3) == 'low') {
$key = substr($filterKey, 0, -4);
- $value = array('>=' => $filterValue);
+ $value = ['>=' => $filterValue];
}
if ($filterKey == 'is_current' || $filterKey == 'isCurrent') {
}
$operator = is_array($value) ? \CRM_Utils_Array::first(array_keys($value)) : NULL;
if (!in_array($operator, \CRM_Core_DAO::acceptedSQLOperators(), TRUE)) {
- $value = array('=' => $value);
+ $value = ['=' => $value];
}
$filters[$key] = \CRM_Core_DAO::createSQLFilter("{$table_name}.{$column_name}", $value);
}
$orGroups = array_map('trim', explode(',', $orGroups));
}
if (!is_array(\CRM_Utils_Array::first($orGroups))) {
- $orGroups = array($orGroups);
+ $orGroups = [$orGroups];
}
foreach ($orGroups as $orGroup) {
- $orClause = array();
+ $orClause = [];
foreach ($orGroup as $key) {
if (!isset($filters[$key])) {
throw new \CiviCRM_API3_Exception("'$key' specified in OR group but not added to params");
protected function getFields() {
require_once 'api/v3/Generic.php';
// Call this function directly instead of using the api wrapper to force unique field names off
- $apiSpec = \civicrm_api3_generic_getfields(array(
+ $apiSpec = \civicrm_api3_generic_getfields([
'entity' => $this->entity,
'version' => 3,
- 'params' => array('action' => 'get'),
- ), FALSE);
+ 'params' => ['action' => 'get'],
+ ], FALSE);
return $apiSpec['values'];
}
foreach ($this->apiFieldSpec as $field) {
if (
$fieldName == \CRM_Utils_Array::value('uniqueName', $field) ||
- array_search($fieldName, \CRM_Utils_Array::value('api.aliases', $field, array())) !== FALSE
+ array_search($fieldName, \CRM_Utils_Array::value('api.aliases', $field, [])) !== FALSE
) {
return $field;
}
* @return array<string>
*/
public static function allEvents() {
- return array(
+ return [
self::AUTHORIZE,
self::EXCEPTION,
self::PREPARE,
self::RESOLVE,
self::RESPOND,
- );
+ ];
}
/**
* @param \Exception|NULL $previous
* A previous exception which caused this new exception.
*/
- public function __construct($message, $extraParams = array(), \Exception $previous = NULL) {
+ public function __construct($message, $extraParams = [], \Exception $previous = NULL) {
parent::__construct($message, \API_Exception::NOT_IMPLEMENTED, $extraParams, $previous);
}
* @param \Exception|NULL $previous
* A previous exception which caused this new exception.
*/
- public function __construct($message, $extraParams = array(), \Exception $previous = NULL) {
+ public function __construct($message, $extraParams = [], \Exception $previous = NULL) {
parent::__construct($message, \API_Exception::UNAUTHORIZED, $extraParams, $previous);
}
* @param array $defaultParams
* Default values to merge into any API calls.
*/
- public function __construct($defaultParams = array()) {
+ public function __construct($defaultParams = []) {
global $civicrm_root;
$this->root = $civicrm_root;
$this->settingsPath = defined('CIVICRM_SETTINGS_PATH') ? CIVICRM_SETTINGS_PATH : NULL;
* @param array $params
* @return ExternalBatch
*/
- public function addCall($entity, $action, $params = array()) {
+ public function addCall($entity, $action, $params = []) {
$params = array_merge($this->defaultParams, $params);
- $this->apiCalls[] = array(
+ $this->apiCalls[] = [
'entity' => $entity,
'action' => $action,
'params' => $params,
- );
+ ];
return $this;
}
if (!$process->isRunning()) {
$parsed = json_decode($process->getOutput(), TRUE);
if ($process->getExitCode() || $parsed === NULL) {
- $this->apiResults[] = array(
+ $this->apiResults[] = [
'is_error' => 1,
'error_message' => 'External API returned malformed response.',
- 'trace' => array(
+ 'trace' => [
'code' => $process->getExitCode(),
'stdout' => $process->getOutput(),
'stderr' => $process->getErrorOutput(),
- ),
- );
+ ],
+ ];
}
else {
$this->apiResults[] = $parsed;
* @throws \CRM_Core_Exception
*/
public function createProcess($apiCall) {
- $parts = array();
+ $parts = [];
if (defined('CIVICRM_TEST') && CIVICRM_TEST) {
// When testing, civicrm.settings.php may rely on $_CV, which is only
}
$command = implode(" ", $parts);
- $env = array_merge($this->env, array(
+ $env = array_merge($this->env, [
'CIVICRM_SETTINGS' => $this->settingsPath,
- ));
+ ]);
return new Process($command, $this->root, $env);
}
* @param array $apiProviders
* Array of ProviderInterface.
*/
- public function __construct($dispatcher, $apiProviders = array()) {
+ public function __construct($dispatcher, $apiProviders = []) {
$this->apiProviders = $apiProviders;
$this->dispatcher = $dispatcher;
}
if (!$resolveEvent->getApiProvider()) {
throw new \Civi\API\Exception\NotImplementedException("API (" . $apiRequest['entity'] . ", " . $apiRequest['action'] . ") does not exist (join the API team and implement it!)");
}
- return array($resolveEvent->getApiProvider(), $apiRequest);
+ return [$resolveEvent->getApiProvider(), $apiRequest];
}
/**
*/
public function getEntityNames($version) {
// Question: Would it better to eliminate $this->apiProviders and just use $this->dispatcher?
- $entityNames = array();
+ $entityNames = [];
foreach ($this->getApiProviders() as $provider) {
/** @var ProviderInterface $provider */
$entityNames = array_merge($entityNames, $provider->getEntityNames($version));
*/
public function getActionNames($version, $entity) {
// Question: Would it better to eliminate $this->apiProviders and just use $this->dispatcher?
- $actionNames = array();
+ $actionNames = [];
foreach ($this->getApiProviders() as $provider) {
/** @var ProviderInterface $provider */
$actionNames = array_merge($actionNames, $provider->getActionNames($version, $entity));
* API response.
*/
public function formatException($e, $apiRequest) {
- $data = array();
+ $data = [];
if (!empty($apiRequest['params']['debug'])) {
$data['trace'] = $e->getTraceAsString();
}
* API response.
*/
public function formatPearException($e, $apiRequest) {
- $data = array();
+ $data = [];
$error = $e->getCause();
if ($error instanceof \DB_Error) {
$data["error_code"] = \DB::errorMessage($error->getCode());
// Using a high priority allows adhoc implementations
// to override standard implementations -- which is
// handy for testing/mocking.
- return array(
- Events::RESOLVE => array(
- array('onApiResolve', Events::W_EARLY),
- ),
- Events::AUTHORIZE => array(
- array('onApiAuthorize', Events::W_EARLY),
- ),
- );
+ return [
+ Events::RESOLVE => [
+ ['onApiResolve', Events::W_EARLY],
+ ],
+ Events::AUTHORIZE => [
+ ['onApiAuthorize', Events::W_EARLY],
+ ],
+ ];
}
/**
* @var array (string $name => array('perm' => string, 'callback' => callable))
*/
- protected $actions = array();
+ protected $actions = [];
/**
* @var string
* @return AdhocProvider
*/
public function addAction($name, $perm, $callback) {
- $this->actions[strtolower($name)] = array(
+ $this->actions[strtolower($name)] = [
'perm' => $perm,
'callback' => $callback,
- );
+ ];
return $this;
}
* @return array
*/
public function getEntityNames($version) {
- return array($this->entity);
+ return [$this->entity];
}
/**
return array_keys($this->actions);
}
else {
- return array();
+ return [];
}
}
* @return array
*/
public static function getSubscribedEvents() {
- return array(
- Events::RESOLVE => array(
- array('onApiResolve', Events::W_MIDDLE),
- ),
- );
+ return [
+ Events::RESOLVE => [
+ ['onApiResolve', Events::W_MIDDLE],
+ ],
+ ];
}
/**
/**
*/
public function __construct() {
- $this->cache = array();
+ $this->cache = [];
}
/**
* @return array
*/
public function getEntityNames($version) {
- $entities = array();
+ $entities = [];
$include_dirs = array_unique(explode(PATH_SEPARATOR, get_include_path()));
#$include_dirs = array(dirname(__FILE__). '/../../');
foreach ($include_dirs as $include_dir) {
$api_dir = implode(DIRECTORY_SEPARATOR,
- array($include_dir, 'api', 'v' . $version));
+ [$include_dir, 'api', 'v' . $version]);
if (!is_dir($api_dir)) {
continue;
}
}
}
}
- $entities = array_diff($entities, array('Generic'));
+ $entities = array_diff($entities, ['Generic']);
$entities = array_unique($entities);
sort($entities);
$entity = _civicrm_api_get_camel_name($entity);
$entities = $this->getEntityNames($version);
if (!in_array($entity, $entities)) {
- return array();
+ return [];
}
$this->loadEntity($entity, $version);
$functions = get_defined_functions();
- $actions = array();
+ $actions = [];
$prefix = 'civicrm_api' . $version . '_' . _civicrm_api_get_entity_name_from_camel($entity) . '_';
$prefixGeneric = 'civicrm_api' . $version . '_generic_';
foreach ($functions['user'] as $fct) {
// someone already loaded the appropriate file
// FIXME: This has the affect of masking bugs in load order; this is
// included to provide bug-compatibility.
- $this->cache[$cachekey] = array('function' => $stdFunction, 'is_generic' => FALSE);
+ $this->cache[$cachekey] = ['function' => $stdFunction, 'is_generic' => FALSE];
return $this->cache[$cachekey];
}
- $stdFiles = array(
+ $stdFiles = [
// By convention, the $camelName.php is more likely to contain the
// function, so test it first
'api/v' . $apiRequest['version'] . '/' . $camelName . '.php',
'api/v' . $apiRequest['version'] . '/' . $camelName . '/' . $actionCamelName . '.php',
- );
+ ];
foreach ($stdFiles as $stdFile) {
if (\CRM_Utils_File::isIncludable($stdFile)) {
require_once $stdFile;
if (function_exists($stdFunction)) {
- $this->cache[$cachekey] = array('function' => $stdFunction, 'is_generic' => FALSE);
+ $this->cache[$cachekey] = ['function' => $stdFunction, 'is_generic' => FALSE];
return $this->cache[$cachekey];
}
}
require_once 'api/v3/Generic.php';
# $genericFunction = 'civicrm_api3_generic_' . $apiRequest['action'];
$genericFunction = $this->getFunctionName('generic', $apiRequest['action'], $apiRequest['version']);
- $genericFiles = array(
+ $genericFiles = [
// By convention, the Generic.php is more likely to contain the
// function, so test it first
'api/v' . $apiRequest['version'] . '/Generic.php',
'api/v' . $apiRequest['version'] . '/Generic/' . $actionCamelName . '.php',
- );
+ ];
foreach ($genericFiles as $genericFile) {
if (\CRM_Utils_File::isIncludable($genericFile)) {
require_once $genericFile;
if (function_exists($genericFunction)) {
- $this->cache[$cachekey] = array('function' => $genericFunction, 'is_generic' => TRUE);
+ $this->cache[$cachekey] = ['function' => $genericFunction, 'is_generic' => TRUE];
return $this->cache[$cachekey];
}
}
}
- $this->cache[$cachekey] = array('function' => FALSE, 'is_generic' => FALSE);
+ $this->cache[$cachekey] = ['function' => FALSE, 'is_generic' => FALSE];
return $this->cache[$cachekey];
}
}
// Check for standalone action files; to match _civicrm_api_resolve(), only load the first one
- $loaded_files = array(); // array($relativeFilePath => TRUE)
+ $loaded_files = []; // array($relativeFilePath => TRUE)
$include_dirs = array_unique(explode(PATH_SEPARATOR, get_include_path()));
foreach ($include_dirs as $include_dir) {
- foreach (array($camelName, 'Generic') as $name) {
+ foreach ([$camelName, 'Generic'] as $name) {
$action_dir = implode(DIRECTORY_SEPARATOR,
- array($include_dir, 'api', "v${version}", $name));
+ [$include_dir, 'api', "v${version}", $name]);
if (!is_dir($action_dir)) {
continue;
}
* @return array
*/
public static function getSubscribedEvents() {
- return array(
- Events::RESOLVE => array(
+ return [
+ Events::RESOLVE => [
// TODO decide if we really want to override others
- array('onApiResolve', Events::W_EARLY),
- ),
- Events::AUTHORIZE => array(
+ ['onApiResolve', Events::W_EARLY],
+ ],
+ Events::AUTHORIZE => [
// TODO decide if we really want to override others
- array('onApiAuthorize', Events::W_EARLY),
- ),
- );
+ ['onApiAuthorize', Events::W_EARLY],
+ ],
+ ];
}
/**
*/
public function __construct($apiKernel) {
$this->apiKernel = $apiKernel;
- $this->actions = array(
- 'Entity' => array('get', 'getactions'),
- '*' => array('getactions'), // 'getfields'
- );
+ $this->actions = [
+ 'Entity' => ['get', 'getactions'],
+ '*' => ['getactions'], // 'getfields'
+ ];
}
/**
* @return array
*/
public function getEntityNames($version) {
- return array('Entity');
+ return ['Entity'];
}
/**
* @return array
*/
public static function getSubscribedEvents() {
- return array(
- Events::RESOLVE => array(
- array('onApiResolve', Events::W_MIDDLE),
- ),
- Events::AUTHORIZE => array(
- array('onApiAuthorize', Events::W_MIDDLE),
- ),
- );
+ return [
+ Events::RESOLVE => [
+ ['onApiResolve', Events::W_MIDDLE],
+ ],
+ Events::AUTHORIZE => [
+ ['onApiAuthorize', Events::W_MIDDLE],
+ ],
+ ];
}
/**
* @param array $records
* List of mock records to be read/updated by API calls.
*/
- public function __construct($version, $entity, $fields, $perms = array(), $records = array()) {
+ public function __construct($version, $entity, $fields, $perms = [], $records = []) {
parent::__construct($version, $entity);
- $perms = array_merge(array(
+ $perms = array_merge([
'create' => \CRM_Core_Permission::ALWAYS_ALLOW_PERMISSION,
'get' => \CRM_Core_Permission::ALWAYS_ALLOW_PERMISSION,
'delete' => \CRM_Core_Permission::ALWAYS_ALLOW_PERMISSION,
- ), $perms);
+ ], $perms);
- $this->records = \CRM_Utils_Array::index(array('id'), $records);
+ $this->records = \CRM_Utils_Array::index(['id'], $records);
$this->fields = $fields;
- $this->addAction('create', $perms['create'], array($this, 'doCreate'));
- $this->addAction('get', $perms['get'], array($this, 'doGet'));
- $this->addAction('delete', $perms['delete'], array($this, 'doDelete'));
+ $this->addAction('create', $perms['create'], [$this, 'doCreate']);
+ $this->addAction('get', $perms['get'], [$this, 'doGet']);
+ $this->addAction('delete', $perms['delete'], [$this, 'doDelete']);
}
/**
}
else {
$id = max(array_keys($this->records)) + 1;
- $this->records[$id] = array();
+ $this->records[$id] = [];
}
if (!isset($this->records[$id])) {
if ($id && isset($this->records[$id])) {
unset($this->records[$id]);
}
- return civicrm_api3_create_success(array());
+ return civicrm_api3_create_success([]);
}
}
$version = \CRM_Utils_Array::value('version', $params);
switch ($version) {
default:
- $apiRequest = array();
+ $apiRequest = [];
$apiRequest['id'] = self::$nextId++;
$apiRequest['version'] = (int) $version;
$apiRequest['params'] = $params;
return $apiRequest;
case 4:
- $callable = array("Civi\\Api4\\$entity", $action);
+ $callable = ["Civi\\Api4\\$entity", $action];
if (!is_callable($callable)) {
throw new Exception\NotImplementedException("API ($entity, $action) does not exist (join the API team and implement it!)");
}
* @var string
*/
protected $entity;
- public $select = array();
- public $where = array();
- public $orderBy = array();
+ public $select = [];
+ public $where = [];
+ public $orderBy = [];
public $limit;
public $offset;
/**
* @var array
*/
- protected $selectFields = array();
+ protected $selectFields = [];
/**
* @var bool
*/
/**
* @var array
*/
- protected $joins = array();
+ protected $joins = [];
/**
* @var array
*/
/**
* @var array
*/
- protected $aclFields = array();
+ protected $aclFields = [];
/**
* @var string|bool
*/
$this->query->limit($this->limit, $this->offset);
}
- $result_entities = array();
+ $result_entities = [];
$result_dao = \CRM_Core_DAO::executeQuery($this->query->toSQL());
while ($result_dao->fetch()) {
$result_dao->free();
return (int) $result_dao->c;
}
- $result_entities[$result_dao->id] = array();
+ $result_entities[$result_dao->id] = [];
foreach ($this->selectFields as $column => $alias) {
$returnName = $alias;
$alias = str_replace('.', '_', $alias);
// Add acl condition
$joinCondition = array_merge(
- array("$prev.$fk = $tableAlias.$keyColumn"),
+ ["$prev.$fk = $tableAlias.$keyColumn"],
$this->getAclClause($tableAlias, \_civicrm_api3_get_BAO($fkField['FKApiName']), $subStack)
);
$fkField = &$fkField['FKApiSpec'][$fieldName];
$prev = $tableAlias;
}
- return array($tableAlias, $fieldName);
+ return [$tableAlias, $fieldName];
}
/**
$tableName = $customField["table_name"];
$columnName = $customField["column_name"];
$tableAlias = "{$baseTable}_to_$tableName";
- $this->join($side, $tableName, $tableAlias, array("`$tableAlias`.entity_id = `$baseTable`.id"));
- return array($tableAlias, $columnName);
+ $this->join($side, $tableName, $tableAlias, ["`$tableAlias`.entity_id = `$baseTable`.id"]);
+ return [$tableAlias, $columnName];
}
/**
$entity = $spec[$name]['FKApiName'];
$spec = $spec[$name]['FKApiSpec'];
}
- $params = array($fieldName => $value);
+ $params = [$fieldName => $value];
\_civicrm_api3_validate_fields($entity, 'get', $params, $spec);
$value = $params[$fieldName];
}
return TRUE;
}
// Build an array of params that relate to the joined entity
- $params = array(
+ $params = [
'version' => 3,
- 'return' => array(),
+ 'return' => [],
'check_permissions' => $this->checkPermissions,
- );
+ ];
$prefix = implode('.', $fieldStack) . '.';
$len = strlen($prefix);
foreach ($this->select as $key => $ret) {
* @param array $stack
* @return array
*/
- protected function getAclClause($tableAlias, $baoName, $stack = array()) {
+ protected function getAclClause($tableAlias, $baoName, $stack = []) {
if (!$this->checkPermissions) {
- return array();
+ return [];
}
// Prevent (most) redundant acl sub clauses if they have already been applied to the main entity.
// FIXME: Currently this only works 1 level deep, but tracking through multiple joins would increase complexity
// and just doing it for the first join takes care of most acl clause deduping.
if (count($stack) === 1 && in_array($stack[0], $this->aclFields)) {
- return array();
+ return [];
}
$clauses = $baoName::getSelectWhereClause($tableAlias);
if (!$stack) {
* @return array
*/
public static function getSubscribedEvents() {
- return array(
- Events::PREPARE => array(
- array('onApiPrepare', Events::W_MIDDLE),
- array('onApiPrepare_validate', Events::W_LATE),
- ),
- );
+ return [
+ Events::PREPARE => [
+ ['onApiPrepare', Events::W_MIDDLE],
+ ['onApiPrepare_validate', Events::W_LATE],
+ ],
+ ];
}
/**
* @return array
*/
public function getDefaults($fields) {
- $defaults = array();
+ $defaults = [];
foreach ($fields as $field => $values) {
if (isset($values['api.default'])) {
* @return array
*/
public function getRequired($fields) {
- $required = array('version');
+ $required = ['version'];
foreach ($fields as $field => $values) {
if (!empty($values['api.required'])) {
* @return array
*/
public static function getSubscribedEvents() {
- return array(
- Events::RESPOND => array('onApiRespond', Events::W_EARLY),
- );
+ return [
+ Events::RESPOND => ['onApiRespond', Events::W_EARLY],
+ ];
}
/**
// We don't need to worry about nested api in the getfields/getoptions
// actions, so just return immediately.
- if (in_array($action, array('getfields', 'getfield', 'getoptions'))) {
+ if (in_array($action, ['getfields', 'getfield', 'getoptions'])) {
return;
}
// $result to be a recursive array
// $result['values'][0] = $result;
$oldResult = $result;
- $result = array('values' => array(0 => $oldResult));
+ $result = ['values' => [0 => $oldResult]];
}
foreach ($params as $field => $newparams) {
if ((is_array($newparams) || $newparams === 1) && $field <> 'api.has_parent' && substr($field, 0, 3) == 'api') {
// 'api.participant.delete' => 1 is a valid options - handle 1
// instead of an array
if ($newparams === 1) {
- $newparams = array('version' => $version);
+ $newparams = ['version' => $version];
}
// can be api_ or api.
$separator = $field[3];
$subAPI = explode($separator, $field);
$subaction = empty($subAPI[2]) ? $action : $subAPI[2];
- $subParams = array(
+ $subParams = [
'debug' => \CRM_Utils_Array::value('debug', $params),
- );
+ ];
$subEntity = _civicrm_api_get_entity_name_from_camel($subAPI[1]);
// Hard coded list of entitys that have fields starting api_ and shouldn't be automatically
// deemed to be chained API calls
- $skipList = array(
- 'SmsProvider' => array('type', 'url', 'params'),
- 'Job' => array('prefix', 'entity', 'action'),
- 'Contact' => array('key'),
- );
+ $skipList = [
+ 'SmsProvider' => ['type', 'url', 'params'],
+ 'Job' => ['prefix', 'entity', 'action'],
+ 'Contact' => ['key'],
+ ];
if (isset($skipList[$entity]) && in_array($subEntity, $skipList[$entity])) {
continue;
}
* @return array
*/
public static function getSubscribedEvents() {
- return array(
- Events::AUTHORIZE => array(
- array('onApiAuthorize', Events::W_EARLY),
- ),
- );
+ return [
+ Events::AUTHORIZE => [
+ ['onApiAuthorize', Events::W_EARLY],
+ ],
+ ];
}
/**
$apiRequest = $event->getApiRequest();
if ($apiRequest['version'] == 3 && \CRM_Utils_String::convertStringToCamel($apiRequest['entity']) == $this->entityName && in_array(strtolower($apiRequest['action']), $this->actions)) {
if (isset($apiRequest['params']['field_name'])) {
- $fldIdx = \CRM_Utils_Array::index(array('field_name'), $this->getCustomFields());
+ $fldIdx = \CRM_Utils_Array::index(['field_name'], $this->getCustomFields());
if (empty($fldIdx[$apiRequest['params']['field_name']])) {
throw new \Exception("Failed to map custom field to entity table");
}
\CRM_Core_Transaction::create(TRUE)->run(function($tx) use ($entity, $action, $entityId, &$exception, $self) {
$tx->rollback(); // Just to be safe.
- $params = array(
+ $params = [
'version' => 3,
'check_permissions' => 1,
'id' => $entityId,
- );
+ ];
$result = $self->kernel->run($entity, $self->getDelegatedAction($action), $params);
if ($result['is_error'] || empty($result['values'])) {
- $exception = new \Civi\API\Exception\UnauthorizedException("Authorization failed on ($entity,$entityId)", array(
+ $exception = new \Civi\API\Exception\UnauthorizedException("Authorization failed on ($entity,$entityId)", [
'cause' => $result,
- ));
+ ]);
}
});
* @throws \Exception
*/
public function getDelegate($id) {
- $query = \CRM_Core_DAO::executeQuery($this->lookupDelegateSql, array(
- 1 => array($id, 'Positive'),
- ));
+ $query = \CRM_Core_DAO::executeQuery($this->lookupDelegateSql, [
+ 1 => [$id, 'Positive'],
+ ]);
if ($query->fetch()) {
if (!preg_match('/^civicrm_value_/', $query->entity_table)) {
// A normal attachment directly on its entity.
- return array($query->is_valid, $query->entity_table, $query->entity_id);
+ return [$query->is_valid, $query->entity_table, $query->entity_id];
}
// Ex: Translate custom-field table ("civicrm_value_foo_4") to
// entity table ("civicrm_activity").
- $tblIdx = \CRM_Utils_Array::index(array('table_name'), $this->getCustomFields());
+ $tblIdx = \CRM_Utils_Array::index(['table_name'], $this->getCustomFields());
if (isset($tblIdx[$query->entity_table])) {
- return array($query->is_valid, $tblIdx[$query->entity_table]['entity_table'], $query->entity_id);
+ return [$query->is_valid, $tblIdx[$query->entity_table]['entity_table'], $query->entity_id];
}
throw new \Exception('Failed to lookup entity table for custom field.');
}
else {
- return array(FALSE, NULL, NULL);
+ return [FALSE, NULL, NULL];
}
}
*/
public function getCustomFields() {
$query = \CRM_Core_DAO::executeQuery($this->lookupCustomFieldSql);
- $rows = array();
+ $rows = [];
while ($query->fetch()) {
- $rows[] = array(
+ $rows[] = [
'field_name' => $query->field_name,
'table_name' => $query->table_name,
'extends' => $query->extends,
'entity_table' => \CRM_Core_BAO_CustomGroup::getTableNameByEntityName($query->extends),
- );
+ ];
}
return $rows;
}
* @return array
*/
public static function getSubscribedEvents() {
- return array(
- Events::PREPARE => array('onApiPrepare', Events::W_MIDDLE),
- );
+ return [
+ Events::PREPARE => ['onApiPrepare', Events::W_MIDDLE],
+ ];
}
/**
// on multi-lang sites based on request and civicrm_uf_match
if ($multiLang) {
$config = \CRM_Core_Config::singleton();
- $languageLimit = array();
+ $languageLimit = [];
if (isset($config->languageLimit) and $config->languageLimit) {
$languageLimit = $config->languageLimit;
}
$lcMessages = $lcMessagesRequest;
}
else {
- throw new \API_Exception(ts('Language not enabled: %1', array(1 => $lcMessagesRequest)));
+ throw new \API_Exception(ts('Language not enabled: %1', [1 => $lcMessagesRequest]));
}
}
* @return array
*/
public static function getSubscribedEvents() {
- return array(
- Events::AUTHORIZE => array(
- array('onApiAuthorize', Events::W_LATE),
- ),
- );
+ return [
+ Events::AUTHORIZE => [
+ ['onApiAuthorize', Events::W_LATE],
+ ],
+ ];
}
/**
case 'ActionSchedule':
$events = \CRM_Event_BAO_Event::getEvents();
$aclEdit = \CRM_ACL_API::group(\CRM_Core_Permission::EDIT, NULL, 'civicrm_event', $events);
- $param = array('id' => $apiRequest['params']['id']);
- $eventId = \CRM_Core_BAO_ActionSchedule::retrieve($param, $value = array());
+ $param = ['id' => $apiRequest['params']['id']];
+ $eventId = \CRM_Core_BAO_ActionSchedule::retrieve($param, $value = []);
if (in_array($eventId->entity_value, $aclEdit)) {
return TRUE;
}
* @return array
*/
public static function getSubscribedEvents() {
- return array(
- Events::PREPARE => array('onApiPrepare', Events::W_EARLY),
- Events::RESPOND => array('onApiRespond', Events::W_MIDDLE),
- Events::EXCEPTION => array('onApiException', Events::W_EARLY),
- );
+ return [
+ Events::PREPARE => ['onApiPrepare', Events::W_EARLY],
+ Events::RESPOND => ['onApiRespond', Events::W_MIDDLE],
+ Events::EXCEPTION => ['onApiException', Events::W_EARLY],
+ ];
}
/**
* @var array (scalar $apiRequestId => CRM_Core_Transaction $tx)
*/
- private $transactions = array();
+ private $transactions = [];
/**
* @var array (scalar $apiRequestId => bool)
* A list of requests which should be forcibly rolled back to
* their save points.
*/
- private $forceRollback = array();
+ private $forceRollback = [];
/**
* Determine if an API request should be treated as transactional.
* @return array
*/
public static function getSubscribedEvents() {
- return array(
- Events::AUTHORIZE => array('onApiAuthorize', Events::W_EARLY),
- Events::RESPOND => array('onApiRespond', Events::W_MIDDLE),
- );
+ return [
+ Events::AUTHORIZE => ['onApiAuthorize', Events::W_EARLY],
+ Events::RESPOND => ['onApiRespond', Events::W_MIDDLE],
+ ];
}
/**
* @throws \CRM_Core_Exception
*/
public function __construct($rules) {
- $this->rules = array();
+ $this->rules = [];
foreach ($rules as $rule) {
/** @var WhitelistRule $rule */
if ($rule->isValid()) {
* @return array
*/
public static function getSubscribedEvents() {
- return array(
- Events::PREPARE => array('onApiPrepare', Events::W_MIDDLE),
- Events::RESPOND => array('onApiRespond', Events::W_EARLY * 2),
- );
+ return [
+ Events::PREPARE => ['onApiPrepare', Events::W_MIDDLE],
+ Events::RESPOND => ['onApiRespond', Events::W_EARLY * 2],
+ ];
}
/**
* @param array $defaults
* array(\API_Wrapper).
*/
- public function __construct($defaults = array()) {
+ public function __construct($defaults = []) {
$this->defaults = $defaults;
}
* @return array
*/
public static function getSubscribedEvents() {
- return array(
- Events::RESPOND => array('onApiRespond', Events::W_LATE),
- );
+ return [
+ Events::RESPOND => ['onApiRespond', Events::W_LATE],
+ ];
}
/**
*/
class WhitelistRule {
- static $IGNORE_FIELDS = array(
+ static $IGNORE_FIELDS = [
'check_permissions',
'debug',
'offset',
'sequential',
'sort',
'version',
- );
+ ];
/**
* Create a batch of rules from an array.
* @return array
*/
public static function createAll($rules) {
- $whitelist = array();
+ $whitelist = [];
foreach ($rules as $rule) {
$whitelist[] = new WhitelistRule($rule);
}
$this->actions = '*';
}
else {
- $this->actions = array();
+ $this->actions = [];
foreach ((array) $ruleSpec['actions'] as $action) {
$this->actions[] = Request::normalizeActionName($action, $ruleSpec['version']);
}
// Kind'a silly we need to (re(re))parse here for each rule; would be more
// performant if pre-parsed by Request::create().
$options = _civicrm_api3_get_options_from_params($apiRequest['params'], TRUE, $apiRequest['entity'], 'get');
- $return = \CRM_Utils_Array::value('return', $options, array());
+ $return = \CRM_Utils_Array::value('return', $options, []);
$activatedFields = array_merge($activatedFields, array_keys($return));
}
* List of acceptable keys.
*/
protected function filterFields($keys) {
- $r = array();
+ $r = [];
foreach ($keys as $key) {
if (in_array($key, $this->fields)) {
$r[] = $key;
* @var array
* Array(scalar $id => Mapping $mapping).
*/
- protected $mappings = array();
+ protected $mappings = [];
/**
* Register a new mapping.
*/
abstract class Mapping implements MappingInterface {
- private static $fields = array(
+ private static $fields = [
'id',
'entity',
'entity_label',
'entity_status_label',
'entity_date_start',
'entity_date_end',
- );
+ ];
/**
* Create mapping.
return \CRM_Core_OptionGroup::values('auto_renew_options');
}
else {
- return array();
+ return [];
}
}
return self::getValueLabelMap($this->entity_status);
* Array(string $fieldName => string $fieldLabel).
*/
public function getDateFields() {
- $dateFieldLabels = array();
+ $dateFieldLabels = [];
if (!empty($this->entity_date_start)) {
$dateFieldLabels[$this->entity_date_start] = ucwords(str_replace('_', ' ', $this->entity_date_start));
}
* Ex: array('assignee' => 'Activity Assignee').
*/
public function getRecipientTypes() {
- return array();
+ return [];
}
/**
* @see getRecipientTypes
*/
public function getRecipientListing($recipientType) {
- return array();
+ return [];
}
protected static function getValueLabelMap($name) {
$valueLabelMap['civicrm_membership_type'] = \CRM_Member_PseudoConstant::membershipType();
$allCustomFields = \CRM_Core_BAO_CustomField::getFields('');
- $dateFields = array(
+ $dateFields = [
'birth_date' => ts('Birth Date'),
'created_date' => ts('Created Date'),
'modified_date' => ts('Modified Date'),
- );
+ ];
foreach ($allCustomFields as $fieldID => $field) {
if ($field['data_type'] == 'Date') {
$dateFields["custom_$fieldID"] = $field['label'];
* List of error messages.
*/
public function validateSchedule($schedule) {
- return array();
+ return [];
}
/**
// which means reference date mismatches with the end_date where end_date may be used as the start_action_date
// criteria for some schedule reminder so in order to send new reminder we INSERT new reminder with new reference_date
// value via UNION operation
- $referenceReminderIDs = array();
+ $referenceReminderIDs = [];
$referenceDate = NULL;
if (!empty($query['casUseReferenceDate'])) {
// First retrieve all the action log's ids which are outdated or in other words reference_date now don't match with entity date.
$query = $this->prepareQuery(self::PHASE_ADDITION_FIRST);
$insertAdditionalSql = \CRM_Utils_SQL_Select::from("civicrm_contact c")
- ->merge($query, array('params'))
+ ->merge($query, ['params'])
->merge($this->selectIntoActionLog(self::PHASE_ADDITION_FIRST, $query))
->merge($this->joinReminder('LEFT JOIN', 'addl', $query))
->where('reminder.id IS NULL')
->merge($this->selectActionLogFields(self::PHASE_RELATION_REPEAT, $query))
->select("MAX(reminder.action_date_time) as latest_log_time")
->merge($this->prepareRepetitionEndFilter($query['casDateField']))
- ->where($this->actionSchedule->start_action_date ? $startDateClauses[0] : array())
+ ->where($this->actionSchedule->start_action_date ? $startDateClauses[0] : [])
->groupBy("reminder.contact_id, reminder.entity_id, reminder.entity_table")
// @todo replace use of timestampdiff with a direct comparison as TIMESTAMPDIFF cannot use an index.
->having("TIMESTAMPDIFF(HOUR, latest_log_time, CAST(!casNow AS datetime)) >= TIMESTAMPDIFF(HOUR, latest_log_time, DATE_ADD(latest_log_time, INTERVAL !casRepetitionInterval))")
- ->param(array(
+ ->param([
'casRepetitionInterval' => $this->parseRepetitionInterval(),
- ))
+ ])
->strict()
->toSQL();
if ($arrValues) {
\CRM_Core_DAO::executeQuery(
\CRM_Utils_SQL_Insert::into('civicrm_action_log')
- ->columns(array('contact_id', 'entity_id', 'entity_table', 'action_schedule_id'))
+ ->columns(['contact_id', 'entity_id', 'entity_table', 'action_schedule_id'])
->rows($arrValues)
->toSQL()
);
$addlCheck = \CRM_Utils_SQL_Select::from($query['casAddlCheckFrom'])
->select('*')
- ->merge($query, array('params', 'wheres', 'joins'))
+ ->merge($query, ['params', 'wheres', 'joins'])
->merge($this->prepareRepetitionEndFilter($query['casDateField']))
->limit(1)
->strict()
->merge($this->selectActionLogFields(self::PHASE_ADDITION_REPEAT, $query))
->merge($this->joinReminder('INNER JOIN', 'addl', $query))
->select("MAX(reminder.action_date_time) as latest_log_time")
- ->merge($this->prepareAddlFilter('c.id'), array('params'))
+ ->merge($this->prepareAddlFilter('c.id'), ['params'])
->where("c.is_deleted = 0 AND c.is_deceased = 0")
->groupBy("reminder.contact_id")
// @todo replace use of timestampdiff with a direct comparison as TIMESTAMPDIFF cannot use an index.
->having("TIMESTAMPDIFF(HOUR, latest_log_time, CAST(!casNow AS datetime)) >= TIMESTAMPDIFF(HOUR, latest_log_time, DATE_ADD(latest_log_time, INTERVAL !casRepetitionInterval))")
- ->param(array(
+ ->param([
'casRepetitionInterval' => $this->parseRepetitionInterval(),
- ))
+ ])
->strict()
->toSQL();
if ($addValues) {
\CRM_Core_DAO::executeQuery(
\CRM_Utils_SQL_Insert::into('civicrm_action_log')
- ->columns(array('contact_id', 'entity_id', 'entity_table', 'action_schedule_id'))
+ ->columns(['contact_id', 'entity_id', 'entity_table', 'action_schedule_id'])
->rows($addValues)
->toSQL()
);
* @throws \CRM_Core_Exception
*/
protected function prepareQuery($phase) {
- $defaultParams = array(
+ $defaultParams = [
'casActionScheduleId' => $this->actionSchedule->id,
'casMappingId' => $this->mapping->getId(),
'casMappingEntity' => $this->mapping->getEntity(),
'casNow' => $this->now,
- );
+ ];
/** @var \CRM_Utils_SQL_Select $query */
$query = $this->mapping->createQuery($this->actionSchedule, $phase, $defaultParams);
$actionSchedule = $this->actionSchedule;
if ($actionSchedule->group_id) {
- $regularGroupIDs = $smartGroupIDs = $groupWhereCLause = array();
+ $regularGroupIDs = $smartGroupIDs = $groupWhereCLause = [];
$query = \CRM_Utils_SQL_Select::fragment();
// get child group IDs if any
$childGroupIDs = \CRM_Contact_BAO_Group::getChildGroupIds($actionSchedule->group_id);
- foreach (array_merge(array($actionSchedule->group_id), $childGroupIDs) as $groupID) {
+ foreach (array_merge([$actionSchedule->group_id], $childGroupIDs) as $groupID) {
if ($this->isSmartGroup($groupID)) {
// Check that the group is in place in the cache and up to date
\CRM_Contact_BAO_GroupContactCache::check($groupID);
*/
protected function prepareStartDateClauses() {
$actionSchedule = $this->actionSchedule;
- $startDateClauses = array();
+ $startDateClauses = [];
if ($actionSchedule->start_action_date) {
$op = ($actionSchedule->start_action_condition == 'before' ? '<=' : '>=');
$operator = ($actionSchedule->start_action_condition == 'before' ? 'DATE_SUB' : 'DATE_ADD');
return \CRM_Utils_SQL_Select::fragment()
->where("@casNow <= !repetitionEndDate")
- ->param(array(
+ ->param([
'!repetitionEndDate' => $repeatEventDateExpr,
- ));
+ ]);
}
/**
$fragment->select($query['casDateField']);
}
$fragment->select(
- array(
+ [
"!casContactIdField as contact_id",
"!casEntityIdField as entity_id",
"@casMappingEntity as entity_table",
"#casActionScheduleId as action_schedule_id",
- )
+ ]
);
break;
case self::PHASE_ADDITION_FIRST:
case self::PHASE_ADDITION_REPEAT:
//CRM-19017: Load default params for fragment query object.
- $params = array(
+ $params = [
'casActionScheduleId' => $this->actionSchedule->id,
'casNow' => $this->now,
- );
+ ];
$fragment = \CRM_Utils_SQL_Select::fragment()->param($params);
$fragment->select(
- array(
+ [
"c.id as contact_id",
"c.id as entity_id",
"'civicrm_contact' as entity_table",
"#casActionScheduleId as action_schedule_id",
- )
+ ]
);
break;
* @throws \CRM_Core_Exception
*/
protected function selectIntoActionLog($phase, $query) {
- $actionLogColumns = array(
+ $actionLogColumns = [
"contact_id",
"entity_id",
"entity_table",
"action_schedule_id",
- );
+ ];
if ($phase === self::PHASE_RELATION_FIRST || $phase === self::PHASE_RELATION_REPEAT) {
if (!empty($query['casUseReferenceDate'])) {
array_unshift($actionLogColumns, 'reference_date');
$this->angular = \Civi::service('angular');
$this->region = \CRM_Utils_Request::retrieve('snippet', 'String') ? 'ajax-snippet' : 'html-header';
$this->pageName = isset($_GET['q']) ? $_GET['q'] : NULL;
- $this->modules = array();
+ $this->modules = [];
}
/**
if ($this->crmApp !== NULL) {
$this->addModules($this->crmApp['modules']);
$region = \CRM_Core_Region::instance($this->crmApp['region']);
- $region->update('default', array('disabled' => TRUE));
- $region->add(array('template' => $this->crmApp['file'], 'weight' => 0));
- $this->res->addSetting(array(
- 'crmApp' => array(
+ $region->update('default', ['disabled' => TRUE]);
+ $region->add(['template' => $this->crmApp['file'], 'weight' => 0]);
+ $this->res->addSetting([
+ 'crmApp' => [
'defaultRoute' => $this->crmApp['defaultRoute'],
- ),
- ));
+ ],
+ ]);
// If trying to load an Angular page via AJAX, the route must be passed as a
// URL parameter, since the server doesn't receive information about
// URL fragments (i.e, what comes after the #).
- $this->res->addSetting(array(
+ $this->res->addSetting([
'angularRoute' => $this->crmApp['activeRoute'],
- ));
+ ]);
}
$moduleNames = $this->findActiveModules();
if (!$this->isAllModules($moduleNames)) {
- $assetParams = array('modules' => implode(',', $moduleNames));
+ $assetParams = ['modules' => implode(',', $moduleNames)];
}
else {
// The module list will be "all modules that the user can see".
- $assetParams = array('nonce' => md5(implode(',', $moduleNames)));
+ $assetParams = ['nonce' => md5(implode(',', $moduleNames))];
}
$res->addSettingsFactory(function () use (&$moduleNames, $angular, $res, $assetParams) {
// TODO optimization; client-side caching
- $result = array_merge($angular->getResources($moduleNames, 'settings', 'settings'), array(
+ $result = array_merge($angular->getResources($moduleNames, 'settings', 'settings'), [
'resourceUrls' => \CRM_Extension_System::singleton()->getMapper()->getActiveModuleUrls(),
- 'angular' => array(
+ 'angular' => [
'modules' => $moduleNames,
'requires' => $angular->getResources($moduleNames, 'requires', 'requires'),
'cacheCode' => $res->getCacheCode(),
'bundleUrl' => \Civi::service('asset_builder')->getUrl('angular-modules.json', $assetParams),
- ),
- ));
+ ],
+ ]);
return $result;
});
* @return AngularLoader
* @link https://code.angularjs.org/1.5.11/docs/guide/bootstrap
*/
- public function useApp($settings = array()) {
- $defaults = array(
- 'modules' => array('crmApp'),
+ public function useApp($settings = []) {
+ $defaults = [
+ 'modules' => ['crmApp'],
'activeRoute' => NULL,
'defaultRoute' => NULL,
'region' => 'page-body',
'file' => 'Civi/Angular/Page/Main.tpl',
- );
+ ];
$this->crmApp = array_merge($defaults, $settings);
return $this;
}
* - resourceType: string
* - callback: function
*/
- protected $resFilters = array();
+ protected $resFilters = [];
/**
* @var array
* - regex: string
* - callback: function
*/
- protected $htmlFilters = array();
+ protected $htmlFilters = [];
/**
* @param string $name
return $this->alterResource('requires',
function ($values) use ($module, $dependencies) {
if (!isset($values[$module])) {
- $values[$module] = array();
+ $values[$module] = [];
}
$values[$module] = array_unique(array_merge($values[$module], $dependencies));
return $values;
* @return ChangeSet
*/
public function alterResource($resourceType, $callback) {
- $this->resFilters[] = array(
+ $this->resFilters[] = [
'resourceType' => $resourceType,
'callback' => $callback,
- );
+ ];
return $this;
}
* @return ChangeSet
*/
public function alterHtml($file, $callback) {
- $this->htmlFilters[] = array(
+ $this->htmlFilters[] = [
'regex' => ($file{0} === ';') ? $file : $this->createRegex($file),
'callback' => $callback,
- );
+ ];
return $this;
}
}
protected function cleanup($html) {
- $html = preg_replace_callback("/([\\-a-zA-Z0-9]+)=(')([^']*)(')/", array($this, 'cleanupAttribute'), $html);
- $html = preg_replace_callback('/([\-a-zA-Z0-9]+)=(")([^"]*)(")/', array($this, 'cleanupAttribute'), $html);
+ $html = preg_replace_callback("/([\\-a-zA-Z0-9]+)=(')([^']*)(')/", [$this, 'cleanupAttribute'], $html);
+ $html = preg_replace_callback('/([\-a-zA-Z0-9]+)=(")([^"]*)(")/', [$this, 'cleanupAttribute'], $html);
return $html;
}
*/
public function __construct($res, \CRM_Utils_Cache_Interface $cache = NULL) {
$this->res = $res;
- $this->cache = $cache ? $cache : new \CRM_Utils_Cache_Arraycache(array());
+ $this->cache = $cache ? $cache : new \CRM_Utils_Cache_Arraycache([]);
}
/**
// Note: It would be nice to just glob("$civicrm_root/ang/*.ang.php"), but at time
// of writing CiviMail and CiviCase have special conditionals.
- $angularModules = array();
+ $angularModules = [];
$angularModules['angularFileUpload'] = include "$civicrm_root/ang/angularFileUpload.ang.php";
$angularModules['crmApp'] = include "$civicrm_root/ang/crmApp.ang.php";
$angularModules['crmAttachment'] = include "$civicrm_root/ang/crmAttachment.ang.php";
\CRM_Utils_Hook::angularModules($angularModules);
foreach (array_keys($angularModules) as $module) {
if (!isset($angularModules[$module]['basePages'])) {
- $angularModules[$module]['basePages'] = array('civicrm/a');
+ $angularModules[$module]['basePages'] = ['civicrm/a'];
}
}
$this->modules = $this->resolvePatterns($angularModules);
*/
public function resolveDependencies($names) {
$allModules = $this->getModules();
- $visited = array();
+ $visited = [];
$result = $names;
while (($missingModules = array_diff($result, array_keys($visited))) && !empty($missingModules)) {
foreach ($missingModules as $module) {
$visited[$module] = 1;
if (!isset($allModules[$module])) {
- \Civi::log()->warning('Unrecognized Angular module {name}. Please ensure that all Angular modules are declared.', array(
+ \Civi::log()->warning('Unrecognized Angular module {name}. Please ensure that all Angular modules are declared.', [
'name' => $module,
'civi.tag' => 'deprecated',
- ));
+ ]);
}
elseif (isset($allModules[$module]['requires'])) {
$result = array_unique(array_merge($result, $allModules[$module]['requires']));
*/
public function resolveDefaultModules($basePage) {
$modules = $this->getModules();
- $result = array();
+ $result = [];
foreach ($modules as $moduleName => $module) {
if (in_array($basePage, $module['basePages']) || in_array('*', $module['basePages'])) {
$result[] = $moduleName;
* Updated list of Angular modules
*/
protected function resolvePatterns($modules) {
- $newModules = array();
+ $newModules = [];
foreach ($modules as $moduleKey => $module) {
- foreach (array('js', 'css', 'partials') as $fileset) {
+ foreach (['js', 'css', 'partials'] as $fileset) {
if (!isset($module[$fileset])) {
continue;
}
*/
public function getRawPartials($name) {
$module = $this->getModule($name);
- $result = array();
+ $result = [];
if (isset($module['partials'])) {
foreach ($module['partials'] as $partialDir) {
$partialDir = $this->res->getPath($module['ext']) . '/' . $partialDir;
*/
public function getTranslatedStrings($name) {
$module = $this->getModule($name);
- $result = array();
+ $result = [];
$strings = $this->getStrings($name);
foreach ($strings as $string) {
// TODO: should we pass translation domain based on $module[ext] or $module[tsDomain]?
// It doesn't look like client side really supports the domain right now...
- $translated = ts($string, array(
- 'domain' => array($module['ext'], NULL),
- ));
+ $translated = ts($string, [
+ 'domain' => [$module['ext'], NULL],
+ ]);
if ($translated != $string) {
$result[$string] = $translated;
}
*/
public function getStrings($name) {
$module = $this->getModule($name);
- $result = array();
+ $result = [];
if (isset($module['js'])) {
foreach ($module['js'] as $file) {
$strings = $this->res->getStrings()->get(
* @throws \CRM_Core_Exception
*/
public function getResources($moduleNames, $resType, $refType) {
- $result = array();
+ $result = [];
$moduleNames = (array) $moduleNames;
foreach ($moduleNames as $moduleName) {
$module = $this->getModule($moduleName);
case 'path-assetBuilder':
$assetName = parse_url($file, PHP_URL_HOST) . parse_url($file, PHP_URL_PATH);
- $assetParams = array();
+ $assetParams = [];
parse_str('' . parse_url($file, PHP_URL_QUERY), $assetParams);
$result[] = \Civi::service('asset_builder')->getPath($assetName, $assetParams);
break;
case 'rawUrl-assetBuilder':
case 'cacheUrl-assetBuilder':
$assetName = parse_url($file, PHP_URL_HOST) . parse_url($file, PHP_URL_PATH);
- $assetParams = array();
+ $assetParams = [];
parse_str('' . parse_url($file, PHP_URL_QUERY), $assetParams);
$result[] = \Civi::service('asset_builder')->getUrl($assetName, $assetParams);
break;
*/
public function getChangeSets() {
if ($this->changeSets === NULL) {
- $this->changeSets = array();
+ $this->changeSets = [];
\CRM_Utils_Hook::alterAngular($this);
}
return $this->changeSets;
public function registerResources() {
$loader = new \Civi\Angular\AngularLoader();
$loader->setPageName('civicrm/a');
- $loader->useApp(array(
+ $loader->useApp([
'activeRoute' => \CRM_Utils_Request::retrieve('route', 'String'),
'defaultRoute' => NULL,
- ));
+ ]);
$loader->load();
}
* @return string
*/
public function digestJs($files) {
- $scripts = array();
+ $scripts = [];
foreach ($files as $file) {
$scripts[] = file_get_contents($file);
}
$scripts = \CRM_Utils_JS::dedupeClosures(
$scripts,
- array('angular', '$', '_'),
- array('angular', 'CRM.$', 'CRM._')
+ ['angular', '$', '_'],
+ ['angular', 'CRM.$', 'CRM._']
);
// This impl of stripComments currently adds 10-20ms and cuts ~7%
return \CRM_Utils_JS::stripComments(implode("\n", $scripts));
*/
public function getMetadata($moduleNames, $angular) {
$modules = $angular->getModules();
- $result = array();
+ $result = [];
foreach ($moduleNames as $moduleName) {
if (isset($modules[$moduleName])) {
- $result[$moduleName] = array();
+ $result[$moduleName] = [];
$result[$moduleName]['domain'] = $modules[$moduleName]['ext'];
$result[$moduleName]['js'] = $angular->getResources($moduleName, 'js', 'rawUrl');
$result[$moduleName]['css'] = $angular->getResources($moduleName, 'css', 'rawUrl');
* @return bool
*/
public function hasActivity($type, $status = NULL) {
- $idx = $this->getActivityIndex(array('activity_type_id', 'status_id'));
- $activityTypeGroup = civicrm_api3('option_group', 'get', array('name' => 'activity_type'));
- $activityType = array(
+ $idx = $this->getActivityIndex(['activity_type_id', 'status_id']);
+ $activityTypeGroup = civicrm_api3('option_group', 'get', ['name' => 'activity_type']);
+ $activityType = [
'name' => $type,
'option_group_id' => $activityTypeGroup['id'],
- );
+ ];
$activityTypeID = civicrm_api3('option_value', 'get', $activityType);
$activityTypeID = $activityTypeID['values'][$activityTypeID['id']]['value'];
if ($status) {
- $activityStatusGroup = civicrm_api3('option_group', 'get', array('name' => 'activity_status'));
- $activityStatus = array(
+ $activityStatusGroup = civicrm_api3('option_group', 'get', ['name' => 'activity_status']);
+ $activityStatus = [
'name' => $status,
'option_group_id' => $activityStatusGroup['id'],
- );
+ ];
$activityStatusID = civicrm_api3('option_value', 'get', $activityStatus);
$activityStatusID = $activityStatusID['values'][$activityStatusID['id']]['value'];
}
if ($this->activities === NULL) {
// TODO find batch-oriented API for getting all activities in a case
$case = $this->getCase();
- $activities = array();
+ $activities = [];
if (isset($case['activities'])) {
foreach ($case['activities'] as $actId) {
- $result = civicrm_api3('Activity', 'get', array(
+ $result = civicrm_api3('Activity', 'get', [
'id' => $actId,
'is_current_revision' => 1,
- ));
+ ]);
$activities = array_merge($activities, $result['values']);
}
}
* @return array|NULL, activity record (api/v3)
*/
public function getSingleActivity($type) {
- $idx = $this->getActivityIndex(array('activity_type_id', 'id'));
+ $idx = $this->getActivityIndex(['activity_type_id', 'id']);
$actTypes = array_flip(\CRM_Activity_BAO_Activity::buildOptions('activity_type_id', 'validate'));
$typeId = $actTypes[$type];
$count = isset($idx[$typeId]) ? count($idx[$typeId]) : 0;
*/
public function getCase() {
if ($this->case === NULL) {
- $this->case = civicrm_api3('case', 'getsingle', array('id' => $this->caseId));
+ $this->case = civicrm_api3('case', 'getsingle', ['id' => $this->caseId]);
}
return $this->case;
}
$this->case = NULL;
$this->caseType = NULL;
$this->activities = NULL;
- $this->indices = array();
+ $this->indices = [];
}
}
* @inheritDoc
*/
public function getHookValues() {
- return array($this->analyzer);
+ return [$this->analyzer];
}
}
*
* We do not want to fire case-change events recursively.
*/
- static $isActive = array();
+ static $isActive = [];
/**
* Following a change to an activity or case, fire the case-change event.
$tx = new \CRM_Core_Transaction();
\CRM_Core_Transaction::addCallback(
\CRM_Core_Transaction::PHASE_POST_COMMIT,
- array(__CLASS__, 'fireCaseChangeForRealz'),
- array($caseId),
+ [__CLASS__, 'fireCaseChangeForRealz'],
+ [$caseId],
"Civi_CCase_Events::fire::{$caseId}"
);
}
$actTypes = array_flip(\CRM_Activity_BAO_Activity::buildOptions('activity_type_id', 'validate'));
$actStatuses = array_flip(\CRM_Activity_BAO_Activity::getStatusesByType(\CRM_Activity_BAO_Activity::COMPLETED));
- $actIndex = $analyzer->getActivityIndex(array('activity_type_id', 'status_id'));
+ $actIndex = $analyzer->getActivityIndex(['activity_type_id', 'status_id']);
foreach ($activitySetXML->ActivityTypes->ActivityType as $actTypeXML) {
$actTypeId = $actTypes[(string) $actTypeXML->name];
}
// OK, the all activities have completed
- civicrm_api3('Case', 'create', array(
+ civicrm_api3('Case', 'create', [
'id' => $analyzer->getCaseId(),
'status_id' => 'Closed',
- ));
+ ]);
$analyzer->flush();
}
* @param \SimpleXMLElement $actXML the <ActivityType> tag which describes the new activity
*/
public function createActivity(Analyzer $analyzer, \SimpleXMLElement $actXML) {
- $params = array(
+ $params = [
'activity_type_id' => (string) $actXML->name,
'status_id' => 'Scheduled',
'activity_date_time' => \CRM_Utils_Time::getTime('YmdHis'),
'case_id' => $analyzer->getCaseId(),
- );
+ ];
$case = $analyzer->getCase();
if (!empty($case['contact_id'])) {
$params['target_id'] = \CRM_Utils_Array::first($case['contact_id']);
* @return array
*/
public static function collect($arr, $col) {
- $r = array();
+ $r = [];
foreach ($arr as $k => $item) {
$r[$k] = $item[$col];
}
fwrite($fh, $csvContent);
rewind($fh);
- $results = array();
+ $results = [];
while (($r = fgetcsv($fh)) !== FALSE) {
$name = str_replace('.', '::', trim($r[0]));
$status = trim($r[1]);
}
list ($program, $target, $suite) = $argv;
- $candidateTests = \Civi\CiUtil\PHPUnitScanner::findTestsByPath(array($suite));
+ $candidateTests = \Civi\CiUtil\PHPUnitScanner::findTestsByPath([$suite]);
// $candidateTests = array(
// array('class' => 'CRM_Core_RegionTest', 'method' => 'testBlank'),
// array('class' => 'CRM_Core_RegionTest', 'method' => 'testDefault'),
// );
$antagonist = self::findAntagonist($target, $candidateTests);
if ($antagonist) {
- print_r(array('found an antagonist' => $antagonist));
+ print_r(['found an antagonist' => $antagonist]);
}
else {
- print_r(array('found no antagonists'));
+ print_r(['found no antagonists']);
}
}
public static function findAntagonist($target, $candidateTests) {
//$phpUnit = new \Civi\CiUtil\EnvTestRunner('./scripts/phpunit', 'EnvTests');
$phpUnit = new \Civi\CiUtil\EnvTestRunner('phpunit', 'tests/phpunit/EnvTests.php');
- $expectedResults = $phpUnit->run(array($target));
- print_r(array('$expectedResults' => $expectedResults));
+ $expectedResults = $phpUnit->run([$target]);
+ print_r(['$expectedResults' => $expectedResults]);
foreach ($candidateTests as $candidateTest) {
$candidateTestName = $candidateTest['class'] . '::' . $candidateTest['method'];
if ($candidateTestName == $target) {
continue;
}
- $actualResults = $phpUnit->run(array(
+ $actualResults = $phpUnit->run([
$candidateTestName,
$target,
- ));
- print_r(array('$actualResults' => $actualResults));
+ ]);
+ print_r(['$actualResults' => $actualResults]);
foreach ($expectedResults as $testName => $expectedResult) {
if ($actualResults[$testName] != $expectedResult) {
- return array(
+ return [
'antagonist' => $candidateTest,
'expectedResults' => $expectedResults,
'actualResults' => $actualResults,
- );
+ ];
}
}
}
exit(1);
}
- $parser = array('\Civi\CiUtil\PHPUnitParser', 'parseJsonResults');
+ $parser = ['\Civi\CiUtil\PHPUnitParser', 'parseJsonResults'];
$printerType = 'txt';
- $suites = array(); // array('file' => string, 'results' => array)
+ $suites = []; // array('file' => string, 'results' => array)
for ($i = 1; $i < count($argv); $i++) {
switch ($argv[$i]) {
case '--phpunit-json':
- $parser = array('\Civi\CiUtil\PHPUnitParser', 'parseJsonResults');
+ $parser = ['\Civi\CiUtil\PHPUnitParser', 'parseJsonResults'];
break;
case '--jenkins-xml':
- $parser = array('\Civi\CiUtil\JenkinsParser', 'parseXmlResults');
+ $parser = ['\Civi\CiUtil\JenkinsParser', 'parseXmlResults'];
break;
case '--csv':
- $parser = array('\Civi\CiUtil\CSVParser', 'parseResults');
+ $parser = ['\Civi\CiUtil\CSVParser', 'parseResults'];
break;
case '--out=txt':
break;
default:
- $suites[] = array(
+ $suites[] = [
'file' => $argv[$i],
'results' => call_user_func($parser, file_get_contents($argv[$i])),
- );
+ ];
}
}
- $tests = array(); // array(string $name)
+ $tests = []; // array(string $name)
foreach ($suites as $suite) {
$tests = array_unique(array_merge(
$tests,
$printer = new \Civi\CiUtil\ComparisonPrinter(\Civi\CiUtil\Arrays::collect($suites, 'file'));
}
foreach ($tests as $test) {
- $values = array();
+ $values = [];
foreach ($suites as $suite) {
$values[] = isset($suite['results'][$test]) ? $suite['results'][$test] : 'MISSING';
}
*/
public static function parseXmlResults($content) {
$xml = simplexml_load_string($content);
- $results = array();
+ $results = [];
foreach ($xml->suites as $suites) {
foreach ($suites->suite as $suite) {
foreach ($suite->cases as $cases) {
*/
protected static function parseJsonStream($content) {
$content = '['
- . strtr($content, array("}{" => "},{"))
+ . strtr($content, ["}{" => "},{"])
. ']';
return json_decode($content, TRUE);
}
*/
public static function parseJsonResults($content) {
$records = self::parseJsonStream($content);
- $results = array();
+ $results = [];
foreach ($records as $r) {
if ($r['event'] == 'test') {
$results[$r['test']] = $r['status'];
* @throws \Exception
*/
public static function findTestClasses($paths) {
- $testClasses = array();
+ $testClasses = [];
$finder = new Finder();
foreach ($paths as $path) {
* - method: string
*/
public static function findTestsByPath($paths) {
- $r = array();
+ $r = [];
$testClasses = self::findTestClasses($paths);
foreach ($testClasses as $testFile => $testClass) {
$clazz = new \ReflectionClass($testClass);
foreach ($clazz->getMethods() as $method) {
if (preg_match('/^test/', $method->name)) {
- $r[] = array(
+ $r[] = [
'file' => $testFile,
'class' => $testClass,
'method' => $method->name,
- );
+ ];
}
}
}
*/
public function login($username, $password) {
$config = \CRM_Core_Config::singleton();
- $handler = array($this, 'loginTo' . $config->userFramework);
+ $handler = [$this, 'loginTo' . $config->userFramework];
if (is_callable($handler)) {
call_user_func($handler, $username, $password);
}
* Array(string $value => string $label).
*/
public static function getCacheModes() {
- return array(
+ return [
'0' => ts('Disable'),
'1' => ts('Enable'),
'auto' => ts('Auto'),
- );
+ ];
}
protected $cacheEnabled;
* URL.
* Ex: 'http://example.org/files/civicrm/dyn/angular.abcd1234abcd1234.json'.
*/
- public function getUrl($name, $params = array()) {
+ public function getUrl($name, $params = []) {
if (!$this->isValidName($name)) {
throw new \RuntimeException("Invalid dynamic asset name");
}
return $this->getCacheUrl($fileName);
}
else {
- return \CRM_Utils_System::url('civicrm/asset/builder', array(
+ return \CRM_Utils_System::url('civicrm/asset/builder', [
'an' => $name,
'ap' => $this->encode($params),
'ad' => $this->digest($name, $params),
- ), TRUE, NULL, FALSE);
+ ], TRUE, NULL, FALSE);
}
}
* URL.
* Ex: '/var/www/files/civicrm/dyn/angular.abcd1234abcd1234.json'.
*/
- public function getPath($name, $params = array()) {
+ public function getPath($name, $params = []) {
if (!$this->isValidName($name)) {
throw new \RuntimeException("Invalid dynamic asset name");
}
throw new UnknownAssetException("Asset name is malformed");
}
$nameParts = explode('.', $name);
- array_splice($nameParts, -1, 0, array($this->digest($name, $params)));
+ array_splice($nameParts, -1, 0, [$this->digest($name, $params)]);
$fileName = implode('.', $nameParts);
if ($force || !file_exists($this->getCachePath($fileName))) {
// No file locking, but concurrent writers should produce
* - content: string, ex: '<body>Hello world</body>'.
* @throws \CRM_Core_Exception
*/
- public function render($name, $params = array()) {
+ public function render($name, $params = []) {
if (!$this->isValidName($name)) {
throw new UnknownAssetException("Asset name is malformed");
}
throw new UnknownAssetException("Unrecognized asset name: $name");
}
// Beg your pardon, sir. Please may I have an HTTP response class instead?
- return array(
+ return [
'statusCode' => 200,
'mimeType' => $mimeType,
'content' => $content,
- );
+ ];
}
/**
*/
protected function decode($str) {
if ($str === NULL || $str === FALSE || $str === '') {
- return array();
+ return [];
}
$str = base64_decode($str);
return $assets->render($get['an'], $assets->decode($get['ap']));
}
catch (UnknownAssetException $e) {
- return array(
+ return [
'statusCode' => 404,
'mimeType' => 'text/plain',
'content' => $e->getMessage(),
- );
+ ];
}
}
* @var array
* Array(string $eventName => trueish).
*/
- private $autoListeners = array();
+ private $autoListeners = [];
/**
* Determine whether $eventName should delegate to the CMS hook system.
// WISHLIST: For native extensions (and possibly D6/D7/D8/BD), enumerate
// the listeners and list them one-by-one. This would make it easier to
// inspect via "cv debug:event-dispatcher".
- $this->addListener($eventName, array(
+ $this->addListener($eventName, [
'\Civi\Core\CiviEventDispatcher',
'delegateToUF',
- ), self::DEFAULT_HOOK_PRIORITY);
+ ], self::DEFAULT_HOOK_PRIORITY);
}
}
}
* @see \CRM_Utils_Hook::eventDefs()
*/
public static function findBuiltInEvents(\Civi\Core\Event\GenericHookEvent $e) {
- $skipList = array('singleton');
+ $skipList = ['singleton'];
$e->inspector->addStaticStubs('CRM_Utils_Hook', 'hook_civicrm_',
function ($eventDef, $method) use ($skipList) {
return in_array($method->name, $skipList) ? NULL : $eventDef;
*/
public function build($force = FALSE) {
if ($force || $this->eventDefs === NULL) {
- $this->eventDefs = array();
+ $this->eventDefs = [];
\CRM_Utils_Hook::eventDefs($this);
ksort($this->eventDefs);
}
return FALSE;
}
- if (!in_array($eventDef['type'], array('hook', 'object'))) {
+ if (!in_array($eventDef['type'], ['hook', 'object'])) {
return FALSE;
}
* @return CiviEventInspector
*/
public function addEventClass($event, $className) {
- $this->add(array(
+ $this->add([
'name' => $event,
'class' => $className,
- ));
+ ]);
return $this;
}
continue;
}
- $eventDef = array(
+ $eventDef = [
'name' => $prefix . $method->name,
'description_html' => $method->getDocComment() ? \CRM_Admin_Page_APIExplorer::formatDocBlock($method->getDocComment()) : '',
- 'fields' => array(),
+ 'fields' => [],
'class' => 'Civi\Core\Event\GenericHookEvent',
'stub' => $method,
- );
+ ];
foreach ($method->getParameters() as $parameter) {
- $eventDef['fields'][$parameter->getName()] = array(
+ $eventDef['fields'][$parameter->getName()] = [
'name' => $parameter->getName(),
'ref' => (bool) $parameter->isPassedByReference(),
// WISHLIST: 'type' => 'mixed',
- );
+ ];
}
if ($filter !== NULL) {
$containerBuilder->compile();
$dumper = new PhpDumper($containerBuilder);
$containerConfigCache->write(
- $dumper->dump(array('class' => 'CachedCiviContainer')),
+ $dumper->dump(['class' => 'CachedCiviContainer']),
$containerBuilder->getResources()
);
}
$container->setDefinition(self::SELF, new Definition(
'Civi\Core\Container',
- array()
+ []
));
// TODO Move configuration to an external file; define caching structure
$container->setDefinition('angular', new Definition(
'Civi\Angular\Manager',
- array()
+ []
))
- ->setFactory(array(new Reference(self::SELF), 'createAngularManager'));
+ ->setFactory([new Reference(self::SELF), 'createAngularManager']);
$container->setDefinition('dispatcher', new Definition(
'Civi\Core\CiviEventDispatcher',
- array(new Reference('service_container'))
+ [new Reference('service_container')]
))
- ->setFactory(array(new Reference(self::SELF), 'createEventDispatcher'));
+ ->setFactory([new Reference(self::SELF), 'createEventDispatcher']);
$container->setDefinition('magic_function_provider', new Definition(
'Civi\API\Provider\MagicFunctionProvider',
- array()
+ []
));
$container->setDefinition('civi_api_kernel', new Definition(
'Civi\API\Kernel',
- array(new Reference('dispatcher'), new Reference('magic_function_provider'))
+ [new Reference('dispatcher'), new Reference('magic_function_provider')]
))
- ->setFactory(array(new Reference(self::SELF), 'createApiKernel'));
+ ->setFactory([new Reference(self::SELF), 'createApiKernel']);
$container->setDefinition('cxn_reg_client', new Definition(
'Civi\Cxn\Rpc\RegistrationClient',
- array()
+ []
))
->setFactory('CRM_Cxn_BAO_Cxn::createRegistrationClient');
- $container->setDefinition('psr_log', new Definition('CRM_Core_Error_Log', array()));
+ $container->setDefinition('psr_log', new Definition('CRM_Core_Error_Log', []));
- $basicCaches = array(
+ $basicCaches = [
'js_strings' => 'js_strings',
'community_messages' => 'community_messages',
'checks' => 'checks',
'session' => 'CiviCRM Session',
'long' => 'long',
- );
+ ];
foreach ($basicCaches as $cacheSvc => $cacheGrp) {
$container->setDefinition("cache.{$cacheSvc}", new Definition(
'CRM_Utils_Cache_Interface',
- array(
- array(
+ [
+ [
'name' => $cacheGrp,
- 'type' => array('*memory*', 'SqlGroup', 'ArrayCache'),
- ),
- )
+ 'type' => ['*memory*', 'SqlGroup', 'ArrayCache'],
+ ],
+ ]
))->setFactory('CRM_Utils_Cache::create');
}
$container->setDefinition('sql_triggers', new Definition(
'Civi\Core\SqlTriggers',
- array()
+ []
));
$container->setDefinition('asset_builder', new Definition(
'Civi\Core\AssetBuilder',
- array()
+ []
));
$container->setDefinition('pear_mail', new Definition('Mail'))
}
// Expose legacy singletons as services in the container.
- $singletons = array(
+ $singletons = [
'httpClient' => 'CRM_Utils_HttpClient',
'cache.default' => 'CRM_Utils_Cache',
'i18n' => 'CRM_Core_I18n',
// Maybe? 'config' => 'CRM_Core_Config',
// Maybe? 'smarty' => 'CRM_Core_Smarty',
- );
+ ];
foreach ($singletons as $name => $class) {
$container->setDefinition($name, new Definition(
$class
))
- ->setFactory(array($class, 'singleton'));
+ ->setFactory([$class, 'singleton']);
}
$container->setAlias('cache.short', 'cache.default');
$container->setDefinition('resources', new Definition(
'CRM_Core_Resources',
[new Reference('service_container')]
- ))->setFactory(array(new Reference(self::SELF), 'createResources'));
+ ))->setFactory([new Reference(self::SELF), 'createResources']);
$container->setDefinition('prevnext', new Definition(
'CRM_Core_PrevNextCache_Interface',
[new Reference('service_container')]
- ))->setFactory(array(new Reference(self::SELF), 'createPrevNextCache'));
+ ))->setFactory([new Reference(self::SELF), 'createPrevNextCache']);
$container->setDefinition('prevnext.driver.sql', new Definition(
'CRM_Core_PrevNextCache_Sql',
));
$container->setDefinition('cache_config', new Definition('ArrayObject'))
- ->setFactory(array(new Reference(self::SELF), 'createCacheConfig'));
+ ->setFactory([new Reference(self::SELF), 'createCacheConfig']);
$container->setDefinition('civi.mailing.triggers', new Definition(
'Civi\Core\SqlTrigger\TimestampTriggers',
- array('civicrm_mailing', 'Mailing')
- ))->addTag('kernel.event_listener', array('event' => 'hook_civicrm_triggerInfo', 'method' => 'onTriggerInfo'));
+ ['civicrm_mailing', 'Mailing']
+ ))->addTag('kernel.event_listener', ['event' => 'hook_civicrm_triggerInfo', 'method' => 'onTriggerInfo']);
$container->setDefinition('civi.activity.triggers', new Definition(
'Civi\Core\SqlTrigger\TimestampTriggers',
- array('civicrm_activity', 'Activity')
- ))->addTag('kernel.event_listener', array('event' => 'hook_civicrm_triggerInfo', 'method' => 'onTriggerInfo'));
+ ['civicrm_activity', 'Activity']
+ ))->addTag('kernel.event_listener', ['event' => 'hook_civicrm_triggerInfo', 'method' => 'onTriggerInfo']);
$container->setDefinition('civi.case.triggers', new Definition(
'Civi\Core\SqlTrigger\TimestampTriggers',
- array('civicrm_case', 'Case')
- ))->addTag('kernel.event_listener', array('event' => 'hook_civicrm_triggerInfo', 'method' => 'onTriggerInfo'));
+ ['civicrm_case', 'Case']
+ ))->addTag('kernel.event_listener', ['event' => 'hook_civicrm_triggerInfo', 'method' => 'onTriggerInfo']);
$container->setDefinition('civi.case.staticTriggers', new Definition(
'Civi\Core\SqlTrigger\StaticTriggers',
- array(
- array(
- array(
- 'upgrade_check' => array('table' => 'civicrm_case', 'column' => 'modified_date'),
+ [
+ [
+ [
+ 'upgrade_check' => ['table' => 'civicrm_case', 'column' => 'modified_date'],
'table' => 'civicrm_case_activity',
'when' => 'AFTER',
- 'event' => array('INSERT'),
+ 'event' => ['INSERT'],
'sql' => "\nUPDATE civicrm_case SET modified_date = CURRENT_TIMESTAMP WHERE id = NEW.case_id;\n",
- ),
- array(
- 'upgrade_check' => array('table' => 'civicrm_case', 'column' => 'modified_date'),
+ ],
+ [
+ 'upgrade_check' => ['table' => 'civicrm_case', 'column' => 'modified_date'],
'table' => 'civicrm_activity',
'when' => 'BEFORE',
- 'event' => array('UPDATE', 'DELETE'),
+ 'event' => ['UPDATE', 'DELETE'],
'sql' => "\nUPDATE civicrm_case SET modified_date = CURRENT_TIMESTAMP WHERE id IN (SELECT ca.case_id FROM civicrm_case_activity ca WHERE ca.activity_id = OLD.id);\n",
- ),
- ),
- )
+ ],
+ ],
+ ]
))
- ->addTag('kernel.event_listener', array('event' => 'hook_civicrm_triggerInfo', 'method' => 'onTriggerInfo'));
+ ->addTag('kernel.event_listener', ['event' => 'hook_civicrm_triggerInfo', 'method' => 'onTriggerInfo']);
$container->setDefinition('civi_token_compat', new Definition(
'Civi\Token\TokenCompatSubscriber',
- array()
+ []
))->addTag('kernel.event_subscriber');
$container->setDefinition("crm_mailing_action_tokens", new Definition(
"CRM_Mailing_ActionTokens",
- array()
+ []
))->addTag('kernel.event_subscriber');
- foreach (array('Activity', 'Contribute', 'Event', 'Mailing', 'Member') as $comp) {
+ foreach (['Activity', 'Contribute', 'Event', 'Mailing', 'Member'] as $comp) {
$container->setDefinition("crm_" . strtolower($comp) . "_tokens", new Definition(
"CRM_{$comp}_Tokens",
- array()
+ []
))->addTag('kernel.event_subscriber');
}
if (\CRM_Utils_Constant::value('CIVICRM_FLEXMAILER_HACK_SERVICES')) {
- \Civi\Core\Resolver::singleton()->call(CIVICRM_FLEXMAILER_HACK_SERVICES, array($container));
+ \Civi\Core\Resolver::singleton()->call(CIVICRM_FLEXMAILER_HACK_SERVICES, [$container]);
}
\CRM_Utils_Hook::container($container);
*/
public function createEventDispatcher($container) {
$dispatcher = new CiviEventDispatcher($container);
- $dispatcher->addListener(SystemInstallEvent::EVENT_NAME, array('\Civi\Core\InstallationCanary', 'check'));
- $dispatcher->addListener(SystemInstallEvent::EVENT_NAME, array('\Civi\Core\DatabaseInitializer', 'initialize'));
- $dispatcher->addListener(SystemInstallEvent::EVENT_NAME, array('\Civi\Core\LocalizationInitializer', 'initialize'));
- $dispatcher->addListener('hook_civicrm_pre', array('\Civi\Core\Event\PreEvent', 'dispatchSubevent'), 100);
- $dispatcher->addListener('hook_civicrm_post', array('\Civi\Core\Event\PostEvent', 'dispatchSubevent'), 100);
- $dispatcher->addListener('hook_civicrm_post::Activity', array('\Civi\CCase\Events', 'fireCaseChange'));
- $dispatcher->addListener('hook_civicrm_post::Case', array('\Civi\CCase\Events', 'fireCaseChange'));
- $dispatcher->addListener('hook_civicrm_caseChange', array('\Civi\CCase\Events', 'delegateToXmlListeners'));
- $dispatcher->addListener('hook_civicrm_caseChange', array('\Civi\CCase\SequenceListener', 'onCaseChange_static'));
- $dispatcher->addListener('hook_civicrm_eventDefs', array('\Civi\Core\CiviEventInspector', 'findBuiltInEvents'));
+ $dispatcher->addListener(SystemInstallEvent::EVENT_NAME, ['\Civi\Core\InstallationCanary', 'check']);
+ $dispatcher->addListener(SystemInstallEvent::EVENT_NAME, ['\Civi\Core\DatabaseInitializer', 'initialize']);
+ $dispatcher->addListener(SystemInstallEvent::EVENT_NAME, ['\Civi\Core\LocalizationInitializer', 'initialize']);
+ $dispatcher->addListener('hook_civicrm_pre', ['\Civi\Core\Event\PreEvent', 'dispatchSubevent'], 100);
+ $dispatcher->addListener('hook_civicrm_post', ['\Civi\Core\Event\PostEvent', 'dispatchSubevent'], 100);
+ $dispatcher->addListener('hook_civicrm_post::Activity', ['\Civi\CCase\Events', 'fireCaseChange']);
+ $dispatcher->addListener('hook_civicrm_post::Case', ['\Civi\CCase\Events', 'fireCaseChange']);
+ $dispatcher->addListener('hook_civicrm_caseChange', ['\Civi\CCase\Events', 'delegateToXmlListeners']);
+ $dispatcher->addListener('hook_civicrm_caseChange', ['\Civi\CCase\SequenceListener', 'onCaseChange_static']);
+ $dispatcher->addListener('hook_civicrm_eventDefs', ['\Civi\Core\CiviEventInspector', 'findBuiltInEvents']);
// TODO We need a better code-convention for metadata about non-hook events.
- $dispatcher->addListener('hook_civicrm_eventDefs', array('\Civi\API\Events', 'hookEventDefs'));
- $dispatcher->addListener('hook_civicrm_eventDefs', array('\Civi\Core\Event\SystemInstallEvent', 'hookEventDefs'));
- $dispatcher->addListener('hook_civicrm_buildAsset', array('\Civi\Angular\Page\Modules', 'buildAngularModules'));
- $dispatcher->addListener('hook_civicrm_buildAsset', array('\CRM_Utils_VisualBundle', 'buildAssetJs'));
- $dispatcher->addListener('hook_civicrm_buildAsset', array('\CRM_Utils_VisualBundle', 'buildAssetCss'));
- $dispatcher->addListener('civi.dao.postInsert', array('\CRM_Core_BAO_RecurringEntity', 'triggerInsert'));
- $dispatcher->addListener('civi.dao.postUpdate', array('\CRM_Core_BAO_RecurringEntity', 'triggerUpdate'));
- $dispatcher->addListener('civi.dao.postDelete', array('\CRM_Core_BAO_RecurringEntity', 'triggerDelete'));
- $dispatcher->addListener('hook_civicrm_unhandled_exception', array(
+ $dispatcher->addListener('hook_civicrm_eventDefs', ['\Civi\API\Events', 'hookEventDefs']);
+ $dispatcher->addListener('hook_civicrm_eventDefs', ['\Civi\Core\Event\SystemInstallEvent', 'hookEventDefs']);
+ $dispatcher->addListener('hook_civicrm_buildAsset', ['\Civi\Angular\Page\Modules', 'buildAngularModules']);
+ $dispatcher->addListener('hook_civicrm_buildAsset', ['\CRM_Utils_VisualBundle', 'buildAssetJs']);
+ $dispatcher->addListener('hook_civicrm_buildAsset', ['\CRM_Utils_VisualBundle', 'buildAssetCss']);
+ $dispatcher->addListener('civi.dao.postInsert', ['\CRM_Core_BAO_RecurringEntity', 'triggerInsert']);
+ $dispatcher->addListener('civi.dao.postUpdate', ['\CRM_Core_BAO_RecurringEntity', 'triggerUpdate']);
+ $dispatcher->addListener('civi.dao.postDelete', ['\CRM_Core_BAO_RecurringEntity', 'triggerDelete']);
+ $dispatcher->addListener('hook_civicrm_unhandled_exception', [
'CRM_Core_LegacyErrorHandler',
'handleException',
- ), -200);
- $dispatcher->addListener(\Civi\ActionSchedule\Events::MAPPINGS, array('CRM_Activity_ActionMapping', 'onRegisterActionMappings'));
- $dispatcher->addListener(\Civi\ActionSchedule\Events::MAPPINGS, array('CRM_Contact_ActionMapping', 'onRegisterActionMappings'));
- $dispatcher->addListener(\Civi\ActionSchedule\Events::MAPPINGS, array('CRM_Contribute_ActionMapping_ByPage', 'onRegisterActionMappings'));
- $dispatcher->addListener(\Civi\ActionSchedule\Events::MAPPINGS, array('CRM_Contribute_ActionMapping_ByType', 'onRegisterActionMappings'));
- $dispatcher->addListener(\Civi\ActionSchedule\Events::MAPPINGS, array('CRM_Event_ActionMapping', 'onRegisterActionMappings'));
- $dispatcher->addListener(\Civi\ActionSchedule\Events::MAPPINGS, array('CRM_Member_ActionMapping', 'onRegisterActionMappings'));
+ ], -200);
+ $dispatcher->addListener(\Civi\ActionSchedule\Events::MAPPINGS, ['CRM_Activity_ActionMapping', 'onRegisterActionMappings']);
+ $dispatcher->addListener(\Civi\ActionSchedule\Events::MAPPINGS, ['CRM_Contact_ActionMapping', 'onRegisterActionMappings']);
+ $dispatcher->addListener(\Civi\ActionSchedule\Events::MAPPINGS, ['CRM_Contribute_ActionMapping_ByPage', 'onRegisterActionMappings']);
+ $dispatcher->addListener(\Civi\ActionSchedule\Events::MAPPINGS, ['CRM_Contribute_ActionMapping_ByType', 'onRegisterActionMappings']);
+ $dispatcher->addListener(\Civi\ActionSchedule\Events::MAPPINGS, ['CRM_Event_ActionMapping', 'onRegisterActionMappings']);
+ $dispatcher->addListener(\Civi\ActionSchedule\Events::MAPPINGS, ['CRM_Member_ActionMapping', 'onRegisterActionMappings']);
if (\CRM_Utils_Constant::value('CIVICRM_FLEXMAILER_HACK_LISTENERS')) {
- \Civi\Core\Resolver::singleton()->call(CIVICRM_FLEXMAILER_HACK_LISTENERS, array($dispatcher));
+ \Civi\Core\Resolver::singleton()->call(CIVICRM_FLEXMAILER_HACK_LISTENERS, [$dispatcher]);
}
return $dispatcher;
// the container. For now, we'll make-do with some define()s.
$lm = new LockManager();
$lm
- ->register('/^cache\./', defined('CIVICRM_CACHE_LOCK') ? CIVICRM_CACHE_LOCK : array('CRM_Core_Lock', 'createScopedLock'))
- ->register('/^data\./', defined('CIVICRM_DATA_LOCK') ? CIVICRM_DATA_LOCK : array('CRM_Core_Lock', 'createScopedLock'))
- ->register('/^worker\.mailing\.send\./', defined('CIVICRM_WORK_LOCK') ? CIVICRM_WORK_LOCK : array('CRM_Core_Lock', 'createCivimailLock'))
- ->register('/^worker\./', defined('CIVICRM_WORK_LOCK') ? CIVICRM_WORK_LOCK : array('CRM_Core_Lock', 'createScopedLock'));
+ ->register('/^cache\./', defined('CIVICRM_CACHE_LOCK') ? CIVICRM_CACHE_LOCK : ['CRM_Core_Lock', 'createScopedLock'])
+ ->register('/^data\./', defined('CIVICRM_DATA_LOCK') ? CIVICRM_DATA_LOCK : ['CRM_Core_Lock', 'createScopedLock'])
+ ->register('/^worker\.mailing\.send\./', defined('CIVICRM_WORK_LOCK') ? CIVICRM_WORK_LOCK : ['CRM_Core_Lock', 'createCivimailLock'])
+ ->register('/^worker\./', defined('CIVICRM_WORK_LOCK') ? CIVICRM_WORK_LOCK : ['CRM_Core_Lock', 'createScopedLock']);
// Registrations may use complex resolver expressions, but (as a micro-optimization)
// the default factory is specified as an array.
$dispatcher->addSubscriber($magicFunctionProvider);
$dispatcher->addSubscriber(new \Civi\API\Subscriber\PermissionCheck());
$dispatcher->addSubscriber(new \Civi\API\Subscriber\APIv3SchemaAdapter());
- $dispatcher->addSubscriber(new \Civi\API\Subscriber\WrapperAdapter(array(
+ $dispatcher->addSubscriber(new \Civi\API\Subscriber\WrapperAdapter([
\CRM_Utils_API_HTMLInputCoder::singleton(),
\CRM_Utils_API_NullOutputCoder::singleton(),
\CRM_Utils_API_ReloadOption::singleton(),
\CRM_Utils_API_MatchOption::singleton(),
- )));
+ ]));
$dispatcher->addSubscriber(new \Civi\API\Subscriber\XDebugSubscriber());
$kernel = new \Civi\API\Kernel($dispatcher);
$dispatcher->addSubscriber(new \Civi\API\Subscriber\DynamicFKAuthorization(
$kernel,
'Attachment',
- array('create', 'get', 'delete'),
+ ['create', 'get', 'delete'],
// Given a file ID, determine the entity+table it's attached to.
'SELECT if(cf.id,1,0) as is_valid, cef.entity_table, cef.entity_id
FROM civicrm_file cf
INNER JOIN civicrm_custom_group grp ON fld.custom_group_id = grp.id
WHERE fld.data_type = "File"
',
- array('civicrm_activity', 'civicrm_mailing', 'civicrm_contact', 'civicrm_grant')
+ ['civicrm_activity', 'civicrm_mailing', 'civicrm_contact', 'civicrm_grant']
));
- $kernel->setApiProviders(array(
+ $kernel->setApiProviders([
$reflectionProvider,
$magicFunctionProvider,
- ));
+ ]);
return $kernel;
}
*/
public static function boot($loadFromDB) {
// Array(string $serviceId => object $serviceInstance).
- $bootServices = array();
+ $bootServices = [];
\Civi::$statics[__CLASS__]['boot'] = &$bootServices;
$bootServices['runtime'] = $runtime = new \CRM_Core_Config_Runtime();
$userPermissionClass = 'CRM_Core_Permission_' . $runtime->userFramework;
$bootServices['userPermissionClass'] = new $userPermissionClass();
- $bootServices['cache.settings'] = \CRM_Utils_Cache::create(array(
+ $bootServices['cache.settings'] = \CRM_Utils_Cache::create([
'name' => 'settings',
- 'type' => array('*memory*', 'SqlGroup', 'ArrayCache'),
- ));
+ 'type' => ['*memory*', 'SqlGroup', 'ArrayCache'],
+ ]);
$bootServices['settings_manager'] = new \Civi\Core\SettingsManager($bootServices['cache.settings']);
* @throws \CRM_Core_Exception
*/
public static function initialize(SystemInstallEvent $event) {
- $api_params = array(
+ $api_params = [
'version' => 3,
'triggers' => 1,
'session' => 1,
- );
+ ];
civicrm_api('System', 'flush', $api_params);
}
* @var mixed
* @deprecated
*/
- private $returnValues = array();
+ private $returnValues = [];
/**
* List of field names that are prohibited due to conflicts
*
* @var array
*/
- private static $BLACKLIST = array(
+ private static $BLACKLIST = [
'name',
'dispatcher',
'propagationStopped',
'hookValues',
'hookFields',
'hookFieldsFlip',
- );
+ ];
/**
* Create a GenericHookEvent using key-value pairs.
* @inheritDoc
*/
public function getHookValues() {
- return array($this->action, $this->entity, $this->id, &$this->object);
+ return [$this->action, $this->entity, $this->id, &$this->object];
}
}
* @inheritDoc
*/
public function getHookValues() {
- return array($this->action, $this->entity, $this->id, &$this->params);
+ return [$this->action, $this->entity, $this->id, &$this->params];
}
}
* @inheritDoc
*/
public function getHookValues() {
- return array($this->exception, $this->request);
+ return [$this->exception, $this->request];
}
}
$fileName = $localeDir . $seedLanguage . DIRECTORY_SEPARATOR . 'settings.default.json';
// initalization
- $settingsParams = array();
+ $settingsParams = [];
if (file_exists($fileName)) {
if (!empty($settings)) {
// get all valid settings
- $results = civicrm_api3('Setting', 'getfields', array());
+ $results = civicrm_api3('Setting', 'getfields', []);
$validSettings = array_keys($results['values']);
// add valid settings to params to send to api
foreach ($settings as $setting => $value) {
// set default currency in currencies_enabled (option group)
if (isset($settings['defaultCurrency'])) {
- \CRM_Admin_Form_Setting_Localization::updateEnabledCurrencies(array($settings['defaultCurrency']), $settings['defaultCurrency']);
+ \CRM_Admin_Form_Setting_Localization::updateEnabledCurrencies([$settings['defaultCurrency']], $settings['defaultCurrency']);
}
}
*/
class LockManager {
- private $rules = array();
+ private $rules = [];
/**
* @param string $name
$factory = $this->getFactory($name);
if ($factory) {
/** @var LockInterface $lock */
- $lock = call_user_func_array($factory, array($name));
+ $lock = call_user_func_array($factory, [$name]);
return $lock;
}
else {
* @see Resolver
*/
public function register($pattern, $factory) {
- $this->rules[] = array(
+ $this->rules[] = [
'pattern' => $pattern,
'factory' => $factory,
- );
+ ];
return $this;
}
* @var array
* Array(string $name => array(url => $, path => $)).
*/
- private $variables = array();
+ private $variables = [];
- private $variableFactory = array();
+ private $variableFactory = [];
/**
* Class constructor.
return \CRM_Core_Config::singleton()->userSystem->getCiviSourceStorage();
})
->register('civicrm.packages', function () {
- return array(
+ return [
'path' => \Civi::paths()->getPath('[civicrm.root]/packages/'),
'url' => \Civi::paths()->getUrl('[civicrm.root]/packages/'),
- );
+ ];
})
->register('civicrm.vendor', function () {
- return array(
+ return [
'path' => \Civi::paths()->getPath('[civicrm.root]/vendor/'),
'url' => \Civi::paths()->getUrl('[civicrm.root]/vendor/'),
- );
+ ];
})
->register('civicrm.bower', function () {
- return array(
+ return [
'path' => \Civi::paths()->getPath('[civicrm.root]/bower_components/'),
'url' => \Civi::paths()->getUrl('[civicrm.root]/bower_components/'),
- );
+ ];
})
->register('civicrm.files', function () {
return \CRM_Core_Config::singleton()->userSystem->getDefaultFileStorage();
})
->register('wp.frontend.base', function () {
- return array('url' => rtrim(CIVICRM_UF_BASEURL, '/') . '/');
+ return ['url' => rtrim(CIVICRM_UF_BASEURL, '/') . '/'];
})
->register('wp.frontend', function () use ($paths) {
$config = \CRM_Core_Config::singleton();
$suffix = defined('CIVICRM_UF_WP_BASEPAGE') ? CIVICRM_UF_WP_BASEPAGE : $config->wpBasePage;
- return array(
+ return [
'url' => $paths->getVariable('wp.frontend.base', 'url') . $suffix,
- );
+ ];
})
->register('wp.backend.base', function () {
- return array('url' => rtrim(CIVICRM_UF_BASEURL, '/') . '/wp-admin/');
+ return ['url' => rtrim(CIVICRM_UF_BASEURL, '/') . '/wp-admin/'];
})
->register('wp.backend', function () use ($paths) {
- return array(
+ return [
'url' => $paths->getVariable('wp.backend.base', 'url') . 'admin.php',
- );
+ ];
})
->register('cms', function () {
- return array(
+ return [
'path' => \CRM_Core_Config::singleton()->userSystem->cmsRootPath(),
'url' => \CRM_Utils_System::baseCMSURL(),
- );
+ ];
})
->register('cms.root', function () {
- return array(
+ return [
'path' => \CRM_Core_Config::singleton()->userSystem->cmsRootPath(),
// Misleading: this *removes* the language part of the URL, producing a pristine base URL.
'url' => \CRM_Utils_System::languageNegotiationURL(\CRM_Utils_System::baseCMSURL(), FALSE, TRUE),
- );
+ ];
});
}
case 'call':
// Callback: Object/method in container.
$obj = \Civi::service($url['host']);
- return array($obj, ltrim($url['path'], '/'));
+ return [$obj, ltrim($url['path'], '/')];
case 'api3':
// Callback: API.
throw new \RuntimeException("Unsupported callback scheme: " . $url['scheme']);
}
}
- elseif (in_array($id, array('0', '1'))) {
+ elseif (in_array($id, ['0', '1'])) {
// Callback: Constant value.
return new ResolverConstantCallback((int) $id);
}
* Fire an API call.
*/
public function __invoke() {
- $apiParams = array();
+ $apiParams = [];
if (isset($this->url['query'])) {
parse_str($this->url['query'], $apiParams);
}
* (e.g. "@1" => "firstValue").
*/
protected function createPlaceholders($prefix, $args) {
- $result = array();
+ $result = [];
foreach ($args as $offset => $arg) {
$result[$prefix . (1 + $offset)] = $arg;
}
public function __construct($domainId, $contactId) {
$this->domainId = $domainId;
$this->contactId = $contactId;
- $this->values = array();
+ $this->values = [];
$this->combined = NULL;
}
// Note: Don't use DAO child classes. They require fields() which require
// translations -- which are keyed off settings!
- $this->values = array();
+ $this->values = [];
$this->combined = NULL;
// Ordinarily, we just load values from `civicrm_setting`. But upgrades require care.
if ($isUpgradeMode && empty($this->contactId) && \CRM_Core_BAO_SchemaHandler::checkIfFieldExists('civicrm_domain', 'config_backend', FALSE)) {
$config_backend = \CRM_Core_DAO::singleValueQuery('SELECT config_backend FROM civicrm_domain WHERE id = %1',
- array(1 => array($this->domainId, 'Positive')));
+ [1 => [$this->domainId, 'Positive']]);
$oldSettings = \CRM_Upgrade_Incremental_php_FourSeven::convertBackendToSettings($this->domainId, $config_backend);
\CRM_Utils_Array::extend($this->values, $oldSettings);
}
public function all() {
if ($this->combined === NULL) {
$this->combined = $this->combine(
- array($this->defaults, $this->values, $this->mandatory)
+ [$this->defaults, $this->values, $this->mandatory]
);
}
return $this->combined;
protected function createQuery() {
$select = \CRM_Utils_SQL_Select::from('civicrm_setting')
->select('id, name, value, domain_id, contact_id, is_domain, component_id, created_date, created_id')
- ->where('domain_id = #id', array(
+ ->where('domain_id = #id', [
'id' => $this->domainId,
- ));
+ ]);
if ($this->contactId === NULL) {
$select->where('is_domain = 1');
}
else {
- $select->where('contact_id = #id', array(
+ $select->where('contact_id = #id', [
'id' => $this->contactId,
- ));
+ ]);
$select->where('is_domain = 0');
}
return $select;
* @return array
*/
protected function combine($arrays) {
- $combined = array();
+ $combined = [];
foreach ($arrays as $array) {
foreach ($array as $k => $v) {
if ($v !== NULL) {
* The new value of the setting.
*/
protected function setDb($name, $value) {
- $fields = array();
- $fieldsToSet = \CRM_Core_BAO_Setting::validateSettingsInput(array($name => $value), $fields);
+ $fields = [];
+ $fieldsToSet = \CRM_Core_BAO_Setting::validateSettingsInput([$name => $value], $fields);
//We haven't traditionally validated inputs to setItem, so this breaks things.
//foreach ($fieldsToSet as $settingField => &$settingValue) {
// self::validateSetting($settingValue, $fields['values'][$settingField]);
* @var
* Array (int $id => SettingsBag $bag).
*/
- protected $bagsByDomain = array(), $bagsByContact = array();
+ protected $bagsByDomain = [], $bagsByContact = [];
/**
* @var array|NULL
$cacheKey = 'defaults_' . $entity;
$defaults = $this->cache->get($cacheKey);
if (!is_array($defaults)) {
- $specs = SettingsMetadata::getMetadata(array(
+ $specs = SettingsMetadata::getMetadata([
'is_contact' => ($entity === 'contact' ? 1 : 0),
- ));
- $defaults = array();
+ ]);
+ $defaults = [];
foreach ($specs as $key => $spec) {
$defaults[$key] = \CRM_Utils_Array::value('default', $spec);
}
* @return array
*/
public static function parseMandatorySettings($civicrm_setting) {
- $result = array(
- 'domain' => array(),
- 'contact' => array(),
- );
+ $result = [
+ 'domain' => [],
+ 'contact' => [],
+ ];
- $rewriteGroups = array(
+ $rewriteGroups = [
//\CRM_Core_BAO_Setting::ADDRESS_STANDARDIZATION_PREFERENCES_NAME => 'domain',
//\CRM_Core_BAO_Setting::CAMPAIGN_PREFERENCES_NAME => 'domain',
//\CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME => 'domain',
//\CRM_Core_BAO_Setting::URL_PREFERENCES_NAME => 'domain',
'domain' => 'domain',
'contact' => 'contact',
- );
+ ];
if (is_array($civicrm_setting)) {
foreach ($civicrm_setting as $oldGroup => $values) {
* @return array
*/
private static function getSystemDefaults($entity) {
- $defaults = array();
+ $defaults = [];
switch ($entity) {
case 'domain':
- $defaults = array(
+ $defaults = [
'installed' => FALSE,
- 'enable_components' => array('CiviEvent', 'CiviContribute', 'CiviMember', 'CiviMail', 'CiviReport', 'CiviPledge'),
+ 'enable_components' => ['CiviEvent', 'CiviContribute', 'CiviMember', 'CiviMail', 'CiviReport', 'CiviPledge'],
'customFileUploadDir' => '[civicrm.files]/custom/',
'imageUploadDir' => '[civicrm.files]/persist/contribute/',
'uploadDir' => '[civicrm.files]/upload/',
'extensionsURL' => '[civicrm.files]/ext/',
'resourceBase' => '[civicrm.root]/',
'userFrameworkResourceURL' => '[civicrm.root]/',
- );
+ ];
break;
}
* - description
* - help_text
*/
- public static function getMetadata($filters = array(), $domainID = NULL) {
+ public static function getMetadata($filters = [], $domainID = NULL) {
if ($domainID === NULL) {
$domainID = \CRM_Core_Config::domainID();
}
$settingsMetadata = $cache->get(self::ALL);
if (empty($settingsMetadata)) {
global $civicrm_root;
- $metaDataFolders = array($civicrm_root . '/settings');
+ $metaDataFolders = [$civicrm_root . '/settings'];
\CRM_Utils_Hook::alterSettingsFolders($metaDataFolders);
$settingsMetadata = self::loadSettingsMetaDataFolders($metaDataFolders);
$cache->set(self::ALL, $settingsMetadata);
* @return array
*/
protected static function loadSettingsMetaDataFolders($metaDataFolders) {
- $settingsMetadata = array();
- $loadedFolders = array();
+ $settingsMetadata = [];
+ $loadedFolders = [];
foreach ($metaDataFolders as $metaDataFolder) {
$realFolder = realpath($metaDataFolder);
if (is_dir($realFolder) && !isset($loadedFolders[$realFolder])) {
* @return array
*/
protected static function loadSettingsMetadata($metaDataFolder) {
- $settingMetaData = array();
+ $settingMetaData = [];
$settingsFiles = \CRM_Utils_File::findFiles($metaDataFolder, '*.setting.php');
foreach ($settingsFiles as $file) {
$settings = include $file;
if (empty($filters)) {
return;
}
- elseif (array_keys($filters) == array('name')) {
- $settingSpec = array($filters['name'] => \CRM_Utils_Array::value($filters['name'], $settingSpec, ''));
+ elseif (array_keys($filters) == ['name']) {
+ $settingSpec = [$filters['name'] => \CRM_Utils_Array::value($filters['name'], $settingSpec, '')];
return;
}
else {
* @var array
* Ex: $stack[0] == ['settingName', 'oldSettingValue'];
*/
- protected $stack = array();
+ protected $stack = [];
/**
* Temporarily apply a setting.
*/
public function push($setting, $settingValue) {
if (isset($GLOBALS['civicrm_setting']['domain'][$setting])) {
- $this->stack[] = array($setting, $GLOBALS['civicrm_setting']['domain'][$setting]);
+ $this->stack[] = [$setting, $GLOBALS['civicrm_setting']['domain'][$setting]];
}
else {
- $this->stack[] = array($setting, NULL);
+ $this->stack[] = [$setting, NULL];
}
$GLOBALS['civicrm_setting']['domain'][$setting] = $settingValue;
\Civi::service('settings_manager')->useMandatory();
$customDataEntity,
$createdDate = 'created_date',
$modifiedDate = 'modified_date',
- $relations = array()
+ $relations = []
) {
$this->tableName = $tableName;
$this->customDataEntity = $customDataEntity;
}
if ($tableFilter == NULL || $tableFilter == $this->getTableName()) {
- $info[] = array(
- 'table' => array($this->getTableName()),
+ $info[] = [
+ 'table' => [$this->getTableName()],
'when' => 'BEFORE',
- 'event' => array('INSERT'),
+ 'event' => ['INSERT'],
'sql' => "\nSET NEW.{$this->getCreatedDate()} = CURRENT_TIMESTAMP;\n",
- );
+ ];
}
// Update timestamp when modifying closely related tables
$relIdx = \CRM_Utils_Array::index(
- array('column', 'table'),
+ ['column', 'table'],
$this->getAllRelations()
);
foreach ($relIdx as $column => $someRelations) {
// If specific related table requested, just process that one.
// (Reply: This feels fishy.)
if (in_array($tableFilter, $relatedTableNames)) {
- $relatedTableNames = array($tableFilter);
+ $relatedTableNames = [$tableFilter];
}
// If no specific table requested (include all related tables),
// or a specific related table requested (as matched above)
if (empty($tableFilter) || isset($relatedTableNames[$tableFilter])) {
- $info[] = array(
+ $info[] = [
'table' => $relatedTableNames,
'when' => 'AFTER',
- 'event' => array('INSERT', 'UPDATE'),
+ 'event' => ['INSERT', 'UPDATE'],
'sql' => "\nUPDATE {$this->getTableName()} SET {$this->getModifiedDate()} = CURRENT_TIMESTAMP WHERE id = NEW.$contactRefColumn;\n",
- );
- $info[] = array(
+ ];
+ $info[] = [
'table' => $relatedTableNames,
'when' => 'AFTER',
- 'event' => array('DELETE'),
+ 'event' => ['DELETE'],
'sql' => "\nUPDATE {$this->getTableName()} SET {$this->getModifiedDate()} = CURRENT_TIMESTAMP WHERE id = OLD.$contactRefColumn;\n",
- );
+ ];
}
}
$customGroupDAO->is_multiple = 0;
$customGroupDAO->find();
while ($customGroupDAO->fetch()) {
- $relations[] = array(
+ $relations[] = [
'table' => $customGroupDAO->table_name,
'column' => 'entity_id',
- );
+ ];
}
}
* @see CRM-9716
*/
public function rebuild($tableName = NULL, $force = FALSE) {
- $info = array();
+ $info = [];
$logging = new \CRM_Logging_Schema();
$logging->triggerInfo($info, $tableName, $force);
return;
}
- $triggers = array();
+ $triggers = [];
// now enumerate the tables and the events and collect the same set in a different format
foreach ($info as $value) {
}
if (is_string($value['table']) == TRUE) {
- $tables = array($value['table']);
+ $tables = [$value['table']];
}
else {
$tables = $value['table'];
}
if (is_string($value['event']) == TRUE) {
- $events = array(strtolower($value['event']));
+ $events = [strtolower($value['event'])];
}
else {
$events = array_map('strtolower', $value['event']);
foreach ($tables as $tableName) {
if (!isset($triggers[$tableName])) {
- $triggers[$tableName] = array();
+ $triggers[$tableName] = [];
}
foreach ($events as $eventName) {
- $template_params = array('{tableName}', '{eventName}');
- $template_values = array($tableName, $eventName);
+ $template_params = ['{tableName}', '{eventName}'];
+ $template_values = [$tableName, $eventName];
$sql = str_replace($template_params,
$template_values,
);
if (!isset($triggers[$tableName][$eventName])) {
- $triggers[$tableName][$eventName] = array();
+ $triggers[$tableName][$eventName] = [];
}
if (!isset($triggers[$tableName][$eventName][$whenName])) {
// We're leaving out cursors, conditions, and handlers for now
// they are kind of dangerous in this context anyway
// better off putting them in stored procedures
- $triggers[$tableName][$eventName][$whenName] = array(
- 'variables' => array(),
- 'sql' => array(),
- );
+ $triggers[$tableName][$eventName][$whenName] = [
+ 'variables' => [],
+ 'sql' => [],
+ ];
}
if ($variables) {
* the specific table requiring a rebuild; or NULL to rebuild all tables.
*/
public function dropTriggers($tableName = NULL) {
- $info = array();
+ $info = [];
$logging = new \CRM_Logging_Schema();
$logging->triggerInfo($info, $tableName);
* @param array $params
* Optional parameters to interpolate into the string.
*/
- public function enqueueQuery($triggerSQL, $params = array()) {
+ public function enqueueQuery($triggerSQL, $params = []) {
if (\Civi::settings()->get('logging_no_trigger_permission')) {
if (!file_exists($this->getFile())) {
// Ugh. Need to let user know somehow. This is the first change.
- \CRM_Core_Session::setStatus(ts('The mysql commands you need to run are stored in %1', array(
+ \CRM_Core_Session::setStatus(ts('The mysql commands you need to run are stored in %1', [
1 => $this->getFile(),
- )),
+ ]),
'',
'alert',
- array('expires' => 0)
+ ['expires' => 0]
);
}
$this->commitStmt = $commitStmt;
$this->rollbackStmt = $rollbackStmt;
- $this->callbacks = array(
- \CRM_Core_Transaction::PHASE_PRE_COMMIT => array(),
- \CRM_Core_Transaction::PHASE_POST_COMMIT => array(),
- \CRM_Core_Transaction::PHASE_PRE_ROLLBACK => array(),
- \CRM_Core_Transaction::PHASE_POST_ROLLBACK => array(),
- );
+ $this->callbacks = [
+ \CRM_Core_Transaction::PHASE_PRE_COMMIT => [],
+ \CRM_Core_Transaction::PHASE_POST_COMMIT => [],
+ \CRM_Core_Transaction::PHASE_PRE_ROLLBACK => [],
+ \CRM_Core_Transaction::PHASE_POST_ROLLBACK => [],
+ ];
}
public function inc() {
*/
public function addCallback($phase, $callback, $params = NULL, $id = NULL) {
if ($id) {
- $this->callbacks[$phase][$id] = array(
+ $this->callbacks[$phase][$id] = [
'callback' => $callback,
- 'parameters' => (is_array($params) ? $params : array($params)),
- );
+ 'parameters' => (is_array($params) ? $params : [$params]),
+ ];
}
else {
- $this->callbacks[$phase][] = array(
+ $this->callbacks[$phase][] = [
'callback' => $callback,
- 'parameters' => (is_array($params) ? $params : array($params)),
- );
+ 'parameters' => (is_array($params) ? $params : [$params]),
+ ];
}
}
/**
* @var array<Frame> stack of SQL transactions/savepoints
*/
- private $frames = array();
+ private $frames = [];
/**
* @var int
// internal state of each frame is consistent with its outcome
$oldFrames = $this->frames;
- $this->frames = array();
+ $this->frames = [];
foreach ($oldFrames as $oldFrame) {
$oldFrame->forceRollback();
}
*/
const REQUIREMENT_ERROR = 2;
- protected $system_checks = array(
+ protected $system_checks = [
'checkMemory',
'checkServerVariables',
'checkMysqlConnectExists',
'checkJsonEncodeExists',
'checkMultibyteExists',
- );
+ ];
- protected $database_checks = array(
+ protected $database_checks = [
'checkMysqlConnection',
'checkMysqlVersion',
'checkMysqlInnodb',
'checkMysqlThreadStack',
'checkMysqlLockTables',
'checkMysqlUtf8mb4',
- );
+ ];
/**
* Run all requirements tests.
* @return array
*/
public function checkSystem(array $file_paths) {
- $errors = array();
+ $errors = [];
$errors[] = $this->checkFilepathIsWritable($file_paths);
foreach ($this->system_checks as $check) {
* @return array
*/
public function checkDatabase(array $db_config) {
- $errors = array();
+ $errors = [];
foreach ($this->database_checks as $check) {
$errors[] = $this->$check($db_config);
$mem = $this->getPHPMemory();
$mem_string = ini_get('memory_limit');
- $results = array(
+ $results = [
'title' => 'CiviCRM memory check',
'severity' => $this::REQUIREMENT_OK,
'details' => "You have $mem_string allocated (minimum 32Mb, recommended 64Mb)",
- );
+ ];
if ($mem < $min && $mem > 0) {
$results['severity'] = $this::REQUIREMENT_ERROR;
* @return array
*/
public function checkServerVariables() {
- $results = array(
+ $results = [
'title' => 'CiviCRM PHP server variables',
'severity' => $this::REQUIREMENT_OK,
'details' => 'The required $_SERVER variables are set',
- );
+ ];
- $required_variables = array('SCRIPT_NAME', 'HTTP_HOST', 'SCRIPT_FILENAME');
- $missing = array();
+ $required_variables = ['SCRIPT_NAME', 'HTTP_HOST', 'SCRIPT_FILENAME'];
+ $missing = [];
foreach ($required_variables as $required_variable) {
if (empty($_SERVER[$required_variable])) {
* @return array
*/
public function checkJsonEncodeExists() {
- $results = array(
+ $results = [
'title' => 'CiviCRM JSON encoding support',
'severity' => $this::REQUIREMENT_OK,
'details' => 'Function json_encode() found',
- );
+ ];
if (!function_exists('json_encode')) {
$results['severity'] = $this::REQUIREMENT_ERROR;
$results['details'] = 'Function json_encode() does not exist';
* @return array
*/
public function checkMultibyteExists() {
- $results = array(
+ $results = [
'title' => 'CiviCRM MultiByte encoding support',
'severity' => $this::REQUIREMENT_OK,
'details' => 'PHP Multibyte etension found',
- );
+ ];
if (!function_exists('mb_substr')) {
$results['severity'] = $this::REQUIREMENT_ERROR;
$results['details'] = 'PHP Multibyte extension has not been installed and enabled';
* @return array
*/
public function checkMysqlConnectExists() {
- $results = array(
+ $results = [
'title' => 'CiviCRM MySQL check',
'severity' => $this::REQUIREMENT_OK,
'details' => 'Function mysqli_connect() found',
- );
+ ];
if (!function_exists('mysqli_connect')) {
$results['severity'] = $this::REQUIREMENT_ERROR;
$results['details'] = 'Function mysqli_connect() does not exist';
* @return array
*/
public function checkMysqlConnection(array $db_config) {
- $results = array(
+ $results = [
'title' => 'CiviCRM MySQL connection',
'severity' => $this::REQUIREMENT_OK,
'details' => "Connected",
- );
+ ];
$conn = $this->connect($db_config);
*/
public function checkMysqlVersion(array $db_config) {
$min = '5.1';
- $results = array(
+ $results = [
'title' => 'CiviCRM MySQL Version',
'severity' => $this::REQUIREMENT_OK,
- );
+ ];
$conn = $this->connect($db_config);
if (!$conn || !($info = mysqli_get_server_info($conn))) {
* @return array
*/
public function checkMysqlInnodb(array $db_config) {
- $results = array(
+ $results = [
'title' => 'CiviCRM InnoDB support',
'severity' => $this::REQUIREMENT_ERROR,
'details' => 'Could not determine if MySQL has InnoDB support. Assuming none.',
- );
+ ];
$conn = $this->connect($db_config);
if (!$conn) {
* @return array
*/
public function checkMysqlTempTables(array $db_config) {
- $results = array(
+ $results = [
'title' => 'CiviCRM MySQL Temp Tables',
'severity' => $this::REQUIREMENT_OK,
'details' => 'MySQL server supports temporary tables',
- );
+ ];
$conn = $this->connect($db_config);
if (!$conn) {
* @return array
*/
public function checkMysqlTrigger($db_config) {
- $results = array(
+ $results = [
'title' => 'CiviCRM MySQL Trigger',
'severity' => $this::REQUIREMENT_OK,
'details' => 'Database supports MySQL triggers',
- );
+ ];
$conn = $this->connect($db_config);
if (!$conn) {
* @return array
*/
public function checkMySQLAutoIncrementIncrementOne(array $db_config) {
- $results = array(
+ $results = [
'title' => 'CiviCRM MySQL AutoIncrementIncrement',
'severity' => $this::REQUIREMENT_OK,
'details' => 'MySQL server auto_increment_increment is 1',
- );
+ ];
$conn = $this->connect($db_config);
if (!$conn) {
public function checkMysqlThreadStack($db_config) {
$min_thread_stack = 192;
- $results = array(
+ $results = [
'title' => 'CiviCRM Mysql thread stack',
'severity' => $this::REQUIREMENT_OK,
'details' => 'MySQL thread_stack is OK',
- );
+ ];
$conn = $this->connect($db_config);
if (!$conn) {
* @return array
*/
public function checkMysqlLockTables($db_config) {
- $results = array(
+ $results = [
'title' => 'CiviCRM MySQL Lock Tables',
'severity' => $this::REQUIREMENT_OK,
'details' => 'Can successfully lock and unlock tables',
- );
+ ];
$conn = $this->connect($db_config);
if (!$conn) {
* @return array
*/
public function checkFilepathIsWritable($file_paths) {
- $results = array(
+ $results = [
'title' => 'CiviCRM directories are writable',
'severity' => $this::REQUIREMENT_OK,
'details' => 'All required directories are writable: ' . implode(', ', $file_paths),
- );
+ ];
- $unwritable_dirs = array();
+ $unwritable_dirs = [];
foreach ($file_paths as $path) {
if (!is_writable($path)) {
$unwritable_dirs[] = $path;
* @return array
*/
public function checkMysqlUtf8mb4($db_config) {
- $results = array(
+ $results = [
'title' => 'CiviCRM MySQL utf8mb4 Support',
'severity' => $this::REQUIREMENT_OK,
'details' => 'Your system supports the MySQL utf8mb4 character set.',
- );
+ ];
$conn = $this->connect($db_config);
if (!$conn) {
/**
* @var array cache
*/
- private $cache = array();
+ private $cache = [];
/**
* @return \Civi\Payment\System
if ($id == 0) {
return new \CRM_Core_Payment_Manual();
}
- $processor = civicrm_api3('payment_processor', 'getsingle', array('id' => $id, 'is_test' => NULL));
+ $processor = civicrm_api3('payment_processor', 'getsingle', ['id' => $id, 'is_test' => NULL]);
return self::getByProcessor($processor);
}
* @throws \CiviCRM_API3_Exception
*/
public function getByName($name, $is_test) {
- $processor = civicrm_api3('payment_processor', 'getsingle', array('name' => $name, 'is_test' => $is_test));
+ $processor = civicrm_api3('payment_processor', 'getsingle', ['name' => $name, 'is_test' => $is_test]);
return self::getByProcessor($processor);
}
* This is particularly used for tests.
*/
public function flushProcessors() {
- $this->cache = array();
+ $this->cache = [];
\CRM_Financial_BAO_PaymentProcessor::getAllPaymentProcessors('all', TRUE);
\CRM_Financial_BAO_PaymentProcessor::getAllPaymentProcessors('live', TRUE);
\CRM_Financial_BAO_PaymentProcessor::getAllPaymentProcessors('test', TRUE);
* @throws \CiviCRM_API3_Exception
*/
public function getByClass($className) {
- return $this->getByProcessor(array(
+ return $this->getByProcessor([
'class_name' => $className,
'id' => 0,
'is_test' => 0,
- ),
+ ],
TRUE);
}
/**
* @var array
*/
- private static $singletons = array();
+ private static $singletons = [];
/**
* Get the data source used for testing.
try {
self::$singletons['pdo'] = new PDO("mysql:host={$host}" . ($port ? ";port=$port" : ""),
$dsninfo['username'], $dsninfo['password'],
- array(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => TRUE)
+ [PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => TRUE]
);
}
catch (PDOException $e) {
// Attempt to convert lowercase action name to CamelCase.
// This is clunky/imperfect due to the convention of all lowercase actions.
$exampleName = \CRM_Utils_String::convertStringToCamel($action);
- $knownPrefixes = array(
+ $knownPrefixes = [
'Get',
'Set',
'Create',
'Update',
'Send',
- );
+ ];
foreach ($knownPrefixes as $prefix) {
if (strpos($exampleName, $prefix) === 0 && $prefix != $exampleName) {
$exampleName[strlen($prefix)] = strtoupper($exampleName[strlen($prefix)]);
unset($params['version']);
}
// Format multiline description as array
- $desc = array();
+ $desc = [];
if (is_string($description) && strlen($description)) {
foreach (explode("\n", $description) as $line) {
$desc[] = trim($line);
if (!is_array($result)) {
return;
}
- $fieldsToChange = array(
+ $fieldsToChange = [
'hash' => '67eac7789eaee00',
'modified_date' => '2012-11-14 16:02:35',
'created_date' => '2013-07-28 08:49:19',
'end_date' => '2013-08-04 00:00:00',
'event_end_date' => '2013-08-04 00:00:00',
'decision_date' => '20130805000000',
- );
+ ];
- $keysToUnset = array('xdebug', 'undefined_fields');
+ $keysToUnset = ['xdebug', 'undefined_fields'];
foreach ($keysToUnset as $unwantedKey) {
if (isset($result[$unwantedKey])) {
unset($result[$unwantedKey]);
* @param string $prefix
* Extra test to add to message.
*/
- public function assertAPIArrayComparison($result, $expected, $valuesToExclude = array(), $prefix = '') {
- $valuesToExclude = array_merge($valuesToExclude, array('debug', 'xdebug', 'sequential'));
+ public function assertAPIArrayComparison($result, $expected, $valuesToExclude = [], $prefix = '') {
+ $valuesToExclude = array_merge($valuesToExclude, ['debug', 'xdebug', 'sequential']);
foreach ($valuesToExclude as $value) {
if (isset($result[$value])) {
unset($result[$value]);
* @param $id
*/
public function assertAPIDeleted($entity, $id) {
- $this->callAPISuccess($entity, 'getcount', array('id' => $id), 0);
+ $this->callAPISuccess($entity, 'getcount', ['id' => $id], 0);
}
/**
*/
public function callAPIFailure($entity, $action, $params, $expectedErrorMessage = NULL, $extraOutput = NULL) {
if (is_array($params)) {
- $params += array(
+ $params += [
'version' => $this->_apiversion,
- );
+ ];
}
$result = $this->civicrm_api($entity, $action, $params);
$this->assertAPIFailure($result, "We expected a failure for $entity $action but got a success", $expectedErrorMessage);
* @return array|int
*/
public function callAPISuccess($entity, $action, $params, $checkAgainst = NULL) {
- $params = array_merge(array(
+ $params = array_merge([
'version' => $this->_apiversion,
'debug' => 1,
- ),
+ ],
$params
);
switch (strtolower($action)) {
* @return array|int
*/
public function callAPISuccessGetCount($entity, $params, $count = NULL) {
- $params += array(
+ $params += [
'version' => $this->_apiversion,
'debug' => 1,
- );
+ ];
$result = $this->civicrm_api($entity, 'getcount', $params);
if (!is_int($result) || !empty($result['is_error']) || isset($result['values'])) {
throw new \Exception('Invalid getcount result : ' . print_r($result, TRUE) . " type :" . gettype($result));
* @return array|int
*/
public function callAPISuccessGetSingle($entity, $params, $checkAgainst = NULL) {
- $params += array(
+ $params += [
'version' => $this->_apiversion,
- );
+ ];
$result = $this->civicrm_api($entity, 'getsingle', $params);
if (!is_array($result) || !empty($result['is_error']) || isset($result['values'])) {
$unfilteredResult = $this->civicrm_api($entity, 'get', $params);
* @return array|int
*/
public function callAPISuccessGetValue($entity, $params, $type = NULL) {
- $params += array(
+ $params += [
'version' => $this->_apiversion,
'debug' => 1,
- );
+ ];
$result = $this->civicrm_api($entity, 'getvalue', $params);
if (is_array($result) && (!empty($result['is_error']) || isset($result['values']))) {
throw new \Exception('Invalid getvalue result' . print_r($result, TRUE));
class CiviEnvBuilder {
protected $name;
- private $steps = array();
+ private $steps = [];
/**
* @var string|NULL
}
public function isValid() {
- if (!in_array($this->action, array('install', 'uninstall'))) {
+ if (!in_array($this->action, ['install', 'uninstall'])) {
return FALSE;
}
foreach ($this->names as $name) {
public function getSig() {
- return implode(' ', array(
+ return implode(' ', [
$this->file,
filemtime($this->file),
filectime($this->file),
- ));
+ ]);
}
public function isValid() {
* Ex: $cache['Some_Test_Class']['civicrm_foobar'] = 'hook_civicrm_foobar';
* Array(string $testClass => Array(string $hookName => string $methodName)).
*/
- private $cache = array();
+ private $cache = [];
/**
* @var \CRM_Core_Transaction|NULL
}
public function endTestSuite(\PHPUnit_Framework_TestSuite $suite) {
- $this->cache = array();
+ $this->cache = [];
}
public function startTest(\PHPUnit_Framework_Test $test) {
protected function findTestHooks(HookInterface $test) {
$class = get_class($test);
if (!isset($this->cache[$class])) {
- $funcs = array();
+ $funcs = [];
foreach (get_class_methods($class) as $func) {
if (preg_match('/^hook_/', $func)) {
$funcs[substr($func, 5)] = $func;
/** @var \CRM_Utils_Hook_UnitTests $hooks */
$hooks = \CRM_Utils_Hook::singleton();
foreach ($this->findTestHooks($test) as $hook => $func) {
- $hooks->setHook($hook, array($test, $func));
+ $hooks->setHook($hook, [$test, $func]);
}
}
*/
protected function cv($cmd, $decode = 'json') {
$cmd = 'cv ' . $cmd;
- $descriptorSpec = array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => STDERR);
+ $descriptorSpec = [0 => ["pipe", "r"], 1 => ["pipe", "w"], 2 => STDERR];
$oldOutput = getenv('CV_OUTPUT');
putenv("CV_OUTPUT=json");
$process = proc_open($cmd, $descriptorSpec, $pipes, __DIR__);
* @return array
*/
protected function indexTestsByInterface($tests) {
- $byInterface = array('HeadlessInterface' => array(), 'EndToEndInterface' => array());
+ $byInterface = ['HeadlessInterface' => [], 'EndToEndInterface' => []];
foreach ($tests as $test) {
/** @var \PHPUnit_Framework_Test $test */
if ($test instanceof HeadlessInterface) {
\Civi\Test::schema()->setStrict(TRUE);
// Rebuild triggers
- civicrm_api('system', 'flush', array('version' => 3, 'triggers' => 1));
+ civicrm_api('system', 'flush', ['version' => 3, 'triggers' => 1]);
- \CRM_Core_BAO_ConfigSetting::setEnabledComponents(array(
+ \CRM_Core_BAO_ConfigSetting::setEnabledComponents([
'CiviEvent',
'CiviContribute',
'CiviMember',
'CiviMail',
'CiviReport',
'CiviPledge',
- ));
+ ]);
return TRUE;
}
$pdo->quote($type)
);
$tables = $pdo->query($query);
- $result = array();
+ $result = [];
foreach ($tables as $table) {
$result[] = $table['table_name'];
}
public function setStrict($checks) {
$dbName = \Civi\Test::dsn('database');
if ($checks) {
- $queries = array(
+ $queries = [
"USE {$dbName};",
"SET global innodb_flush_log_at_trx_commit = 1;",
"SET SQL_MODE='STRICT_ALL_TABLES';",
"SET foreign_key_checks = 1;",
- );
+ ];
}
else {
- $queries = array(
+ $queries = [
"USE {$dbName};",
"SET foreign_key_checks = 0",
"SET SQL_MODE='STRICT_ALL_TABLES';",
"SET global innodb_flush_log_at_trx_commit = 2;",
- );
+ ];
}
foreach ($queries as $query) {
if (\Civi\Test::execute($query) === FALSE) {
}
public function dropAll() {
- $queries = array();
+ $queries = [];
foreach ($this->getTables('VIEW') as $table) {
if (preg_match('/^(civicrm_|log_)/', $table)) {
$queries[] = "DROP VIEW $table";
public function truncateAll() {
$tables = \Civi\Test::schema()->getTables('BASE TABLE');
- $truncates = array();
- $drops = array();
+ $truncates = [];
+ $drops = [];
foreach ($tables as $table) {
// skip log tables
if (substr($table, 0, 4) == 'log_') {
abstract class AbstractTokenSubscriber implements EventSubscriberInterface {
public static function getSubscribedEvents() {
- return array(
+ return [
Events::TOKEN_REGISTER => 'registerTokens',
Events::TOKEN_EVALUATE => 'evaluateTokens',
\Civi\ActionSchedule\Events::MAILING_QUERY => 'alterActionScheduleQuery',
- );
+ ];
}
/**
* @param array $tokenNames
* Array(string $tokenName => string $label).
*/
- public function __construct($entity, $tokenNames = array()) {
+ public function __construct($entity, $tokenNames = []) {
$this->entity = $entity;
$this->tokenNames = $tokenNames;
}
return;
}
foreach ($this->tokenNames as $name => $label) {
- $e->register(array(
+ $e->register([
'entity' => $this->entity,
'field' => $name,
'label' => $label,
- ));
+ ]);
}
}
$params = $paramsOrField;
}
else {
- $params = array(
+ $params = [
'field' => $paramsOrField,
'label' => $label,
- );
+ ];
}
$params = array_merge($this->defaults, $params);
$this->tokenProcessor->addToken($params);
* @inheritDoc
*/
public static function getSubscribedEvents() {
- return array(
+ return [
Events::TOKEN_EVALUATE => 'onEvaluate',
Events::TOKEN_RENDER => 'onRender',
- );
+ ];
}
/**
// hook *categories* (aka entities aka namespaces). We'll cache
// this in the TokenProcessor's context.
- $hookTokens = array();
+ $hookTokens = [];
\CRM_Utils_Hook::tokens($hookTokens);
$categories = array_keys($hookTokens);
$e->getTokenProcessor()->context['hookTokenCategories'] = $categories;
/** @var int $contactId */
$contactId = $row->context['contactId'];
if (empty($row->context['contact'])) {
- $params = array(
- array('contact_id', '=', $contactId, 0, 0),
- );
+ $params = [
+ ['contact_id', '=', $contactId, 0, 0],
+ ];
list($contact, $_) = \CRM_Contact_BAO_Query::apiQuery($params);
$contact = reset($contact); //CRM-4524
if (!$contact || is_a($contact, 'CRM_Core_Error')) {
if (!empty($messageTokens['contact'])) {
foreach ($messageTokens['contact'] as $token) {
if (\CRM_Core_BAO_CustomField::getKeyID($token)) {
- $contact[$token] = civicrm_api3('Contact', 'getvalue', array(
+ $contact[$token] = civicrm_api3('Contact', 'getvalue', [
'return' => $token,
'id' => $contactId,
- ));
+ ]);
}
}
}
$contact = array_merge($contact, $row->context['tmpTokenParams']);
}
- $contactArray = !is_array($contactId) ? array($contactId => $contact) : $contact;
+ $contactArray = !is_array($contactId) ? [$contactId => $contact] : $contact;
// Note: This is a small contract change from the past; data should be missing
// less randomly.
* @return TokenProcessor
*/
public function addMessage($name, $value, $format) {
- $this->messages[$name] = array(
+ $this->messages[$name] = [
'string' => $value,
'format' => $format,
'tokens' => \CRM_Utils_Token::getTokens($value),
- );
+ ];
return $this;
}
*/
public function addRow() {
$key = $this->next++;
- $this->rowContexts[$key] = array();
- $this->rowValues[$key] = array(
- 'text/plain' => array(),
- 'text/html' => array(),
- );
+ $this->rowContexts[$key] = [];
+ $this->rowValues[$key] = [
+ 'text/plain' => [],
+ 'text/html' => [],
+ ];
return new TokenRow($this, $key);
}
* @return array
*/
public function getMessageTokens() {
- $tokens = array();
+ $tokens = [];
foreach ($this->messages as $message) {
$tokens = \CRM_Utils_Array::crmArrayMerge($tokens, $message['tokens']);
}
*/
public function getTokens() {
if ($this->tokens === NULL) {
- $this->tokens = array();
- $event = new TokenRegisterEvent($this, array('entity' => 'undefined'));
+ $this->tokens = [];
+ $event = new TokenRegisterEvent($this, ['entity' => 'undefined']);
$this->dispatcher->dispatch(Events::TOKEN_REGISTER, $event);
}
return $this->tokens;
*/
public function listTokens() {
if ($this->listTokens === NULL) {
- $this->listTokens = array();
+ $this->listTokens = [];
foreach ($this->getTokens() as $token => $values) {
$this->listTokens['{' . $token . '}'] = $values['label'];
}
// FIXME preg_callback.
$tokens = $this->rowValues[$row->tokenRow][$message['format']];
- $flatTokens = array();
+ $flatTokens = [];
\CRM_Utils_Array::flatten($tokens, $flatTokens, '', '.');
- $filteredTokens = array();
+ $filteredTokens = [];
foreach ($flatTokens as $k => $v) {
$filteredTokens['{' . $k . '}'] = ($useSmarty ? \CRM_Utils_Token::tokenEscapeSmarty($v) : $v);
}
}
if (!isset($this->tokenProcessor->rowValues[$this->tokenRow]['text/html'])) {
- $this->tokenProcessor->rowValues[$this->tokenRow]['text/html'] = array();
+ $this->tokenProcessor->rowValues[$this->tokenRow]['text/html'] = [];
}
if (!isset($this->tokenProcessor->rowValues[$this->tokenRow]['text/plain'])) {
- $this->tokenProcessor->rowValues[$this->tokenRow]['text/plain'] = array();
+ $this->tokenProcessor->rowValues[$this->tokenRow]['text/plain'] = [];
}
$htmlTokens = &$this->tokenProcessor->rowValues[$this->tokenRow]['text/html'];
case 'text/html':
// Plain => HTML.
foreach ($textTokens as $entity => $values) {
- $entityFields = civicrm_api3($entity, "getFields", array('api_action' => 'get'));
+ $entityFields = civicrm_api3($entity, "getFields", ['api_action' => 'get']);
foreach ($values as $field => $value) {
if (!isset($htmlTokens[$entity][$field])) {
// CRM-18420 - Activity Details Field are enclosed within <p>,
// in CiviCRM. See also:
// http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_angularModules
-return array(
+return [
'ext' => 'civicrm',
- 'js' => array('bower_components/angular-file-upload/angular-file-upload.min.js'),
-);
+ 'js' => ['bower_components/angular-file-upload/angular-file-upload.min.js'],
+];
// in CiviCRM. See also:
// http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_angularModules
-return array(
+return [
'ext' => 'civicrm',
- 'js' => array('ang/crmApp.js'),
-);
+ 'js' => ['ang/crmApp.js'],
+];
// in CiviCRM. See also:
// http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_angularModules
-return array(
+return [
'ext' => 'civicrm',
- 'js' => array('ang/crmAttachment.js'),
- 'css' => array('ang/crmAttachment.css'),
- 'partials' => array('ang/crmAttachment'),
- 'settings' => array(
+ 'js' => ['ang/crmAttachment.js'],
+ 'css' => ['ang/crmAttachment.css'],
+ 'partials' => ['ang/crmAttachment'],
+ 'settings' => [
'token' => \CRM_Core_Page_AJAX_Attachment::createToken(),
- ),
- 'requires' => array('angularFileUpload', 'crmResource'),
-);
+ ],
+ 'requires' => ['angularFileUpload', 'crmResource'],
+];
// in CiviCRM. See also:
// http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_angularModules
-return array(
+return [
'ext' => 'civicrm',
- 'js' => array('ang/crmAutosave.js'),
- 'requires' => array('crmUtil'),
-);
+ 'js' => ['ang/crmAutosave.js'],
+ 'requires' => ['crmUtil'],
+];
// ODDITY: This only loads if CiviCase is active.
-CRM_Core_Resources::singleton()->addSetting(array(
- 'crmCaseType' => array(
+CRM_Core_Resources::singleton()->addSetting([
+ 'crmCaseType' => [
'REL_TYPE_CNAME' => CRM_Case_XMLProcessor::REL_TYPE_CNAME,
- ),
-));
+ ],
+]);
-return array(
+return [
'ext' => 'civicrm',
- 'js' => array('ang/crmCaseType.js'),
- 'css' => array('ang/crmCaseType.css'),
- 'partials' => array('ang/crmCaseType'),
- 'requires' => array('ngRoute', 'ui.utils', 'crmUi', 'unsavedChanges', 'crmUtil', 'crmResource'),
-);
+ 'js' => ['ang/crmCaseType.js'],
+ 'css' => ['ang/crmCaseType.css'],
+ 'partials' => ['ang/crmCaseType'],
+ 'requires' => ['ngRoute', 'ui.utils', 'crmUi', 'unsavedChanges', 'crmUtil', 'crmResource'],
+];
};
});
- crmCaseType.controller('CaseTypeCtrl', function($scope, crmApi, apiCalls) {
+ crmCaseType.controller('CaseTypeCtrl', function($scope, crmApi, apiCalls, crmUiHelp) {
var REL_TYPE_CNAME, defaultAssigneeDefaultValue, ts;
(function init () {
REL_TYPE_CNAME = CRM.crmCaseType.REL_TYPE_CNAME;
ts = $scope.ts = CRM.ts(null);
+ $scope.hs = crmUiHelp({file: 'CRM/Case/CaseType'});
$scope.locks = { caseTypeName: true, activitySetName: true };
$scope.workflows = { timeline: 'Timeline', sequence: 'Sequence' };
defaultAssigneeDefaultValue = _.find(apiCalls.defaultAssigneeTypes.values, { is_default: '1' }) || {};
$scope.caseType.definition.caseRoles = $scope.caseType.definition.caseRoles || [];
$scope.caseType.definition.statuses = $scope.caseType.definition.statuses || [];
$scope.caseType.definition.timelineActivityTypes = $scope.caseType.definition.timelineActivityTypes || [];
+ $scope.caseType.definition.restrictActivityAsgmtToCmsUser = $scope.caseType.definition.restrictActivityAsgmtToCmsUser || 0;
+ $scope.caseType.definition.activityAsgmtGrps = $scope.caseType.definition.activityAsgmtGrps || [];
_.each($scope.caseType.definition.activitySets, function (set) {
_.each(set.activityTypes, function (type, name) {
} else {
CRM.loadForm(CRM.url('civicrm/admin/reltype', {action: 'add', reset: 1, label_a_b: roleName, label_b_a: roleName}))
.on('crmFormSuccess', function(e, data) {
- roles.push({name: data.relationshipType[REL_TYPE_CNAME]});
- $scope.relationshipTypeOptions.push({id: data.relationshipType[REL_TYPE_CNAME], text: data.relationshipType.label_b_a});
+ var newType = _.values(data.relationshipType)[0];
+ roles.push({name: newType[REL_TYPE_CNAME]});
+ $scope.relationshipTypeOptions.push({id: newType[REL_TYPE_CNAME], text: newType.label_b_a});
$scope.$digest();
});
}
});
// Ignore if ALL or NONE selected
$scope.caseType.definition.statuses = selectedStatuses.length == _.size($scope.selectedStatuses) ? [] : selectedStatuses;
+
+ if ($scope.caseType.definition.activityAsgmtGrps) {
+ $scope.caseType.definition.activityAsgmtGrps = $scope.caseType.definition.activityAsgmtGrps.toString().split(",");
+ }
+
var result = crmApi('CaseType', 'create', $scope.caseType, true);
result.then(function(data) {
if (data.is_error === 0 || data.is_error == '0') {
<div crm-ui-field="{title: ts('Enabled?')}">
<input name="is_active" type="checkbox" ng-model="caseType.is_active" ng-true-value="'1'" ng-false-value="'0'"/>
</div>
+ <fieldset class="crm-collapsible">
+ <legend class="collapsible-title">{{ ts('Activity assignment settings') }}</legend>
+ <div>
+ <div crm-ui-field="{name: 'caseTypeDetailForm.activityAsgmtGrps', title: ts('Restrict to Groups'), help: hs('activityAsgmtGrps')}">
+ <input
+ name="activityAsgmtGrps"
+ crm-ui-id="caseTypeDetailForm.activityAsgmtGrps"
+ crm-entityref="{entity: 'Group', api: {params: {is_hidden: 0, is_active: 1}}, select: {allowClear: true, multiple: true, placeholder: ts('Select Group')}}"
+ ng-model="caseType.definition.activityAsgmtGrps"
+ />
+ </div>
+ <div crm-ui-field="{title: ts('Restrict to Website Users'), help: hs('restrictActivityAsgmtToCmsUser')}">
+ <input
+ name="restrictActivityAsgmtToCmsUser"
+ type="checkbox"
+ ng-model="caseType.definition.restrictActivityAsgmtToCmsUser"
+ ng-true-value="'1'"
+ ng-false-value="'0'"
+ />
+ </div>
+ </div>
+ </fieldset>
+ </div>
</div>
</div>
// in CiviCRM. See also:
// http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_angularModules
-return array(
+return [
'ext' => 'civicrm',
- 'js' => array('ang/crmCxn.js', 'ang/crmCxn/*.js'),
- 'css' => array('ang/crmCxn.css'),
- 'partials' => array('ang/crmCxn'),
- 'requires' => array('crmUtil', 'ngRoute', 'ngSanitize', 'ui.utils', 'crmUi', 'dialogService', 'crmResource'),
-);
+ 'js' => ['ang/crmCxn.js', 'ang/crmCxn/*.js'],
+ 'css' => ['ang/crmCxn.css'],
+ 'partials' => ['ang/crmCxn'],
+ 'requires' => ['crmUtil', 'ngRoute', 'ngSanitize', 'ui.utils', 'crmUi', 'dialogService', 'crmResource'],
+];
// ODDITY: Only loads if you have CiviMail permissions.
// ODDITY: Extra resources loaded via CRM_Mailing_Info::getAngularModules.
-return array(
+return [
'ext' => 'civicrm',
- 'js' => array(
+ 'js' => [
'ang/crmD3.js',
'bower_components/d3/d3.min.js',
- ),
- 'requires' => array(),
-);
+ ],
+ 'requires' => [],
+];
// in CiviCRM. See also:
// http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_angularModules
-return array(
+return [
'ext' => 'civicrm',
- 'js' => array('ang/crmExample.js'),
- 'partials' => array('ang/crmExample'),
- 'requires' => array('crmUtil', 'ngRoute', 'ui.utils', 'crmUi', 'crmResource'),
-);
+ 'js' => ['ang/crmExample.js'],
+ 'partials' => ['ang/crmExample'],
+ 'requires' => ['crmUtil', 'ngRoute', 'ui.utils', 'crmUi', 'crmResource'],
+];
// ODDITY: Only loads if you have CiviMail permissions.
// ODDITY: Extra resources loaded via CRM_Mailing_Info::getAngularModules.
-return array(
+return [
'ext' => 'civicrm',
- 'js' => array(
+ 'js' => [
'ang/crmMailing.js',
'ang/crmMailing/*.js',
- ),
- 'css' => array('ang/crmMailing.css'),
- 'partials' => array('ang/crmMailing'),
- 'requires' => array('crmUtil', 'crmAttachment', 'crmAutosave', 'ngRoute', 'ui.utils', 'crmUi', 'dialogService', 'crmResource'),
-);
+ ],
+ 'css' => ['ang/crmMailing.css'],
+ 'partials' => ['ang/crmMailing'],
+ 'requires' => ['crmUtil', 'crmAttachment', 'crmAutosave', 'ngRoute', 'ui.utils', 'crmUi', 'dialogService', 'crmResource'],
+];
// ODDITY: Only loads if you have CiviMail permissions.
// ODDITY: Extra resources loaded via CRM_Mailing_Info::getAngularModules.
-return array(
+return [
'ext' => 'civicrm',
- 'js' => array(
+ 'js' => [
'ang/crmMailingAB.js',
'ang/crmMailingAB/*.js',
'ang/crmMailingAB/*/*.js',
- ),
- 'css' => array('ang/crmMailingAB.css'),
- 'partials' => array('ang/crmMailingAB'),
- 'requires' => array('ngRoute', 'ui.utils', 'crmUi', 'crmAttachment', 'crmMailing', 'crmD3', 'crmResource'),
-);
+ ],
+ 'css' => ['ang/crmMailingAB.css'],
+ 'partials' => ['ang/crmMailingAB'],
+ 'requires' => ['ngRoute', 'ui.utils', 'crmUi', 'crmAttachment', 'crmMailing', 'crmD3', 'crmResource'],
+];
// in CiviCRM. See also:
// http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_angularModules
-return array(
+return [
'ext' => 'civicrm',
// 'js' => array('js/angular-crmResource/byModule.js'), // One HTTP request per module.
- 'js' => array('js/angular-crmResource/all.js'), // One HTTP request for all modules.
-);
+ 'js' => ['js/angular-crmResource/all.js'], // One HTTP request for all modules.
+];
// in CiviCRM. See also:
// http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_angularModules
-return array(
+return [
'ext' => 'civicrm',
- 'js' => array('ang/crmRouteBinder.js'),
- 'css' => array(),
- 'partials' => array(),
- 'requires' => array('ngRoute'),
-);
+ 'js' => ['ang/crmRouteBinder.js'],
+ 'css' => [],
+ 'partials' => [],
+ 'requires' => ['ngRoute'],
+];
// ODDITY: Angular name 'statuspage' doesn't match the file name 'crmStatusPage'.
-return array(
+return [
'ext' => 'civicrm',
- 'js' => array('ang/crmStatusPage.js', 'ang/crmStatusPage/*.js'),
- 'css' => array('ang/crmStatusPage.css'),
- 'partials' => array('ang/crmStatusPage'),
- 'settings' => array(),
- 'requires' => array('crmUi', 'crmUtil', 'ngRoute', 'crmResource'),
-);
+ 'js' => ['ang/crmStatusPage.js', 'ang/crmStatusPage/*.js'],
+ 'css' => ['ang/crmStatusPage.css'],
+ 'partials' => ['ang/crmStatusPage'],
+ 'settings' => [],
+ 'requires' => ['crmUi', 'crmUtil', 'ngRoute', 'crmResource'],
+];
// in CiviCRM. See also:
// http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_angularModules
-return array(
+return [
'ext' => 'civicrm',
- 'js' => array('ang/crmUi.js'),
- 'partials' => array('ang/crmUi'),
- 'requires' => array(
+ 'js' => ['ang/crmUi.js'],
+ 'partials' => ['ang/crmUi'],
+ 'requires' => [
'crmResource',
'ui.utils',
- ),
-);
+ ],
+];
// in CiviCRM. See also:
// http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_angularModules
-return array(
+return [
'ext' => 'civicrm',
- 'js' => array('ang/crmUtil.js'),
- 'requires' => array(),
-);
+ 'js' => ['ang/crmUtil.js'],
+ 'requires' => [],
+];
// https://github.com/jwstadler/angular-jquery-dialog-service
-return array(
+return [
'ext' => 'civicrm',
- 'js' => array('bower_components/angular-jquery-dialog-service/dialog-service.js'),
-);
+ 'js' => ['bower_components/angular-jquery-dialog-service/dialog-service.js'],
+];
// in CiviCRM. See also:
// http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_angularModules
-return array(
+return [
'ext' => 'civicrm',
- 'js' => array('bower_components/angular-route/angular-route.min.js'),
-);
+ 'js' => ['bower_components/angular-route/angular-route.min.js'],
+];
// in CiviCRM. See also:
// http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_angularModules
-return array(
+return [
'ext' => 'civicrm',
- 'js' => array('bower_components/angular-sanitize/angular-sanitize.min.js'),
-);
+ 'js' => ['bower_components/angular-sanitize/angular-sanitize.min.js'],
+];
// in CiviCRM. See also:
// http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_angularModules
-return array(
+return [
'ext' => 'civicrm',
- 'basePages' => array(),
- 'js' => array('bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js'),
- 'css' => array('bower_components/angular-bootstrap/ui-bootstrap-csp.css', 'ang/ui.bootstrap.css'),
-);
+ 'basePages' => [],
+ 'js' => ['bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js'],
+ 'css' => ['bower_components/angular-bootstrap/ui-bootstrap-csp.css', 'ang/ui.bootstrap.css'],
+];
// in CiviCRM. See also:
// http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_angularModules
-return array(
+return [
'ext' => 'civicrm',
- 'js' => array('bower_components/angular-ui-sortable/sortable.min.js'),
-);
+ 'js' => ['bower_components/angular-ui-sortable/sortable.min.js'],
+];
// in CiviCRM. See also:
// http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_angularModules
-return array(
+return [
'ext' => 'civicrm',
- 'js' => array('bower_components/angular-ui-utils/ui-utils.min.js'),
-);
+ 'js' => ['bower_components/angular-ui-utils/ui-utils.min.js'],
+];
// in CiviCRM. See also:
// http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_angularModules
-return array(
+return [
'ext' => 'civicrm',
- 'js' => array('bower_components/angular-unsavedChanges/dist/unsavedChanges.min.js'),
-);
+ 'js' => ['bower_components/angular-unsavedChanges/dist/unsavedChanges.min.js'],
+];
const UNAUTHORIZED = 'unauthorized';
const NOT_IMPLEMENTED = 'not-found';
- private $extraParams = array();
+ private $extraParams = [];
/**
* Class constructor.
* @param Exception|NULL $previous
* A previous exception which caused this new exception.
*/
- public function __construct($message, $error_code = 0, $extraParams = array(), Exception $previous = NULL) {
+ public function __construct($message, $error_code = 0, $extraParams = [], Exception $previous = NULL) {
// Using int for error code "old way") ?
if (is_numeric($error_code)) {
$code = $error_code;
$code = 0;
}
parent::__construct(ts($message), $code, $previous);
- $this->extraParams = $extraParams + array('error_code' => $error_code);
+ $this->extraParams = $extraParams + ['error_code' => $error_code];
}
/**
* @return array
*/
public function getErrorCodes() {
- return array(
+ return [
2000 => '$params was not an array',
2001 => 'Invalid Value for Date field',
2100 => 'String value is longer than permitted length',
self::UNAUTHORIZED => 'Unauthorized',
self::NOT_IMPLEMENTED => 'Entity or method is not implemented',
- );
+ ];
}
}
* API_Exception from the api wrapper as the namespace is more generic
*/
class CiviCRM_API3_Exception extends Exception {
- private $extraParams = array();
+ private $extraParams = [];
/**
* Class constructor.
* @param Exception|NULL $previous
* A previous exception which caused this new exception.
*/
- public function __construct($message, $error_code = 0, $extraParams = array(), Exception $previous = NULL) {
+ public function __construct($message, $error_code = 0, $extraParams = [], Exception $previous = NULL) {
parent::__construct(ts($message));
- $this->extraParams = $extraParams + array('error_code' => $error_code);
+ $this->extraParams = $extraParams + ['error_code' => $error_code];
}
/**
* @throws CiviCRM_API3_Exception
* @return array
*/
-function civicrm_api3($entity, $action, $params = array()) {
+function civicrm_api3($entity, $action, $params = []) {
$params['version'] = 3;
$result = \Civi::service('civi_api_kernel')->runSafe($entity, $action, $params);
if (is_array($result) && !empty($result['is_error'])) {
// $apiRequest['params']['action'] = $apiRequest['params']['api_action'];
// unset($apiRequest['params']['api_action']);
}
- return array('action' => array('api.aliases' => array('api_action')));
+ return ['action' => ['api.aliases' => ['api_action']]];
}
- $getFieldsParams = array('action' => $apiRequest['action']);
+ $getFieldsParams = ['action' => $apiRequest['action']];
$entity = $apiRequest['entity'];
if ($entity == 'Profile' && array_key_exists('profile_id', $apiRequest['params'])) {
$getFieldsParams['profile_id'] = $apiRequest['params']['profile_id'];
*/
public function __construct($config = NULL) {
$this->local = TRUE;
- $this->input = array();
- $this->lastResult = array();
+ $this->input = [];
+ $this->lastResult = [];
if (isset($config) && isset($config['server'])) {
// we are calling a remote server via REST
$this->local = FALSE;
*
* @return \stdClass
*/
- private function remoteCall($entity, $action, $params = array()) {
+ private function remoteCall($entity, $action, $params = []) {
$query = $this->uri . "?entity=$entity&action=$action";
- $fields = http_build_query(array(
+ $fields = http_build_query([
'key' => $this->key,
'api_key' => $this->api_key,
'json' => json_encode($params),
- ));
+ ]);
if (function_exists('curl_init')) {
// To facilitate debugging without leaking info, entity & action
$res->is_error = 1;
$res->error_message = curl_error($ch);
$res->level = "cURL";
- $res->error = array('cURL error' => curl_error($ch));
+ $res->error = ['cURL error' => curl_error($ch)];
return $res;
}
curl_close($ch);
$res->is_error = 1;
$res->error_message = 'Unable to parse returned JSON';
$res->level = 'json_decode';
- $res->error = array('Unable to parse returned JSON' => $result);
+ $res->error = ['Unable to parse returned JSON' => $result];
$res->row_result = $result;
}
return $res;
*
* @return bool
*/
- private function call($entity, $action = 'Get', $params = array()) {
+ private function call($entity, $action = 'Get', $params = []) {
if (is_int($params)) {
- $params = array('id' => $params);
+ $params = ['id' => $params];
}
elseif (is_string($params)) {
$params = json_decode($params);
$this->lastResult = json_decode(json_encode(civicrm_api($entity, $action, $params)));
}
// Reset the input to be ready for a new call.
- $this->input = array();
+ $this->input = [];
if (property_exists($this->lastResult, 'is_error')) {
return !$this->lastResult->is_error;
}
* @return array
*/
function civicrm_api3_action_schedule_create($params) {
- civicrm_api3_verify_one_mandatory($params, NULL, array('start_action_date', 'absolute_date'));
+ civicrm_api3_verify_one_mandatory($params, NULL, ['start_action_date', 'absolute_date']);
if (!array_key_exists('name', $params) && !array_key_exists('id', $params)) {
$params['name'] = CRM_Utils_String::munge($params['title']);
}
// an update does not require any mandatory parameters
civicrm_api3_verify_one_mandatory($params,
NULL,
- array(
+ [
'activity_name',
'activity_type_id',
'activity_label',
- )
+ ]
);
}
}
// processing for custom data
- $values = $activityArray = array();
+ $values = $activityArray = [];
_civicrm_api3_custom_format_params($params, $values, 'Activity');
if (!empty($values['custom'])) {
// this handling should all be moved to the BAO layer
$case_id = '';
$createRevision = FALSE;
- $oldActivityValues = array();
+ $oldActivityValues = [];
// Lookup case id if not supplied
if (!isset($params['case_id']) && !empty($params['id'])) {
$params['case_id'] = CRM_Core_DAO::singleValueQuery("SELECT case_id FROM civicrm_case_activity WHERE activity_id = " . (int) $params['id']);
if (!empty($params['case_id'])) {
$case_id = $params['case_id'];
if (!empty($params['id']) && Civi::settings()->get('civicaseActivityRevisions')) {
- $oldActivityParams = array('id' => $params['id']);
+ $oldActivityParams = ['id' => $params['id']];
if (!$oldActivityValues) {
CRM_Activity_BAO_Activity::retrieve($oldActivityParams, $oldActivityValues);
}
if ($case_id && $isNew && !$createRevision) {
// If this is a brand new case activity, add to case(s)
foreach ((array) $case_id as $singleCaseId) {
- $caseActivityParams = array('activity_id' => $activityBAO->id, 'case_id' => $singleCaseId);
+ $caseActivityParams = ['activity_id' => $activityBAO->id, 'case_id' => $singleCaseId];
CRM_Case_BAO_Case::processCaseActivity($caseActivityParams);
}
}
*/
function _civicrm_api3_activity_create_spec(&$params) {
- $params['status_id']['api.aliases'] = array('activity_status');
+ $params['status_id']['api.aliases'] = ['activity_status'];
- $params['assignee_contact_id'] = array(
+ $params['assignee_contact_id'] = [
'name' => 'assignee_id',
'title' => 'Activity Assignee',
'description' => 'Contact(s) assigned to this activity.',
'type' => 1,
'FKClassName' => 'CRM_Contact_DAO_Contact',
'FKApiName' => 'Contact',
- );
- $params['target_contact_id'] = array(
+ ];
+ $params['target_contact_id'] = [
'name' => 'target_id',
'title' => 'Activity Target',
'description' => 'Contact(s) participating in this activity.',
'type' => 1,
'FKClassName' => 'CRM_Contact_DAO_Contact',
'FKApiName' => 'Contact',
- );
+ ];
- $params['source_contact_id'] = array(
+ $params['source_contact_id'] = [
'name' => 'source_contact_id',
'title' => 'Activity Source Contact',
'description' => 'Person who created this activity. Defaults to current user.',
'api.default' => 'user_contact_id',
'FKApiName' => 'Contact',
'api.required' => TRUE,
- );
+ ];
- $params['case_id'] = array(
+ $params['case_id'] = [
'name' => 'case_id',
'title' => 'Case ID',
'description' => 'For creating an activity as part of a case.',
'type' => 1,
'FKClassName' => 'CRM_Case_DAO_Case',
'FKApiName' => 'Case',
- );
+ ];
}
* @param array $params
*/
function _civicrm_api3_activity_get_spec(&$params) {
- $params['tag_id'] = array(
+ $params['tag_id'] = [
'title' => 'Tags',
'description' => 'Find activities with specified tags.',
'type' => CRM_Utils_Type::T_INT,
'FKClassName' => 'CRM_Core_DAO_Tag',
'FKApiName' => 'Tag',
'supports_joins' => TRUE,
- );
- $params['file_id'] = array(
+ ];
+ $params['file_id'] = [
'title' => 'Attached Files',
'description' => 'Find activities with attached files.',
'type' => CRM_Utils_Type::T_INT,
'FKClassName' => 'CRM_Core_DAO_File',
'FKApiName' => 'File',
- );
- $params['case_id'] = array(
+ ];
+ $params['case_id'] = [
'title' => 'Cases',
'description' => 'Find activities within specified cases.',
'type' => CRM_Utils_Type::T_INT,
'FKClassName' => 'CRM_Case_DAO_Case',
'FKApiName' => 'Case',
'supports_joins' => TRUE,
- );
- $params['contact_id'] = array(
+ ];
+ $params['contact_id'] = [
'title' => 'Activity Contact ID',
'description' => 'Find activities involving this contact (as target, source, OR assignee).',
'type' => CRM_Utils_Type::T_INT,
'FKClassName' => 'CRM_Contact_DAO_Contact',
'FKApiName' => 'Contact',
- );
- $params['target_contact_id'] = array(
+ ];
+ $params['target_contact_id'] = [
'title' => 'Target Contact ID',
'description' => 'Find activities with specified target contact.',
'type' => CRM_Utils_Type::T_INT,
'FKClassName' => 'CRM_Contact_DAO_Contact',
'FKApiName' => 'Contact',
- );
- $params['source_contact_id'] = array(
+ ];
+ $params['source_contact_id'] = [
'title' => 'Source Contact ID',
'description' => 'Find activities with specified source contact.',
'type' => CRM_Utils_Type::T_INT,
'FKClassName' => 'CRM_Contact_DAO_Contact',
'FKApiName' => 'Contact',
- );
- $params['assignee_contact_id'] = array(
+ ];
+ $params['assignee_contact_id'] = [
'title' => 'Assignee Contact ID',
'description' => 'Find activities with specified assignee contact.',
'type' => CRM_Utils_Type::T_INT,
'FKClassName' => 'CRM_Contact_DAO_Contact',
'FKApiName' => 'Contact',
- );
- $params['is_overdue'] = array(
+ ];
+ $params['is_overdue'] = [
'title' => 'Is Activity Overdue',
'description' => 'Incomplete activities with a past date.',
'type' => CRM_Utils_Type::T_BOOLEAN,
- );
+ ];
}
/**
*/
function _civicrm_api3_activity_get_extraFilters(&$params, &$sql) {
// Filter by activity contacts
- $activityContactOptions = array(
+ $activityContactOptions = [
'contact_id' => NULL,
'target_contact_id' => CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_ActivityContact', 'record_type_id', 'Activity Targets'),
'source_contact_id' => CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_ActivityContact', 'record_type_id', 'Activity Source'),
'assignee_contact_id' => CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_ActivityContact', 'record_type_id', 'Activity Assignees'),
- );
+ ];
foreach ($activityContactOptions as $activityContactName => $activityContactValue) {
if (!empty($params[$activityContactName])) {
if (!is_array($params[$activityContactName])) {
- $params[$activityContactName] = array('=' => $params[$activityContactName]);
+ $params[$activityContactName] = ['=' => $params[$activityContactName]];
}
$clause = \CRM_Core_DAO::createSQLFilter('contact_id', $params[$activityContactName]);
$typeClause = $activityContactValue ? 'record_type_id = #typeId AND ' : '';
$sql->where("a.id IN (SELECT activity_id FROM civicrm_activity_contact WHERE $typeClause !clause)",
- array('#typeId' => $activityContactValue, '!clause' => $clause)
+ ['#typeId' => $activityContactValue, '!clause' => $clause]
);
}
}
// Subqueries are nice in (a) avoiding duplicates and (b) when the result
// list is expected to be bite-sized. Joins are nice (a) with larger
// datasets and (b) checking for non-existent relations.
- $rels = array(
- 'tag_id' => array(
+ $rels = [
+ 'tag_id' => [
'subquery' => 'a.id IN (SELECT entity_id FROM civicrm_entity_tag WHERE entity_table = "civicrm_activity" AND !clause)',
'join' => '!joinType civicrm_entity_tag !alias ON (!alias.entity_table = "civicrm_activity" AND !alias.entity_id = a.id)',
'column' => 'tag_id',
- ),
- 'file_id' => array(
+ ],
+ 'file_id' => [
'subquery' => 'a.id IN (SELECT entity_id FROM civicrm_entity_file WHERE entity_table = "civicrm_activity" AND !clause)',
'join' => '!joinType civicrm_entity_file !alias ON (!alias.entity_table = "civicrm_activity" AND !alias.entity_id = a.id)',
'column' => 'file_id',
- ),
- 'case_id' => array(
+ ],
+ 'case_id' => [
'subquery' => 'a.id IN (SELECT activity_id FROM civicrm_case_activity WHERE !clause)',
'join' => '!joinType civicrm_case_activity !alias ON (!alias.activity_id = a.id)',
'column' => 'case_id',
- ),
- );
+ ],
+ ];
foreach ($rels as $filter => $relSpec) {
if (!empty($params[$filter])) {
if (!is_array($params[$filter])) {
- $params[$filter] = array('=' => $params[$filter]);
+ $params[$filter] = ['=' => $params[$filter]];
}
// $mode is one of ('LEFT JOIN', 'INNER JOIN', 'SUBQUERY')
$mode = isset($params[$filter]['IS NULL']) ? 'LEFT JOIN' : 'SUBQUERY';
if ($mode === 'SUBQUERY') {
$clause = \CRM_Core_DAO::createSQLFilter($relSpec['column'], $params[$filter]);
if ($clause) {
- $sql->where($relSpec['subquery'], array('!clause' => $clause));
+ $sql->where($relSpec['subquery'], ['!clause' => $clause]);
}
}
else {
$alias = 'actjoin_' . $filter;
$clause = \CRM_Core_DAO::createSQLFilter($alias . "." . $relSpec['column'], $params[$filter]);
if ($clause) {
- $sql->join($alias, $relSpec['join'], array('!alias' => $alias, 'joinType' => $mode));
+ $sql->join($alias, $relSpec['join'], ['!alias' => $alias, 'joinType' => $mode]);
$sql->where($clause);
}
}
_civicrm_api3_activity_fill_activity_contact_names($activities, $params, $returns);
- $tagGet = array('tag_id', 'entity_id');
- $caseGet = $caseIds = array();
+ $tagGet = ['tag_id', 'entity_id'];
+ $caseGet = $caseIds = [];
foreach (array_keys($returns) as $key) {
if (strpos($key, 'tag_id.') === 0) {
$tagGet[] = $key;
break;
case 'tag_id':
- $tags = civicrm_api3('EntityTag', 'get', array(
+ $tags = civicrm_api3('EntityTag', 'get', [
'entity_table' => 'civicrm_activity',
- 'entity_id' => array('IN' => array_keys($activities)),
+ 'entity_id' => ['IN' => array_keys($activities)],
'return' => $tagGet,
- 'options' => array('limit' => 0),
- ));
+ 'options' => ['limit' => 0],
+ ]);
foreach ($tags['values'] as $tag) {
$key = (int) $tag['entity_id'];
unset($tag['entity_id'], $tag['id']);
case 'file_id':
$dao = CRM_Core_DAO::executeQuery("SELECT entity_id, file_id FROM civicrm_entity_file WHERE entity_table = 'civicrm_activity' AND entity_id IN (%1)",
- array(1 => array(implode(',', array_keys($activities)), 'String', CRM_Core_DAO::QUERY_FORMAT_NO_QUOTES)));
+ [1 => [implode(',', array_keys($activities)), 'String', CRM_Core_DAO::QUERY_FORMAT_NO_QUOTES]]);
while ($dao->fetch()) {
$activities[$dao->entity_id]['file_id'][] = $dao->file_id;
}
case 'case_id':
$dao = CRM_Core_DAO::executeQuery("SELECT activity_id, case_id FROM civicrm_case_activity WHERE activity_id IN (%1)",
- array(1 => array(implode(',', array_keys($activities)), 'String', CRM_Core_DAO::QUERY_FORMAT_NO_QUOTES)));
+ [1 => [implode(',', array_keys($activities)), 'String', CRM_Core_DAO::QUERY_FORMAT_NO_QUOTES]]);
while ($dao->fetch()) {
$activities[$dao->activity_id]['case_id'][] = $dao->case_id;
$caseIds[$dao->case_id] = $dao->case_id;
// Fetch case fields via the join syntax
// Note this is limited to the first case if the activity belongs to more than one
if ($caseGet && $caseIds) {
- $cases = civicrm_api3('Case', 'get', array(
- 'id' => array('IN' => $caseIds),
- 'options' => array('limit' => 0),
+ $cases = civicrm_api3('Case', 'get', [
+ 'id' => ['IN' => $caseIds],
+ 'options' => ['limit' => 0],
'check_permissions' => !empty($params['check_permissions']),
'return' => $caseGet,
- ));
+ ]);
foreach ($activities as &$activity) {
if (!empty($activity['case_id'])) {
$case = CRM_Utils_Array::value($activity['case_id'][0], $cases['values']);
* array with errors
*/
function _civicrm_api3_activity_check_params(&$params) {
- $activityIds = array(
+ $activityIds = [
'activity' => CRM_Utils_Array::value('id', $params),
'parent' => CRM_Utils_Array::value('parent_id', $params),
'original' => CRM_Utils_Array::value('original_id', $params),
- );
+ ];
foreach ($activityIds as $id => $value) {
if ($value &&
* API request.
*/
function _civicrm_api3_activity_getlist_params(&$request) {
- $fieldsToReturn = array(
+ $fieldsToReturn = [
'activity_date_time',
'activity_type_id',
'subject',
'source_contact_id',
- );
+ ];
$request['params']['return'] = array_unique(array_merge($fieldsToReturn, $request['extra']));
$request['params']['options']['sort'] = 'activity_date_time DESC';
- $request['params'] += array(
+ $request['params'] += [
'is_current_revision' => 1,
'is_deleted' => 0,
- );
+ ];
}
/**
* @return array
*/
function _civicrm_api3_activity_getlist_output($result, $request) {
- $output = array();
+ $output = [];
if (!empty($result['values'])) {
foreach ($result['values'] as $row) {
- $data = array(
+ $data = [
'id' => $row[$request['id_field']],
'label' => $row[$request['label_field']] ? $row[$request['label_field']] : ts('(no subject)'),
- 'description' => array(
+ 'description' => [
CRM_Core_Pseudoconstant::getLabel('CRM_Activity_BAO_Activity', 'activity_type_id', $row['activity_type_id']),
- ),
- );
+ ],
+ ];
if (!empty($row['activity_date_time'])) {
$data['description'][0] .= ': ' . CRM_Utils_Date::customFormat($row['activity_date_time']);
}
if (!empty($row['source_contact_id'])) {
- $data['description'][] = ts('By %1', array(
+ $data['description'][] = ts('By %1', [
1 => CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $row['source_contact_id'], 'display_name'),
- ));
+ ]);
}
// Add repeating info
$repeat = CRM_Core_BAO_RecurringEntity::getPositionAndCount($row['id'], 'civicrm_activity');
$data['extra']['is_recur'] = FALSE;
if ($repeat) {
- $data['suffix'] = ts('(%1 of %2)', array(1 => $repeat[0], 2 => $repeat[1]));
+ $data['suffix'] = ts('(%1 of %2)', [1 => $repeat[0], 2 => $repeat[1]]);
$data['extra']['is_recur'] = TRUE;
}
$output[] = $data;
}
$activityObject = CRM_Core_OptionValue::addOptionValue($params, 'activity_type', $action, $optionValueID);
- $activityType = array();
+ $activityType = [];
_civicrm_api3_object_to_array($activityObject, $activityType[$activityObject->id]);
return civicrm_api3_create_success($activityType, $params, 'activity_type', 'create');
}
* Array of parameters determined by getfields.
*/
function _civicrm_api3_activity_type_create_spec(&$params) {
- $params['label'] = array(
+ $params['label'] = [
'api.required' => 1,
'title' => 'Label',
'type' => CRM_Utils_Type::T_STRING,
- );
- $params['weight'] = array(
+ ];
+ $params['weight'] = [
'api.required' => 1,
'title' => 'Weight',
'type' => CRM_Utils_Type::T_STRING,
- );
+ ];
}
/**
function _civicrm_api3_address_create_spec(&$params) {
$params['location_type_id']['api.required'] = 1;
$params['contact_id']['api.required'] = 1;
- $params['street_parsing'] = array(
+ $params['street_parsing'] = [
'title' => 'Street Address Parsing',
'description' => 'Optional param to indicate you want the street_address field parsed into individual params',
'type' => CRM_Utils_Type::T_BOOLEAN,
- );
- $params['skip_geocode'] = array(
+ ];
+ $params['skip_geocode'] = [
'title' => 'Skip geocode',
'description' => 'Optional param to indicate you want to skip geocoding (useful when importing a lot of addresses
at once, the job \'Geocode and Parse Addresses\' can execute this task after the import)',
'type' => CRM_Utils_Type::T_BOOLEAN,
- );
- $params['fix_address'] = array(
+ ];
+ $params['fix_address'] = [
'title' => ts('Fix address'),
'description' => ts('When true, apply various fixes to the address before insert. Default true.'),
'type' => CRM_Utils_Type::T_BOOLEAN,
'api.default' => TRUE,
- );
- $params['world_region'] = array(
+ ];
+ $params['world_region'] = [
'title' => ts('World Region'),
'name' => 'world_region',
'type' => CRM_Utils_Type::T_TEXT,
- );
+ ];
}
/**
* Array of parameters determined by getfields.
*/
function _civicrm_api3_address_get_spec(&$params) {
- $params['world_region'] = array(
+ $params['world_region'] = [
'title' => ts('World Region'),
'name' => 'world_region',
'type' => CRM_Utils_Type::T_TEXT,
- );
+ ];
}
/**
function civicrm_api3_attachment_create($params) {
if (empty($params['id'])) {
// When creating we need either entity_table or field_name.
- civicrm_api3_verify_one_mandatory($params, NULL, array('entity_table', 'field_name'));
+ civicrm_api3_verify_one_mandatory($params, NULL, ['entity_table', 'field_name']);
}
$config = CRM_Core_Config::singleton();
throw new API_Exception("'content' and 'options.move-file' are mutually exclusive");
}
if ($id && !$isTrusted && isset($file['upload_date']) && $file['upload_date'] != CRM_Utils_Date::isoToMysql($fileDao->upload_date)) {
- throw new API_Exception("Cannot modify upload_date" . var_export(array($file['upload_date'], $fileDao->upload_date, CRM_Utils_Date::isoToMysql($fileDao->upload_date)), TRUE));
+ throw new API_Exception("Cannot modify upload_date" . var_export([$file['upload_date'], $fileDao->upload_date, CRM_Utils_Date::isoToMysql($fileDao->upload_date)], TRUE));
}
if ($id && $name && $name != CRM_Utils_File::cleanFileName($fileDao->uri)) {
throw new API_Exception("Cannot modify name");
// Save custom field to entity
if (!$id && empty($params['entity_table']) && isset($params['field_name'])) {
- civicrm_api3('custom_value', 'create', array(
+ civicrm_api3('custom_value', 'create', [
'entity_id' => $params['entity_id'],
$params['field_name'] => $fileDao->id,
- ));
+ ]);
}
- $result = array(
+ $result = [
$fileDao->id => _civicrm_api3_attachment_format_result($fileDao, $entityFileDao, $returnContent, $isTrusted),
- );
+ ];
return civicrm_api3_create_success($result, $params, 'Attachment', 'create');
}
list($id, $file, $entityFile, $name, $content, $moveFile, $isTrusted, $returnContent) = _civicrm_api3_attachment_parse_params($params);
$dao = __civicrm_api3_attachment_find($params, $id, $file, $entityFile, $isTrusted);
- $result = array();
+ $result = [];
while ($dao->fetch()) {
$result[$dao->id] = _civicrm_api3_attachment_format_result($dao, $dao, $returnContent, $isTrusted);
}
list($id, $file, $entityFile, $name, $content, $moveFile, $isTrusted, $returnContent) = _civicrm_api3_attachment_parse_params($params);
$dao = __civicrm_api3_attachment_find($params, $id, $file, $entityFile, $isTrusted);
- $filePaths = array();
- $fileIds = array();
+ $filePaths = [];
+ $fileIds = [];
while ($dao->fetch()) {
$filePaths[] = $config->customFileUploadDir . DIRECTORY_SEPARATOR . $dao->uri;
$fileIds[] = $dao->id;
}
}
- $result = array();
+ $result = [];
return civicrm_api3_create_success($result, $params, 'Attachment', 'create');
}
* @throws API_Exception
*/
function __civicrm_api3_attachment_find($params, $id, $file, $entityFile, $isTrusted) {
- foreach (array('name', 'content', 'path', 'url') as $unsupportedFilter) {
+ foreach (['name', 'content', 'path', 'url'] as $unsupportedFilter) {
if (!empty($params[$unsupportedFilter])) {
throw new API_Exception("Get by $unsupportedFilter is not currently supported");
}
$select = CRM_Utils_SQL_Select::from('civicrm_file cf')
->join('cef', 'INNER JOIN civicrm_entity_file cef ON cf.id = cef.file_id')
- ->select(array(
+ ->select([
'cf.id',
'cf.uri',
'cf.mime_type',
'cf.created_id',
'cef.entity_table',
'cef.entity_id',
- ));
+ ]);
if ($id) {
- $select->where('cf.id = #id', array('#id' => $id));
+ $select->where('cf.id = #id', ['#id' => $id]);
}
// Recall: $file is filtered by parse_params.
foreach ($file as $key => $value) {
- $select->where('cf.!field = @value', array(
+ $select->where('cf.!field = @value', [
'!field' => $key,
'@value' => $value,
- ));
+ ]);
}
// Recall: $entityFile is filtered by parse_params.
foreach ($entityFile as $key => $value) {
- $select->where('cef.!field = @value', array(
+ $select->where('cef.!field = @value', [
'!field' => $key,
'@value' => $value,
- ));
+ ]);
}
if (!$isTrusted) {
// FIXME ACLs: Add any JOIN or WHERE clauses needed to enforce access-controls for the target entity.
throw new API_Exception("Malformed id");
}
- $file = array();
- foreach (array('mime_type', 'description', 'upload_date') as $field) {
+ $file = [];
+ foreach (['mime_type', 'description', 'upload_date'] as $field) {
if (array_key_exists($field, $params)) {
$file[$field] = $params[$field];
}
}
- $entityFile = array();
- foreach (array('entity_table', 'entity_id') as $field) {
+ $entityFile = [];
+ foreach (['entity_table', 'entity_id'] as $field) {
if (array_key_exists($field, $params)) {
$entityFile[$field] = $params[$field];
}
$isTrusted = empty($params['check_permissions']);
- $returns = isset($params['return']) ? $params['return'] : array();
- $returns = is_array($returns) ? $returns : array($returns);
+ $returns = isset($params['return']) ? $params['return'] : [];
+ $returns = is_array($returns) ? $returns : [$returns];
$returnContent = in_array('content', $returns);
- return array($id, $file, $entityFile, $name, $content, $moveFile, $isTrusted, $returnContent);
+ return [$id, $file, $entityFile, $name, $content, $moveFile, $isTrusted, $returnContent];
}
/**
$config = CRM_Core_Config::singleton();
$path = $config->customFileUploadDir . DIRECTORY_SEPARATOR . $fileDao->uri;
- $result = array(
+ $result = [
'id' => $fileDao->id,
'name' => CRM_Utils_File::cleanFileName($fileDao->uri),
'mime_type' => $fileDao->mime_type,
'entity_id' => $entityFileDao->entity_id,
'icon' => CRM_Utils_File::getIconFromMimeType($fileDao->mime_type),
'created_id' => $fileDao->created_id,
- );
+ ];
$fileHash = CRM_Core_BAO_File::generateFileHash($result['entity_id'], $result['id']);
$result['url'] = CRM_Utils_System::url(
'civicrm/file', 'reset=1&id=' . $result['id'] . '&eid=' . $result['entity_id'] . '&fcs=' . $fileHash,
$fileFields = CRM_Core_DAO_File::fields();
$entityFileFields = CRM_Core_DAO_EntityFile::fields();
- $spec = array();
+ $spec = [];
$spec['id'] = $fileFields['id'];
- $spec['name'] = array(
+ $spec['name'] = [
'title' => 'Name (write-once)',
'description' => 'The logical file name (not searchable)',
'type' => CRM_Utils_Type::T_STRING,
- );
- $spec['field_name'] = array(
+ ];
+ $spec['field_name'] = [
'title' => 'Field Name (write-once)',
'description' => 'Alternative to "entity_table" param - sets custom field value.',
'type' => CRM_Utils_Type::T_STRING,
- );
+ ];
$spec['mime_type'] = $fileFields['mime_type'];
$spec['description'] = $fileFields['description'];
$spec['upload_date'] = $fileFields['upload_date'];
$spec['entity_table']['title'] = CRM_Utils_Array::value('title', $spec['entity_table'], 'Entity Table') . ' (write-once)';
$spec['entity_id'] = $entityFileFields['entity_id'];
$spec['entity_id']['title'] = CRM_Utils_Array::value('title', $spec['entity_id'], 'Entity ID') . ' (write-once)'; // would be hard to securely handle changes
- $spec['url'] = array(
+ $spec['url'] = [
'title' => 'URL (read-only)',
'description' => 'URL for downloading the file (not searchable, expire-able)',
'type' => CRM_Utils_Type::T_STRING,
- );
- $spec['path'] = array(
+ ];
+ $spec['path'] = [
'title' => 'Path (read-only)',
'description' => 'Local file path (not searchable, local-only)',
'type' => CRM_Utils_Type::T_STRING,
- );
- $spec['content'] = array(
+ ];
+ $spec['content'] = [
'title' => 'Content',
'description' => 'File content (not searchable, not returned by default)',
'type' => CRM_Utils_Type::T_STRING,
- );
- $spec['created_id'] = array(
+ ];
+ $spec['created_id'] = [
'title' => 'Created By Contact ID',
'type' => CRM_Utils_Type::T_INT,
'description' => 'FK to civicrm_contact, who uploaded this file',
- );
+ ];
return $spec;
}
if (empty($params['id'])) {
// Creating a new case, so make sure we have the necessary parameters
- civicrm_api3_verify_mandatory($params, NULL, array(
+ civicrm_api3_verify_mandatory($params, NULL, [
'contact_id',
'subject',
- array('case_type', 'case_type_id'),
- )
+ ['case_type', 'case_type_id'],
+ ]
);
}
else {
throw new API_Exception('You cannot update creator id');
}
- $mergedCaseIds = $origContactIds = array();
+ $mergedCaseIds = $origContactIds = [];
// If a contact ID is specified we need to make sure this is the main contact ID for the case (and update if necessary)
if (!empty($params['contact_id'])) {
if (isset($params['contact_id']) && !isset($params['id'])) {
foreach ((array) $params['contact_id'] as $cid) {
- $contactParams = array('case_id' => $caseBAO->id, 'contact_id' => $cid);
+ $contactParams = ['case_id' => $caseBAO->id, 'contact_id' => $cid];
CRM_Case_BAO_CaseContact::create($contactParams);
}
}
}
// return case
- $values = array();
+ $values = [];
_civicrm_api3_object_to_array($caseBAO, $values[$caseBAO->id]);
return civicrm_api3_create_success($values, $params, 'Case', 'create', $caseBAO);
// Initialize XML processor with $params
$xmlProcessor = new CRM_Case_XMLProcessor_Process();
- $xmlProcessorParams = array(
+ $xmlProcessorParams = [
'clientID' => CRM_Utils_Array::value('contact_id', $params),
'creatorID' => CRM_Utils_Array::value('creator_id', $params),
'standardTimeline' => 1,
'duration' => CRM_Utils_Array::value('duration', $params),
'medium_id' => CRM_Utils_Array::value('medium_id', $params),
'details' => CRM_Utils_Array::value('details', $params),
- 'custom' => array(),
+ 'custom' => [],
'relationship_end_date' => CRM_Utils_Array::value('end_date', $params),
- );
+ ];
// Do it! :-D
$xmlProcessor->run($params['case_type'], $xmlProcessorParams);
* Parameters determined by getfields.
*/
function _civicrm_api3_case_get_spec(&$params) {
- $params['contact_id'] = array(
- 'api.aliases' => array('client_id'),
+ $params['contact_id'] = [
+ 'api.aliases' => ['client_id'],
'title' => 'Case Client',
'description' => 'Contact id of one or more clients to retrieve cases for',
'type' => CRM_Utils_Type::T_INT,
- );
- $params['activity_id'] = array(
+ ];
+ $params['activity_id'] = [
'title' => 'Case Activity',
'description' => 'Id of an activity in the case',
'type' => CRM_Utils_Type::T_INT,
- );
- $params['tag_id'] = array(
+ ];
+ $params['tag_id'] = [
'title' => 'Tags',
'description' => 'Find cases with specified tags.',
'type' => 1,
'FKClassName' => 'CRM_Core_DAO_Tag',
'FKApiName' => 'Tag',
'supports_joins' => TRUE,
- );
+ ];
}
/**
* Array of parameters determined by getfields.
*/
function _civicrm_api3_case_create_spec(&$params) {
- $params['contact_id'] = array(
- 'api.aliases' => array('client_id'),
+ $params['contact_id'] = [
+ 'api.aliases' => ['client_id'],
'title' => 'Case Client',
'description' => 'Contact id of case client(s)',
'api.required' => 1,
'type' => CRM_Utils_Type::T_INT,
'FKApiName' => 'Contact',
- );
+ ];
$params['status_id']['api.default'] = 1;
- $params['status_id']['api.aliases'] = array('case_status');
+ $params['status_id']['api.aliases'] = ['case_status'];
$params['creator_id']['api.default'] = 'user_contact_id';
$params['creator_id']['type'] = CRM_Utils_Type::T_INT;
$params['creator_id']['title'] = 'Case Created By';
$params['start_date']['api.default'] = 'now';
- $params['medium_id'] = array(
+ $params['medium_id'] = [
'name' => 'medium_id',
'title' => 'Activity Medium',
'type' => CRM_Utils_Type::T_INT,
- );
+ ];
}
/**
if (is_array($params['contact_id'])) {
$operator = CRM_Utils_Array::first(array_keys($params['contact_id']));
if (!in_array($operator, \CRM_Core_DAO::acceptedSQLOperators(), TRUE)) {
- $params['contact_id'] = array('IN' => $params['contact_id']);
+ $params['contact_id'] = ['IN' => $params['contact_id']];
}
}
else {
- $params['contact_id'] = array('=' => $params['contact_id']);
+ $params['contact_id'] = ['=' => $params['contact_id']];
}
$clause = CRM_Core_DAO::createSQLFilter('contact_id', $params['contact_id']);
$sql->where("a.id IN (SELECT case_id FROM civicrm_case_contact WHERE $clause)");
// Clause to search by tag
if (!empty($params['tag_id'])) {
- $dummySpec = array();
+ $dummySpec = [];
_civicrm_api3_validate_integer($params, 'tag_id', $dummySpec, 'Case');
if (!is_array($params['tag_id'])) {
- $params['tag_id'] = array('=' => $params['tag_id']);
+ $params['tag_id'] = ['=' => $params['tag_id']];
}
$clause = \CRM_Core_DAO::createSQLFilter('tag_id', $params['tag_id']);
if ($clause) {
- $sql->where('a.id IN (SELECT entity_id FROM civicrm_entity_tag WHERE entity_table = "civicrm_case" AND !clause)', array('!clause' => $clause));
+ $sql->where('a.id IN (SELECT entity_id FROM civicrm_entity_tag WHERE entity_table = "civicrm_case" AND !clause)', ['!clause' => $clause]);
}
}
- $cases = _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), array('sequential' => 0) + $params, TRUE, 'Case', $sql);
+ $cases = _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), ['sequential' => 0] + $params, TRUE, 'Case', $sql);
if (empty($options['is_count']) && !empty($cases['values'])) {
// For historic reasons we return these by default only when fetching a case by id
if (!empty($params['id']) && is_numeric($params['id']) && empty($options['return'])) {
- $options['return'] = array(
+ $options['return'] = [
'contacts' => 1,
'activities' => 1,
'contact_id' => 1,
- );
+ ];
}
_civicrm_api3_case_read($cases['values'], $options);
*/
function civicrm_api3_case_activity_create($params) {
require_once "api/v3/Activity.php";
- return civicrm_api3_activity_create($params) + array(
+ return civicrm_api3_activity_create($params) + [
'deprecated' => CRM_Utils_Array::value('activity_create', _civicrm_api3_case_deprecation()),
- );
+ ];
}
/**
function civicrm_api3_case_addtimeline($params) {
$caseType = CRM_Case_BAO_Case::getCaseType($params['case_id'], 'name');
$xmlProcessor = new CRM_Case_XMLProcessor_Process();
- $xmlProcessorParams = array(
+ $xmlProcessorParams = [
'clientID' => CRM_Case_BAO_Case::getCaseClients($params['case_id']),
'creatorID' => $params['creator_id'],
'standardTimeline' => 0,
'caseID' => $params['case_id'],
'caseType' => $caseType,
'activitySetName' => $params['timeline'],
- );
+ ];
$xmlProcessor->run($caseType, $xmlProcessorParams);
return civicrm_api3_create_success();
}
* Array of parameters determined by getfields.
*/
function _civicrm_api3_case_addtimeline_spec(&$params) {
- $params['case_id'] = array(
+ $params['case_id'] = [
'title' => 'Case ID',
'description' => 'Id of case to update',
'type' => CRM_Utils_Type::T_INT,
'api.required' => 1,
- );
- $params['timeline'] = array(
+ ];
+ $params['timeline'] = [
'title' => 'Timeline',
'description' => 'Name of activity set',
'type' => CRM_Utils_Type::T_STRING,
'api.required' => 1,
- );
- $params['activity_date_time'] = array(
+ ];
+ $params['activity_date_time'] = [
'api.default' => 'now',
'title' => 'Activity date time',
'description' => 'Timeline start date',
'type' => CRM_Utils_Type::T_DATE,
- );
- $params['creator_id'] = array(
+ ];
+ $params['creator_id'] = [
'api.default' => 'user_contact_id',
'title' => 'Activity creator',
'description' => 'Contact id of timeline creator',
'type' => CRM_Utils_Type::T_INT,
- );
+ ];
}
/**
* Array of parameters determined by getfields.
*/
function _civicrm_api3_case_merge_spec(&$params) {
- $params['case_id_1'] = array(
+ $params['case_id_1'] = [
'title' => 'Case ID 1',
'description' => 'Id of main case',
'type' => CRM_Utils_Type::T_INT,
'api.required' => 1,
- );
- $params['case_id_2'] = array(
+ ];
+ $params['case_id_2'] = [
'title' => 'Case ID 2',
'description' => 'Id of second case',
'type' => CRM_Utils_Type::T_INT,
'api.required' => 1,
- );
+ ];
}
/**
* Array of deprecated actions
*/
function _civicrm_api3_case_deprecation() {
- return array('activity_create' => 'Case api "activity_create" action is deprecated. Use the activity api instead.');
+ return ['activity_create' => 'Case api "activity_create" action is deprecated. Use the activity api instead.'];
}
/**
}
//check parameters
- civicrm_api3_verify_mandatory($params, NULL, array('id'));
+ civicrm_api3_verify_mandatory($params, NULL, ['id']);
// return error if modifying creator id
if (array_key_exists('creator_id', $params)) {
throw new API_Exception(ts('You cannot update creator id'));
}
- $mCaseId = $origContactIds = array();
+ $mCaseId = $origContactIds = [];
// get original contact id and creator id of case
if (!empty($params['contact_id'])) {
$dao->copyValues($params);
$dao->save();
- $case = array();
+ $case = [];
_civicrm_api3_object_to_array($dao, $case);
- return civicrm_api3_create_success(array($dao->id => $case), $params, 'Case', 'update', $dao);
+ return civicrm_api3_create_success([$dao->id => $case], $params, 'Case', 'update', $dao);
}
/**
*/
function civicrm_api3_case_delete($params) {
//check parameters
- civicrm_api3_verify_mandatory($params, NULL, array('id'));
+ civicrm_api3_verify_mandatory($params, NULL, ['id']);
if (CRM_Case_BAO_Case::deleteCase($params['id'], CRM_Utils_Array::value('move_to_trash', $params, FALSE))) {
return civicrm_api3_create_success($params, $params, 'Case', 'delete');
* @return void
*/
function _civicrm_api3_case_restore_spec(&$spec) {
- $result = civicrm_api3('Case', 'getfields', array('api_action' => 'delete'));
- $spec = array('id' => $result['values']['id']);
+ $result = civicrm_api3('Case', 'getfields', ['api_action' => 'delete']);
+ $spec = ['id' => $result['values']['id']];
}
/**
}
if (!empty($options['return']['activities'])) {
// add case activities array - we'll populate them in bulk below
- $case['activities'] = array();
+ $case['activities'] = [];
}
// Properly render this joined field
if (!empty($options['return']['case_type_id.definition'])) {
$caseTypeName = !empty($case['case_type_id.name']) ? $case['case_type_id.name'] : CRM_Core_DAO::getFieldValue('CRM_Case_DAO_CaseType', $caseTypeId, 'name');
$xml = CRM_Case_XMLRepository::singleton()->retrieve($caseTypeName);
}
- $case['case_type_id.definition'] = array();
+ $case['case_type_id.definition'] = [];
if ($xml) {
$case['case_type_id.definition'] = CRM_Case_BAO_CaseType::convertXmlToDefinition($xml);
}
// Bulk-load activities
if (!empty($options['return']['activities'])) {
$query = "SELECT case_id, activity_id FROM civicrm_case_activity WHERE case_id IN (%1)";
- $params = array(1 => array(implode(',', array_keys($cases)), 'String', CRM_Core_DAO::QUERY_FORMAT_NO_QUOTES));
+ $params = [1 => [implode(',', array_keys($cases)), 'String', CRM_Core_DAO::QUERY_FORMAT_NO_QUOTES]];
$dao = CRM_Core_DAO::executeQuery($query, $params);
while ($dao->fetch()) {
$cases[$dao->case_id]['activities'][] = $dao->activity_id;
}
}
// Bulk-load tags. Supports joins onto the tag entity.
- $tagGet = array('tag_id', 'entity_id');
+ $tagGet = ['tag_id', 'entity_id'];
foreach (array_keys($options['return']) as $key) {
if (strpos($key, 'tag_id.') === 0) {
$tagGet[] = $key;
}
}
if (!empty($options['return']['tag_id'])) {
- $tags = civicrm_api3('EntityTag', 'get', array(
+ $tags = civicrm_api3('EntityTag', 'get', [
'entity_table' => 'civicrm_case',
- 'entity_id' => array('IN' => array_keys($cases)),
+ 'entity_id' => ['IN' => array_keys($cases)],
'return' => $tagGet,
- 'options' => array('limit' => 0),
- ));
+ 'options' => ['limit' => 0],
+ ]);
foreach ($tags['values'] as $tag) {
$key = (int) $tag['entity_id'];
unset($tag['entity_id'], $tag['id']);
*/
function _civicrm_api3_case_format_params(&$params) {
// Format/include custom params
- $values = array();
+ $values = [];
_civicrm_api3_custom_format_params($params, $values, 'Case');
$params = array_merge($params, $values);
// Convert single value to array here to simplify processing in later functions which expect an array.
if (isset($params['contact_id'])) {
if (!is_array($params['contact_id'])) {
- $params['contact_id'] = array($params['contact_id']);
+ $params['contact_id'] = [$params['contact_id']];
}
}
require_once 'api/v3/CaseContact.php';
//CRM:19956 - Assign case_id param if both id and case_id is passed to retrieve the case
if (!empty($params['id']) && !empty($params['params']) && !empty($params['params']['case_id'])) {
- $params['params']['case_id'] = array('IN' => $params['id']);
+ $params['params']['case_id'] = ['IN' => $params['id']];
unset($params['id']);
}
$params['id_field'] = 'case_id';
$params['label_field'] = $params['search_field'] = 'contact_id.sort_name';
- $params['description_field'] = array(
+ $params['description_field'] = [
'case_id',
'case_id.case_type_id.title',
'case_id.subject',
'case_id.status_id',
'case_id.start_date',
- );
- $apiRequest = array(
+ ];
+ $apiRequest = [
'version' => 3,
'entity' => 'CaseContact',
'action' => 'getlist',
'params' => $params,
- );
+ ];
return civicrm_api3_generic_getList($apiRequest);
}
* @return array
*/
function _civicrm_api3_case_contact_getlist_output($result, $request, $entity, $fields) {
- $output = array();
+ $output = [];
if (!empty($result['values'])) {
foreach ($result['values'] as $row) {
- $data = array(
+ $data = [
'id' => $row[$request['id_field']],
'label' => $row[$request['label_field']] . ' - ' . $row['case_id.case_type_id.title'],
- );
+ ];
$status = CRM_Core_PseudoConstant::getLabel('CRM_Case_BAO_Case', 'status_id', $row['case_id.status_id']);
$date = CRM_Utils_Date::customFormat($row['case_id.start_date']);
- $data['description'] = array(
- "#{$row['case_id']}: $status " . ts('(opened %1)', array(1 => $date)),
+ $data['description'] = [
+ "#{$row['case_id']}: $status " . ts('(opened %1)', [1 => $date]),
$row['case_id.subject'],
- );
+ ];
if (!empty($request['image_field'])) {
$data['image'] = isset($row[$request['image_field']]) ? $row[$request['image_field']] : '';
}
* @return array
* @throws \CRM_Core_Exception
*/
-function _civicrm_api3_case_type_get_formatResult(&$result, $options = array()) {
+function _civicrm_api3_case_type_get_formatResult(&$result, $options = []) {
foreach ($result['values'] as $key => &$caseType) {
if (!empty($caseType['definition'])) {
list($xml) = CRM_Utils_XML::parseString($caseType['definition']);
- $caseType['definition'] = $xml ? CRM_Case_BAO_CaseType::convertXmlToDefinition($xml) : array();
+ $caseType['definition'] = $xml ? CRM_Case_BAO_CaseType::convertXmlToDefinition($xml) : [];
}
else {
if (empty($options['return']) || !empty($options['return']['definition'])) {
$caseTypeName = (isset($caseType['name'])) ? $caseType['name'] : CRM_Core_DAO::getFieldValue('CRM_Case_DAO_CaseType', $caseType['id'], 'name', 'id', TRUE);
$xml = CRM_Case_XMLRepository::singleton()->retrieve($caseTypeName);
- $caseType['definition'] = $xml ? CRM_Case_BAO_CaseType::convertXmlToDefinition($xml) : array();
+ $caseType['definition'] = $xml ? CRM_Case_BAO_CaseType::convertXmlToDefinition($xml) : [];
}
}
$caseType['is_forkable'] = CRM_Case_BAO_CaseType::isForkable($caseType['id']);
// once tests are 100% can try removing the first block & a similar block from Generic:getoptions
// Whitelist approach is safer
- $allowedClasses = array(
+ $allowedClasses = [
'CRM_Core_PseudoConstant',
'CRM_Event_PseudoConstant',
'CRM_Contribute_PseudoConstant',
'CRM_Member_PseudoConstant',
- );
+ ];
$className = $allowedClasses[0];
if (!empty($params['class']) && in_array($params['class'], $allowedClasses)) {
$className = $params['class'];
$callable = "$className::$name";
if (is_callable($callable)) {
if (empty($params)) {
- $values = call_user_func(array($className, $name));
+ $values = call_user_func([$className, $name]);
}
else {
- $values = call_user_func(array($className, $name));
+ $values = call_user_func([$className, $name]);
//@TODO XAV take out the param the COOKIE, Entity, Action and so there are only the "real param" in it
//$values = call_user_func_array( array( $className, $name ), $params );
}
return civicrm_api3_create_success($values, $params, 'Constant');
}
else {
- $values = call_user_func(array('CRM_Utils_PseudoConstant', 'getConstant'), $name);
+ $values = call_user_func(['CRM_Utils_PseudoConstant', 'getConstant'], $name);
if (!empty($values)) {
return civicrm_api3_create_success($values, $params, 'Constant');
}
* @param array $params
*/
function _civicrm_api3_constant_get_spec(&$params) {
- $options = array(
+ $options = [
'activityStatus',
'activityType',
'addressee',
'visibility',
'worldRegion',
'wysiwygEditor',
- );
- $params = array(
- 'name' => array(
+ ];
+ $params = [
+ 'name' => [
'title' => 'Constant Name',
'name' => 'name',
'api.required' => 1,
'options' => array_combine($options, $options),
'type' => CRM_Utils_Type::T_STRING,
- ),
- );
+ ],
+ ];
}
* ContactType array
*/
function civicrm_api3_contact_type_create($params) {
- civicrm_api3_verify_mandatory($params, _civicrm_api3_get_DAO(__FUNCTION__), array('name', 'parent_id'));
+ civicrm_api3_verify_mandatory($params, _civicrm_api3_get_DAO(__FUNCTION__), ['name', 'parent_id']);
if (empty($params['id'])) {
if (!array_key_exists('label', $params)) {
* Api result array
*/
function civicrm_api3_contribution_create(&$params) {
- $values = array();
+ $values = [];
_civicrm_api3_custom_format_params($params, $values, 'Contribution');
$params = array_merge($params, $values);
// The BAO should not clean money - it should be done in the form layer & api wrapper
}
}
if (!empty($params['id']) && !empty($params['contribution_status_id'])) {
- $error = array();
+ $error = [];
//throw error for invalid status change such as setting completed back to pending
//@todo this sort of validation belongs in the BAO not the API - if it is not an OK
// action it needs to be blocked there. If it is Ok through a form it needs to be OK through the api
}
}
if (!empty($params['id']) && !empty($params['financial_type_id'])) {
- $error = array();
+ $error = [];
CRM_Contribute_BAO_Contribution::checkFinancialTypeChange($params['financial_type_id'], $params['id'], $error);
if (array_key_exists('financial_type_id', $error)) {
throw new API_Exception($error['financial_type_id']);
function _civicrm_api3_contribution_create_spec(&$params) {
$params['contact_id']['api.required'] = 1;
$params['total_amount']['api.required'] = 1;
- $params['payment_instrument_id']['api.aliases'] = array('payment_instrument');
+ $params['payment_instrument_id']['api.aliases'] = ['payment_instrument'];
$params['receive_date']['api.default'] = 'now';
$params['receive_date']['api.required'] = TRUE;
- $params['payment_processor'] = array(
+ $params['payment_processor'] = [
'name' => 'payment_processor',
'title' => 'Payment Processor ID',
'description' => 'ID of payment processor used for this contribution',
// field is called payment processor - not payment processor id but can only be one id so
// it seems likely someone will fix it up one day to be more consistent - lets alias it from the start
- 'api.aliases' => array('payment_processor_id'),
+ 'api.aliases' => ['payment_processor_id'],
'type' => CRM_Utils_Type::T_INT,
- );
- $params['financial_type_id']['api.aliases'] = array('contribution_type_id', 'contribution_type');
+ ];
+ $params['financial_type_id']['api.aliases'] = ['contribution_type_id', 'contribution_type'];
$params['financial_type_id']['api.required'] = 1;
- $params['note'] = array(
+ $params['note'] = [
'name' => 'note',
'uniqueName' => 'contribution_note',
'title' => 'note',
'type' => 2,
'description' => 'Associated Note in the notes table',
- );
- $params['soft_credit_to'] = array(
+ ];
+ $params['soft_credit_to'] = [
'name' => 'soft_credit_to',
'title' => 'Soft Credit contact ID (legacy)',
'type' => CRM_Utils_Type::T_INT,
'description' => 'ID of Contact to be Soft credited to (deprecated - use contribution_soft api)',
'FKClassName' => 'CRM_Contact_DAO_Contact',
- );
- $params['honor_contact_id'] = array(
+ ];
+ $params['honor_contact_id'] = [
'name' => 'honor_contact_id',
'title' => 'Honoree contact ID (legacy)',
'type' => CRM_Utils_Type::T_INT,
'description' => 'ID of honoree contact (deprecated - use contribution_soft api)',
'FKClassName' => 'CRM_Contact_DAO_Contact',
- );
- $params['honor_type_id'] = array(
+ ];
+ $params['honor_type_id'] = [
'name' => 'honor_type_id',
'title' => 'Honoree Type (legacy)',
'type' => CRM_Utils_Type::T_INT,
'description' => 'Type of honoree contact (deprecated - use contribution_soft api)',
'pseudoconstant' => TRUE,
- );
+ ];
// note this is a recommended option but not adding as a default to avoid
// creating unnecessary changes for the dev
- $params['skipRecentView'] = array(
+ $params['skipRecentView'] = [
'name' => 'skipRecentView',
'title' => 'Skip adding to recent view',
'type' => CRM_Utils_Type::T_BOOLEAN,
'description' => 'Do not add to recent view (setting this improves performance)',
- );
- $params['skipLineItem'] = array(
+ ];
+ $params['skipLineItem'] = [
'name' => 'skipLineItem',
'title' => 'Skip adding line items',
'type' => CRM_Utils_Type::T_BOOLEAN,
'api.default' => 0,
'description' => 'Do not add line items by default (if you wish to add your own)',
- );
- $params['batch_id'] = array(
+ ];
+ $params['batch_id'] = [
'title' => 'Batch',
'type' => CRM_Utils_Type::T_INT,
'description' => 'Batch which relevant transactions should be added to',
- );
- $params['refund_trxn_id'] = array(
+ ];
+ $params['refund_trxn_id'] = [
'title' => 'Refund Transaction ID',
'type' => CRM_Utils_Type::T_STRING,
'description' => 'Transaction ID specific to the refund taking place',
- );
- $params['card_type_id'] = array(
+ ];
+ $params['card_type_id'] = [
'title' => 'Card Type ID',
'description' => 'Providing Credit Card Type ID',
'type' => CRM_Utils_Type::T_INT,
- 'pseudoconstant' => array(
+ 'pseudoconstant' => [
'optionGroupName' => 'accept_creditcard',
- ),
- );
+ ],
+ ];
}
/**
function _civicrm_api3_contribution_create_legacy_support_45(&$params) {
//legacy soft credit handling - recommended approach is chaining
if (!empty($params['soft_credit_to'])) {
- $params['soft_credit'][] = array(
+ $params['soft_credit'][] = [
'contact_id' => $params['soft_credit_to'],
'amount' => $params['total_amount'],
'soft_credit_type_id' => CRM_Core_OptionGroup::getDefaultValue("soft_credit_type"),
- );
+ ];
}
if (!empty($params['honor_contact_id'])) {
- $params['soft_credit'][] = array(
+ $params['soft_credit'][] = [
'contact_id' => $params['honor_contact_id'],
'amount' => $params['total_amount'],
'soft_credit_type_id' => CRM_Utils_Array::value('honor_type_id', $params, CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_ContributionSoft', 'soft_credit_type_id', 'in_honor_of')),
- );
+ ];
}
}
throw new API_Exception('You do not have permission to delete this contribution');
}
if (CRM_Contribute_BAO_Contribution::deleteContribution($contributionID)) {
- return civicrm_api3_create_success(array($contributionID => 1));
+ return civicrm_api3_create_success([$contributionID => 1]);
}
else {
throw new API_Exception('Could not delete contribution');
* @param array $params
*/
function _civicrm_api3_contribution_delete_spec(&$params) {
- $params['id']['api.aliases'] = array('contribution_id');
+ $params['id']['api.aliases'] = ['contribution_id'];
}
/**
* @throws \API_Exception
*/
function _civicrm_api3_contribution_get_support_nonunique_returns($params) {
- $additionalOptions = array();
+ $additionalOptions = [];
$options = _civicrm_api3_get_options_from_params($params, TRUE);
- foreach (array('check_number', 'address_id') as $changedVariable) {
+ foreach (['check_number', 'address_id'] as $changedVariable) {
if (isset($options['return']) && !empty($options['return'][$changedVariable])) {
$additionalOptions['return']['contribution_' . $changedVariable] = 1;
}
// Arguably we should also do the same with 'campaign_id' &
// 'source' - which are also fields being rendered with unique names.
// That seems more consistent with other api where we output the actual field names.
- $outputAliases = array(
+ $outputAliases = [
'contribution_check_number' => 'check_number',
'contribution_address_id' => 'address_id',
'payment_instrument_id' => 'instrument_id',
- );
+ ];
foreach ($outputAliases as $returnName => $copyTo) {
if (array_key_exists($returnName, $contribution)) {
$contribution[$copyTo] = $contribution[$returnName];
* @return int
*/
function civicrm_api3_contribution_getcount($params) {
- $count = _civicrm_api3_get_using_query_object('Contribution', $params, array(), TRUE, CRM_Contact_BAO_Query::MODE_CONTRIBUTE);
+ $count = _civicrm_api3_get_using_query_object('Contribution', $params, [], TRUE, CRM_Contact_BAO_Query::MODE_CONTRIBUTE);
return (int) $count;
}
* Array of parameters determined by getfields.
*/
function _civicrm_api3_contribution_get_spec(&$params) {
- $params['contribution_test'] = array(
+ $params['contribution_test'] = [
'api.default' => 0,
'type' => CRM_Utils_Type::T_BOOLEAN,
'title' => 'Get Test Contributions?',
- 'api.aliases' => array('is_test'),
- );
+ 'api.aliases' => ['is_test'],
+ ];
- $params['financial_type_id']['api.aliases'] = array('contribution_type_id');
- $params['payment_instrument_id']['api.aliases'] = array('contribution_payment_instrument', 'payment_instrument');
+ $params['financial_type_id']['api.aliases'] = ['contribution_type_id'];
+ $params['payment_instrument_id']['api.aliases'] = ['contribution_payment_instrument', 'payment_instrument'];
$params['contact_id'] = CRM_Utils_Array::value('contribution_contact_id', $params);
- $params['contact_id']['api.aliases'] = array('contribution_contact_id');
+ $params['contact_id']['api.aliases'] = ['contribution_contact_id'];
unset($params['contribution_contact_id']);
}
function _civicrm_api3_contribute_format_params($params, &$values) {
//legacy way of formatting from v2 api - v3 way is to define metadata & do it in the api layer
_civicrm_api3_filter_fields_for_bao('Contribution', $params, $values);
- return array();
+ return [];
}
/**
* Array of parameters determined by getfields.
*/
function _civicrm_api3_contribution_transact_spec(&$params) {
- $fields = civicrm_api3('Contribution', 'getfields', array('action' => 'create'));
+ $fields = civicrm_api3('Contribution', 'getfields', ['action' => 'create']);
$params = array_merge($params, $fields['values']);
$params['receive_date']['api.default'] = 'now';
}
* @throws Exception
*/
function civicrm_api3_contribution_sendconfirmation($params) {
- $ids = $values = array();
- $allowedParams = array(
+ $ids = $values = [];
+ $allowedParams = [
'receipt_from_email',
'receipt_from_name',
'receipt_update',
'bcc_receipt',
'receipt_text',
'payment_processor_id',
- );
+ ];
$input = array_intersect_key($params, array_flip($allowedParams));
$input['is_email_receipt'] = TRUE;
CRM_Contribute_BAO_Contribution::sendMail($input, $ids, $params['id'], $values);
* Array of parameters determined by getfields.
*/
function _civicrm_api3_contribution_sendconfirmation_spec(&$params) {
- $params['id'] = array(
+ $params['id'] = [
'api.required' => 1,
'title' => ts('Contribution ID'),
'type' => CRM_Utils_Type::T_INT,
- );
- $params['receipt_from_email'] = array(
+ ];
+ $params['receipt_from_email'] = [
'title' => ts('From Email address (string)'),
'type' => CRM_Utils_Type::T_STRING,
- );
- $params['receipt_from_name'] = array(
+ ];
+ $params['receipt_from_name'] = [
'title' => ts('From Name (string)'),
'type' => CRM_Utils_Type::T_STRING,
- );
- $params['cc_receipt'] = array(
+ ];
+ $params['cc_receipt'] = [
'title' => ts('CC Email address (string)'),
'type' => CRM_Utils_Type::T_STRING,
- );
- $params['bcc_receipt'] = array(
+ ];
+ $params['bcc_receipt'] = [
'title' => ts('BCC Email address (string)'),
'type' => CRM_Utils_Type::T_STRING,
- );
- $params['receipt_text'] = array(
+ ];
+ $params['receipt_text'] = [
'title' => ts('Message (string)'),
'type' => CRM_Utils_Type::T_STRING,
- );
- $params['receipt_update'] = array(
+ ];
+ $params['receipt_update'] = [
'title' => ts('Update the Receipt Date'),
'type' => CRM_Utils_Type::T_BOOLEAN,
'api.default' => TRUE,
- );
- $params['payment_processor_id'] = array(
+ ];
+ $params['payment_processor_id'] = [
'title' => ts('Payment processor Id (avoids mis-guesses)'),
'type' => CRM_Utils_Type::T_INT,
- );
+ ];
}
/**
* @throws \Exception
*/
function civicrm_api3_contribution_completetransaction(&$params) {
- $input = $ids = array();
+ $input = $ids = [];
if (isset($params['payment_processor_id'])) {
$input['payment_processor_id'] = $params['payment_processor_id'];
}
* @param array $params
*/
function _civicrm_api3_contribution_completetransaction_spec(&$params) {
- $params['id'] = array(
+ $params['id'] = [
'title' => 'Contribution ID',
'type' => CRM_Utils_Type::T_INT,
'api.required' => TRUE,
- );
- $params['trxn_id'] = array(
+ ];
+ $params['trxn_id'] = [
'title' => 'Transaction ID',
'type' => CRM_Utils_Type::T_STRING,
- );
- $params['is_email_receipt'] = array(
+ ];
+ $params['is_email_receipt'] = [
'title' => 'Send email Receipt?',
'type' => CRM_Utils_Type::T_BOOLEAN,
- );
- $params['receipt_from_email'] = array(
+ ];
+ $params['receipt_from_email'] = [
'title' => 'Email to send receipt from.',
'description' => 'If not provided this will default to being based on domain mail or contribution page',
'type' => CRM_Utils_Type::T_EMAIL,
- );
- $params['receipt_from_name'] = array(
+ ];
+ $params['receipt_from_name'] = [
'title' => 'Name to send receipt from',
'description' => '. If not provided this will default to domain mail or contribution page',
'type' => CRM_Utils_Type::T_STRING,
- );
- $params['payment_processor_id'] = array(
+ ];
+ $params['payment_processor_id'] = [
'title' => 'Payment processor ID',
'description' => 'Providing this is strongly recommended, as not possible to calculate it accurately always',
'type' => CRM_Utils_Type::T_INT,
- );
- $params['fee_amount'] = array(
+ ];
+ $params['fee_amount'] = [
'title' => 'Fee charged on transaction',
'description' => 'If a fee has been charged then the amount',
'type' => CRM_Utils_Type::T_FLOAT,
- );
- $params['trxn_date'] = array(
+ ];
+ $params['trxn_date'] = [
'title' => 'Transaction Date',
'description' => 'Date this transaction occurred',
'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
- );
- $params['card_type_id'] = array(
+ ];
+ $params['card_type_id'] = [
'title' => 'Card Type ID',
'description' => 'Providing Credit Card Type ID',
'type' => CRM_Utils_Type::T_INT,
- 'pseudoconstant' => array(
+ 'pseudoconstant' => [
'optionGroupName' => 'accept_creditcard',
- ),
- );
+ ],
+ ];
}
/**
* @throws API_Exception
*/
function civicrm_api3_contribution_repeattransaction(&$params) {
- $input = $ids = array();
- civicrm_api3_verify_one_mandatory($params, NULL, array('contribution_recur_id', 'original_contribution_id'));
+ $input = $ids = [];
+ civicrm_api3_verify_one_mandatory($params, NULL, ['contribution_recur_id', 'original_contribution_id']);
if (empty($params['original_contribution_id'])) {
// CRM-19873 call with test mode.
- $params['original_contribution_id'] = civicrm_api3('contribution', 'getvalue', array(
+ $params['original_contribution_id'] = civicrm_api3('contribution', 'getvalue', [
'return' => 'id',
- 'contribution_status_id' => array('IN' => array('Completed')),
+ 'contribution_status_id' => ['IN' => ['Completed']],
'contribution_recur_id' => $params['contribution_recur_id'],
'contribution_test' => CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionRecur', $params['contribution_recur_id'], 'is_test'),
- 'options' => array('limit' => 1, 'sort' => 'id DESC'),
- ));
+ 'options' => ['limit' => 1, 'sort' => 'id DESC'],
+ ]);
}
$contribution = new CRM_Contribute_BAO_Contribution();
$contribution->id = $params['original_contribution_id'];
'A valid original contribution ID is required', 'invalid_data');
}
$original_contribution = clone $contribution;
- $input['payment_processor_id'] = civicrm_api3('contributionRecur', 'getvalue', array(
+ $input['payment_processor_id'] = civicrm_api3('contributionRecur', 'getvalue', [
'return' => 'payment_processor_id',
'id' => $contribution->contribution_recur_id,
- ));
+ ]);
try {
if (!$contribution->loadRelatedObjects($input, $ids, TRUE)) {
throw new API_Exception('failed to load related objects');
unset($contribution->id, $contribution->receive_date, $contribution->invoice_id);
$contribution->receive_date = $params['receive_date'];
- $passThroughParams = array(
+ $passThroughParams = [
'trxn_id',
'total_amount',
'campaign_id',
'fee_amount',
'financial_type_id',
'contribution_status_id',
- );
+ ];
$input = array_intersect_key($params, array_fill_keys($passThroughParams, NULL));
return _ipn_process_transaction($params, $contribution, $input, $ids, $original_contribution);
* @param array $params
*/
function _civicrm_api3_contribution_repeattransaction_spec(&$params) {
- $params['original_contribution_id'] = array(
+ $params['original_contribution_id'] = [
'title' => 'Original Contribution ID',
'description' => 'Contribution ID to copy (will be calculated from recurring contribution if not provided)',
'type' => CRM_Utils_Type::T_INT,
- );
- $params['contribution_recur_id'] = array(
+ ];
+ $params['contribution_recur_id'] = [
'title' => 'Recurring contribution ID',
'type' => CRM_Utils_Type::T_INT,
- );
- $params['trxn_id'] = array(
+ ];
+ $params['trxn_id'] = [
'title' => 'Transaction ID',
'type' => CRM_Utils_Type::T_STRING,
- );
- $params['is_email_receipt'] = array(
+ ];
+ $params['is_email_receipt'] = [
'title' => 'Send email Receipt?',
'type' => CRM_Utils_Type::T_BOOLEAN,
- );
- $params['contribution_status_id'] = array(
+ ];
+ $params['contribution_status_id'] = [
'title' => 'Contribution Status ID',
'name' => 'contribution_status_id',
'type' => CRM_Utils_Type::T_INT,
- 'pseudoconstant' => array(
+ 'pseudoconstant' => [
'optionGroupName' => 'contribution_status',
- ),
+ ],
'api.required' => TRUE,
- );
- $params['receive_date'] = array(
+ ];
+ $params['receive_date'] = [
'title' => 'Contribution Receive Date',
'name' => 'receive_date',
'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
'api.default' => 'now',
- );
- $params['trxn_id'] = array(
+ ];
+ $params['trxn_id'] = [
'title' => 'Transaction ID',
'name' => 'trxn_id',
'type' => CRM_Utils_Type::T_STRING,
- );
- $params['campaign_id'] = array(
+ ];
+ $params['campaign_id'] = [
'title' => 'Campaign ID',
'name' => 'campaign_id',
'type' => CRM_Utils_Type::T_INT,
- 'pseudoconstant' => array(
+ 'pseudoconstant' => [
'table' => 'civicrm_campaign',
'keyColumn' => 'id',
'labelColumn' => 'title',
- ),
- );
- $params['financial_type_id'] = array(
+ ],
+ ];
+ $params['financial_type_id'] = [
'title' => 'Financial ID (ignored if more than one line item)',
'name' => 'financial_type_id',
'type' => CRM_Utils_Type::T_INT,
- 'pseudoconstant' => array(
+ 'pseudoconstant' => [
'table' => 'civicrm_financial_type',
'keyColumn' => 'id',
'labelColumn' => 'name',
- ),
- );
- $params['payment_processor_id'] = array(
+ ],
+ ];
+ $params['payment_processor_id'] = [
'description' => ts('Payment processor ID, will be loaded from contribution_recur if not provided'),
'title' => 'Payment processor ID',
'name' => 'payment_processor_id',
'type' => CRM_Utils_Type::T_INT,
- );
+ ];
}
*/
function _civicrm_api3_contribution_page_create_spec(&$params) {
$params['financial_type_id']['api.required'] = 1;
- $params['payment_processor']['api.aliases'] = array('payment_processor_id');
+ $params['payment_processor']['api.aliases'] = ['payment_processor_id'];
$params['is_active']['api.default'] = 1;
}
* API result array
*/
function civicrm_api3_contribution_page_validate($params) {
+ // If we are calling this as a result of a POST action (e.g validating a form submission before first getting payment
+ // authorization from a payment processor like Paypal checkout) the lack of a qfKey will not result in a valid
+ // one being generated so we generate one first.
+ $originalRequest = $_REQUEST;
+ $qfKey = CRM_Utils_Array::value('qfKey', $_REQUEST);
+ if (!$qfKey) {
+ $_REQUEST['qfKey'] = CRM_Core_Key::get('CRM_Core_Controller', TRUE);
+ }
$form = new CRM_Contribute_Form_Contribution_Main();
$form->controller = new CRM_Core_Controller();
$form->set('id', $params['id']);
if ($errors === TRUE) {
$errors = [];
}
+ $_REQUEST = $originalRequest;
return civicrm_api3_create_success($errors, $params, 'ContributionPage', 'validate');
}
+/**
+ * Metadata for validate action.
+ *
+ * @param array $params
+ */
+function _civicrm_api3_contribution_page_validate_spec(&$params) {
+ $params['id'] = [
+ 'title' => ts('Contribution Page ID'),
+ 'api.required' => TRUE,
+ 'type' => CRM_Utils_Type::T_INT,
+ ];
+}
+
/**
* Set default getlist parameters.
*
* @return array
*/
function _civicrm_api3_contribution_page_getlist_defaults(&$request) {
- return array(
- 'description_field' => array(
+ return [
+ 'description_field' => [
'intro_text',
- ),
- 'params' => array(
+ ],
+ 'params' => [
'is_active' => 1,
- ),
- );
+ ],
+ ];
}
* returns true is successfully cancelled
*/
function civicrm_api3_contribution_recur_cancel($params) {
- civicrm_api3_verify_one_mandatory($params, NULL, array('id'));
+ civicrm_api3_verify_one_mandatory($params, NULL, ['id']);
return CRM_Contribute_BAO_ContributionRecur::cancelRecurContribution($params['id']) ? civicrm_api3_create_success() : civicrm_api3_create_error(ts('Error while cancelling recurring contribution'));
}
foreach ($params['option_values'] as $key => $value) {
// Translate simple key/value pairs into full-blown option values
if (!is_array($value)) {
- $value = array(
+ $value = [
'label' => $value,
'value' => $key,
'is_active' => 1,
'weight' => $weight,
- );
+ ];
$key = $weight++;
}
$params['option_label'][$key] = $value['label'];
$params['option_weight'][$key] = $value['weight'];
}
}
- $values = array();
+ $values = [];
$customField = CRM_Core_BAO_CustomField::create($params);
_civicrm_api3_object_to_array_unique_fields($customField, $values[$customField->id]);
_civicrm_api3_custom_field_flush_static_caches();
* Flush static caches in functions that might have stored available custom fields.
*/
function _civicrm_api3_custom_field_flush_static_caches() {
- civicrm_api('CustomField', 'getfields', array('version' => 3, 'cache_clear' => 1));
+ civicrm_api('CustomField', 'getfields', ['version' => 3, 'cache_clear' => 1]);
CRM_Core_BAO_UFField::getAvailableFieldsFlat(TRUE);
}
$params['label']['api.required'] = 1;
$params['custom_group_id']['api.required'] = 1;
$params['is_active']['api.default'] = 1;
- $params['option_values'] = array(
+ $params['option_values'] = [
'title' => 'Option Values',
'description' => "Pass an array of options (value => label) to create this field's option values",
- );
+ ];
// TODO: Why expose this to the api at all?
- $params['option_type'] = array(
+ $params['option_type'] = [
'title' => 'Option Type',
'description' => 'This (boolean) field tells the BAO to create an option group for the field if the field type is appropriate',
'api.default' => 1,
'type' => CRM_Utils_Type::T_BOOLEAN,
- );
+ ];
$params['data_type']['api.default'] = 'String';
$params['is_active']['api.default'] = 1;
}
$field->id = $params['id'];
$field->find(TRUE);
$customFieldDelete = CRM_Core_BAO_CustomField::deleteField($field);
- civicrm_api('CustomField', 'getfields', array('version' => 3, 'cache_clear' => 1));
+ civicrm_api('CustomField', 'getfields', ['version' => 3, 'cache_clear' => 1]);
return $customFieldDelete ? civicrm_api3_create_error('Error while deleting custom field') : civicrm_api3_create_success();
}
* @todo remove this function - not in use but need to review functionality before
* removing as it might be useful in wrapper layer
*/
-function _civicrm_api3_custom_field_validate_field($fieldName, $value, $fieldDetails, &$errors = array()) {
+function _civicrm_api3_custom_field_validate_field($fieldName, $value, $fieldDetails, &$errors = []) {
return NULL;
//see comment block
if (!$value) {
}
if (!is_array($value)) {
- $value = array($value);
+ $value = [$value];
}
$query = "SELECT count(*) FROM civicrm_country WHERE id IN (" . implode(',', $value) . ")";
}
if (!is_array($value)) {
- $value = array($value);
+ $value = [$value];
}
$query = "
break;
}
- if (in_array($htmlType, array(
- 'Select', 'Multi-Select', 'CheckBox', 'Radio')) &&
+ if (in_array($htmlType, [
+ 'Select', 'Multi-Select', 'CheckBox', 'Radio']) &&
!isset($errors[$fieldName])
) {
$options = CRM_Core_OptionGroup::valuesByID($fieldDetails['option_group_id']);
if (!is_array($value)) {
- $value = array($value);
+ $value = [$value];
}
$invalidOptions = array_diff($value, array_keys($options));
*/
function civicrm_api3_custom_field_setvalue($params) {
require_once 'api/v3/Generic/Setvalue.php';
- $result = civicrm_api3_generic_setValue(array("entity" => 'CustomField', 'params' => $params));
+ $result = civicrm_api3_generic_setValue(["entity" => 'CustomField', 'params' => $params]);
if (empty($result['is_error'])) {
CRM_Utils_System::flushCache();
}
*/
function civicrm_api3_custom_group_setvalue($params) {
require_once 'api/v3/Generic/Setvalue.php';
- $result = civicrm_api3_generic_setValue(array("entity" => 'CustomGroup', 'params' => $params));
+ $result = civicrm_api3_generic_setValue(["entity" => 'CustomGroup', 'params' => $params]);
if (empty($result['is_error'])) {
CRM_Utils_System::flushCache();
}
$params['option_group_id']['api.default'] = CRM_Core_DAO::getFieldValue(
'CRM_Core_DAO_OptionGroup', 'custom_search', 'id', 'name'
);
- $params['name']['api.aliases'] = array('class_name');
+ $params['name']['api.aliases'] = ['class_name'];
}
/**
if (!empty($params['entity_table']) && substr($params['entity_table'], 0, 7) == 'civicrm') {
$params['entity_table'] = substr($params['entity_table'], 8, 7);
}
- $create = array('entityID' => $params['entity_id']);
+ $create = ['entityID' => $params['entity_id']];
// Translate names and
//Convert arrays to multi-value strings
$sp = CRM_Core_DAO::VALUE_SEPARATOR;
*/
function civicrm_api3_custom_value_get($params) {
- $getParams = array(
+ $getParams = [
'entityID' => $params['entity_id'],
'entityType' => CRM_Utils_Array::value('entity_table', $params, ''),
- );
+ ];
if (strstr($getParams['entityType'], 'civicrm_')) {
$getParams['entityType'] = ucfirst(substr($getParams['entityType'], 8));
}
if ($result['is_error']) {
if ($result['error_message'] == "No values found for the specified entity ID and custom field(s).") {
- $values = array();
+ $values = [];
return civicrm_api3_create_success($values, $params, 'CustomValue');
}
else {
* @throws \CiviCRM_API3_Exception
*/
function _civicrm_api3_custom_value_gettree_spec(&$spec) {
- $spec['entity_id'] = array(
+ $spec['entity_id'] = [
'title' => 'Entity Id',
'description' => 'Id of entity',
'type' => CRM_Utils_Type::T_INT,
'api.required' => 1,
- );
+ ];
$entities = civicrm_api3('Entity', 'get');
$entities = array_diff($entities['values'], $entities['deprecated']);
- $spec['entity_type'] = array(
+ $spec['entity_type'] = [
'title' => 'Entity Type',
'description' => 'API name of entity type, e.g. "Contact"',
'type' => CRM_Utils_Type::T_STRING,
'api.required' => 1,
'options' => array_combine($entities, $entities),
- );
+ ];
// Return params for custom group, field & value
foreach (CRM_Core_DAO_CustomGroup::fields() as $field) {
$name = 'custom_group.' . $field['name'];
- $spec[$name] = array('name' => $name) + $field;
+ $spec[$name] = ['name' => $name] + $field;
}
foreach (CRM_Core_DAO_CustomField::fields() as $field) {
$name = 'custom_field.' . $field['name'];
- $spec[$name] = array('name' => $name) + $field;
+ $spec[$name] = ['name' => $name] + $field;
}
- $spec['custom_value.id'] = array(
+ $spec['custom_value.id'] = [
'title' => 'Custom Value Id',
'description' => 'Id of record in custom value table',
'type' => CRM_Utils_Type::T_INT,
- );
- $spec['custom_value.data'] = array(
+ ];
+ $spec['custom_value.data'] = [
'title' => 'Custom Value (Raw)',
'description' => 'Raw value as stored in the database',
'type' => CRM_Utils_Type::T_STRING,
- );
- $spec['custom_value.display'] = array(
+ ];
+ $spec['custom_value.display'] = [
'title' => 'Custom Value (Formatted)',
'description' => 'Custom value formatted for display',
'type' => CRM_Utils_Type::T_STRING,
- );
+ ];
}
/**
* @throws \CiviCRM_API3_Exception
*/
function civicrm_api3_custom_value_gettree($params) {
- $ret = array();
+ $ret = [];
$options = _civicrm_api3_get_options_from_params($params);
- $toReturn = array(
- 'custom_group' => array(),
- 'custom_field' => array(),
- 'custom_value' => array(),
- );
+ $toReturn = [
+ 'custom_group' => [],
+ 'custom_field' => [],
+ 'custom_value' => [],
+ ];
foreach (array_keys($options['return']) as $r) {
list($type, $field) = explode('.', $r);
if (isset($toReturn[$type])) {
}
switch ($params['entity_type']) {
case 'Contact':
- $ret = array('entityType' => 'contact_type', 'subTypes' => 'contact_sub_type');
+ $ret = ['entityType' => 'contact_type', 'subTypes' => 'contact_sub_type'];
break;
case 'Activity':
case 'Grant':
case 'Membership':
case 'Relationship':
- $ret = array('subTypes' => strtolower($params['entity_type']) . '_type_id');
+ $ret = ['subTypes' => strtolower($params['entity_type']) . '_type_id'];
break;
case 'Participant':
// todo
}
- $treeParams = array(
+ $treeParams = [
'entityType' => $params['entity_type'],
- 'subTypes' => array(),
+ 'subTypes' => [],
'subName' => NULL,
- );
+ ];
// Fetch entity data for custom group type/sub-type
// Also verify access permissions (api3 will throw an exception if permission denied)
if ($ret || !empty($params['check_permissions'])) {
- $entityData = civicrm_api3($params['entity_type'], 'getsingle', array(
+ $entityData = civicrm_api3($params['entity_type'], 'getsingle', [
'id' => $params['entity_id'],
'check_permissions' => !empty($params['check_permissions']),
- 'return' => array_merge(array('id'), array_values($ret)),
- ));
+ 'return' => array_merge(['id'], array_values($ret)),
+ ]);
foreach ($ret as $param => $key) {
if (isset($entityData[$key])) {
$treeParams[$param] = $entityData[$key];
}
$tree = CRM_Core_BAO_CustomGroup::getTree($treeParams['entityType'], $toReturn, $params['entity_id'], NULL, $treeParams['subTypes'], $treeParams['subName'], TRUE, NULL, FALSE, CRM_Utils_Array::value('check_permissions', $params, TRUE));
unset($tree['info']);
- $result = array();
+ $result = [];
foreach ($tree as $group) {
- $result[$group['name']] = array();
+ $result[$group['name']] = [];
$groupToReturn = $toReturn['custom_group'] ? $toReturn['custom_group'] : array_keys($group);
foreach ($groupToReturn as $item) {
$result[$group['name']][$item] = CRM_Utils_Array::value($item, $group);
}
- $result[$group['name']]['fields'] = array();
+ $result[$group['name']]['fields'] = [];
foreach ($group['fields'] as $fieldInfo) {
- $field = array('value' => NULL);
+ $field = ['value' => NULL];
$fieldToReturn = $toReturn['custom_field'] ? $toReturn['custom_field'] : array_keys($fieldInfo);
foreach ($fieldToReturn as $item) {
$field[$item] = CRM_Utils_Array::value($item, $fieldInfo);
function _civicrm_api3_cxn_register_spec(&$spec) {
$daoFields = CRM_Cxn_DAO_Cxn::fields();
$spec['app_guid'] = $daoFields['app_guid'];
- $spec['app_meta_url'] = array(
+ $spec['app_meta_url'] = [
'name' => 'app_meta_url',
'type' => CRM_Utils_Type::T_STRING,
'title' => ts('Application Metadata URL'),
'description' => 'Application Metadata URL',
'maxlength' => 255,
'size' => CRM_Utils_Type::HUGE,
- );
+ ];
}
/**
}
}
elseif (!empty($params['app_guid'])) {
- $appMeta = civicrm_api3('CxnApp', 'getsingle', array(
+ $appMeta = civicrm_api3('CxnApp', 'getsingle', [
'appId' => $params['app_guid'],
- ));
+ ]);
}
if (empty($appMeta) || !is_array($appMeta)) {
$daoFields = CRM_Cxn_DAO_Cxn::fields();
$spec['cxn_guid'] = $daoFields['cxn_guid'];
$spec['app_guid'] = $daoFields['app_guid'];
- $spec['force'] = array(
+ $spec['force'] = [
'name' => 'force',
'type' => CRM_Utils_Type::T_BOOLEAN,
'title' => ts('Force'),
'description' => 'Destroy connection even if the remote application is non-responsive.',
'default' => '0',
- );
+ ];
}
/**
$cxnId = $params['cxn_guid'];
}
elseif (!empty($params['app_guid'])) {
- $cxnId = CRM_Core_DAO::singleValueQuery('SELECT cxn_guid FROM civicrm_cxn WHERE app_guid = %1', array(
- 1 => array($params['app_guid'], 'String'),
- ));
+ $cxnId = CRM_Core_DAO::singleValueQuery('SELECT cxn_guid FROM civicrm_cxn WHERE app_guid = %1', [
+ 1 => [$params['app_guid'], 'String'],
+ ]);
if (!$cxnId) {
throw new API_Exception("The app_guid does not correspond to an active connection.");
}
$daoFields = CRM_Cxn_DAO_Cxn::fields();
$spec['app_guid'] = $daoFields['app_guid'];
$spec['cxn_guid'] = $daoFields['cxn_guid'];
- $spec['page_name'] = array(
+ $spec['page_name'] = [
'name' => 'page_name',
'type' => CRM_Utils_Type::T_STRING,
'title' => ts('Page Type'),
'description' => 'The type of page (eg "settings")',
'maxlength' => 63,
'size' => CRM_Utils_Type::HUGE,
- 'api.aliases' => array('page'),
- );
+ 'api.aliases' => ['page'],
+ ];
}
/**
/** @var \Civi\Cxn\Rpc\RegistrationClient $client */
$client = \Civi::service('cxn_reg_client');
- return $client->call($appMeta, 'Cxn', 'getlink', array(
+ return $client->call($appMeta, 'Cxn', 'getlink', [
'page' => $params['page_name'],
- ));
+ ]);
}
/**
* @throws Exception
*/
function civicrm_api3_cxn_getcfg($params) {
- $result = array(
+ $result = [
'CIVICRM_CXN_CA' => defined('CIVICRM_CXN_CA') ? CIVICRM_CXN_CA : NULL,
'CIVICRM_CXN_VIA' => defined('CIVICRM_CXN_VIA') ? CIVICRM_CXN_VIA : NULL,
'CIVICRM_CXN_APPS_URL' => defined('CIVICRM_CXN_APPS_URL') ? CIVICRM_CXN_APPS_URL : NULL,
'siteCallbackUrl' => CRM_Cxn_BAO_Cxn::getSiteCallbackUrl(),
- );
+ ];
return civicrm_api3_create_success($result);
}
* List of fields.
*/
function _civicrm_api3_cxn_app_get_spec(&$spec) {
- $spec['appCert'] = array(
+ $spec['appCert'] = [
'name' => 'appCert',
'type' => CRM_Utils_Type::T_TEXT,
'title' => ts('Certificate'),
'description' => 'PEM-encoded certificate',
- );
- $spec['appId'] = array(
+ ];
+ $spec['appId'] = [
'name' => 'appId',
'type' => CRM_Utils_Type::T_STRING,
'title' => ts('Application GUID'),
'description' => 'Application GUID',
'maxlength' => 128,
'size' => CRM_Utils_Type::HUGE,
- );
- $spec['appUrl'] = array(
+ ];
+ $spec['appUrl'] = [
'name' => 'appUrl',
'type' => CRM_Utils_Type::T_STRING,
'title' => ts('Registration URL'),
'description' => 'An endpoint to notify when performing registration',
'maxlength' => 255,
'size' => CRM_Utils_Type::HUGE,
- );
- $spec['desc'] = array(
+ ];
+ $spec['desc'] = [
'name' => 'desc',
'type' => CRM_Utils_Type::T_TEXT,
'title' => ts('Description'),
'description' => 'Description',
- );
+ ];
//$spec['perm'] = array(
// 'name' => 'perm',
// 'type' => CRM_Utils_Type::T_TEXT,
$agent = new \Civi\Cxn\Rpc\Agent(NULL, NULL);
$agent->setCertValidator(CRM_Cxn_BAO_Cxn::createCertificateValidator());
- $message = $agent->decode(array(AppMetasMessage::NAME, GarbledMessage::NAME), $blob);
+ $message = $agent->decode([AppMetasMessage::NAME, GarbledMessage::NAME], $blob);
if ($message instanceof AppMetasMessage) {
return _civicrm_api3_basic_array_get('CxnApp', $params, $message->getData(), 'appId',
- array('appId', 'appUrl', 'desc', 'appCert', 'perm'));
+ ['appId', 'appUrl', 'desc', 'appCert', 'perm']);
}
elseif ($message instanceof GarbledMessage) {
- return civicrm_api3_create_error('Received garbled response', array(
+ return civicrm_api3_create_error('Received garbled response', [
'garbled_message' => $message->getData(),
- ));
+ ]);
}
else {
return civicrm_api3_create_error("Unrecognized message");
* Array containing 'is_error' to denote success or failure and details of the created activity
*/
function civicrm_api3_dashboard_create($params) {
- civicrm_api3_verify_one_mandatory($params, NULL, array(
+ civicrm_api3_verify_one_mandatory($params, NULL, [
'name',
'label',
'url',
'fullscreen_url',
- )
+ ]
);
return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'Dashboard');
}
if (empty($params['id'])) {
civicrm_api3_verify_one_mandatory($params,
NULL,
- array(
+ [
'dashboard_id',
- )
+ ]
);
}
$errors = _civicrm_api3_dashboard_contact_check_params($params);
foreach ($domains as $domain) {
if (!empty($domain['contact_id'])) {
- $values = array();
- $locparams = array(
+ $values = [];
+ $locparams = [
'contact_id' => $domain['contact_id'],
- );
+ ];
$values['location'] = CRM_Core_BAO_Location::getValues($locparams, TRUE);
- $address_array = array(
+ $address_array = [
'street_address', 'supplemental_address_1', 'supplemental_address_2', 'supplemental_address_3',
'city', 'state_province_id', 'postal_code', 'country_id',
'geo_code_1', 'geo_code_2',
- );
+ ];
if (!empty($values['location']['email'])) {
$domain['domain_email'] = CRM_Utils_Array::value('email', $values['location']['email'][1]);
}
if (!empty($values['location']['phone'])) {
- $domain['domain_phone'] = array(
+ $domain['domain_phone'] = [
'phone_type' => CRM_Core_PseudoConstant::getLabel('CRM_Core_BAO_Phone', 'phone_type_id',
CRM_Utils_Array::value(
'phone_type_id',
'phone',
$values['location']['phone'][1]
),
- );
+ ];
}
if (!empty($values['location']['address'])) {
* Array of parameters determined by getfields.
*/
function _civicrm_api3_domain_get_spec(&$params) {
- $params['current_domain'] = array(
+ $params['current_domain'] = [
'title' => "Current Domain",
'description' => "get loaded domain",
- );
+ ];
}
/**
* Array of parameters determined by getfields.
*/
function _civicrm_api3_domain_create_spec(&$params) {
- $params['domain_version'] = array(
+ $params['domain_version'] = [
'title' => "CiviCRM Version",
'description' => "The civicrm version this instance is running",
'type' => CRM_Utils_Type::T_STRING,
- );
+ ];
$params['domain_version']['api.required'] = 1;
unset($params['version']);
$params['name']['api.required'] = 1;
* Array of deprecated api entities
*/
function _civicrm_api3_entity_deprecation($entities) {
- $deprecated = array();
+ $deprecated = [];
if (!empty($entities['values'])) {
foreach ($entities['values'] as $entity) {
if (is_string(_civicrm_api3_deprecation_check($entity))) {
function civicrm_api3_entity_getfields($params) {
// we return an empty array so it makes it easier to write generic getdefaults / required tests
// without putting an exception in for entity
- return civicrm_api3_create_success(array());
+ return civicrm_api3_create_success([]);
}
* Array of parameters determined by getfields.
*/
function _civicrm_api3_entity_tag_get_spec(&$params) {
- $params['entity_id']['api.aliases'] = array('contact_id');
+ $params['entity_id']['api.aliases'] = ['contact_id'];
$params['entity_table']['api.default'] = 'civicrm_contact';
}
*/
function _civicrm_api3_entity_tag_common($params, $op = 'add') {
- $entityIDs = $tagIDs = array();
+ $entityIDs = $tagIDs = [];
$entityTable = 'civicrm_contact';
if (is_array($params)) {
foreach ($params as $n => $v) {
}
}
- $values = array('is_error' => 0);
+ $values = ['is_error' => 0];
if ($op == 'add') {
$values['total_count'] = $values['added'] = $values['not_added'] = 0;
foreach ($tagIDs as $tagID) {
function civicrm_api3_event_create($params) {
// Required fields for creating an event
if (empty($params['id']) && empty($params['is_template'])) {
- civicrm_api3_verify_mandatory($params, NULL, array(
+ civicrm_api3_verify_mandatory($params, NULL, [
'start_date',
'title',
- array('event_type_id', 'template_id'),
- ));
+ ['event_type_id', 'template_id'],
+ ]);
}
// Required fields for creating an event template
elseif (empty($params['id']) && !empty($params['is_template'])) {
- civicrm_api3_verify_mandatory($params, NULL, array(
+ civicrm_api3_verify_mandatory($params, NULL, [
'template_title',
- ));
+ ]);
}
// Clone event from template
*/
function _civicrm_api3_event_create_spec(&$params) {
$params['is_active']['api.default'] = 1;
- $params['financial_type_id']['api.aliases'] = array('contribution_type_id');
+ $params['financial_type_id']['api.aliases'] = ['contribution_type_id'];
$params['is_template']['api.default'] = 0;
}
* Array of parameters determined by getfields.
*/
function _civicrm_api3_event_get_spec(&$params) {
- $params['financial_type_id']['api.aliases'] = array('contribution_type_id');
+ $params['financial_type_id']['api.aliases'] = ['contribution_type_id'];
}
/**
* @param array $request
*/
function _civicrm_api3_event_getlist_params(&$request) {
- $fieldsToReturn = array('start_date', 'event_type_id', 'title', 'summary');
+ $fieldsToReturn = ['start_date', 'event_type_id', 'title', 'summary'];
$request['params']['return'] = array_unique(array_merge($fieldsToReturn, $request['extra']));
$request['params']['options']['sort'] = 'start_date DESC';
if (empty($request['params']['id'])) {
- $request['params'] += array(
+ $request['params'] += [
'is_template' => 0,
'is_active' => 1,
- );
+ ];
}
}
* @return array
*/
function _civicrm_api3_event_getlist_output($result, $request) {
- $output = array();
+ $output = [];
if (!empty($result['values'])) {
foreach ($result['values'] as $row) {
- $data = array(
+ $data = [
'id' => $row[$request['id_field']],
'label' => $row[$request['label_field']],
- 'description' => array(
+ 'description' => [
CRM_Core_Pseudoconstant::getLabel(
'CRM_Event_BAO_Event',
'event_type_id',
$row['event_type_id']
),
- ),
- );
+ ],
+ ];
if (!empty($row['start_date'])) {
$data['description'][0] .= ': ' . CRM_Utils_Date::customFormat($row['start_date']);
}
$repeat = CRM_Core_BAO_RecurringEntity::getPositionAndCount($row['id'], 'civicrm_event');
$data['extra']['is_recur'] = FALSE;
if ($repeat) {
- $data['suffix'] = ts('(%1 of %2)', array(1 => $repeat[0], 2 => $repeat[1]));
+ $data['suffix'] = ts('(%1 of %2)', [1 => $repeat[0], 2 => $repeat[1]]);
$data['extra']['is_recur'] = TRUE;
}
$output[] = $data;
* @param $fields
*/
function _civicrm_api3_extension_install_spec(&$fields) {
- $fields['keys'] = array(
+ $fields['keys'] = [
'title' => 'Extension Key(s)',
- 'api.aliases' => array('key'),
+ 'api.aliases' => ['key'],
'type' => CRM_Utils_Type::T_STRING,
'description' => 'Fully qualified name of one or more extensions',
- );
- $fields['path'] = array(
+ ];
+ $fields['path'] = [
'title' => 'Extension Path',
'type' => CRM_Utils_Type::T_STRING,
'description' => 'The path to the extension. May use wildcard ("*").',
- );
+ ];
}
/**
function civicrm_api3_extension_upgrade() {
CRM_Core_Invoke::rebuildMenuAndCaches(TRUE);
$queue = CRM_Extension_Upgrades::createQueue();
- $runner = new CRM_Queue_Runner(array(
+ $runner = new CRM_Queue_Runner([
'title' => 'Extension Upgrades',
'queue' => $queue,
'errorMode' => CRM_Queue_Runner::ERROR_ABORT,
- ));
+ ]);
try {
$result = $runner->runAll();
CRM_Extension_System::singleton()->getCache()->flush();
CRM_Extension_System::singleton(TRUE);
if (CRM_Utils_Array::value('install', $params, TRUE)) {
- CRM_Extension_System::singleton()->getManager()->install(array($params['key']));
+ CRM_Extension_System::singleton()->getManager()->install([$params['key']]);
}
return civicrm_api3_create_success();
* @param $fields
*/
function _civicrm_api3_extension_download_spec(&$fields) {
- $fields['key'] = array(
+ $fields['key'] = [
'title' => 'Extension Key',
'api.required' => 1,
'type' => CRM_Utils_Type::T_STRING,
'description' => 'Fully qualified name of the extension',
- );
- $fields['url'] = array(
+ ];
+ $fields['url'] = [
'title' => 'Download URL',
'type' => CRM_Utils_Type::T_STRING,
'description' => 'Optional as the system can determine the url automatically for public extensions',
- );
- $fields['install'] = array(
+ ];
+ $fields['install'] = [
'title' => 'Auto-install',
'type' => CRM_Utils_Type::T_STRING,
'description' => 'Automatically install the downloaded extension',
'api.default' => TRUE,
- );
+ ];
}
/**
* @param $fields
*/
function _civicrm_api3_extension_refresh_spec(&$fields) {
- $fields['local'] = array(
+ $fields['local'] = [
'title' => 'Rescan Local',
'api.default' => 1,
'type' => CRM_Utils_Type::T_BOOLEAN,
'description' => 'Whether to rescan the local filesystem (default TRUE)',
- );
- $fields['remote'] = array(
+ ];
+ $fields['remote'] = [
'title' => 'Rescan Remote',
'api.default' => 1,
'type' => CRM_Utils_Type::T_BOOLEAN,
'description' => 'Whether to rescan the remote repository (default TRUE)',
- );
+ ];
}
/**
$keys = array_merge($full_names, $keys);
$statuses = CRM_Extension_System::singleton()->getManager()->getStatuses();
$mapper = CRM_Extension_System::singleton()->getMapper();
- $result = array();
+ $result = [];
$id = 0;
foreach ($statuses as $key => $status) {
try {
$obj = $mapper->keyToInfo($key);
}
catch (CRM_Extension_Exception $ex) {
- CRM_Core_Session::setStatus(ts('Failed to read extension (%1). Please refresh the extension list.', array(1 => $key)));
+ CRM_Core_Session::setStatus(ts('Failed to read extension (%1). Please refresh the extension list.', [1 => $key]));
continue;
}
$info = CRM_Extension_System::createExtendedInfo($obj);
unset($params['keys']);
unset($params['full_name']);
- $filterableFields = array('id', 'type', 'status', 'path');
+ $filterableFields = ['id', 'type', 'status', 'path'];
return _civicrm_api3_basic_array_get('Extension', $params, $result, 'id', $filterableFields);
}
*/
function civicrm_api3_extension_getremote($params) {
$extensions = CRM_Extension_System::singleton()->getBrowser()->getExtensions();
- $result = array();
+ $result = [];
$id = 0;
foreach ($extensions as $key => $obj) {
- $info = array();
+ $info = [];
$info['id'] = $id++; // backward compatibility with indexing scheme
$info = array_merge($info, (array) $obj);
$result[] = $info;
}
- return _civicrm_api3_basic_array_get('Extension', $params, $result, 'id', CRM_Utils_Array::value('return', $params, array()));
+ return _civicrm_api3_basic_array_get('Extension', $params, $result, 'id', CRM_Utils_Array::value('return', $params, []));
}
/**
return $params[$key];
}
if ($params[$key] == '') {
- return array();
+ return [];
}
return explode(API_V3_EXTENSION_DELIMITER, $params[$key]);
}
else {
- return array();
+ return [];
}
}
*/
function civicrm_api3_file_create($params) {
- civicrm_api3_verify_mandatory($params, 'CRM_Core_DAO_File', array('uri'));
+ civicrm_api3_verify_mandatory($params, 'CRM_Core_DAO_File', ['uri']);
if (!isset($params['upload_date'])) {
$params['upload_date'] = date("Ymd");
}
$fileDAO = new CRM_Core_DAO_File();
- $properties = array(
+ $properties = [
'id',
'file_type_id',
'mime_type',
'document',
'description',
'upload_date',
- );
+ ];
foreach ($properties as $name) {
if (array_key_exists($name, $params)) {
$fileDAO->save();
- $file = array();
+ $file = [];
_civicrm_api3_object_to_array($fileDAO, $file);
return civicrm_api3_create_success($file, $params, 'File', 'create', $fileDAO);
}
$fileDAO->save();
}
- $file = array();
+ $file = [];
$cloneDAO = clone($fileDAO);
_civicrm_api3_object_to_array($cloneDAO, $file);
return $file;
*/
function civicrm_api3_file_delete($params) {
- civicrm_api3_verify_mandatory($params, NULL, array('id'));
+ civicrm_api3_verify_mandatory($params, NULL, ['id']);
if (CRM_Core_BAO_File::deleteEntityFile('*', $params['id'])) {
return civicrm_api3_create_success();
}
* API success object
*/
function civicrm_api3_generic_getfields($apiRequest, $unique = TRUE) {
- static $results = array();
+ static $results = [];
if ((CRM_Utils_Array::value('cache_clear', $apiRequest['params']))) {
- $results = array();
+ $results = [];
// we will also clear pseudoconstants here - should potentially be moved to relevant BAO classes
CRM_Core_PseudoConstant::flush();
if (!empty($apiRequest['params']['fieldname'])) {
CRM_Utils_PseudoConstant::flushConstant($apiRequest['params']['fieldname']);
}
if (!empty($apiRequest['params']['option_group_id'])) {
- $optionGroupName = civicrm_api('option_group', 'getvalue', array(
+ $optionGroupName = civicrm_api('option_group', 'getvalue', [
'version' => 3,
'id' => $apiRequest['params']['option_group_id'],
'return' => 'name',
- ));
+ ]);
if (is_string($optionGroupName)) {
CRM_Utils_PseudoConstant::flushConstant(_civicrm_api_get_camel_name($optionGroupName));
}
$subentity = CRM_Utils_Array::value('contact_type', $apiRequest['params']);
$action = CRM_Utils_Array::value('action', $apiRequest['params']);
$sequential = empty($apiRequest['params']['sequential']) ? 0 : 1;
- $apiRequest['params']['options'] = CRM_Utils_Array::value('options', $apiRequest['params'], array());
- $optionsToResolve = (array) CRM_Utils_Array::value('get_options', $apiRequest['params']['options'], array());
+ $apiRequest['params']['options'] = CRM_Utils_Array::value('options', $apiRequest['params'], []);
+ $optionsToResolve = (array) CRM_Utils_Array::value('get_options', $apiRequest['params']['options'], []);
if (!$action || $action == 'getvalue' || $action == 'getcount') {
$action = 'get';
if (!empty($metadata[strtolower($apiRequest['entity']) . '_id'])) {
$metadata['id'] = $metadata[$lowercase_entity . '_id'];
unset($metadata[$lowercase_entity . '_id']);
- $metadata['id']['api.aliases'] = array($lowercase_entity . '_id');
+ $metadata['id']['api.aliases'] = [$lowercase_entity . '_id'];
}
}
else {
// (note) or setting for all api where fields is returning 'id' & we want to accept 'note_id' @ the api layer
// nb we don't officially accept note_id anyway - rationale here is more about centralising a now-tested
// inconsistency
- $metadata['id']['api.aliases'] = array($lowercase_entity . '_id');
+ $metadata['id']['api.aliases'] = [$lowercase_entity . '_id'];
}
break;
case 'delete':
- $metadata = array(
- 'id' => array(
+ $metadata = [
+ 'id' => [
'title' => $entity . ' ID',
'api.required' => 1,
- 'api.aliases' => array($lowercase_entity . '_id'),
+ 'api.aliases' => [$lowercase_entity . '_id'],
'type' => CRM_Utils_Type::T_INT,
- ));
+ ]];
break;
// Note: adding setvalue case here instead of in a generic spec function because
// some APIs override the generic setvalue fn which causes the generic spec to be overlooked.
case 'setvalue':
- $metadata = array(
- 'field' => array(
+ $metadata = [
+ 'field' => [
'title' => 'Field name',
'api.required' => 1,
'type' => CRM_Utils_Type::T_STRING,
- ),
- 'id' => array(
+ ],
+ 'id' => [
'title' => $entity . ' ID',
'api.required' => 1,
'type' => CRM_Utils_Type::T_INT,
- ),
- 'value' => array(
+ ],
+ 'value' => [
'title' => 'Value',
'description' => "Field value to set",
'api.required' => 1,
- ),
- );
- if (array_intersect(array('all', 'field'), $optionsToResolve)) {
- $options = civicrm_api3_generic_getfields(array('entity' => $entity, array('params' => array('action' => 'create'))));
+ ],
+ ];
+ if (array_intersect(['all', 'field'], $optionsToResolve)) {
+ $options = civicrm_api3_generic_getfields(['entity' => $entity, ['params' => ['action' => 'create']]]);
$metadata['field']['options'] = CRM_Utils_Array::collect('title', $options['values']);
}
break;
default:
// oddballs are on their own
- $metadata = array();
+ $metadata = [];
}
// Hack for product api to pass tests.
}
// find any supplemental information
- $hypApiRequest = array('entity' => $apiRequest['entity'], 'action' => $action, 'version' => $apiRequest['version']);
+ $hypApiRequest = ['entity' => $apiRequest['entity'], 'action' => $action, 'version' => $apiRequest['version']];
if ($action == 'getsingle') {
$hypApiRequest['action'] = 'get';
}
* @throws \Exception
*/
function _civicrm_api3_generic_getfield_spec(&$params, $apiRequest) {
- $params = array(
- 'name' => array(
+ $params = [
+ 'name' => [
'title' => 'Field name',
'description' => 'Name or alias of field to lookup',
'api.required' => 1,
'type' => CRM_Utils_Type::T_STRING,
- ),
- 'action' => array(
+ ],
+ 'action' => [
'title' => 'API Action',
'api.required' => 1,
'type' => CRM_Utils_Type::T_STRING,
- 'api.aliases' => array('api_action'),
- ),
- 'get_options' => array(
+ 'api.aliases' => ['api_action'],
+ ],
+ 'get_options' => [
'title' => 'Get Options',
'description' => 'Context for which to get field options, or null to skip fetching options.',
'type' => CRM_Utils_Type::T_STRING,
'options' => CRM_Core_DAO::buildOptionsContext(),
- 'api.aliases' => array('context'),
- ),
- );
+ 'api.aliases' => ['context'],
+ ],
+ ];
// Add available options to these params if requested
- if (array_intersect(array('all', 'action'), $apiRequest['params']['options']['get_options'])) {
+ if (array_intersect(['all', 'action'], $apiRequest['params']['options']['get_options'])) {
$actions = civicrm_api3($apiRequest['entity'], 'getactions');
$actions = array_combine($actions['values'], $actions['values']);
// Let's not go meta-crazy
return $result['values'][0];
}
if ($result['count'] !== 1) {
- return civicrm_api3_create_error("Expected one " . $apiRequest['entity'] . " but found " . $result['count'], array('count' => $result['count']));
+ return civicrm_api3_create_error("Expected one " . $apiRequest['entity'] . " but found " . $result['count'], ['count' => $result['count']]);
}
return civicrm_api3_create_error("Undefined behavior");
}
return $result;
}
if ($result['count'] !== 1) {
- $result = civicrm_api3_create_error("Expected one " . $apiRequest['entity'] . " but found " . $result['count'], array('count' => $result['count']));
+ $result = civicrm_api3_create_error("Expected one " . $apiRequest['entity'] . " but found " . $result['count'], ['count' => $result['count']]);
return $result;
}
// we only take "return=" as valid options
if (!empty($apiRequest['params']['return'])) {
if (!isset($result['values'][0][$apiRequest['params']['return']])) {
- return civicrm_api3_create_error("field " . $apiRequest['params']['return'] . " unset or not existing", array('invalid_field' => $apiRequest['params']['return']));
+ return civicrm_api3_create_error("field " . $apiRequest['params']['return'] . " unset or not existing", ['invalid_field' => $apiRequest['params']['return']]);
}
return $result['values'][0][$apiRequest['params']['return']];
}
- return civicrm_api3_create_error("missing param return=field you want to read the value of", array('error_type' => 'mandatory_missing', 'missing_param' => 'return'));
+ return civicrm_api3_create_error("missing param return=field you want to read the value of", ['error_type' => 'mandatory_missing', 'missing_param' => 'return']);
}
/**
return civicrm_api3_create_success($dao->getReferenceCounts());
}
else {
- return civicrm_api3_create_success(array());
+ return civicrm_api3_create_success([]);
}
}
* @param $apiRequest
*/
function _civicrm_api3_generic_getoptions_spec(&$params, $apiRequest) {
- $params += array(
- 'field' => array(
+ $params += [
+ 'field' => [
'title' => 'Field name',
'api.required' => 1,
'type' => CRM_Utils_Type::T_STRING,
- ),
- 'context' => array(
+ ],
+ 'context' => [
'title' => 'Context',
'type' => CRM_Utils_Type::T_STRING,
'options' => CRM_Core_DAO::buildOptionsContext(),
- ),
- );
+ ],
+ ];
// Add available fields if requested
- if (array_intersect(array('all', 'field'), $apiRequest['params']['options']['get_options'])) {
- $fields = civicrm_api3_generic_getfields(array('entity' => $apiRequest['entity'], array('params' => array('action' => 'create'))));
- $params['field']['options'] = array();
+ if (array_intersect(['all', 'field'], $apiRequest['params']['options']['get_options'])) {
+ $fields = civicrm_api3_generic_getfields(['entity' => $apiRequest['entity'], ['params' => ['action' => 'create']]]);
+ $params['field']['options'] = [];
foreach ($fields['values'] as $name => $field) {
if (isset($field['pseudoconstant']) || CRM_Utils_Array::value('type', $field) == CRM_Utils_Type::T_BOOLEAN) {
$params['field']['options'][$name] = CRM_Utils_Array::value('title', $field, $name);
}
}
- $options = civicrm_api($apiRequest['entity'], 'getoptions', array('version' => 3, 'field' => $fieldname, 'context' => $context));
+ $options = civicrm_api($apiRequest['entity'], 'getoptions', ['version' => 3, 'field' => $fieldname, 'context' => $context]);
if (is_array(CRM_Utils_Array::value('values', $options))) {
$metadata[$fieldname]['options'] = $options['values'];
}
* @throws API_Exception
*/
function civicrm_api3_generic_getActions($apiRequest) {
- civicrm_api3_verify_mandatory($apiRequest, NULL, array('entity'));
+ civicrm_api3_verify_mandatory($apiRequest, NULL, ['entity']);
$mfp = \Civi::service('magic_function_provider');
$actions = $mfp->getActionNames($apiRequest['version'], $apiRequest['entity']);
return civicrm_api3_create_success($actions, $apiRequest['params'], $apiRequest['entity'], 'getactions');
function civicrm_api3_generic_getList($apiRequest) {
$entity = _civicrm_api_get_entity_name_from_camel($apiRequest['entity']);
$request = $apiRequest['params'];
- $meta = civicrm_api3_generic_getfields(array('action' => 'get') + $apiRequest, FALSE);
+ $meta = civicrm_api3_generic_getfields(['action' => 'get'] + $apiRequest, FALSE);
// Hey api, would you like to provide default values?
$fnName = "_civicrm_api3_{$entity}_getlist_defaults";
- $defaults = function_exists($fnName) ? $fnName($request) : array();
+ $defaults = function_exists($fnName) ? $fnName($request) : [];
_civicrm_api3_generic_getList_defaults($entity, $request, $defaults, $meta['values']);
// Hey api, would you like to format the search params?
_civicrm_api3_generic_getlist_postprocess($result, $request, $values);
- $output = array('page_num' => $request['page_num']);
+ $output = ['page_num' => $request['page_num']];
// Limit is set for searching but not fetching by id
if (!empty($request['params']['options']['limit'])) {
* @param array $fields
*/
function _civicrm_api3_generic_getList_defaults($entity, &$request, $apiDefaults, $fields) {
- $defaults = array(
+ $defaults = [
'page_num' => 1,
'input' => '',
'image_field' => NULL,
'color_field' => isset($fields['color']) ? 'color' : NULL,
'id_field' => $entity == 'option_value' ? 'value' : 'id',
- 'description_field' => array(),
+ 'description_field' => [],
'add_wildcard' => Civi::settings()->get('includeWildCardInName'),
- 'params' => array(),
- 'extra' => array(),
- );
+ 'params' => [],
+ 'extra' => [],
+ ];
// Find main field from meta
- foreach (array('sort_name', 'title', 'label', 'name', 'subject') as $field) {
+ foreach (['sort_name', 'title', 'label', 'name', 'subject'] as $field) {
if (isset($fields[$field])) {
$defaults['label_field'] = $defaults['search_field'] = $field;
break;
}
}
// Find fields to be used for the description
- foreach (array('description') as $field) {
+ foreach (['description'] as $field) {
if (isset($fields[$field])) {
$defaults['description_field'][] = $field;
}
}
$request += $apiDefaults + $defaults;
// Default api params
- $params = array(
+ $params = [
'sequential' => 1,
- 'options' => array(),
- );
+ 'options' => [],
+ ];
// When searching e.g. autocomplete
if ($request['input']) {
- $params[$request['search_field']] = array('LIKE' => ($request['add_wildcard'] ? '%' : '') . $request['input'] . '%');
+ $params[$request['search_field']] = ['LIKE' => ($request['add_wildcard'] ? '%' : '') . $request['input'] . '%'];
}
// When looking up a field e.g. displaying existing record
if (!empty($request['id'])) {
// Don't run into search limits when prefilling selection
$params['options']['limit'] = NULL;
unset($params['options']['offset'], $request['params']['options']['limit'], $request['params']['options']['offset']);
- $params[$request['id_field']] = is_array($request['id']) ? array('IN' => $request['id']) : $request['id'];
+ $params[$request['id_field']] = is_array($request['id']) ? ['IN' => $request['id']] : $request['id'];
}
$request['params'] += $params;
- $request['params']['options'] += array(
+ $request['params']['options'] += [
// Add pagination parameters
'sort' => $request['label_field'],
// Adding one extra result allows us to see if there are any more
'limit' => $resultsPerPage + 1,
// Because sql is zero-based
'offset' => ($request['page_num'] - 1) * $resultsPerPage,
- );
+ ];
}
/**
* @param array $request
*/
function _civicrm_api3_generic_getlist_params(&$request) {
- $fieldsToReturn = array($request['id_field'], $request['label_field']);
+ $fieldsToReturn = [$request['id_field'], $request['label_field']];
if (!empty($request['image_field'])) {
$fieldsToReturn[] = $request['image_field'];
}
* @return array
*/
function _civicrm_api3_generic_getlist_output($result, $request, $entity, $fields) {
- $output = array();
+ $output = [];
if (!empty($result['values'])) {
foreach ($result['values'] as $row) {
- $data = array(
+ $data = [
'id' => $row[$request['id_field']],
'label' => $row[$request['label_field']],
- );
+ ];
if (!empty($request['description_field'])) {
- $data['description'] = array();
+ $data['description'] = [];
foreach ((array) $request['description_field'] as $field) {
if (!empty($row[$field])) {
if (!isset($fields[$field]['pseudoconstant'])) {
* @param $values
*/
function _civicrm_api3_generic_getlist_postprocess($result, $request, &$values) {
- $chains = array();
+ $chains = [];
foreach ($request['params'] as $field => $param) {
if (substr($field, 0, 4) === 'api.') {
$chains[] = $field;
* @param array $apiRequest
*/
function _civicrm_api3_generic_getlist_spec(&$params, $apiRequest) {
- $params += array(
- 'page_num' => array(
+ $params += [
+ 'page_num' => [
'title' => 'Page Number',
'description' => "Current page of a multi-page lookup",
'type' => CRM_Utils_Type::T_INT,
- ),
- 'input' => array(
+ ],
+ 'input' => [
'title' => 'Search Input',
'description' => "String to search on",
'type' => CRM_Utils_Type::T_TEXT,
- ),
- 'params' => array(
+ ],
+ 'params' => [
'title' => 'API Params',
'description' => "Additional filters to send to the {$apiRequest['entity']} API.",
- ),
- 'extra' => array(
+ ],
+ 'extra' => [
'title' => 'Extra',
'description' => 'Array of additional fields to return.',
- ),
- 'image_field' => array(
+ ],
+ 'image_field' => [
'title' => 'Image Field',
'description' => "Field that this entity uses to store icons (usually automatic)",
'type' => CRM_Utils_Type::T_TEXT,
- ),
- 'id_field' => array(
+ ],
+ 'id_field' => [
'title' => 'ID Field',
'description' => "Field that uniquely identifies this entity (usually automatic)",
'type' => CRM_Utils_Type::T_TEXT,
- ),
- 'description_field' => array(
+ ],
+ 'description_field' => [
'title' => 'Description Field',
'description' => "Field that this entity uses to store summary text (usually automatic)",
'type' => CRM_Utils_Type::T_TEXT,
- ),
- 'label_field' => array(
+ ],
+ 'label_field' => [
'title' => 'Label Field',
'description' => "Field to display as title of results (usually automatic)",
'type' => CRM_Utils_Type::T_TEXT,
- ),
- 'search_field' => array(
+ ],
+ 'search_field' => [
'title' => 'Search Field',
'description' => "Field to search on (assumed to be the same as label field unless otherwise specified)",
'type' => CRM_Utils_Type::T_TEXT,
- ),
- );
+ ],
+ ];
}
*/
function civicrm_api3_generic_getunique($apiRequest) {
$entity = _civicrm_api_get_entity_name_from_camel($apiRequest['entity']);
- $uniqueFields = array();
+ $uniqueFields = [];
$dao = _civicrm_api3_get_DAO($entity);
$uFields = $dao::indices();
$params = $apiRequest['params'];
$id = $params['id'];
if (!is_numeric($id)) {
- return civicrm_api3_create_error(ts('Please enter a number'), array(
+ return civicrm_api3_create_error(ts('Please enter a number'), [
'error_code' => 'NaN',
'field' => "id",
- ));
+ ]);
}
$field = CRM_Utils_String::munge($params['field']);
$value = $params['value'];
- $fields = civicrm_api($entity, 'getFields', array(
+ $fields = civicrm_api($entity, 'getFields', [
'version' => 3,
'action' => 'create',
- "sequential")
+ "sequential"]
);
// getfields error, shouldn't happen.
if ($fields['is_error']) {
// Trim off the id portion of a multivalued custom field name
$fieldKey = $isCustom && substr_count($field, '_') > 1 ? rtrim(rtrim($field, '1234567890'), '_') : $field;
if (!array_key_exists($fieldKey, $fields)) {
- return civicrm_api3_create_error("Param 'field' ($field) is invalid. must be an existing field", array("error_code" => "invalid_field", "fields" => array_keys($fields)));
+ return civicrm_api3_create_error("Param 'field' ($field) is invalid. must be an existing field", ["error_code" => "invalid_field", "fields" => array_keys($fields)]);
}
$def = $fields[$fieldKey];
// TODO: create a utility for this since it's needed in many places
if (!empty($def['required']) || !empty($def['is_required'])) {
if ((empty($value) || $value === 'null') && $value !== '0' && $value !== 0) {
- return civicrm_api3_create_error(ts('%1 is a required field.', array(1 => $title)), array("error_code" => "required", "field" => $field));
+ return civicrm_api3_create_error(ts('%1 is a required field.', [1 => $title]), ["error_code" => "required", "field" => $field]);
}
}
switch ($def['type']) {
case CRM_Utils_Type::T_FLOAT:
if (!is_numeric($value) && !empty($value) && $value !== 'null') {
- return civicrm_api3_create_error(ts('%1 must be a number.', array(1 => $title)), array('error_code' => 'NaN'));
+ return civicrm_api3_create_error(ts('%1 must be a number.', [1 => $title]), ['error_code' => 'NaN']);
}
break;
case CRM_Utils_Type::T_INT:
if (!CRM_Utils_Rule::integer($value) && !empty($value) && $value !== 'null') {
- return civicrm_api3_create_error(ts('%1 must be a number.', array(1 => $title)), array('error_code' => 'NaN'));
+ return civicrm_api3_create_error(ts('%1 must be a number.', [1 => $title]), ['error_code' => 'NaN']);
}
break;
case CRM_Utils_Type::T_STRING:
case CRM_Utils_Type::T_TEXT:
if (!CRM_Utils_Rule::xssString($value)) {
- return civicrm_api3_create_error(ts('Illegal characters in input (potential scripting attack)'), array('error_code' => 'XSS'));
+ return civicrm_api3_create_error(ts('Illegal characters in input (potential scripting attack)'), ['error_code' => 'XSS']);
}
if (array_key_exists('maxlength', $def)) {
$value = substr($value, 0, $def['maxlength']);
break;
default:
- return civicrm_api3_create_error("Param '$field' is of a type not managed yet (" . $def['type'] . "). Join the API team and help us implement it", array('error_code' => 'NOT_IMPLEMENTED'));
+ return civicrm_api3_create_error("Param '$field' is of a type not managed yet (" . $def['type'] . "). Join the API team and help us implement it", ['error_code' => 'NOT_IMPLEMENTED']);
}
$dao_name = _civicrm_api3_get_DAO($entity);
- $params = array('id' => $id, $field => $value);
+ $params = ['id' => $id, $field => $value];
if ((!empty($def['pseudoconstant']) || !empty($def['option_group_id'])) && $value !== '' && $value !== 'null') {
_civicrm_api3_api_match_pseudoconstant($params[$field], $entity, $field, $def);
if (strtolower($apiRequest['entity']) == 'contribution') {
return civicrm_api($apiRequest['entity'], 'create', $apiRequest['params']);
}
- $seek = array($key_id => $apiRequest['params'][$key_id], 'version' => $apiRequest['version']);
+ $seek = [$key_id => $apiRequest['params'][$key_id], 'version' => $apiRequest['version']];
$existing = civicrm_api($apiRequest['entity'], 'get', $seek);
if ($existing['is_error']) {
return $existing;
}
$existing = array_pop($existing['values']);
+ // Per Unit test testUpdateHouseholdWithAll we don't want to load these from the DB
+ // if they are not passed in then we'd rather they are calculated.
+ // Note update is not recomended anyway...
+ foreach (['sort_name', 'display_name'] as $fieldToNotSet) {
+ unset($existing[$fieldToNotSet]);
+ }
$p = array_merge($existing, $apiRequest['params']);
return civicrm_api($apiRequest['entity'], 'create', $p);
}
$params['grant_type_id']['api.required'] = 1;
$params['status_id']['api.required'] = 1;
$params['amount_total']['api.required'] = 1;
- $params['status_id']['api.aliases'] = array('grant_status');
+ $params['status_id']['api.aliases'] = ['grant_status'];
}
/**
* @throws API_Exception
*/
function civicrm_api3_group_delete($params) {
- $group = civicrm_api3_group_get(array('id' => $params['id']));
+ $group = civicrm_api3_group_get(['id' => $params['id']]);
if ($group['count'] == 0) {
throw new API_Exception('Could not delete group ' . $params['id']);
}
function civicrm_api3_group_contact_create($params) {
// Nonstandard bao - doesn't accept ID as a param, so convert id to group_id + contact_id
if (!empty($params['id'])) {
- $getParams = array('id' => $params['id']);
+ $getParams = ['id' => $params['id']];
$info = _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $getParams);
if (!empty($info['values'][$params['id']])) {
$params['group_id'] = $info['values'][$params['id']]['group_id'];
*/
function civicrm_api3_group_contact_delete($params) {
$checkParams = $params;
- if (!empty($checkParams['status']) && in_array($checkParams['status'], array('Removed', 'Deleted'))) {
- $checkParams['status'] = array('IN' => array('Added', 'Pending'));
+ if (!empty($checkParams['status']) && in_array($checkParams['status'], ['Removed', 'Deleted'])) {
+ $checkParams['status'] = ['IN' => ['Added', 'Pending']];
}
elseif (!empty($checkParams['status']) && $checkParams['status'] == 'Added') {
- $checkParams['status'] = array('IN' => array('Pending', 'Removed'));
+ $checkParams['status'] = ['IN' => ['Pending', 'Removed']];
}
elseif (!empty($checkParams['status'])) {
unset($checkParams['status']);
}
$groupContact = civicrm_api3('GroupContact', 'get', $checkParams);
if ($groupContact['count'] == 0 && !empty($params['skip_undelete'])) {
- $checkParams['status'] = array('IN' => array('Removed', 'Pending'));
+ $checkParams['status'] = ['IN' => ['Removed', 'Pending']];
}
$groupContact2 = civicrm_api3('GroupContact', 'get', $checkParams);
if ($groupContact['count'] == 0 && $groupContact2['count'] == 0) {
*/
function _civicrm_api3_group_contact_common($params, $op = 'Added') {
- $contactIDs = array();
- $groupIDs = array();
+ $contactIDs = [];
+ $groupIDs = [];
// CRM-16959: Handle multiple Contact IDs and Group IDs in legacy format
// (contact_id.1, contact_id.2) or as an array
$tracking = CRM_Utils_Array::value('tracking', $params);
if ($op == 'Added' || $op == 'Pending') {
- $extraReturnValues = array(
+ $extraReturnValues = [
'total_count' => 0,
'added' => 0,
'not_added' => 0,
- );
+ ];
foreach ($groupIDs as $groupID) {
list($tc, $a, $na) = CRM_Contact_BAO_GroupContact::addContactsToGroup($contactIDs,
$groupID,
}
}
else {
- $extraReturnValues = array(
+ $extraReturnValues = [
'total_count' => 0,
'removed' => 0,
'not_removed' => 0,
- );
+ ];
foreach ($groupIDs as $groupID) {
list($tc, $r, $nr) = CRM_Contact_BAO_GroupContact::removeContactsFromGroup($contactIDs, $groupID, $method, $status, $tracking);
$extraReturnValues['total_count'] += $tc;
*/
function civicrm_api3_group_contact_update_status($params) {
- civicrm_api3_verify_mandatory($params, NULL, array('contact_id', 'group_id'));
+ civicrm_api3_verify_mandatory($params, NULL, ['contact_id', 'group_id']);
CRM_Contact_BAO_GroupContact::addContactsToGroup(
- array($params['contact_id']),
+ [$params['contact_id']],
$params['group_id'],
CRM_Utils_Array::value('method', $params, 'API'),
'Added',
* Array of deprecated actions
*/
function _civicrm_api3_group_contact_deprecation() {
- return array(
+ return [
'delete' => 'GroupContact "delete" action is deprecated in favor of "create".',
'pending' => 'GroupContact "pending" action is deprecated in favor of "create".',
'update_status' => 'GroupContact "update_status" action is deprecated in favor of "create".',
- );
+ ];
}
$params['last_run'] = 'null';
$params['scheduled_run_date'] = 'null';
$newJobDAO = CRM_Core_BAO_Job::copy($id, $params);
- return civicrm_api3('Job', 'get', array('id' => $newJobDAO->id));
+ return civicrm_api3('Job', 'get', ['id' => $newJobDAO->id]);
}
/**
* @param array $params
*/
function _civicrm_api3_job_geocode_spec(&$params) {
- $params['start'] = array(
+ $params['start'] = [
'title' => 'Starting Contact ID',
'type' => CRM_Utils_Type::T_INT,
- );
- $params['end'] = array(
+ ];
+ $params['end'] = [
'title' => 'Ending Contact ID',
'type' => CRM_Utils_Type::T_INT,
- );
- $params['geocoding'] = array(
+ ];
+ $params['geocoding'] = [
'title' => 'Geocode address?',
'type' => CRM_Utils_Type::T_BOOLEAN,
- );
- $params['parse'] = array(
+ ];
+ $params['parse'] = [
'title' => 'Parse street address?',
'type' => CRM_Utils_Type::T_BOOLEAN,
- );
- $params['throttle'] = array(
+ ];
+ $params['throttle'] = [
'title' => 'Throttle?',
'description' => 'If enabled, geo-codes at a slow rate',
'type' => CRM_Utils_Type::T_BOOLEAN,
- );
+ ];
}
/**
function _civicrm_api3_job_send_reminder(&$params) {
//@todo this function will now take all fields in action_schedule as params
// as it is calling the api fn to set the filters - update getfields to reflect
- $params['id'] = array(
+ $params['id'] = [
'type' => CRM_Utils_Type::T_INT,
'title' => 'Action Schedule ID',
- );
+ ];
}
/**
* Execute a specific report instance and send the output via email.
* Array of parameters determined by getfields.
*/
function _civicrm_api3_job_update_greeting_spec(&$params) {
- $params['ct'] = array(
+ $params['ct'] = [
'api.required' => 1,
'title' => 'Contact Type',
'type' => CRM_Utils_Type::T_STRING,
- );
- $params['gt'] = array(
+ ];
+ $params['gt'] = [
'api.required' => 1,
'title' => 'Greeting Type',
'type' => CRM_Utils_Type::T_STRING,
- );
+ ];
}
/**
return civicrm_api3_create_error('Process Queue failed');
}
else {
- $values = array(
+ $values = [
'processed' => CRM_Mailing_BAO_MailingJob::$mailsProcessed - $mailsProcessedOrig,
- );
+ ];
return civicrm_api3_create_success($values, $params, 'Job', 'process_mailing');
}
}
return civicrm_api3_create_error('Process Queue failed');
}
else {
- $values = array(
+ $values = [
'processed' => CRM_Mailing_BAO_MailingJob::$mailsProcessed - $mailsProcessedOrig,
- );
+ ];
return civicrm_api3_create_success($values, $params, 'Job', 'process_sms');
}
}
* @param array $params
*/
function _civicrm_api3_job_fetch_bounces_spec(&$params) {
- $params['is_create_activities'] = array(
+ $params['is_create_activities'] = [
'api.default' => 0,
'type' => CRM_Utils_Type::T_BOOLEAN,
'title' => ts('Create activities for replies?'),
- );
+ ];
}
/**
try {
CRM_Utils_Mail_EmailProcessor::processActivities();
- $values = array();
+ $values = [];
$lock->release();
return civicrm_api3_create_success($values, $params, 'Job', 'fetch_activities');
}
function civicrm_api3_job_process_batch_merge($params) {
$rule_group_id = CRM_Utils_Array::value('rule_group_id', $params);
if (!$rule_group_id) {
- $rule_group_id = civicrm_api3('RuleGroup', 'getvalue', array(
+ $rule_group_id = civicrm_api3('RuleGroup', 'getvalue', [
'contact_type' => 'Individual',
'used' => 'Unsupervised',
'return' => 'id',
- 'options' => array('limit' => 1),
- ));
+ 'options' => ['limit' => 1],
+ ]);
}
$rgid = CRM_Utils_Array::value('rgid', $params);
$gid = CRM_Utils_Array::value('gid', $params);
$mode = CRM_Utils_Array::value('mode', $params, 'safe');
- $result = CRM_Dedupe_Merger::batchMerge($rule_group_id, $gid, $mode, 1, 2, CRM_Utils_Array::value('criteria', $params, array()), CRM_Utils_Array::value('check_permissions', $params));
+ $result = CRM_Dedupe_Merger::batchMerge($rule_group_id, $gid, $mode, 1, 2, CRM_Utils_Array::value('criteria', $params, []), CRM_Utils_Array::value('check_permissions', $params));
return civicrm_api3_create_success($result, $params);
}
* @param $params
*/
function _civicrm_api3_job_process_batch_merge_spec(&$params) {
- $params['rule_group_id'] = array(
+ $params['rule_group_id'] = [
'title' => 'Dedupe rule group id, defaults to Contact Unsupervised rule',
'type' => CRM_Utils_Type::T_INT,
- 'api.aliases' => array('rgid'),
- );
- $params['gid'] = array(
+ 'api.aliases' => ['rgid'],
+ ];
+ $params['gid'] = [
'title' => 'group id',
'type' => CRM_Utils_Type::T_INT,
- );
- $params['mode'] = array(
+ ];
+ $params['mode'] = [
'title' => 'Mode',
'description' => 'helps decide how to behave when there are conflicts. A \'safe\' value skips the merge if there are no conflicts. Does a force merge otherwise.',
'type' => CRM_Utils_Type::T_STRING,
- );
- $params['auto_flip'] = array(
+ ];
+ $params['auto_flip'] = [
'title' => 'Auto Flip',
'description' => 'let the api decide which contact to retain and which to delete?',
'type' => CRM_Utils_Type::T_BOOLEAN,
- );
+ ];
}
/**
'PaymentCron',
array_merge(
$params,
- array(
+ [
'caller' => 'api',
- )
+ ]
)
);
'PaymentCron',
array_merge(
$params,
- array(
+ [
'mode' => 'test',
- )
+ ]
)
);
}
* @throws \API_Exception
*/
function civicrm_api3_loc_block_create($params) {
- $entities = array();
- $any_mandatory = array(
+ $entities = [];
+ $any_mandatory = [
'address',
'address_id',
'phone',
'im_id',
'email',
'email_id',
- );
+ ];
civicrm_api3_verify_one_mandatory($params, NULL, $any_mandatory);
// Call the appropriate api to create entities if any are passed in the params.
// This is basically chaining but in reverse - we create the sub-entities first
// because chaining does not work in reverse, or with keys like 'email_2'.
- $items = array('address', 'email', 'phone', 'im');
+ $items = ['address', 'email', 'phone', 'im'];
foreach ($items as $item) {
- foreach (array('', '_2') as $suf) {
+ foreach (['', '_2'] as $suf) {
$key = $item . $suf;
if (!empty($params[$key]) && is_array($params[$key])) {
$info = $params[$key];
$dao->copyValues($params);
$dao->save();
if (!empty($dao->id)) {
- $values = array($dao->id => $entities);
+ $values = [$dao->id => $entities];
_civicrm_api3_object_to_array($dao, $values[$dao->id]);
return civicrm_api3_create_success($values, $params, 'LocBlock', 'create', $dao);
}
// This is a helper because api chaining does not work with a key like 'email_2'.
if (!empty($options['return'])) {
unset($params['return']);
- $values = array();
- $items = array('address', 'email', 'phone', 'im');
+ $values = [];
+ $items = ['address', 'email', 'phone', 'im'];
$returnAll = !empty($options['return']['all']);
foreach (_civicrm_api3_basic_get('CRM_Core_DAO_LocBlock', $params, FALSE) as $val) {
foreach ($items as $item) {
- foreach (array('', '_2') as $suf) {
+ foreach (['', '_2'] as $suf) {
$key = $item . $suf;
if (!empty($val[$key . '_id']) && ($returnAll || !empty($options['return'][$key]))) {
- $val[$key] = civicrm_api($item, 'getsingle', array('version' => 3, 'id' => $val[$key . '_id']));
+ $val[$key] = civicrm_api($item, 'getsingle', ['version' => 3, 'id' => $val[$key . '_id']]);
}
}
}
* @throws \Civi\API\Exception\UnauthorizedException
*/
function _civicrm_api3_logging_revert_spec(&$params) {
- $params['log_conn_id'] = array(
+ $params['log_conn_id'] = [
'title' => 'Logging Connection ID',
'type' => CRM_Utils_Type::T_STRING,
'api.required' => TRUE,
- );
- $params['log_date'] = array(
+ ];
+ $params['log_date'] = [
'title' => 'Logging Timestamp',
'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
- );
- $params['interval'] = array(
+ ];
+ $params['interval'] = [
'title' => ts('Interval (required if date is included)'),
'type' => CRM_Utils_Type::T_STRING,
'api.default' => '10 SECOND',
'description' => ts('Used when log_date is passed in'),
- );
+ ];
- $params['tables'] = array(
+ $params['tables'] = [
'title' => ts('Tables to revert'),
'type' => CRM_Utils_Type::T_STRING,
'description' => ts('Tables to revert, if not set all contact-referring entities will be reverted'),
- );
+ ];
}
/**
* @throws \Civi\API\Exception\UnauthorizedException
*/
function _civicrm_api3_logging_get_spec(&$params) {
- $params['log_conn_id'] = array(
+ $params['log_conn_id'] = [
'title' => 'Logging Connection ID',
'type' => CRM_Utils_Type::T_STRING,
'api.required' => TRUE,
- );
- $params['log_date'] = array(
+ ];
+ $params['log_date'] = [
'title' => 'Logging Timestamp',
'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
- );
- $params['interval'] = array(
+ ];
+ $params['interval'] = [
'title' => ts('Interval (required if date is included)'),
'type' => CRM_Utils_Type::T_STRING,
'api.default' => '10 SECOND',
'description' => ts('Used when log_date is passed in'),
- );
- $params['tables'] = array(
+ ];
+ $params['tables'] = [
'title' => ts('Tables to query'),
'type' => CRM_Utils_Type::T_STRING,
'description' => ts('Tables to query, if not set all contact-referring entities will be queried'),
- );
+ ];
}
*/
function civicrm_api3_mailing_create($params) {
if (isset($params['template_options']) && is_array($params['template_options'])) {
- $params['template_options'] = ($params['template_options'] === array()) ? '{}' : json_encode($params['template_options']);
+ $params['template_options'] = ($params['template_options'] === []) ? '{}' : json_encode($params['template_options']);
}
if (CRM_Mailing_Info::workflowEnabled()) {
// Note: 'schedule mailings' and 'approve mailings' can update certain fields, but can't create.
}
}
- $safeParams = array();
+ $safeParams = [];
$fieldPerms = CRM_Mailing_BAO_Mailing::getWorkflowFieldPerms();
foreach (array_keys($params) as $field) {
if (CRM_Core_Permission::check($fieldPerms[$field])) {
* @throws \API_Exception
*/
function civicrm_api3_mailing_gettokens($params) {
- $tokens = array();
+ $tokens = [];
foreach ((array) $params['entity'] as $ent) {
$func = lcfirst($ent) . 'Tokens';
if (!method_exists('CRM_Core_SelectValues', $func)) {
* Array of parameters determined by getfields.
*/
function _civicrm_api3_mailing_gettokens_spec(&$params) {
- $params['entity'] = array(
- 'api.default' => array('contact'),
+ $params['entity'] = [
+ 'api.default' => ['contact'],
'api.required' => 1,
'api.multiple' => 1,
'title' => 'Entity',
- 'options' => array(),
- );
+ 'options' => [],
+ ];
// Fetch a list of token functions and format to look like entity names
foreach (get_class_methods('CRM_Core_SelectValues') as $func) {
if (strpos($func, 'Tokens')) {
* @throws \CiviCRM_API3_Exception
*/
function civicrm_api3_mailing_clone($params) {
- $BLACKLIST = array(
+ $BLACKLIST = [
'id',
'is_completed',
'created_id',
'is_archived',
'hash',
'mailing_type',
- );
+ ];
- $get = civicrm_api3('Mailing', 'getsingle', array('id' => $params['id']));
+ $get = civicrm_api3('Mailing', 'getsingle', ['id' => $params['id']]);
- $newParams = array();
+ $newParams = [];
$newParams['debug'] = CRM_Utils_Array::value('debug', $params);
- $newParams['groups']['include'] = array();
- $newParams['groups']['exclude'] = array();
- $newParams['mailings']['include'] = array();
- $newParams['mailings']['exclude'] = array();
+ $newParams['groups']['include'] = [];
+ $newParams['groups']['exclude'] = [];
+ $newParams['mailings']['include'] = [];
+ $newParams['mailings']['exclude'] = [];
foreach ($get as $field => $value) {
if (!in_array($field, $BLACKLIST)) {
$newParams[$field] = $value;
* @throws API_Exception
*/
function civicrm_api3_mailing_submit($params) {
- civicrm_api3_verify_mandatory($params, 'CRM_Mailing_DAO_Mailing', array('id'));
+ civicrm_api3_verify_mandatory($params, 'CRM_Mailing_DAO_Mailing', ['id']);
if (!isset($params['scheduled_date']) && !isset($updateParams['approval_date'])) {
throw new API_Exception("Missing parameter scheduled_date and/or approval_date");
throw new API_Exception("Failed to determine current user");
}
- $updateParams = array();
+ $updateParams = [];
$updateParams['id'] = $params['id'];
// Note: we'll pass along scheduling/approval fields, but they may get ignored
* Array of deprecated actions
*/
function _civicrm_api3_mailing_deprecation() {
- return array('event_confirm' => 'Mailing api "event_confirm" action is deprecated. Use the mailing_event_confirm api instead.');
+ return ['event_confirm' => 'Mailing api "event_confirm" action is deprecated. Use the mailing_event_confirm api instead.'];
}
/**
function civicrm_api3_mailing_event_click($params) {
civicrm_api3_verify_mandatory($params,
'CRM_Mailing_Event_DAO_TrackableURLOpen',
- array('event_queue_id', 'url_id'),
+ ['event_queue_id', 'url_id'],
FALSE
);
$url = CRM_Mailing_Event_BAO_TrackableURLOpen::track($queue, $url_id);
- $values = array();
+ $values = [];
$values['url'] = $url;
$values['is_error'] = 0;
civicrm_api3_verify_mandatory($params,
'CRM_Mailing_Event_DAO_Opened',
- array('event_queue_id'),
+ ['event_queue_id'],
FALSE
);
if (!$contactID) {
$contactID = $session->get('userID');
}
- $mailingParams = array('contact_id' => $contactID);
+ $mailingParams = ['contact_id' => $contactID];
$details = CRM_Utils_Token::getTokenDetails($mailingParams, $returnProperties, TRUE, TRUE, NULL, $mailing->getFlattenedTokens());
TRUE, $details[0][$contactID], $attachments
);
- return civicrm_api3_create_success(array(
+ return civicrm_api3_create_success([
'id' => $params['id'],
'contact_id' => $contactID,
'subject' => $mime->headers()['Subject'],
'body_html' => $mime->getHTMLBody(),
'body_text' => $mime->getTXTBody(),
- ));
+ ]);
}
/**
}
civicrm_api3_verify_mandatory($params,
'CRM_Mailing_DAO_MailingJob',
- array('mailing_id'),
+ ['mailing_id'],
FALSE
);
$testEmailParams['emails'] = array_key_exists('test_email', $testEmailParams) ? explode(',', strtolower($testEmailParams['test_email'])) : NULL;
if (!empty($params['test_email'])) {
$query = CRM_Utils_SQL_Select::from('civicrm_email e')
- ->select(array('e.id', 'e.contact_id', 'e.email'))
+ ->select(['e.id', 'e.contact_id', 'e.email'])
->join('c', 'INNER JOIN civicrm_contact c ON e.contact_id = c.id')
- ->where('e.email IN (@emails)', array('@emails' => $testEmailParams['emails']))
+ ->where('e.email IN (@emails)', ['@emails' => $testEmailParams['emails']])
->where('e.on_hold = 0')
->where('c.is_opt_out = 0')
->where('c.do_not_email = 0')
->where('c.is_deceased = 0')
->where('c.is_deleted = 0')
->groupBy('e.id')
- ->orderBy(array('e.is_bulkmail DESC', 'e.is_primary DESC'))
+ ->orderBy(['e.is_bulkmail DESC', 'e.is_primary DESC'])
->toSQL();
$dao = CRM_Core_DAO::executeQuery($query);
- $emailDetail = array();
+ $emailDetail = [];
// fetch contact_id and email id for all existing emails
while ($dao->fetch()) {
- $emailDetail[strtolower($dao->email)] = array(
+ $emailDetail[strtolower($dao->email)] = [
'contact_id' => $dao->contact_id,
'email_id' => $dao->id,
- );
+ ];
}
foreach ($testEmailParams['emails'] as $key => $email) {
$email = trim($email);
if (!$contactId) {
//create new contact.
$contact = civicrm_api3('Contact', 'create',
- array(
+ [
'contact_type' => 'Individual',
'email' => $email,
- 'api.Email.get' => array('return' => 'id'),
- )
+ 'api.Email.get' => ['return' => 'id'],
+ ]
);
$contactId = $contact['id'];
$emailId = $contact['values'][$contactId]['api.Email.get']['id'];
}
civicrm_api3('MailingEventQueue', 'create',
- array(
+ [
'job_id' => $job['id'],
'email_id' => $emailId,
'contact_id' => $contactId,
- )
+ ]
);
}
}
function civicrm_api3_mailing_stats($params) {
civicrm_api3_verify_mandatory($params,
'CRM_Mailing_DAO_MailingJob',
- array('mailing_id'),
+ ['mailing_id'],
FALSE
);
$params['date'] = CRM_Utils_Date::processDate($params['date'] . ' ' . $params['date_time']);
}
- $stats[$params['mailing_id']] = array();
+ $stats[$params['mailing_id']] = [];
if (empty($params['job_id'])) {
$params['job_id'] = NULL;
}
- foreach (array('Delivered', 'Bounces', 'Unsubscribers', 'Unique Clicks', 'Opened') as $detail) {
+ foreach (['Delivered', 'Bounces', 'Unsubscribers', 'Unique Clicks', 'Opened'] as $detail) {
switch ($detail) {
case 'Delivered':
- $stats[$params['mailing_id']] += array(
+ $stats[$params['mailing_id']] += [
$detail => CRM_Mailing_Event_BAO_Delivered::getTotalCount($params['mailing_id'], $params['job_id'], (bool) $params['is_distinct'], $params['date']),
- );
+ ];
break;
case 'Bounces':
- $stats[$params['mailing_id']] += array(
+ $stats[$params['mailing_id']] += [
$detail => CRM_Mailing_Event_BAO_Bounce::getTotalCount($params['mailing_id'], $params['job_id'], (bool) $params['is_distinct'], $params['date']),
- );
+ ];
break;
case 'Unsubscribers':
- $stats[$params['mailing_id']] += array(
+ $stats[$params['mailing_id']] += [
$detail => CRM_Mailing_Event_BAO_Unsubscribe::getTotalCount($params['mailing_id'], $params['job_id'], (bool) $params['is_distinct'], NULL, $params['date']),
- );
+ ];
break;
case 'Unique Clicks':
- $stats[$params['mailing_id']] += array(
+ $stats[$params['mailing_id']] += [
$detail => CRM_Mailing_Event_BAO_TrackableURLOpen::getTotalCount($params['mailing_id'], $params['job_id'], (bool) $params['is_distinct'], NULL, $params['date']),
- );
+ ];
break;
case 'Opened':
- $stats[$params['mailing_id']] += array(
+ $stats[$params['mailing_id']] += [
$detail => CRM_Mailing_Event_BAO_Opened::getTotalCount($params['mailing_id'], $params['job_id'], (bool) $params['is_distinct'], $params['date']),
- );
+ ];
break;
}
}
* @throws API_Exception
*/
function civicrm_api3_mailing_a_b_submit($params) {
- civicrm_api3_verify_mandatory($params, 'CRM_Mailing_DAO_MailingAB', array('id', 'status'));
+ civicrm_api3_verify_mandatory($params, 'CRM_Mailing_DAO_MailingAB', ['id', 'status']);
if (!isset($params['scheduled_date']) && !isset($updateParams['approval_date'])) {
throw new API_Exception("Missing parameter scheduled_date and/or approval_date");
throw new API_Exception("Missing mailing IDs for A/B test");
}
- $submitParams = CRM_Utils_Array::subset($params, array(
+ $submitParams = CRM_Utils_Array::subset($params, [
'scheduled_date',
'approval_date',
'approval_note',
'approval_status_id',
- ));
+ ]);
switch ($params['status']) {
case 'Testing':
if (!empty($dao->status) && $dao->status != 'Draft') {
throw new API_Exception("Cannot transition to state 'Testing'");
}
- civicrm_api3('Mailing', 'submit', $submitParams + array(
+ civicrm_api3('Mailing', 'submit', $submitParams + [
'id' => $dao->mailing_id_a,
'_skip_evil_bao_auto_recipients_' => 0,
- ));
- civicrm_api3('Mailing', 'submit', $submitParams + array(
+ ]);
+ civicrm_api3('Mailing', 'submit', $submitParams + [
'id' => $dao->mailing_id_b,
'_skip_evil_bao_auto_recipients_' => 1,
- ));
+ ]);
CRM_Mailing_BAO_MailingAB::distributeRecipients($dao);
break;
if ($dao->status != 'Testing') {
throw new API_Exception("Cannot transition to state 'Final'");
}
- civicrm_api3('Mailing', 'submit', $submitParams + array(
+ civicrm_api3('Mailing', 'submit', $submitParams + [
'id' => $dao->mailing_id_c,
'_skip_evil_bao_auto_recipients_' => 1,
- ));
+ ]);
break;
default:
throw new API_Exception("Unrecognized submission status");
}
- return civicrm_api3('MailingAB', 'create', array(
+ return civicrm_api3('MailingAB', 'create', [
'id' => $dao->id,
'status' => $params['status'],
- 'options' => array(
+ 'options' => [
'reload' => 1,
- ),
- ));
+ ],
+ ]);
}
/**
* Array of parameters determined by getfields.
*/
function _civicrm_api3_mailing_a_b_graph_stats_spec(&$params) {
- $params['criteria'] = array(
+ $params['criteria'] = [
'title' => 'Criteria',
'default' => 'Open',
'type' => CRM_Utils_Type::T_STRING,
- );
+ ];
// mailing_ab_winner_criteria
$params['target_date']['title'] = 'Target Date';
$params['target_date']['type'] = CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME;
- $params['split_count'] = array(
+ $params['split_count'] = [
'title' => 'Split Count',
'api.default' => 6,
'type' => CRM_Utils_Type::T_INT,
- );
+ ];
$params['split_count_select']['title'] = 'Split Count Select';
$params['split_count_select']['api.required'] = 1;
$params['target_url']['title'] = 'Target URL';
function civicrm_api3_mailing_a_b_graph_stats($params) {
civicrm_api3_verify_mandatory($params,
'CRM_Mailing_DAO_MailingAB',
- array('id'),
+ ['id'],
FALSE
);
- $defaults = array(
+ $defaults = [
'criteria' => 'Open',
'target_date' => CRM_Utils_Time::getTime('YmdHis'),
'split_count' => 6,
'split_count_select' => 1,
- );
+ ];
$params = array_merge($defaults, $params);
- $mailingAB = civicrm_api3('MailingAB', 'getsingle', array('id' => $params['id']));
- $graphStats = array();
- $ABFormat = array('A' => 'mailing_id_a', 'B' => 'mailing_id_b');
+ $mailingAB = civicrm_api3('MailingAB', 'getsingle', ['id' => $params['id']]);
+ $graphStats = [];
+ $ABFormat = ['A' => 'mailing_id_a', 'B' => 'mailing_id_b'];
foreach ($ABFormat as $name => $column) {
switch (strtolower($params['criteria'])) {
$dateDuration = round(round(strtotime($targetDate) - strtotime($startDate)) / $params['split_count']);
$toDate = strtotime($startDate) + ($dateDuration * $params['split_count_select']);
$toDate = date('YmdHis', $toDate);
- $graphStats[$name] = array(
- $params['split_count_select'] => array(
+ $graphStats[$name] = [
+ $params['split_count_select'] => [
'count' => CRM_Mailing_Event_BAO_Opened::getTotalCount($mailingAB[$column], NULL, TRUE, $toDate),
'time' => CRM_Utils_Date::customFormat($toDate),
- ),
- );
+ ],
+ ];
break;
case 'total unique clicks':
$dateDuration = round(abs(strtotime($targetDate) - strtotime($startDate)) / $params['split_count']);
$toDate = strtotime($startDate) + ($dateDuration * $params['split_count_select']);
$toDate = date('YmdHis', $toDate);
- $graphStats[$name] = array(
- $params['split_count_select'] => array(
+ $graphStats[$name] = [
+ $params['split_count_select'] => [
'count' => CRM_Mailing_Event_BAO_TrackableURLOpen::getTotalCount($params['mailing_id'], NULL, FALSE, NULL, $toDate),
'time' => CRM_Utils_Date::customFormat($toDate),
- ),
- );
+ ],
+ ];
break;
case 'total clicks on a particular link':
$dateDuration = round(abs(strtotime($targetDate) - strtotime($startDate)) / $params['split_count']);
$toDate = strtotime($startDate) + ($dateDuration * $params['split_count_select']);
$toDate = CRM_Utils_Date::processDate($toDate);
- $graphStats[$name] = array(
- $params['split_count_select'] => array(
+ $graphStats[$name] = [
+ $params['split_count_select'] => [
'count' => CRM_Mailing_Event_BAO_TrackableURLOpen::getTotalCount($params['mailing_id'], NULL, FALSE, $url_id, $toDate),
'time' => CRM_Utils_Date::customFormat($toDate),
- ),
- );
+ ],
+ ];
break;
}
}
* Array of parameters determined by getfields.
*/
function _civicrm_api3_mailing_contact_get_spec(&$params) {
- $params['contact_id'] = array(
+ $params['contact_id'] = [
'api.required' => 1,
'title' => 'Contact ID',
'type' => CRM_Utils_Type::T_INT,
- );
+ ];
- $params['type'] = array(
+ $params['type'] = [
'api.default' => 'Delivered',
'title' => 'Type', // doesn't really explain the field - but not sure I understand it to explain it better
'type' => CRM_Utils_Type::T_STRING,
- 'options' => array(
+ 'options' => [
'Delivered' => 'Delivered',
'Bounced' => 'Bounced',
- ),
- );
+ ],
+ ];
}
/**
GROUP BY m.id
";
- $qParams = array(
- 1 => array($contactID, 'Integer'),
- );
+ $qParams = [
+ 1 => [$contactID, 'Integer'],
+ ];
$dao = CRM_Core_DAO::executeQuery($sql, $qParams);
$results = $dao->N;
}
else {
- $defaultFields = array(
+ $defaultFields = [
'm.id' => 'mailing_id',
'm.subject' => 'subject',
'c.id' => 'creator_id',
'c.sort_name' => 'creator_name',
- );
+ ];
if ($selectFields) {
$fields = array_merge($selectFields, $defaultFields);
$fields = $defaultFields;
}
- $select = array();
+ $select = [];
foreach ($fields as $n => $l) {
$select[] = "$n as $l";
}
";
}
- $qParams = array(
- 1 => array($contactID, 'Integer'),
- 2 => array($offset, 'Integer'),
- 3 => array($limit, 'Integer'),
- );
+ $qParams = [
+ 1 => [$contactID, 'Integer'],
+ 2 => [$offset, 'Integer'],
+ 3 => [$limit, 'Integer'],
+ ];
$dao = CRM_Core_DAO::executeQuery($sql, $qParams);
- $results = array();
+ $results = [];
while ($dao->fetch()) {
foreach ($fields as $n => $l) {
$results[$dao->mailing_id][$l] = $dao->$l;
$sort,
$getCount
) {
- $selectFields = array('med.time_stamp' => 'start_date');
+ $selectFields = ['med.time_stamp' => 'start_date'];
$fromClause = "
INNER JOIN civicrm_mailing_event_delivered med ON med.event_queue_id = meq.id
* Array of parameters determined by getfields.
*/
function _civicrm_api3_mailing_event_confirm_create_spec(&$params) {
- $params['contact_id'] = array(
+ $params['contact_id'] = [
'api.required' => 1,
'title' => 'Contact ID',
'type' => CRM_Utils_Type::T_INT,
- );
- $params['subscribe_id'] = array(
+ ];
+ $params['subscribe_id'] = [
'api.required' => 1,
'title' => 'Subscribe Event ID',
'type' => CRM_Utils_Type::T_INT,
- );
- $params['hash'] = array(
+ ];
+ $params['hash'] = [
'api.required' => 1,
'title' => 'Hash',
'type' => CRM_Utils_Type::T_STRING,
- );
+ ];
}
}
civicrm_api3_verify_mandatory($params,
'CRM_Mailing_DAO_MailingJob',
- array('job_id', 'contact_id'),
+ ['job_id', 'contact_id'],
FALSE
);
return _civicrm_api3_basic_create('CRM_Mailing_Event_BAO_Queue', $params, 'Queue');
* Array of parameters determined by getfields.
*/
function _civicrm_api3_mailing_event_resubscribe_create_spec(&$params) {
- $params['event_queue_id'] = array(
+ $params['event_queue_id'] = [
'api.required' => 1,
'title' => 'Event Queue ID',
'type' => CRM_Utils_Type::T_INT,
- );
- $params['job_id'] = array(
+ ];
+ $params['job_id'] = [
'api.required' => 1,
'title' => 'Job ID',
'type' => CRM_Utils_Type::T_INT,
- );
- $params['hash'] = array(
+ ];
+ $params['hash'] = [
'api.required' => 1,
'title' => 'Hash',
'type' => CRM_Utils_Type::T_STRING,
- );
+ ];
}
$subscribe->send_confirm_request($email);
- $values = array();
+ $values = [];
$values[$subscribe->id]['contact_id'] = $subscribe->contact_id;
$values[$subscribe->id]['subscribe_id'] = $subscribe->id;
$values[$subscribe->id]['hash'] = $subscribe->hash;
* Array of parameters determined by getfields.
*/
function _civicrm_api3_mailing_event_subscribe_create_spec(&$params) {
- $params['email'] = array(
+ $params['email'] = [
'api.required' => 1,
'title' => 'Unsubscribe Email',
'type' => CRM_Utils_Type::T_STRING,
- );
- $params['group_id'] = array(
+ ];
+ $params['group_id'] = [
'api.required' => 1,
'title' => 'Unsubscribe From Group',
'type' => CRM_Utils_Type::T_INT,
- );
+ ];
}
* Array of parameters determined by getfields.
*/
function _civicrm_api3_mailing_event_unsubscribe_create_spec(&$params) {
- $params['job_id'] = array(
+ $params['job_id'] = [
'api.required' => 1,
'title' => 'Mailing Job ID',
'type' => CRM_Utils_Type::T_INT,
- );
- $params['hash'] = array(
+ ];
+ $params['hash'] = [
'api.required' => 1,
'title' => 'Mailing Hash',
'type' => CRM_Utils_Type::T_STRING,
- );
- $params['event_queue_id'] = array(
+ ];
+ $params['event_queue_id'] = [
'api.required' => 1,
'title' => 'Mailing Queue ID',
'type' => CRM_Utils_Type::T_INT,
- );
+ ];
}
*/
function _civicrm_api3_mailing_group_deprecation() {
$message = 'This action is deprecated. Use the mailing_event API instead.';
- return array(
+ return [
'event_unsubscribe' => $message,
'event_domain_unsubscribe' => $message,
'event_resubscribe' => $message,
'event_subscribe' => $message,
- );
+ ];
}
/**
* Array of parameters determined by getfields.
*/
function _civicrm_api3_membership_delete_spec(&$params) {
- $params['preserve_contribution'] = array(
+ $params['preserve_contribution'] = [
'api.required' => 0,
'title' => 'Preserve Contribution',
'description' => 'By default this is 0, or 0 if not set. Set to 1 to preserve the associated contribution record when membership is deleted.',
'type' => CRM_Utils_Type::T_BOOLEAN,
- );
+ ];
}
/**
}
}
- $values = array();
+ $values = [];
_civicrm_api3_custom_format_params($params, $values, 'Membership');
$params = array_merge($params, $values);
$params['num_terms']
);
}
- foreach (array('join_date', 'start_date', 'end_date') as $date) {
+ foreach (['join_date', 'start_date', 'end_date'] as $date) {
if (empty($params[$date]) && isset($calcDates[$date])) {
$params[$date] = $calcDates[$date];
}
if (empty($params['id'])) {
$params['action'] = CRM_Core_Action::ADD;
// we need user id during add mode
- $ids = array();
+ $ids = [];
if (!empty($params['contact_id'])) {
$ids['userId'] = $params['contact_id'];
}
return civicrm_api3_create_error(ts('The membership can not be saved, no valid membership status for given dates'));
}
- $membership = array();
+ $membership = [];
_civicrm_api3_object_to_array($membershipBAO, $membership[$membershipBAO->id]);
return civicrm_api3_create_success($membership, $params, 'Membership', 'create', $membershipBAO);
$params['contact_id']['api.required'] = 1;
$params['membership_type_id']['api.required'] = 1;
$params['is_test']['api.default'] = 0;
- $params['membership_type_id']['api.aliases'] = array('membership_type');
- $params['status_id']['api.aliases'] = array('membership_status');
- $params['skipStatusCal'] = array(
+ $params['membership_type_id']['api.aliases'] = ['membership_type'];
+ $params['status_id']['api.aliases'] = ['membership_status'];
+ $params['skipStatusCal'] = [
'title' => 'Skip status calculation',
'description' => 'By default this is 0 if id is not set and 1 if it is set.',
'type' => CRM_Utils_Type::T_BOOLEAN,
- );
- $params['num_terms'] = array(
+ ];
+ $params['num_terms'] = [
'title' => 'Number of terms',
'description' => 'Terms to add/renew. If this parameter is passed, dates will be calculated automatically. If no id is passed (new membership) and no dates are given, num_terms will be assumed to be 1.',
'type' => CRM_Utils_Type::T_INT,
- );
+ ];
}
/**
* Array of parameters determined by getfields.
*/
function _civicrm_api3_membership_get_spec(&$params) {
- $params['membership_type_id']['api.aliases'] = array('membership_type');
- $params['active_only'] = array(
+ $params['membership_type_id']['api.aliases'] = ['membership_type'];
+ $params['active_only'] = [
'title' => 'Active Only',
'description' => 'Only retrieve active memberships',
'type' => CRM_Utils_Type::T_BOOLEAN,
- );
+ ];
}
/**
}
$activeOnly = CRM_Utils_Array::value('active_only', $params, $activeOnly);
if ($activeOnly && empty($params['status_id'])) {
- $params['status_id'] = array('IN' => CRM_Member_BAO_MembershipStatus::getMembershipStatusCurrent());
+ $params['status_id'] = ['IN' => CRM_Member_BAO_MembershipStatus::getMembershipStatusCurrent()];
}
$options = _civicrm_api3_get_options_from_params($params, TRUE, 'Membership', 'get');
*/
function _civicrm_api3_membership_get_customv2behaviour(&$params, $membershipTypeId, $activeOnly) {
// get the membership for the given contact ID
- $membershipParams = array('contact_id' => $params['contact_id']);
+ $membershipParams = ['contact_id' => $params['contact_id']];
if ($membershipTypeId) {
$membershipParams['membership_type_id'] = $membershipTypeId;
}
- $membershipValues = array();
+ $membershipValues = [];
CRM_Member_BAO_Membership::getValues($membershipParams, $membershipValues, $activeOnly);
return $membershipValues;
}
* result for calling function
*/
function _civicrm_api3_membership_relationsship_get_customv2behaviour(&$params, $membershipValues, $contactID) {
- $relationships = array();
+ $relationships = [];
foreach ($membershipValues as $membershipId => $values) {
// populate the membership type name for the membership type id
$membershipType = CRM_Member_BAO_MembershipType::getMembershipTypeDetails($values['membership_type_id']);
function _civicrm_api3_membership_payment_create_spec(&$params) {
$params['membership_id']['api.required'] = 1;
$params['contribution_id']['api.required'] = 1;
- $params['membership_type_id'] = array(
+ $params['membership_type_id'] = [
'title' => 'Membership type id',
'description' => 'The id of the membership type',
'type' => CRM_Utils_Type::T_INT,
- );
+ ];
}
/**
*/
function civicrm_api3_membership_status_update($params) {
- civicrm_api3_verify_mandatory($params, NULL, array('id'));
+ civicrm_api3_verify_mandatory($params, NULL, ['id']);
//don't allow duplicate names.
$name = CRM_Utils_Array::value('name', $params);
if ($name) {
}
$membershipStatusBAO->save();
}
- $membershipStatus = array();
+ $membershipStatus = [];
$cloneBAO = clone($membershipStatusBAO);
_civicrm_api3_object_to_array($cloneBAO, $membershipStatus);
$membershipStatus['is_error'] = 0;
WHERE id = %1
";
- $params = array(1 => array($membershipID, 'Integer'));
+ $params = [1 => [$membershipID, 'Integer']];
$dao = CRM_Core_DAO::executeQuery($query, $params);
if ($dao->fetch()) {
$membershipTypeID = empty($membershipParams['membership_type_id']) ? $dao->membership_type_id : $membershipParams['membership_type_id'];
*/
function civicrm_api3_membership_type_create($params) {
// Workaround for fields using nonstandard serialization
- foreach (array('relationship_type_id', 'relationship_direction') as $field) {
+ foreach (['relationship_type_id', 'relationship_direction'] as $field) {
if (isset($params[$field]) && is_array($params[$field])) {
$params[$field] = implode(CRM_Core_DAO::VALUE_SEPARATOR, $params[$field]);
}
if (!empty($results['values']) && is_array($results['values'])) {
foreach ($results['values'] as &$item) {
// Workaround for fields using nonstandard serialization
- foreach (array('relationship_type_id', 'relationship_direction') as $field) {
+ foreach (['relationship_type_id', 'relationship_direction'] as $field) {
if (isset($item[$field]) && !is_array($item[$field])) {
$item[$field] = (array) $item[$field];
}
*/
function civicrm_api3_message_template_send($params) {
// Change external param names to internal ones
- $fieldSpec = array();
+ $fieldSpec = [];
_civicrm_api3_message_template_send_spec($fieldSpec);
foreach ($fieldSpec as $field => $spec) {
throw new API_Exception(
"Mandatory key(s) missing from params array: requires id or option_group_name + option_value_name",
"mandatory_missing",
- array("fields" => array('id', 'option_group_name', 'option_value_name'))
+ ["fields" => ['id', 'option_group_name', 'option_value_name']]
);
}
}
function _civicrm_api3_message_template_send_spec(&$params) {
$params['id']['description'] = 'ID of the template';
$params['id']['title'] = 'Message Template ID';
- $params['id']['api.aliases'] = array('messageTemplateID', 'message_template_id');
+ $params['id']['api.aliases'] = ['messageTemplateID', 'message_template_id'];
$params['id']['type'] = CRM_Utils_Type::T_INT;
$params['option_group_name']['description'] = 'option group name of the template (required if no id supplied)';
$params['option_group_name']['title'] = 'Option Group Name';
- $params['option_group_name']['api.aliases'] = array('groupName');
+ $params['option_group_name']['api.aliases'] = ['groupName'];
$params['option_group_name']['type'] = CRM_Utils_Type::T_STRING;
$params['option_value_name']['description'] = 'option value name of the template (required if no id supplied)';
$params['option_value_name']['title'] = 'Option Value Name';
- $params['option_value_name']['api.aliases'] = array('valueName');
+ $params['option_value_name']['api.aliases'] = ['valueName'];
$params['option_value_name']['type'] = CRM_Utils_Type::T_STRING;
$params['contact_id']['description'] = 'contact id if contact tokens are to be replaced';
$params['contact_id']['title'] = 'Contact ID';
- $params['contact_id']['api.aliases'] = array('contactId');
+ $params['contact_id']['api.aliases'] = ['contactId'];
$params['contact_id']['type'] = CRM_Utils_Type::T_INT;
$params['template_params']['description'] = 'additional template params (other than the ones already set in the template singleton)';
$params['template_params']['title'] = 'Template Params';
- $params['template_params']['api.aliases'] = array('tplParams');
+ $params['template_params']['api.aliases'] = ['tplParams'];
// FIXME: Type??
$params['from']['description'] = 'the From: header';
$params['to_name']['description'] = 'the recipient’s name';
$params['to_name']['title'] = 'Recipient Name';
- $params['to_name']['api.aliases'] = array('toName');
+ $params['to_name']['api.aliases'] = ['toName'];
$params['to_name']['type'] = CRM_Utils_Type::T_STRING;
$params['to_email']['description'] = 'the recipient’s email - mail is sent only if set';
$params['to_email']['title'] = 'Recipient Email';
- $params['to_email']['api.aliases'] = array('toEmail');
+ $params['to_email']['api.aliases'] = ['toEmail'];
$params['to_email']['type'] = CRM_Utils_Type::T_STRING;
$params['cc']['description'] = 'the Cc: header';
$params['reply_to']['description'] = 'the Reply-To: header';
$params['reply_to']['title'] = 'Reply To';
- $params['reply_to']['api.aliases'] = array('replyTo');
+ $params['reply_to']['api.aliases'] = ['replyTo'];
$params['reply_to']['type'] = CRM_Utils_Type::T_STRING;
$params['attachments']['description'] = 'email attachments';
$params['is_test']['description'] = 'whether this is a test email (and hence should include the test banner)';
$params['is_test']['title'] = 'Is Test';
- $params['is_test']['api.aliases'] = array('isTest');
+ $params['is_test']['api.aliases'] = ['isTest'];
$params['is_test']['type'] = CRM_Utils_Type::T_BOOLEAN;
$params['pdf_filename']['description'] = 'filename of optional PDF version to add as attachment (do not include path)';
$params['pdf_filename']['title'] = 'PDF Filename';
- $params['pdf_filename']['api.aliases'] = array('PDFFilename');
+ $params['pdf_filename']['api.aliases'] = ['PDFFilename'];
$params['pdf_filename']['type'] = CRM_Utils_Type::T_STRING;
}
$params['for']['api.required'] = TRUE;
$params['for']['title'] = "Is this reset for all navigation or reports";
$params['for']['type'] = CRM_Utils_Type::T_STRING;
- $params['for']['options'] = array(
+ $params['for']['options'] = [
'all' => 'General Navigation rebuild from xml',
'report' => 'Reset report menu to default structure',
- );
+ ];
$params['domain_id']['api.default'] = CRM_Core_Config::domainID();
$params['domain_id']['type'] = CRM_Utils_Type::T_INT;
$params['domain_id']['title'] = 'Domain ID';
* API result array.
*/
function civicrm_api3_navigation_create($params) {
- civicrm_api3_verify_one_mandatory($params, NULL, array('name', 'label'));
+ civicrm_api3_verify_one_mandatory($params, NULL, ['name', 'label']);
return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'Navigation');
}
* Nested associative array beginning with direct children of given note.
*/
function civicrm_api3_note_tree_get($params) {
- civicrm_api3_verify_mandatory($params, NULL, array('id'));
+ civicrm_api3_verify_mandatory($params, NULL, ['id']);
if (!is_numeric($params['id'])) {
return civicrm_api3_create_error(ts("Invalid note ID"));
*/
function civicrm_api3_option_group_create($params) {
$result = _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'OptionGroup');
- civicrm_api('option_value', 'getfields', array('version' => 3, 'cache_clear' => 1));
+ civicrm_api('option_value', 'getfields', ['version' => 3, 'cache_clear' => 1]);
return $result;
}
* Array of parameters determined by getfields.
*/
function _civicrm_api3_option_value_get_spec(&$params) {
- $params['option_group_id']['api.aliases'] = array('option_group_name');
+ $params['option_group_id']['api.aliases'] = ['option_group_name'];
}
/**
$groupId = $params['option_group_id'];
}
- civicrm_api('option_value', 'getfields', array('version' => 3, 'cache_clear' => 1, 'option_group_id' => $groupId));
+ civicrm_api('option_value', 'getfields', ['version' => 3, 'cache_clear' => 1, 'option_group_id' => $groupId]);
return $result;
}
function _civicrm_api3_option_value_create_spec(&$params) {
$params['is_active']['api.default'] = 1;
//continue to support component
- $params['component_id']['api.aliases'] = array('component');
+ $params['component_id']['api.aliases'] = ['component'];
// $params['name']['api.aliases'] = array('label');
$params['option_group_id']['api.required'] = TRUE;
}
*/
function civicrm_api3_option_value_delete($params) {
// We will get the option group id before deleting so we can flush pseudoconstants.
- $optionGroupID = civicrm_api('option_value', 'getvalue', array('version' => 3, 'id' => $params['id'], 'return' => 'option_group_id'));
+ $optionGroupID = civicrm_api('option_value', 'getvalue', ['version' => 3, 'id' => $params['id'], 'return' => 'option_group_id']);
$result = CRM_Core_BAO_OptionValue::del($params['id']);
if ($result) {
- civicrm_api('option_value', 'getfields', array('version' => 3, 'cache_clear' => 1, 'option_group_id' => $optionGroupID));
+ civicrm_api('option_value', 'getfields', ['version' => 3, 'cache_clear' => 1, 'option_group_id' => $optionGroupID]);
return civicrm_api3_create_success();
}
else {
* Array of Order, if error an array with an error id and error message
*/
function civicrm_api3_order_get($params) {
- $contributions = array();
- $params['api.line_item.get'] = array('qty' => array('<>' => 0));
+ $contributions = [];
+ $params['api.line_item.get'] = ['qty' => ['<>' => 0]];
$isSequential = FALSE;
if (CRM_Utils_Array::value('sequential', $params)) {
$params['sequential'] = 0;
function civicrm_api3_order_create(&$params) {
$entity = NULL;
- $entityIds = array();
+ $entityIds = [];
if (CRM_Utils_Array::value('line_items', $params) && is_array($params['line_items'])) {
$priceSetID = NULL;
CRM_Contribute_BAO_Contribution::checkLineItems($params);
foreach ($params['line_items'] as $lineItems) {
- $entityParams = CRM_Utils_Array::value('params', $lineItems, array());
+ $entityParams = CRM_Utils_Array::value('params', $lineItems, []);
if (!empty($entityParams) && !empty($lineItems['line_item'])) {
$item = reset($lineItems['line_item']);
$entity = str_replace('civicrm_', '', $item['entity_table']);
}
if ($entityParams) {
- if (in_array($entity, array('participant', 'membership'))) {
+ if (in_array($entity, ['participant', 'membership'])) {
$entityParams['skipLineItem'] = TRUE;
$entityResult = civicrm_api3($entity, 'create', $entityParams);
$params['contribution_mode'] = $entity;
}
if (empty($priceSetID)) {
$item = reset($lineItems['line_item']);
- $priceSetID = civicrm_api3('PriceField', 'getvalue', array(
+ $priceSetID = civicrm_api3('PriceField', 'getvalue', [
'return' => 'price_set_id',
'id' => $item['price_field_id'],
- ));
- $params['line_item'][$priceSetID] = array();
+ ]);
+ $params['line_item'][$priceSetID] = [];
}
$params['line_item'][$priceSetID] = array_merge($params['line_item'][$priceSetID], $lineItems['line_item']);
}
// add payments
if ($entity && CRM_Utils_Array::value('id', $contribution)) {
foreach ($entityIds as $entityId) {
- $paymentParams = array(
+ $paymentParams = [
'contribution_id' => $contribution['id'],
$entity . '_id' => $entityId,
- );
+ ];
// if entity is pledge then build pledge param
if ($entity == 'pledge') {
$paymentParams += $entityParams;
* @throws CiviCRM_API3_Exception
*/
function civicrm_api3_order_delete($params) {
- $contribution = civicrm_api3('Contribution', 'get', array(
- 'return' => array('is_test'),
+ $contribution = civicrm_api3('Contribution', 'get', [
+ 'return' => ['is_test'],
'id' => $params['id'],
- ));
+ ]);
if ($contribution['id'] && $contribution['values'][$contribution['id']]['is_test'] == TRUE) {
$result = civicrm_api3('Contribution', 'delete', $params);
}
* Array of parameters determined by getfields.
*/
function _civicrm_api3_order_cancel_spec(&$params) {
- $params['contribution_id'] = array(
+ $params['contribution_id'] = [
'api.required' => 1 ,
'title' => 'Contribution ID',
'type' => CRM_Utils_Type::T_INT,
- );
+ ];
}
/**
* Array of parameters determined by getfields.
*/
function _civicrm_api3_order_create_spec(&$params) {
- $params['contact_id'] = array(
+ $params['contact_id'] = [
'name' => 'contact_id',
'title' => 'Contact ID',
'type' => CRM_Utils_Type::T_INT,
'api.required' => TRUE,
- );
- $params['total_amount'] = array(
+ ];
+ $params['total_amount'] = [
'name' => 'total_amount',
'title' => 'Total Amount',
'api.required' => TRUE,
- );
+ ];
$params['financial_type_id'] = [
'name' => 'financial_type_id',
'title' => 'Financial Type',
* Array of parameters determined by getfields.
*/
function _civicrm_api3_order_delete_spec(&$params) {
- $params['contribution_id'] = array(
+ $params['contribution_id'] = [
'api.required' => TRUE,
'title' => 'Contribution ID',
'type' => CRM_Utils_Type::T_INT,
- );
- $params['id']['api.aliases'] = array('contribution_id');
+ ];
+ $params['id']['api.aliases'] = ['contribution_id'];
}
}
}
- $values = $participant = array();
+ $values = $participant = [];
_civicrm_api3_custom_format_params($params, $values, 'Participant');
$params = array_merge($values, $params);
where ps.id is not null and pfv.label = %2
";
- $qParams = array(
- 1 => array($params['event_id'], 'Integer'),
- 2 => array($label, 'String'),
- );
+ $qParams = [
+ 1 => [$params['event_id'], 'Integer'],
+ 2 => [$label, 'String'],
+ ];
$dao = CRM_Core_DAO::executeQuery($sql, $qParams);
if ($dao->fetch()) {
- $lineItemParams = array(
+ $lineItemParams = [
'price_field_id' => $dao->priceFieldID,
'price_field_value_id' => $dao->priceFieldValueID,
'entity_table' => 'civicrm_participant',
'participant_count' => 0,
'unit_price' => $dao->amount,
'line_total' => $qty * $dao->amount,
- );
+ ];
civicrm_api3('line_item', 'create', $lineItemParams);
}
$params['event_id']['api.required'] = 1;
$params['contact_id']['api.required'] = 1;
// These are for the sake of search builder options - can be removed if that is fixed
- $params['role_id']['api.aliases'] = array('participant_role');
- $params['status_id']['api.aliases'] = array('participant_status');
+ $params['role_id']['api.aliases'] = ['participant_role'];
+ $params['status_id']['api.aliases'] = ['participant_status'];
}
/**
list($dao, $query) = _civicrm_api3_get_query_object($params, $mode, 'Participant');
- $participant = array();
+ $participant = [];
while ($dao->fetch()) {
$query->convertToPseudoNames($dao, FALSE, TRUE);
$participant[$dao->participant_id] = $query->store($dao);
* Array of parameters determined by getfields.
*/
function _civicrm_api3_participant_get_spec(&$params) {
- $params['participant_test'] = array(
+ $params['participant_test'] = [
'api.default' => 0,
'title' => 'Get Test Participants',
'type' => CRM_Utils_Type::T_BOOLEAN,
- );
+ ];
}
/**
* Array of financial transactions which are payments, if error an array with an error id and error message
*/
function civicrm_api3_payment_get($params) {
- $financialTrxn = array();
+ $financialTrxn = [];
$limit = '';
if (isset($params['options']) && CRM_Utils_Array::value('limit', $params['options'])) {
$limit = CRM_Utils_Array::value('limit', $params['options']);
$params['options']['limit'] = 0;
$eft = civicrm_api3('EntityFinancialTrxn', 'get', $params);
if (!empty($eft['values'])) {
- $eftIds = array();
+ $eftIds = [];
foreach ($eft['values'] as $efts) {
if (empty($efts['financial_trxn_id'])) {
continue;
$map[$efts['financial_trxn_id']] = $efts['entity_id'];
}
if (!empty($eftIds)) {
- $ftParams = array(
- 'id' => array('IN' => $eftIds),
+ $ftParams = [
+ 'id' => ['IN' => $eftIds],
'is_payment' => 1,
- );
+ ];
if ($limit) {
$ftParams['options']['limit'] = $limit;
}
}
}
}
- return civicrm_api3_create_success(CRM_Utils_Array::value('values', $financialTrxn, array()), $params, 'Payment', 'get');
+ return civicrm_api3_create_success(CRM_Utils_Array::value('values', $financialTrxn, []), $params, 'Payment', 'get');
}
/**
* Api result array
*/
function civicrm_api3_payment_cancel(&$params) {
- $eftParams = array(
+ $eftParams = [
'entity_table' => 'civicrm_contribution',
'financial_trxn_id' => $params['id'],
- );
+ ];
$entity = civicrm_api3('EntityFinancialTrxn', 'getsingle', $eftParams);
$contributionId = $entity['entity_id'];
$params['total_amount'] = $entity['amount'];
$trxn = CRM_Contribute_BAO_Contribution::recordAdditionalPayment($contributionId, $params, 'refund', NULL, FALSE);
- $values = array();
+ $values = [];
_civicrm_api3_object_to_array_unique_fields($trxn, $values[$trxn->id]);
return civicrm_api3_create_success($values, $params, 'Payment', 'cancel', $trxn);
}
}
$trxn = CRM_Financial_BAO_Payment::create($params);
- $values = array();
+ $values = [];
_civicrm_api3_object_to_array_unique_fields($trxn, $values[$trxn->id]);
return civicrm_api3_create_success($values, $params, 'Payment', 'create', $trxn);
}
* Array of parameters.
*/
function _civicrm_api3_payment_create_spec(&$params) {
- $params = array(
- 'contribution_id' => array(
+ $params = [
+ 'contribution_id' => [
'api.required' => 1 ,
'title' => 'Contribution ID',
'type' => CRM_Utils_Type::T_INT,
- ),
- 'total_amount' => array(
+ ],
+ 'total_amount' => [
'api.required' => 1 ,
'title' => 'Total Payment Amount',
'type' => CRM_Utils_Type::T_FLOAT,
- ),
- 'payment_processor_id' => array(
+ ],
+ 'payment_processor_id' => [
'title' => 'Payment Processor ID',
'type' => CRM_Utils_Type::T_INT,
'description' => ts('Payment processor ID - required for payment processor payments'),
- ),
- 'id' => array(
+ ],
+ 'id' => [
'title' => 'Payment ID',
'type' => CRM_Utils_Type::T_INT,
- 'api.aliases' => array('payment_id'),
- ),
- );
+ 'api.aliases' => ['payment_id'],
+ ],
+ ];
}
/**
* Array of parameters determined by getfields.
*/
function _civicrm_api3_payment_get_spec(&$params) {
- $params = array(
- 'contribution_id' => array(
+ $params = [
+ 'contribution_id' => [
'title' => 'Contribution ID',
'type' => CRM_Utils_Type::T_INT,
- ),
- 'entity_table' => array(
+ ],
+ 'entity_table' => [
'title' => 'Entity Table',
'api.default' => 'civicrm_contribution',
- ),
- 'entity_id' => array(
+ ],
+ 'entity_id' => [
'title' => 'Entity ID',
'type' => CRM_Utils_Type::T_INT,
- 'api.aliases' => array('contribution_id'),
- ),
- );
+ 'api.aliases' => ['contribution_id'],
+ ],
+ ];
}
/**
* Array of parameters.
*/
function _civicrm_api3_payment_delete_spec(&$params) {
- $params = array(
- 'id' => array(
+ $params = [
+ 'id' => [
'api.required' => 1 ,
'title' => 'Payment ID',
'type' => CRM_Utils_Type::T_INT,
- 'api.aliases' => array('payment_id'),
- ),
- );
+ 'api.aliases' => ['payment_id'],
+ ],
+ ];
}
/**
* Array of parameters.
*/
function _civicrm_api3_payment_cancel_spec(&$params) {
- $params = array(
- 'id' => array(
+ $params = [
+ 'id' => [
'api.required' => 1 ,
'title' => 'Payment ID',
'type' => CRM_Utils_Type::T_INT,
- 'api.aliases' => array('payment_id'),
- ),
- );
+ 'api.aliases' => ['payment_id'],
+ ],
+ ];
}
/**
* Array of parameters determined by getfields.
*/
function _civicrm_api3_payment_sendconfirmation_spec(&$params) {
- $params['id'] = array(
+ $params['id'] = [
'api.required' => 1,
'title' => ts('Payment ID'),
'type' => CRM_Utils_Type::T_INT,
- );
+ ];
}
*/
function civicrm_api3_payment_processor_create($params) {
if (empty($params['id']) && empty($params['payment_instrument_id'])) {
- $params['payment_instrument_id'] = civicrm_api3('PaymentProcessorType', 'getvalue', array(
+ $params['payment_instrument_id'] = civicrm_api3('PaymentProcessorType', 'getvalue', [
'id' => $params['payment_processor_type_id'],
'return' => 'payment_instrument_id',
- ));
+ ]);
}
return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'PaymentProcessor');
}
* @return array
*/
function _civicrm_api3_payment_processor_getlist_defaults(&$request) {
- return array(
- 'description_field' => array(
+ return [
+ 'description_field' => [
'payment_processor_type_id',
'description',
- ),
- 'params' => array(
+ ],
+ 'params' => [
'is_test' => 0,
'is_active' => 1,
- ),
- );
+ ],
+ ];
}
*/
function civicrm_api3_pledge_delete($params) {
if (CRM_Pledge_BAO_Pledge::deletePledge($params['id'])) {
- return civicrm_api3_create_success(array(
+ return civicrm_api3_create_success([
'id' => $params['id'],
- ), $params, 'Pledge', 'delete');
+ ], $params, 'Pledge', 'delete');
}
else {
return civicrm_api3_create_error('Could not delete pledge');
*/
function _civicrm_api3_pledge_delete_spec(&$params) {
// set as not required as pledge_id also acceptable & no either/or std yet
- $params['id']['api.aliases'] = array('pledge_id');
+ $params['id']['api.aliases'] = ['pledge_id'];
}
/**
* @param array $params
*/
function _civicrm_api3_pledge_get_spec(&$params) {
- $params['next_pay_date'] = array(
+ $params['next_pay_date'] = [
'name' => 'next_pay_date',
'type' => 12,
'title' => 'Pledge Made',
'api.filter' => 0,
'api.return' => 1,
- );
+ ];
$params['pledge_is_test']['api.default'] = 0;
- $params['pledge_financial_type_id']['api.aliases'] = array('contribution_type_id', 'contribution_type');
+ $params['pledge_financial_type_id']['api.aliases'] = ['contribution_type_id', 'contribution_type'];
}
*/
function _civicrm_api3_pledge_create_spec(&$params) {
- $required = array('contact_id', 'amount', 'installments', 'start_date', 'financial_type_id');
+ $required = ['contact_id', 'amount', 'installments', 'start_date', 'financial_type_id'];
foreach ($required as $required_field) {
$params[$required_field]['api.required'] = 1;
}
// @todo this can come from xml
- $params['amount']['api.aliases'] = array('pledge_amount');
- $params['financial_type_id']['api.aliases'] = array('contribution_type_id', 'contribution_type');
+ $params['amount']['api.aliases'] = ['pledge_amount'];
+ $params['financial_type_id']['api.aliases'] = ['contribution_type_id', 'contribution_type'];
}
/**
list($dao, $query) = _civicrm_api3_get_query_object($params, $mode, 'Pledge');
- $pledge = array();
+ $pledge = [];
while ($dao->fetch()) {
$pledge[$dao->pledge_id] = $query->store($dao);
}
* Set default to not return test params.
*/
function _civicrm_api3_pledge_get_defaults() {
- return array('pledge_test' => 0);
+ return ['pledge_test' => 0];
}
/**
}
$dao = CRM_Pledge_BAO_PledgePayment::add($paymentParams);
- $result = array();
+ $result = [];
if (empty($dao->pledge_id)) {
$dao->find(TRUE);
}
function civicrm_api3_pledge_payment_delete($params) {
if (CRM_Pledge_BAO_PledgePayment::del($params['id'])) {
- return civicrm_api3_create_success(array('id' => $params['id']), $params, 'PledgePayment', 'delete');
+ return civicrm_api3_create_success(['id' => $params['id']], $params, 'PledgePayment', 'delete');
}
else {
return civicrm_api3_create_error('Could not delete payment');
* Modifiable list of fields allowed for the PledgePayment.get action.
*/
function civicrm_api3_pledge_payment_get_spec(&$params) {
- $params['option.create_new'] = array(
+ $params['option.create_new'] = [
'title' => "Create New",
'description' => "Create new field rather than update an unpaid payment",
'type' => CRM_Utils_Type::T_BOOLEAN,
- );
+ ];
}
* @param array $params
*/
function _civicrm_api3_premium_get_spec(&$params) {
- $params['premiums_active']['api.aliases'] = array('is_active');
+ $params['premiums_active']['api.aliases'] = ['is_active'];
}
/**
* @param array $params
*/
function _civicrm_api3_premium_create_spec(&$params) {
- $params['premiums_active']['api.aliases'] = array('is_active');
+ $params['premiums_active']['api.aliases'] = ['is_active'];
}
* API result array.
*/
function civicrm_api3_price_field_value_create($params) {
- $ids = array();
+ $ids = [];
if (!empty($params['id'])) {
$ids['id'] = $params['id'];
}
$bao = CRM_Price_BAO_PriceFieldValue::create($params, $ids);
- $values = array();
+ $values = [];
_civicrm_api3_object_to_array($bao, $values[$bao->id]);
return civicrm_api3_create_success($values, $params, 'PriceFieldValue', 'create', $bao);
*/
function civicrm_api3_profile_get($params) {
$nonStandardLegacyBehaviour = is_numeric($params['profile_id']) ? TRUE : FALSE;
- if (!empty($params['check_permissions']) && !empty($params['contact_id']) && !1 === civicrm_api3('contact', 'getcount', array('contact_id' => $params['contact_id'], 'check_permissions' => 1))) {
+ if (!empty($params['check_permissions']) && !empty($params['contact_id']) && !1 === civicrm_api3('contact', 'getcount', ['contact_id' => $params['contact_id'], 'check_permissions' => 1])) {
throw new API_Exception('permission denied');
}
$profiles = (array) $params['profile_id'];
- $values = array();
+ $values = [];
$ufGroupBAO = new CRM_Core_BAO_UFGroup();
foreach ($profiles as $profileID) {
$profileID = _civicrm_api3_profile_getProfileID($profileID);
- $values[$profileID] = array();
+ $values[$profileID] = [];
if (strtolower($profileID) == 'billing') {
$values[$profileID] = _civicrm_api3_profile_getbillingpseudoprofile($params);
continue;
);
if ($isContactActivityProfile) {
- civicrm_api3_verify_mandatory($params, NULL, array('activity_id'));
+ civicrm_api3_verify_mandatory($params, NULL, ['activity_id']);
$errors = CRM_Profile_Form::validateContactActivityProfile($params['activity_id'],
$params['contact_id'],
throw new API_Exception(array_pop($errors));
}
- $contactFields = $activityFields = array();
+ $contactFields = $activityFields = [];
foreach ($profileFields as $fieldName => $field) {
if (CRM_Utils_Array::value('field_type', $field) == 'Activity') {
$activityFields[$fieldName] = $field;
throw new API_Exception('Update profiles including more than one entity not currently supported');
}
- $contactParams = $activityParams = $missingParams = array();
+ $contactParams = $activityParams = $missingParams = [];
- $profileFields = civicrm_api3('Profile', 'getfields', array('action' => 'submit', 'profile_id' => $profileID));
+ $profileFields = civicrm_api3('Profile', 'getfields', ['action' => 'submit', 'profile_id' => $profileID]);
$profileFields = $profileFields['values'];
if ($isContactActivityProfile) {
- civicrm_api3_verify_mandatory($params, NULL, array('activity_id'));
+ civicrm_api3_verify_mandatory($params, NULL, ['activity_id']);
$errors = CRM_Profile_Form::validateContactActivityProfile($params['activity_id'],
$params['contact_id'],
if ($params[$fieldName] && isset($params[$fieldName . '_id'])) {
$value = $params[$fieldName . '_id'];
}
- $contactEntities = array('contact', 'individual', 'organization', 'household');
- $locationEntities = array('email', 'address', 'phone', 'website', 'im');
+ $contactEntities = ['contact', 'individual', 'organization', 'household'];
+ $locationEntities = ['email', 'address', 'phone', 'website', 'im'];
$entity = strtolower(CRM_Utils_Array::value('entity', $field));
if ($entity && !in_array($entity, array_merge($contactEntities, $locationEntities))) {
}
}
if (isset($contactParams['api.contribution.create']) && isset($contactParams['api.membership.create'])) {
- $contactParams['api.membership_payment.create'] = array(
+ $contactParams['api.membership_payment.create'] = [
'contribution_id' => '$value.api.contribution.create.id',
'membership_id' => '$value.api.membership.create.id',
- );
+ ];
}
if (isset($contactParams['api.contribution.create']) && isset($contactParams['api.participant.create'])) {
- $contactParams['api.participant_payment.create'] = array(
+ $contactParams['api.participant_payment.create'] = [
'contribution_id' => '$value.api.contribution.create.id',
'participant_id' => '$value.api.participant.create.id',
- );
+ ];
}
$contactParams['contact_id'] = empty($params['contact_id']) ? CRM_Utils_Array::value('id', $params) : $params['contact_id'];
if (empty($params['contact_id'])) {
$config = CRM_Core_Config::singleton();
- $blanks = array(
+ $blanks = [
'billing_first_name' => '',
'billing_middle_name' => '',
'billing_last_name' => '',
'billing_street_address-' . $locationTypeID => '',
'billing_country_id-' . $locationTypeID => $config->defaultContactCountry,
'billing_state_province_id-' . $locationTypeID => $config->defaultContactStateProvince,
- );
+ ];
return $blanks;
}
- $addressFields = array('street_address', 'city', 'state_province_id', 'country_id', 'postal_code');
- $result = civicrm_api3('contact', 'getsingle', array(
+ $addressFields = ['street_address', 'city', 'state_province_id', 'country_id', 'postal_code'];
+ $result = civicrm_api3('contact', 'getsingle', [
'id' => $params['contact_id'],
- 'api.address.get.1' => array('location_type_id' => 'Billing', 'return' => $addressFields),
+ 'api.address.get.1' => ['location_type_id' => 'Billing', 'return' => $addressFields],
// getting the is_billing required or not is an extra db call but probably cheap enough as this isn't an import api
- 'api.address.get.2' => array('is_billing' => TRUE, 'return' => $addressFields),
- 'api.email.get.1' => array('location_type_id' => 'Billing'),
- 'api.email.get.2' => array('is_billing' => TRUE),
+ 'api.address.get.2' => ['is_billing' => TRUE, 'return' => $addressFields],
+ 'api.email.get.1' => ['location_type_id' => 'Billing'],
+ 'api.email.get.2' => ['is_billing' => TRUE],
'return' => 'api.email.get, api.address.get, api.address.getoptions, country, state_province, email, first_name, last_name, middle_name, ' . implode($addressFields, ','),
- )
+ ]
);
- $values = array(
+ $values = [
'billing_first_name' => $result['first_name'],
'billing_middle_name' => $result['middle_name'],
'billing_last_name' => $result['last_name'],
- );
+ ];
if (!empty($result['api.address.get.1']['count'])) {
foreach ($addressFields as $fieldname) {
* @return array|void
*/
function _civicrm_api3_buildprofile_submitfields($profileID, $optionsBehaviour = 1, $is_flush) {
- static $profileFields = array();
+ static $profileFields = [];
if ($is_flush) {
- $profileFields = array();
+ $profileFields = [];
if (empty($profileID)) {
return NULL;
}
if (isset($profileFields[$profileID])) {
return $profileFields[$profileID];
}
- $fields = civicrm_api3('uf_field', 'get', array('uf_group_id' => $profileID));
- $entities = array();
+ $fields = civicrm_api3('uf_field', 'get', ['uf_group_id' => $profileID]);
+ $entities = [];
foreach ($fields['values'] as $field) {
if (!$field['is_active']) {
continue;
}
list($entity, $fieldName) = _civicrm_api3_map_profile_fields_to_entity($field);
- $aliasArray = array();
+ $aliasArray = [];
if (strtolower($fieldName) != $fieldName) {
- $aliasArray['api.aliases'] = array($fieldName);
+ $aliasArray['api.aliases'] = [$fieldName];
$fieldName = strtolower($fieldName);
}
- $profileFields[$profileID][$fieldName] = array_merge(array(
+ $profileFields[$profileID][$fieldName] = array_merge([
'api.required' => $field['is_required'],
'title' => $field['label'],
'help_pre' => CRM_Utils_Array::value('help_pre', $field),
'help_post' => CRM_Utils_Array::value('help_post', $field),
'entity' => $entity,
'weight' => CRM_Utils_Array::value('weight', $field),
- ), $aliasArray);
+ ], $aliasArray);
$ufFieldTaleFieldName = $field['field_name'];
if (isset($entity[$ufFieldTaleFieldName]['name'])) {
//see function notes
// as we build up a list of these we should be able to determine a generic approach
//
- $hardCodedEntityFields = array(
+ $hardCodedEntityFields = [
'state_province' => 'state_province_id',
'country' => 'country_id',
'participant_status' => 'status_id',
'group' => 'group_id',
'tag' => 'tag_id',
'soft_credit_type' => 'soft_credit_type_id',
- );
+ ];
if (array_key_exists($ufFieldTaleFieldName, $hardCodedEntityFields)) {
$ufFieldTaleFieldName = $hardCodedEntityFields[$ufFieldTaleFieldName];
}
foreach ($entities as $entity => $entityFields) {
- $result = civicrm_api3($entity, 'getfields', array('action' => 'create'));
+ $result = civicrm_api3($entity, 'getfields', ['action' => 'create']);
$entityGetFieldsResult = _civicrm_api3_profile_appendaliases($result['values'], $entity);
foreach ($entityFields as $entityfield => $realName) {
$fieldName = strtolower($entityfield);
}
$profileFields[$profileID][$fieldName] = array_merge($entityGetFieldsResult[$realName], $profileFields[$profileID][$entityfield]);
if (!isset($profileFields[$profileID][$fieldName]['api.aliases'])) {
- $profileFields[$profileID][$fieldName]['api.aliases'] = array();
+ $profileFields[$profileID][$fieldName]['api.aliases'] = [];
}
if ($optionsBehaviour && !empty($entityGetFieldsResult[$realName]['pseudoconstant'])) {
- if ($optionsBehaviour > 1 || !in_array($realName, array('state_province_id', 'county_id', 'country_id'))) {
- $options = civicrm_api3($entity, 'getoptions', array('field' => $realName));
+ if ($optionsBehaviour > 1 || !in_array($realName, ['state_province_id', 'county_id', 'country_id'])) {
+ $options = civicrm_api3($entity, 'getoptions', ['field' => $realName]);
$profileFields[$profileID][$fieldName]['options'] = $options['values'];
}
}
*/
function _civicrm_api3_map_profile_fields_to_entity(&$field) {
$entity = $field['field_type'];
- $contactTypes = civicrm_api3('contact', 'getoptions', array('field' => 'contact_type'));
+ $contactTypes = civicrm_api3('contact', 'getoptions', ['field' => 'contact_type']);
if (in_array($entity, $contactTypes['values'])) {
$entity = 'contact';
}
$entity = _civicrm_api_get_entity_name_from_camel($entity);
- $locationFields = array('email' => 'email');
+ $locationFields = ['email' => 'email'];
$fieldName = $field['field_name'];
if (!empty($field['location_type_id'])) {
if ($fieldName == 'email') {
// not a great solution but probably if we looked in the BAO we'd find a scary switch statement
// in a perfect world the uf_field table would hold the correct entity for each item
// & only the relationships between entities would need to be coded
- $hardCodedEntityMappings = array(
+ $hardCodedEntityMappings = [
'street_address' => 'address',
'street_number' => 'address',
'supplemental_address_1' => 'address',
'group' => 'group_contact',
'tag' => 'entity_tag',
'note' => 'note',
- );
+ ];
if (array_key_exists($fieldName, $hardCodedEntityMappings)) {
$entity = $hardCodedEntityMappings[$fieldName];
}
- return array($entity, $fieldName);
+ return [$entity, $fieldName];
}
/**
*/
function _civicrm_api3_profile_getProfileID($profileID) {
if (!empty($profileID) && strtolower($profileID) != 'billing' && !is_numeric($profileID)) {
- $profileID = civicrm_api3('uf_group', 'getvalue', array('return' => 'id', 'name' => $profileID));
+ $profileID = civicrm_api3('uf_group', 'getvalue', ['return' => 'id', 'name' => $profileID]);
}
return $profileID;
}
}
}
//special case on membership & contribution - can't see how to handle in a generic way
- if (in_array($entity, array('membership', 'contribution'))) {
- $values['send_receipt'] = array('title' => 'Send Receipt', 'type' => (int) 16);
+ if (in_array($entity, ['membership', 'contribution'])) {
+ $values['send_receipt'] = ['title' => 'Send Receipt', 'type' => (int) 16];
}
return $values;
}
* Array of deprecated actions
*/
function _civicrm_api3_profile_deprecation() {
- return array(
+ return [
'set' => 'Profile api "set" action is deprecated in favor of "submit".',
'apply' => 'Profile api "apply" action is deprecated in favor of "submit".',
- );
+ ];
}
* Array of parameters determined by getfields.
*/
function _civicrm_api3_recurring_entity_get_spec(&$params) {
- $params['entity_table']['options'] = array(
+ $params['entity_table']['options'] = [
'civicrm_event' => 'civicrm_event',
'civicrm_activity' => 'civicrm_activity',
- );
+ ];
}
/**
* Array of parameters determined by getfields.
*/
function _civicrm_api3_recurring_entity_create_spec(&$params) {
- $params['entity_table']['options'] = array(
+ $params['entity_table']['options'] = [
'civicrm_event' => 'civicrm_event',
'civicrm_activity' => 'civicrm_activity',
- );
+ ];
$params['entity_table']['api.required'] = 1;
}
}
//perhaps we should add a 'getcount' but at this stage lets just handle getcount output
if ($options['is_count']) {
- return array('count' => $relationships);
+ return ['count' => $relationships];
}
foreach ($relationships as $relationshipId => $values) {
_civicrm_api3_custom_data_get($relationships[$relationshipId], CRM_Utils_Array::value('check_permissions', $params), 'Relationship', $relationshipId, NULL, CRM_Utils_Array::value('relationship_type_id', $values));
*/
function civicrm_api3_relationship_setvalue($params) {
require_once 'api/v3/Generic/Setvalue.php';
- $result = civicrm_api3_generic_setValue(array("entity" => 'Relationship', 'params' => $params));
+ $result = civicrm_api3_generic_setValue(["entity" => 'Relationship', 'params' => $params]);
if (empty($result['is_error']) && CRM_Utils_String::munge($params['field']) == 'is_active') {
$action = CRM_Core_Action::DISABLE;
* @return array
*/
function _civicrm_api3_relationship_type_getlist_defaults($request) {
- return array(
+ return [
'label_field' => 'label_a_b',
'search_field' => 'label_a_b',
- );
+ ];
}
$params['view_mode']['api.default'] = 'view';
$params['view_mode']['title'] = ts('View Mode for Navigation URL');
$params['view_mode']['type'] = CRM_Utils_Type::T_STRING;
- $params['view_mode']['options'] = array(
+ $params['view_mode']['options'] = [
'view' => ts('View'),
'criteria' => ts('Show Criteria'),
- );
+ ];
}
/**
'CRM_Core_DAO_OptionGroup', 'report_template', 'id', 'name'
);
if (!empty($params['component_id']) && !is_numeric($params['component_id'])) {
- $components = CRM_Core_PseudoConstant::get('CRM_Core_DAO_OptionValue', 'component_id', array('onlyActive' => FALSE, 'labelColumn' => 'name'));
+ $components = CRM_Core_PseudoConstant::get('CRM_Core_DAO_OptionValue', 'component_id', ['onlyActive' => FALSE, 'labelColumn' => 'name']);
$params['component_id'] = array_search($params['component_id'], $components);
}
return civicrm_api3_option_value_create($params);
function _civicrm_api3_report_template_create_spec(&$params) {
require_once 'api/v3/OptionValue.php';
_civicrm_api3_option_value_create_spec($params);
- $params['value']['api.aliases'] = array('report_url');
- $params['name']['api.aliases'] = array('class_name');
+ $params['value']['api.aliases'] = ['report_url'];
+ $params['name']['api.aliases'] = ['class_name'];
$params['option_group_id']['api.default'] = CRM_Core_DAO::getFieldValue(
'CRM_Core_DAO_OptionGroup', 'report_template', 'id', 'name'
);
* API result array
*/
function civicrm_api3_report_template_getrows($params) {
- civicrm_api3_verify_one_mandatory($params, NULL, array('report_id', 'instance_id'));
+ civicrm_api3_verify_one_mandatory($params, NULL, ['report_id', 'instance_id']);
list($rows, $instance, $metadata) = _civicrm_api3_report_template_getrows($params);
$instance->cleanUpTemporaryTables();
return civicrm_api3_create_success($rows, $params, 'ReportTemplate', 'getrows', CRM_Core_DAO::$_nullObject, $metadata);
*/
function _civicrm_api3_report_template_getrows($params) {
if (empty($params['report_id'])) {
- $params['report_id'] = civicrm_api3('report_instance', 'getvalue', array('id' => $params['instance_id'], 'return' => 'report_id'));
+ $params['report_id'] = civicrm_api3('report_instance', 'getvalue', ['id' => $params['instance_id'], 'return' => 'report_id']);
}
- $class = (string) civicrm_api3('option_value', 'getvalue', array(
+ $class = (string) civicrm_api3('option_value', 'getvalue', [
'option_group_name' => 'report_template',
'return' => 'name',
'value' => $params['report_id'],
- )
+ ]
);
$reportInstance = new $class();
$reportInstance->beginPostProcessCommon();
$sql = $reportInstance->buildQuery();
$reportInstance->addToDeveloperTab($sql);
- $rows = $metadata = $requiredMetadata = array();
+ $rows = $metadata = $requiredMetadata = [];
$reportInstance->buildRows($sql, $rows);
$reportInstance->formatDisplay($rows);
$metadata['metadata']['sql'] = $reportInstance->getReportSql();
}
}
- return array($rows, $reportInstance, $metadata);
+ return [$rows, $reportInstance, $metadata];
}
/**
* Input parameters.
*/
function _civicrm_api3_report_template_getrows_spec(&$params) {
- $params['report_id'] = array(
+ $params['report_id'] = [
'title' => 'Report ID - eg. member/lapse',
- );
+ ];
}
/* @codingStandardsIgnoreStart
* @access public
*/
function civicrm_api3_saved_search_create($params) {
- civicrm_api3_verify_one_mandatory($params, NULL, array('form_values', 'where_clause'));
+ civicrm_api3_verify_one_mandatory($params, NULL, ['form_values', 'where_clause']);
// The create function of the dao expects a 'formValues' that is
// not serialized. The get function returns form_values, that is
// serialized.
*/
function civicrm_api3_setting_getfields($params) {
if (!empty($params['action']) && strtolower($params['action']) == 'getvalue') {
- $result = array(
- 'name' => array(
+ $result = [
+ 'name' => [
'title' => 'name of setting field',
'api.required' => 1,
- 'type' => CRM_Utils_Type::T_STRING),
- 'group' => array(
+ 'type' => CRM_Utils_Type::T_STRING],
+ 'group' => [
'api.required' => 0,
'title' => 'Setting Group',
'description' => 'Settings Group. This is required if the setting is not stored in config',
- 'type' => CRM_Utils_Type::T_STRING),
- );
+ 'type' => CRM_Utils_Type::T_STRING],
+ ];
return civicrm_api3_create_success($result, $params, 'Setting', 'getfields');
}
if (!empty($params['name'])) {
}
$result = CRM_Core_BAO_Setting::getSettingSpecification(
CRM_Utils_Array::value('component_id', $params),
- CRM_Utils_Array::value('filters', $params, array()),
+ CRM_Utils_Array::value('filters', $params, []),
CRM_Utils_Array::value('domain_id', $params, NULL),
CRM_Utils_Array::value('profile', $params, NULL)
);
* @param array $params
*/
function _civicrm_api3_setting_getfields_spec(&$params) {
- $params['filters'] = array(
+ $params['filters'] = [
'title' => 'Filters',
'description' => 'Fields you wish to filter by e.g. array("group_name" => "CiviCRM Preferences")',
- );
- $params['component_id'] = array(
+ ];
+ $params['component_id'] = [
'title' => 'Component ID',
'description' => 'ID of relevant component',
- );
- $params['profile'] = array(
+ ];
+ $params['profile'] = [
'title' => 'Profile',
'description' => 'Profile is passed through to hooks & added to cachestring',
- );
+ ];
}
/**
function civicrm_api3_setting_getdefaults(&$params) {
$settings = civicrm_api3('Setting', 'getfields', $params);
$domains = _civicrm_api3_setting_getDomainArray($params);
- $defaults = array();
+ $defaults = [];
foreach ($domains as $domainID) {
- $defaults[$domainID] = array();
+ $defaults[$domainID] = [];
foreach ($settings['values'] as $setting => $spec) {
if (array_key_exists('default', $spec) && !is_null($spec['default'])) {
$defaults[$domainID][$setting] = $spec['default'];
* Parameters as passed to the API.
*/
function _civicrm_api3_setting_getdefaults_spec(&$params) {
- $params['domain_id'] = array(
+ $params['domain_id'] = [
'api.default' => 'current_domain',
'description' => 'Defaults may differ by domain - if you do not pass in a domain id this will default to the current domain
an array or "all" are acceptable values for multiple domains',
'title' => 'Setting Domain',
- );
+ ];
}
/**
// but it's tightly coupled to DAO/field. However, if you really need to support
// more pseudoconstant types, then probably best to refactor it. For now, KISS.
if (!empty($pseudoconstant['callback'])) {
- $values = Civi\Core\Resolver::singleton()->call($pseudoconstant['callback'], array());
+ $values = Civi\Core\Resolver::singleton()->call($pseudoconstant['callback'], []);
return civicrm_api3_create_success($values, $params, 'Setting', 'getoptions');
}
elseif (!empty($pseudoconstant['optionGroupName'])) {
$fields = civicrm_api('Setting', 'getfields', $params);
$fields = $fields['values'];
$domains = _civicrm_api3_setting_getDomainArray($params);
- $result = array();
+ $result = [];
foreach ($domains as $domainID) {
$valuesToRevert = array_intersect_key($defaults['values'][$domainID], $fields);
if (!empty($valuesToRevert)) {
* @param array $params
*/
function _civicrm_api3_setting_revert_spec(&$params) {
- $params['name'] = array(
+ $params['name'] = [
'title' => 'Name',
'description' => 'Setting Name belongs to',
- );
- $params['component_id'] = array(
+ ];
+ $params['component_id'] = [
'title' => 'Component ID',
'description' => 'ID of relevant component',
- );
- $params['domain_id'] = array(
+ ];
+ $params['domain_id'] = [
'api.default' => 'current_domain',
'description' => 'Defaults may differ by domain - if you do not pass in a domain id this will default to the current domain'
. ' an array or "all" are acceptable values for multiple domains',
'title' => 'Setting Domain',
- );
+ ];
}
/**
function civicrm_api3_setting_fill(&$params) {
$defaults = civicrm_api3('Setting', 'getdefaults', $params);
$domains = _civicrm_api3_setting_getDomainArray($params);
- $result = array();
+ $result = [];
foreach ($domains as $domainID) {
- $apiArray = array(
+ $apiArray = [
'version' => $params['version'],
'domain_id' => $domainID,
- );
+ ];
$existing = civicrm_api3('Setting', 'get', $apiArray);
$valuesToFill = array_diff_key($defaults['values'][$domainID], $existing['values'][$domainID]);
if (!empty($valuesToFill)) {
* @param array $params
*/
function _civicrm_api3_setting_fill_spec(&$params) {
- $params['name'] = array(
+ $params['name'] = [
'title' => 'Name',
'description' => 'Setting Name belongs to',
- );
- $params['component_id'] = array(
+ ];
+ $params['component_id'] = [
'title' => 'Component ID',
'description' => 'ID of relevant component',
- );
- $params['domain_id'] = array(
+ ];
+ $params['domain_id'] = [
'api.default' => 'current_domain',
'title' => 'Setting Domain',
'description' => 'Defaults may differ by domain - if you do not pass in a domain id this will default to the '
. 'current domain, an array or "all" are acceptable values for multiple domains',
- );
+ ];
}
/**
* Parameters as passed to the API.
*/
function _civicrm_api3_setting_create_spec(&$params) {
- $params['domain_id'] = array(
+ $params['domain_id'] = [
'api.default' => 'current_domain',
'title' => 'Setting Domain',
'description' => 'if you do not pass in a domain id this will default to the current domain
an array or "all" are acceptable values for multiple domains',
- );
- $params['group'] = array(
+ ];
+ $params['group'] = [
'title' => 'Setting Group',
'description' => 'if you know the group defining it will make the api more efficient',
- );
+ ];
}
/**
*/
function civicrm_api3_setting_get($params) {
$domains = _civicrm_api3_setting_getDomainArray($params);
- $result = CRM_Core_BAO_Setting::getItems($params, $domains, CRM_Utils_Array::value('return', $params, array()));
+ $result = CRM_Core_BAO_Setting::getItems($params, $domains, CRM_Utils_Array::value('return', $params, []));
return civicrm_api3_create_success($result, $params, 'Setting', 'get');
}
/**
* Parameters as passed to the API.
*/
function _civicrm_api3_setting_get_spec(&$params) {
- $params['domain_id'] = array(
+ $params['domain_id'] = [
'api.default' => 'current_domain',
'title' => 'Setting Domain',
'description' => 'if you do not pass in a domain id this will default to the current domain',
- );
- $params['group'] = array(
+ ];
+ $params['group'] = [
'title' => 'Setting Group',
'description' => 'if you know the group defining it will make the api more efficient',
- );
+ ];
}
/**
* Returns value for specific parameter.
*/
function _civicrm_api3_setting_getvalue_spec(&$params) {
- $params['group'] = array(
+ $params['group'] = [
'title' => 'Settings Group',
'api.required' => TRUE,
- );
- $params['name'] = array(
+ ];
+ $params['name'] = [
'title' => 'Setting Name',
- 'api.aliases' => array('return'),
- );
- $params['default_value'] = array(
+ 'api.aliases' => ['return'],
+ ];
+ $params['default_value'] = [
'title' => 'Default Value',
- );
- $params['component_id'] = array(
+ ];
+ $params['component_id'] = [
'title' => 'Component Id',
- );
- $params['contact_id'] = array(
+ ];
+ $params['contact_id'] = [
'title' => 'Contact Id',
- );
- $params['domain_id'] = array(
+ ];
+ $params['domain_id'] = [
'title' => 'Setting Domain',
'description' => 'if you do not pass in a domain id this will default to the current domain',
- );
+ ];
}
/**
}
if ($params['domain_id'] == 'all') {
- $domainAPIResult = civicrm_api('domain', 'get', array('version' => 3, 'return' => 'id'));
+ $domainAPIResult = civicrm_api('domain', 'get', ['version' => 3, 'return' => 'id']);
if (isset($domainAPIResult['values'])) {
$params['domain_id'] = array_keys($domainAPIResult['values']);
}
$domains = $params['domain_id'];
}
else {
- $domains = array($params['domain_id']);
+ $domains = [$params['domain_id']];
}
return $domains;
}
* @return array
*/
function _civicrm_api3_survey_getlist_defaults(&$request) {
- return array(
- 'description_field' => array(
+ return [
+ 'description_field' => [
'campaign_id',
- ),
- 'params' => array(
+ ],
+ 'params' => [
'is_active' => 1,
- ),
- );
+ ],
+ ];
}
*/
function civicrm_api3_survey_respondant_get(&$params) {
- civicrm_api3_verify_one_mandatory($params, NULL, array('survey_id', 'id'));
+ civicrm_api3_verify_one_mandatory($params, NULL, ['survey_id', 'id']);
if (array_key_exists('survey_id', $params)) {
$surveyID = $params['survey_id'];
$interviewerID = $params['interviewer_id'];
}
- $statusIds = array();
+ $statusIds = [];
if (array_key_exists('status_id', $params)) {
$statusIds = explode(',', $params['status_id']);
}
* Array of parameters determined by getfields.
*/
function _civicrm_api3_system_flush_spec(&$params) {
- $params['triggers'] = array(
+ $params['triggers'] = [
'title' => 'Triggers',
'description' => 'rebuild triggers (boolean)',
'type' => CRM_Utils_Type::T_BOOLEAN,
- );
- $params['session'] = array(
+ ];
+ $params['session'] = [
'title' => 'Sessions',
'description' => 'refresh sessions (boolean)',
'type' => CRM_Utils_Type::T_BOOLEAN,
- );
+ ];
}
/**
* @see http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
*/
function _civicrm_api3_system_check_spec(&$spec) {
- $spec['id'] = array(
+ $spec['id'] = [
'title' => 'ID',
'description' => 'Not a real identifier - do not use',
'type' => CRM_Utils_Type::T_INT,
- );
- $spec['name'] = array(
+ ];
+ $spec['name'] = [
'title' => 'Name',
'description' => 'Unique identifier',
'type' => CRM_Utils_Type::T_STRING,
- );
- $spec['title'] = array(
+ ];
+ $spec['title'] = [
'title' => 'Title',
'description' => 'Short title text',
'type' => CRM_Utils_Type::T_STRING,
- );
- $spec['message'] = array(
+ ];
+ $spec['message'] = [
'title' => 'Message',
'description' => 'Long description html',
'type' => CRM_Utils_Type::T_STRING,
- );
- $spec['help'] = array(
+ ];
+ $spec['help'] = [
'title' => 'Help',
'description' => 'Optional extra help (html string)',
'type' => CRM_Utils_Type::T_STRING,
- );
- $spec['severity'] = array(
+ ];
+ $spec['severity'] = [
'title' => 'Severity',
'description' => 'Psr\Log\LogLevel string',
'type' => CRM_Utils_Type::T_STRING,
'options' => array_combine(CRM_Utils_Check::getSeverityList(), CRM_Utils_Check::getSeverityList()),
- );
- $spec['severity_id'] = array(
+ ];
+ $spec['severity_id'] = [
'title' => 'Severity ID',
'description' => 'Integer representation of Psr\Log\LogLevel',
'type' => CRM_Utils_Type::T_INT,
'options' => CRM_Utils_Check::getSeverityList(),
- );
- $spec['is_visible'] = array(
+ ];
+ $spec['is_visible'] = [
'title' => 'is visible',
'description' => '0 if message has been hidden by the user',
'type' => CRM_Utils_Type::T_BOOLEAN,
- );
- $spec['hidden_until'] = array(
+ ];
+ $spec['hidden_until'] = [
'title' => 'Hidden_until',
'description' => 'When will hidden message be visible again?',
'type' => CRM_Utils_Type::T_DATE,
- );
+ ];
}
/**
function civicrm_api3_system_check($params) {
// array(array('name'=> $, 'severity'=>$, ...))
$id = 1;
- $returnValues = $fields = array();
+ $returnValues = $fields = [];
_civicrm_api3_system_check_spec($fields);
// array(CRM_Utils_Check_Message)
$messages = CRM_Utils_Check::checkAll();
foreach ($messages as $msg) {
- $returnValues[] = $msg->toArray() + array('id' => $id++);
+ $returnValues[] = $msg->toArray() + ['id' => $id++];
}
return _civicrm_api3_basic_array_get('systemCheck', $params, $returnValues, "id", array_keys($fields));
// This part means fields with separate db storage are accepted as params which kind of seems more intuitive to me
// because I felt like not doing this required a bunch of explanation in the spec function - but perhaps other won't see it as helpful?
if (!isset($params['context'])) {
- $params['context'] = array();
+ $params['context'] = [];
}
- $specialFields = array('contact_id', 'hostname');
+ $specialFields = ['contact_id', 'hostname'];
foreach ($specialFields as $specialField) {
if (isset($params[$specialField]) && !isset($params['context'])) {
$params['context'][$specialField] = $params[$specialField];
* @param array $params
*/
function _civicrm_api3_system_log_spec(&$params) {
- $params['level'] = array(
+ $params['level'] = [
'title' => 'Log Level',
'description' => 'Log level as described in PSR3 (info, debug, warning etc)',
'type' => CRM_Utils_Type::T_STRING,
'api.required' => TRUE,
- );
- $params['message'] = array(
+ ];
+ $params['message'] = [
'title' => 'Log Message',
'description' => 'Standardised message string, you can also ',
'type' => CRM_Utils_Type::T_STRING,
'api.required' => TRUE,
- );
- $params['context'] = array(
+ ];
+ $params['context'] = [
'title' => 'Log Context',
'description' => 'An array of additional data to store.',
'type' => CRM_Utils_Type::T_LONGTEXT,
- 'api.default' => array(),
- );
- $params['contact_id'] = array(
+ 'api.default' => [],
+ ];
+ $params['contact_id'] = [
'title' => 'Log Contact ID',
'description' => 'Optional ID of relevant contact',
'type' => CRM_Utils_Type::T_INT,
- );
- $params['hostname'] = array(
+ ];
+ $params['hostname'] = [
'title' => 'Log Hostname',
'description' => 'Optional name of host',
'type' => CRM_Utils_Type::T_STRING,
- );
+ ];
}
/**
*/
function civicrm_api3_system_get($params) {
$config = CRM_Core_Config::singleton();
- $returnValues = array(
- array(
+ $returnValues = [
+ [
'version' => CRM_Utils_System::version(), // deprecated in favor of civi.version
'uf' => CIVICRM_UF, // deprecated in favor of cms.type
- 'php' => array(
+ 'php' => [
'version' => phpversion(),
'time' => time(),
'tz' => date_default_timezone_get(),
'sapi' => php_sapi_name(),
'extensions' => get_loaded_extensions(),
'ini' => _civicrm_api3_system_get_redacted_ini(),
- ),
- 'mysql' => array(
+ ],
+ 'mysql' => [
'version' => CRM_Core_DAO::singleValueQuery('SELECT @@version'),
'time' => CRM_Core_DAO::singleValueQuery('SELECT unix_timestamp()'),
'vars' => _civicrm_api3_system_get_redacted_mysql(),
- ),
- 'cms' => array(
+ ],
+ 'cms' => [
'version' => $config->userSystem->getVersion(),
'type' => CIVICRM_UF,
'modules' => CRM_Core_Module::collectStatuses($config->userSystem->getModules()),
- ),
- 'civi' => array(
+ ],
+ 'civi' => [
'version' => CRM_Utils_System::version(),
'dev' => (bool) CRM_Utils_System::isDevelopment(),
'components' => array_keys(CRM_Core_Component::getEnabledComponents()),
'multidomain' => CRM_Core_DAO::singleValueQuery('SELECT count(*) FROM civicrm_domain') > 1,
'settings' => _civicrm_api3_system_get_redacted_settings(),
'exampleUrl' => CRM_Utils_System::url('civicrm/example', NULL, TRUE, NULL, FALSE),
- ),
- 'http' => array(
+ ],
+ 'http' => [
'software' => CRM_Utils_Array::value('SERVER_SOFTWARE', $_SERVER),
'forwarded' => !empty($_SERVER['HTTP_X_FORWARDED_FOR']) || !empty($_SERVER['X_FORWARDED_PROTO']),
'port' => (empty($_SERVER['SERVER_PORT']) || $_SERVER['SERVER_PORT'] == 80 || $_SERVER['SERVER_PORT'] == 443) ? 'Standard' : 'Nonstandard',
- ),
- 'os' => array(
+ ],
+ 'os' => [
'type' => php_uname('s'),
'release' => php_uname('r'),
'version' => php_uname('v'),
'machine' => php_uname('m'),
- ),
- ),
- );
+ ],
+ ],
+ ];
return civicrm_api3_create_success($returnValues, $params, 'System', 'get');
}
}
$inis = ini_get_all(NULL, FALSE);
- $result = array();
+ $result = [];
foreach ($inis as $k => $v) {
if (empty($v) || in_array($k, $whitelist)) {
$result[$k] = $v;
}
$inis = ini_get_all(NULL, FALSE);
- $result = array();
+ $result = [];
$dao = CRM_Core_DAO::executeQuery('SHOW VARIABLES');
while ($dao->fetch()) {
if (empty($dao->Variable_name) || in_array($dao->Variable_name, $whitelist)) {
$whitelist = _civicrm_api3_system_get_whitelist(__DIR__ . '/System/setting-whitelist.txt');
}
- $apiResult = civicrm_api3('Setting', 'get', array());
- $result = array();
+ $apiResult = civicrm_api3('Setting', 'get', []);
+ $result = [];
foreach ($apiResult['values'] as $settings) {
foreach ($settings as $key => $value) {
if (in_array($key, $whitelist)) {
function _civicrm_api3_tag_create_spec(&$params) {
$params['used_for']['api.default'] = 'civicrm_contact';
$params['name']['api.required'] = 1;
- $params['id']['api.aliases'] = array('tag');
+ $params['id']['api.aliases'] = ['tag'];
}
/**
$params['field_name']['api.required'] = TRUE;
$params['uf_group_id']['api.required'] = TRUE;
- $params['option.autoweight'] = array(
+ $params['option.autoweight'] = [
'title' => "Auto Weight",
'description' => "Automatically adjust weights in UFGroup to align with UFField",
'type' => CRM_Utils_Type::T_BOOLEAN,
'api.default' => TRUE,
- );
+ ];
$params['is_active']['api.default'] = TRUE;
}
*/
function _civicrm_api3_uf_field_delete_spec(&$params) {
// legacy support for field_id
- $params['id']['api.aliases'] = array('field_id');
+ $params['id']['api.aliases'] = ['field_id'];
}
* @return array
*/
function _civicrm_api3_uf_group_getlist_defaults(&$request) {
- return array(
- 'description_field' => array(
+ return [
+ 'description_field' => [
'description',
'group_type',
- ),
- 'params' => array(
+ ],
+ 'params' => [
'is_active' => 1,
- ),
- );
+ ],
+ ];
}
/**
* @return array
*/
function _civicrm_api3_uf_group_getlist_output($result, $request, $entity, $fields) {
- $output = array();
+ $output = [];
if (!empty($result['values'])) {
foreach ($result['values'] as $row) {
- $data = array(
+ $data = [
'id' => $row[$request['id_field']],
'label' => $row[$request['label_field']],
- );
+ ];
if (!empty($request['description_field'])) {
- $data['description'] = array();
+ $data['description'] = [];
foreach ((array) $request['description_field'] as $field) {
if (!empty($row[$field])) {
// Special formatting for group_type field
*/
function civicrm_api3_user_get($params) {
if (empty($params['contact_id'])) {
- $params['contact_id'] = civicrm_api3('UFMatch', 'getvalue', array(
+ $params['contact_id'] = civicrm_api3('UFMatch', 'getvalue', [
'uf_id' => $params['id'],
'domain_id' => CRM_Core_Config::domainID(),
'return' => 'contact_id',
- ));
+ ]);
}
$result = CRM_Core_Config::singleton()->userSystem->getUser($params['contact_id']);
$result['contact_id'] = $params['contact_id'];
return civicrm_api3_create_success(
- array($result['id'] => $result),
+ [$result['id'] => $result],
$params,
'user',
'get'
*/
function _civicrm_api3_user_get_spec(&$params) {
// At this stage contact-id is required - we may be able to loosen this.
- $params['contact_id'] = array(
+ $params['contact_id'] = [
'title' => 'Contact ID',
'type' => CRM_Utils_Type::T_INT,
'api.required' => 1,
- );
- $params['id'] = array(
+ ];
+ $params['id'] = [
'title' => 'CMS User ID',
'type' => CRM_Utils_Type::T_INT,
- );
- $params['name'] = array(
+ ];
+ $params['name'] = [
'title' => 'Username',
'type' => CRM_Utils_Type::T_STRING,
- );
+ ];
}
* API result array
*/
function activity_create_example() {
- $params = array(
+ $params = [
'source_contact_id' => 1,
'activity_type_id' => 'Test activity type',
'subject' => 'test activity type id',
'location' => 'Pennsylvania',
'details' => 'a test activity',
'custom_2' => '1',
- );
+ ];
try{
$result = civicrm_api3('Activity', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function activity_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'id' => '1',
'source_record_id' => '',
'activity_type_id' => '9999',
'engagement_level' => '',
'weight' => '',
'is_star' => '',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function activity_get_example() {
- $params = array(
+ $params = [
'return.custom_2' => 1,
'id' => 1,
- );
+ ];
try{
$result = civicrm_api3('Activity', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function activity_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'id' => '1',
'activity_type_id' => '9999',
'subject' => 'test activity type id',
'custom_1_1' => 'defaultValue',
'custom_2_1' => 'Anderson, Anthony',
'custom_2_1_id' => '1',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function activity_create_example() {
- $params = array(
+ $params = [
'source_contact_id' => 1,
'activity_type_id' => 'Test activity type',
'subject' => 'test activity type id',
'location' => 'Pennsylvania',
'details' => 'a test activity',
'custom_1' => 'custom string',
- );
+ ];
try{
$result = civicrm_api3('Activity', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function activity_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'id' => '1',
'source_record_id' => '',
'activity_type_id' => '9999',
'engagement_level' => '',
'weight' => '',
'is_star' => '',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function activity_get_example() {
- $params = array(
+ $params = [
'source_contact_id' => 1,
'filter.activity_date_time_high' => '20120101000000',
'sequential' => 1,
- );
+ ];
try{
$result = civicrm_api3('Activity', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function activity_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '0' => array(
+ 'values' => [
+ '0' => [
'id' => '1',
'activity_type_id' => '9999',
'subject' => 'Make-it-Happen Meeting',
'is_deleted' => 0,
'is_star' => 0,
'source_contact_id' => '1',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function activity_get_example() {
- $params = array(
+ $params = [
'filter.activity_date_time_low' => '20120101000000',
'sequential' => 1,
- );
+ ];
try{
$result = civicrm_api3('Activity', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function activity_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 2,
- 'values' => array(
- '0' => array(
+ 'values' => [
+ '0' => [
'id' => '2',
'activity_type_id' => '9999',
'subject' => 'Make-it-Happen Meeting',
'is_deleted' => 0,
'is_star' => 0,
'source_contact_id' => '1',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function activity_delete_example() {
- $params = array(
+ $params = [
'id' => 1,
- );
+ ];
try{
$result = civicrm_api3('Activity', 'delete', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function activity_delete_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'values' => 1,
- );
+ ];
return $expectedResult;
}
* API result array
*/
function activity_get_example() {
- $params = array(
+ $params = [
'contact_id' => 1,
'activity_type_id' => 9999,
'sequential' => 1,
'return.custom_1' => 1,
- );
+ ];
try{
$result = civicrm_api3('Activity', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function activity_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '0' => array(
+ 'values' => [
+ '0' => [
'id' => '1',
'activity_type_id' => '9999',
'subject' => 'test activity type id',
'status' => 'Completed',
'activity_name' => 'Test activity type',
'custom_1_1' => 'custom string',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function activity_getfields_example() {
- $params = array(
+ $params = [
'action' => 'create',
- );
+ ];
try{
$result = civicrm_api3('Activity', 'getfields', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function activity_getfields_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 29,
- 'values' => array(
- 'source_record_id' => array(
+ 'values' => [
+ 'source_record_id' => [
'name' => 'source_record_id',
'type' => 1,
'title' => 'Source Record',
'table_name' => 'civicrm_activity',
'entity' => 'Activity',
'bao' => 'CRM_Activity_BAO_Activity',
- ),
- 'activity_type_id' => array(
+ ],
+ 'activity_type_id' => [
'name' => 'activity_type_id',
'type' => 1,
'title' => 'Activity Type ID',
'table_name' => 'civicrm_activity',
'entity' => 'Activity',
'bao' => 'CRM_Activity_BAO_Activity',
- 'html' => array(
+ 'html' => [
'type' => 'Select',
'size' => 6,
'maxlength' => 14,
- ),
- 'pseudoconstant' => array(
+ ],
+ 'pseudoconstant' => [
'optionGroupName' => 'activity_type',
'optionEditPath' => 'civicrm/admin/options/activity_type',
- ),
- ),
- 'activity_date_time' => array(
+ ],
+ ],
+ 'activity_date_time' => [
'name' => 'activity_date_time',
'type' => 12,
'title' => 'Activity Date',
'table_name' => 'civicrm_activity',
'entity' => 'Activity',
'bao' => 'CRM_Activity_BAO_Activity',
- 'html' => array(
+ 'html' => [
'type' => 'Select Date',
'format' => 'activityDateTime',
- ),
- ),
- 'phone_id' => array(
+ ],
+ ],
+ 'phone_id' => [
'name' => 'phone_id',
'type' => 1,
'title' => 'Phone (called) ID',
'entity' => 'Activity',
'bao' => 'CRM_Activity_BAO_Activity',
'FKClassName' => 'CRM_Core_DAO_Phone',
- 'html' => array(
+ 'html' => [
'type' => 'EntityRef',
'size' => 6,
'maxlength' => 14,
- ),
+ ],
'FKApiName' => 'Phone',
- ),
- 'phone_number' => array(
+ ],
+ 'phone_number' => [
'name' => 'phone_number',
'type' => 2,
'title' => 'Phone (called) Number',
'table_name' => 'civicrm_activity',
'entity' => 'Activity',
'bao' => 'CRM_Activity_BAO_Activity',
- 'html' => array(
+ 'html' => [
'type' => 'Text',
'maxlength' => 64,
'size' => 30,
- ),
- ),
- 'priority_id' => array(
+ ],
+ ],
+ 'priority_id' => [
'name' => 'priority_id',
'type' => 1,
'title' => 'Priority',
'table_name' => 'civicrm_activity',
'entity' => 'Activity',
'bao' => 'CRM_Activity_BAO_Activity',
- 'html' => array(
+ 'html' => [
'type' => 'Select',
'size' => 6,
'maxlength' => 14,
- ),
- 'pseudoconstant' => array(
+ ],
+ 'pseudoconstant' => [
'optionGroupName' => 'priority',
'optionEditPath' => 'civicrm/admin/options/priority',
- ),
- ),
- 'parent_id' => array(
+ ],
+ ],
+ 'parent_id' => [
'name' => 'parent_id',
'type' => 1,
'title' => 'Parent Activity Id',
'bao' => 'CRM_Activity_BAO_Activity',
'FKClassName' => 'CRM_Activity_DAO_Activity',
'FKApiName' => 'Activity',
- ),
- 'is_auto' => array(
+ ],
+ 'is_auto' => [
'name' => 'is_auto',
'type' => 16,
'title' => 'Auto',
'table_name' => 'civicrm_activity',
'entity' => 'Activity',
'bao' => 'CRM_Activity_BAO_Activity',
- ),
- 'relationship_id' => array(
+ ],
+ 'relationship_id' => [
'name' => 'relationship_id',
'type' => 1,
'title' => 'Relationship Id',
'bao' => 'CRM_Activity_BAO_Activity',
'FKClassName' => 'CRM_Contact_DAO_Relationship',
'FKApiName' => 'Relationship',
- ),
- 'is_current_revision' => array(
+ ],
+ 'is_current_revision' => [
'name' => 'is_current_revision',
'type' => 16,
'title' => 'Is this activity a current revision in versioning chain?',
'table_name' => 'civicrm_activity',
'entity' => 'Activity',
'bao' => 'CRM_Activity_BAO_Activity',
- 'html' => array(
+ 'html' => [
'type' => 'CheckBox',
- ),
- ),
- 'original_id' => array(
+ ],
+ ],
+ 'original_id' => [
'name' => 'original_id',
'type' => 1,
'title' => 'Original Activity ID ',
'bao' => 'CRM_Activity_BAO_Activity',
'FKClassName' => 'CRM_Activity_DAO_Activity',
'FKApiName' => 'Activity',
- ),
- 'weight' => array(
+ ],
+ 'weight' => [
'name' => 'weight',
'type' => 1,
'title' => 'Order',
'table_name' => 'civicrm_activity',
'entity' => 'Activity',
'bao' => 'CRM_Activity_BAO_Activity',
- 'html' => array(
+ 'html' => [
'type' => 'Text',
'size' => 6,
'maxlength' => 14,
- ),
- ),
- 'is_star' => array(
+ ],
+ ],
+ 'is_star' => [
'name' => 'is_star',
'type' => 16,
'title' => 'Is Starred',
'table_name' => 'civicrm_activity',
'entity' => 'Activity',
'bao' => 'CRM_Activity_BAO_Activity',
- ),
- 'id' => array(
+ ],
+ 'id' => [
'name' => 'id',
'type' => 1,
'title' => 'Activity ID',
'entity' => 'Activity',
'bao' => 'CRM_Activity_BAO_Activity',
'uniqueName' => 'activity_id',
- 'api.aliases' => array(
+ 'api.aliases' => [
'0' => 'activity_id',
- ),
- ),
- 'subject' => array(
+ ],
+ ],
+ 'subject' => [
'name' => 'subject',
'type' => 2,
'title' => 'Subject',
'table_name' => 'civicrm_activity',
'entity' => 'Activity',
'bao' => 'CRM_Activity_BAO_Activity',
- 'html' => array(
+ 'html' => [
'type' => 'Text',
'maxlength' => 255,
'size' => 45,
- ),
+ ],
'uniqueName' => 'activity_subject',
- ),
- 'duration' => array(
+ ],
+ 'duration' => [
'name' => 'duration',
'type' => 1,
'title' => 'Duration',
'table_name' => 'civicrm_activity',
'entity' => 'Activity',
'bao' => 'CRM_Activity_BAO_Activity',
- 'html' => array(
+ 'html' => [
'type' => 'Text',
'size' => 6,
'maxlength' => 14,
- ),
+ ],
'uniqueName' => 'activity_duration',
- ),
- 'location' => array(
+ ],
+ 'location' => [
'name' => 'location',
'type' => 2,
'title' => 'Location',
'table_name' => 'civicrm_activity',
'entity' => 'Activity',
'bao' => 'CRM_Activity_BAO_Activity',
- 'html' => array(
+ 'html' => [
'type' => 'Text',
'maxlength' => 255,
'size' => 45,
- ),
+ ],
'uniqueName' => 'activity_location',
- ),
- 'details' => array(
+ ],
+ 'details' => [
'name' => 'details',
'type' => 32,
'title' => 'Details',
'table_name' => 'civicrm_activity',
'entity' => 'Activity',
'bao' => 'CRM_Activity_BAO_Activity',
- 'html' => array(
+ 'html' => [
'type' => 'RichTextEditor',
'rows' => 2,
'cols' => 80,
- ),
+ ],
'uniqueName' => 'activity_details',
- ),
- 'status_id' => array(
+ ],
+ 'status_id' => [
'name' => 'status_id',
'type' => 1,
'title' => 'Activity Status',
'table_name' => 'civicrm_activity',
'entity' => 'Activity',
'bao' => 'CRM_Activity_BAO_Activity',
- 'html' => array(
+ 'html' => [
'type' => 'Select',
'size' => 6,
'maxlength' => 14,
- ),
- 'pseudoconstant' => array(
+ ],
+ 'pseudoconstant' => [
'optionGroupName' => 'activity_status',
'optionEditPath' => 'civicrm/admin/options/activity_status',
- ),
+ ],
'uniqueName' => 'activity_status_id',
- 'api.aliases' => array(
+ 'api.aliases' => [
'0' => 'activity_status',
- ),
- ),
- 'is_test' => array(
+ ],
+ ],
+ 'is_test' => [
'name' => 'is_test',
'type' => 16,
'title' => 'Test',
'table_name' => 'civicrm_activity',
'entity' => 'Activity',
'bao' => 'CRM_Activity_BAO_Activity',
- 'html' => array(
+ 'html' => [
'type' => 'Select',
- ),
+ ],
'uniqueName' => 'activity_is_test',
- ),
- 'medium_id' => array(
+ ],
+ 'medium_id' => [
'name' => 'medium_id',
'type' => 1,
'title' => 'Activity Medium',
'table_name' => 'civicrm_activity',
'entity' => 'Activity',
'bao' => 'CRM_Activity_BAO_Activity',
- 'html' => array(
+ 'html' => [
'type' => 'Select',
'size' => 6,
'maxlength' => 14,
- ),
- 'pseudoconstant' => array(
+ ],
+ 'pseudoconstant' => [
'optionGroupName' => 'encounter_medium',
'optionEditPath' => 'civicrm/admin/options/encounter_medium',
- ),
+ ],
'uniqueName' => 'activity_medium_id',
- ),
- 'result' => array(
+ ],
+ 'result' => [
'name' => 'result',
'type' => 2,
'title' => 'Result',
'table_name' => 'civicrm_activity',
'entity' => 'Activity',
'bao' => 'CRM_Activity_BAO_Activity',
- 'html' => array(
+ 'html' => [
'type' => 'Text',
'maxlength' => 255,
'size' => 45,
- ),
+ ],
'uniqueName' => 'activity_result',
- ),
- 'is_deleted' => array(
+ ],
+ 'is_deleted' => [
'name' => 'is_deleted',
'type' => 16,
'title' => 'Activity is in the Trash',
'table_name' => 'civicrm_activity',
'entity' => 'Activity',
'bao' => 'CRM_Activity_BAO_Activity',
- 'html' => array(
+ 'html' => [
'type' => 'Text',
- ),
+ ],
'uniqueName' => 'activity_is_deleted',
- ),
- 'campaign_id' => array(
+ ],
+ 'campaign_id' => [
'name' => 'campaign_id',
'type' => 1,
'title' => 'Campaign',
'entity' => 'Activity',
'bao' => 'CRM_Activity_BAO_Activity',
'FKClassName' => 'CRM_Campaign_DAO_Campaign',
- 'html' => array(
+ 'html' => [
'type' => 'CheckBox',
'size' => 6,
'maxlength' => 14,
- ),
- 'pseudoconstant' => array(
+ ],
+ 'pseudoconstant' => [
'table' => 'civicrm_campaign',
'keyColumn' => 'id',
'labelColumn' => 'title',
- ),
+ ],
'uniqueName' => 'activity_campaign_id',
'FKApiName' => 'Campaign',
- ),
- 'engagement_level' => array(
+ ],
+ 'engagement_level' => [
'name' => 'engagement_level',
'type' => 1,
'title' => 'Engagement Index',
'table_name' => 'civicrm_activity',
'entity' => 'Activity',
'bao' => 'CRM_Activity_BAO_Activity',
- 'html' => array(
+ 'html' => [
'type' => 'Select',
'size' => 6,
'maxlength' => 14,
- ),
- 'pseudoconstant' => array(
+ ],
+ 'pseudoconstant' => [
'optionGroupName' => 'engagement_index',
'optionEditPath' => 'civicrm/admin/options/engagement_index',
- ),
+ ],
'uniqueName' => 'activity_engagement_level',
- ),
- 'source_contact_id' => array(
+ ],
+ 'source_contact_id' => [
'name' => 'source_contact_id',
'title' => 'Activity Source Contact',
'description' => 'Person who created this activity. Defaults to current user.',
'FKClassName' => 'CRM_Contact_DAO_Contact',
'api.default' => 'user_contact_id',
'FKApiName' => 'Contact',
- ),
- 'assignee_contact_id' => array(
+ ],
+ 'assignee_contact_id' => [
'name' => 'assignee_id',
'title' => 'Activity Assignee',
'description' => 'Contact(s) assigned to this activity.',
'type' => 1,
'FKClassName' => 'CRM_Contact_DAO_Contact',
'FKApiName' => 'Contact',
- ),
- 'target_contact_id' => array(
+ ],
+ 'target_contact_id' => [
'name' => 'target_id',
'title' => 'Activity Target',
'description' => 'Contact(s) participating in this activity.',
'type' => 1,
'FKClassName' => 'CRM_Contact_DAO_Contact',
'FKApiName' => 'Contact',
- ),
- 'case_id' => array(
+ ],
+ 'case_id' => [
'name' => 'case_id',
'title' => 'Case ID',
'description' => 'For creating an activity as part of a case.',
'type' => 1,
'FKClassName' => 'CRM_Case_DAO_Case',
'FKApiName' => 'Case',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function activity_create_example() {
- $params = array(
+ $params = [
'source_contact_id' => 1,
'subject' => 'Make-it-Happen Meeting',
'activity_date_time' => '20110316',
'priority_id' => 1,
'target_contact_id' => 1,
'assignee_contact_id' => 1,
- );
+ ];
try{
$result = civicrm_api3('Activity', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function activity_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'id' => '1',
'source_record_id' => '',
'activity_type_id' => '1',
'engagement_level' => '',
'weight' => '',
'is_star' => '',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function activity_getsingle_example() {
- $params = array(
+ $params = [
'id' => 1,
- 'return' => array(
+ 'return' => [
'0' => 'source_contact_name',
'1' => 'target_contact_name',
'2' => 'assignee_contact_name',
'3' => 'subject',
- ),
- );
+ ],
+ ];
try{
$result = civicrm_api3('Activity', 'getsingle', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function activity_getsingle_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'id' => '1',
'subject' => 'Make-it-Happen Meeting',
'source_contact_id' => '6',
'source_contact_name' => 'D Bug',
- 'target_contact_id' => array(
+ 'target_contact_id' => [
'1' => '4',
- ),
- 'target_contact_name' => array(
+ ],
+ 'target_contact_name' => [
'3' => 'A Cat',
'4' => 'B Good',
- ),
- 'assignee_contact_id' => array(),
- 'assignee_contact_name' => array(
+ ],
+ 'assignee_contact_id' => [],
+ 'assignee_contact_name' => [
'5' => 'C Shore',
- ),
- );
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function activity_get_example() {
- $params = array(
+ $params = [
'activity_id' => 1,
'sequential' => 1,
'return.assignee_contact_id' => 1,
- 'api.contact.get' => array(
+ 'api.contact.get' => [
'id' => '$value.source_contact_id',
- ),
- );
+ ],
+ ];
try{
$result = civicrm_api3('Activity', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function activity_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '0' => array(
+ 'values' => [
+ '0' => [
'id' => '1',
'activity_type_id' => '9999',
'subject' => 'test activity type id',
'is_current_revision' => '1',
'is_deleted' => 0,
'is_star' => 0,
- 'assignee_contact_id' => array(
+ 'assignee_contact_id' => [
'0' => '3',
- ),
+ ],
'source_contact_id' => '1',
- 'api.contact.get' => array(
+ 'api.contact.get' => [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '0' => array(
+ 'values' => [
+ '0' => [
'contact_id' => '1',
'contact_type' => 'Individual',
'contact_sub_type' => '',
'state_province' => '',
'country' => '',
'id' => '1',
- ),
- ),
- ),
- ),
- ),
- );
+ ],
+ ],
+ ],
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function activity_contact_create_example() {
- $params = array(
+ $params = [
'contact_id' => 3,
'activity_id' => 1,
'record_type_id' => 2,
- );
+ ];
try{
$result = civicrm_api3('ActivityContact', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function activity_contact_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 4,
- 'values' => array(
- '4' => array(
+ 'values' => [
+ '4' => [
'id' => '4',
'activity_id' => '1',
'contact_id' => '3',
'record_type_id' => '2',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function activity_contact_delete_example() {
- $params = array(
+ $params = [
'id' => 8,
- );
+ ];
try{
$result = civicrm_api3('ActivityContact', 'delete', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function activity_contact_delete_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'values' => 1,
- );
+ ];
return $expectedResult;
}
* API result array
*/
function activity_type_create_example() {
- $params = array(
+ $params = [
'weight' => '2',
'label' => 'send out letters',
'filter' => 0,
'is_active' => 1,
'is_optgroup' => 1,
'is_default' => 0,
- );
+ ];
try{
$result = civicrm_api3('ActivityType', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function activity_type_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 849,
- 'values' => array(
- '849' => array(
+ 'values' => [
+ '849' => [
'id' => '849',
'option_group_id' => '2',
'label' => 'send out letters',
'visibility_id' => '',
'icon' => '',
'color' => '',
- ),
- ),
+ ],
+ ],
'deprecated' => 'The ActivityType api is deprecated. Please use the OptionValue api instead.',
- );
+ ];
return $expectedResult;
}
* API result array
*/
function activity_type_get_example() {
- $params = array();
+ $params = [];
try{
$result = civicrm_api3('ActivityType', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function activity_type_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 54,
- 'values' => array(
+ 'values' => [
'1' => 'Meeting',
'2' => 'Phone Call',
'3' => 'Email',
'52' => 'Contact Deleted by Merge',
'53' => 'Failed Payment',
'54' => 'Close Accounting Period',
- ),
+ ],
'deprecated' => 'The ActivityType api is deprecated. Please use the OptionValue api instead.',
- );
+ ];
return $expectedResult;
}
* API result array
*/
function address_get_example() {
- $params = array(
- 'street_address' => array(
+ $params = [
+ 'street_address' => [
'LIKE' => '%mb%',
- ),
+ ],
'sequential' => 1,
- );
+ ];
try{
$result = civicrm_api3('Address', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function address_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '0' => array(
+ 'values' => [
+ '0' => [
'id' => '1',
'contact_id' => '20',
'location_type_id' => '18',
'postal_code' => '6971 BN',
'country_id' => '1152',
'manual_geo_code' => 0,
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function address_create_example() {
- $params = array(
+ $params = [
'street_parsing' => 1,
'street_address' => '54A Excelsior Ave. Apt 1C',
'location_type_id' => 7,
'contact_id' => 4,
- );
+ ];
try{
$result = civicrm_api3('Address', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function address_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'id' => '1',
'contact_id' => '4',
'location_type_id' => '7',
'street_name' => 'Excelsior Ave.',
'street_unit' => 'Apt 1C',
'manual_geo_code' => 0,
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function address_get_example() {
- $params = array(
- 'options' => array(
+ $params = [
+ 'options' => [
'sort' => 'street_address DESC',
'limit' => 2,
- ),
+ ],
'sequential' => 1,
- );
+ ];
try{
$result = civicrm_api3('Address', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function address_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 2,
- 'values' => array(
- '0' => array(
+ 'values' => [
+ '0' => [
'id' => '2',
'contact_id' => '19',
'location_type_id' => '17',
'postal_code' => '6971 BN',
'country_id' => '1152',
'manual_geo_code' => 0,
- ),
- '1' => array(
+ ],
+ '1' => [
'id' => '1',
'contact_id' => '19',
'location_type_id' => '17',
'postal_code' => '6971 BN',
'country_id' => '1152',
'manual_geo_code' => 0,
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function address_create_example() {
- $params = array(
+ $params = [
'contact_id' => 3,
'location_type_id' => 6,
'street_name' => 'Ambachtstraat',
'country_id' => '1152',
'city' => 'Brummen',
'is_primary' => 1,
- );
+ ];
try{
$result = civicrm_api3('Address', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function address_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 2,
- 'values' => array(
- '2' => array(
+ 'values' => [
+ '2' => [
'id' => '2',
'contact_id' => '3',
'location_type_id' => '6',
'postal_code' => '6971 BN',
'country_id' => '1152',
'manual_geo_code' => 0,
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function address_delete_example() {
- $params = array(
+ $params = [
'id' => 1,
- );
+ ];
try{
$result = civicrm_api3('Address', 'delete', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function address_delete_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'values' => 1,
- );
+ ];
return $expectedResult;
}
* API result array
*/
function address_get_example() {
- $params = array(
+ $params = [
'contact_id' => 17,
'street_name' => 'Ambachtstraat',
- );
+ ];
try{
$result = civicrm_api3('Address', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function address_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'id' => '1',
'contact_id' => '17',
'location_type_id' => '15',
'postal_code' => '6971 BN',
'country_id' => '1152',
'manual_geo_code' => 0,
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function address_getoptions_example() {
- $params = array(
+ $params = [
'field' => 'location_type_id',
- );
+ ];
try{
$result = civicrm_api3('Address', 'getoptions', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function address_getoptions_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 5,
- 'values' => array(
+ 'values' => [
'5' => 'Billing',
'1' => 'Home',
'3' => 'Main',
'4' => 'Other',
'2' => 'Work',
- ),
- );
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function batch_create_example() {
- $params = array(
+ $params = [
'name' => 'New_Batch_04',
'title' => 'New Batch 04',
'description' => 'This is description for New Batch 04',
'total' => '400.44',
'item_count' => 4,
'id' => 3,
- );
+ ];
try{
$result = civicrm_api3('Batch', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function batch_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 3,
- 'values' => array(
- '3' => array(
+ 'values' => [
+ '3' => [
'id' => '3',
'name' => 'New_Batch_04',
'title' => 'New Batch 04',
'payment_instrument_id' => '',
'exported_date' => '',
'data' => '',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function batch_delete_example() {
- $params = array(
+ $params = [
'id' => 5,
- );
+ ];
try{
$result = civicrm_api3('Batch', 'delete', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function batch_delete_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'values' => 1,
- );
+ ];
return $expectedResult;
}
* API result array
*/
function batch_get_example() {
- $params = array(
+ $params = [
'id' => 1,
- );
+ ];
try{
$result = civicrm_api3('Batch', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function batch_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'id' => '1',
'name' => 'Batch_433397',
'title' => 'Batch_433397',
'modified_date' => '2012-11-14 16:02:35',
'status_id' => '1',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function batch_update_example() {
- $params = array(
+ $params = [
'name' => 'New_Batch_04',
'title' => 'New Batch 04',
'description' => 'This is description for New Batch 04',
'total' => '400.44',
'item_count' => 4,
'id' => 3,
- );
+ ];
try{
$result = civicrm_api3('batch', 'update', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'error' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function batch_update_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 3,
- 'values' => array(
- '3' => array(
+ 'values' => [
+ '3' => [
'id' => '3',
'name' => 'New_Batch_04',
'title' => 'New Batch 04',
'payment_instrument_id' => '',
'exported_date' => '',
'data' => '',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function campaign_create_example() {
- $params = array(
+ $params = [
'title' => 'campaign title',
'description' => 'Call people, ask for money',
'created_date' => 'first sat of July 2008',
- );
+ ];
try{
$result = civicrm_api3('Campaign', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function campaign_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'id' => '1',
'name' => 'campaign_title',
'title' => 'campaign title',
'last_modified_date' => '',
'goal_general' => '',
'goal_revenue' => '',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function campaign_delete_example() {
- $params = array(
+ $params = [
'id' => 3,
- );
+ ];
try{
$result = civicrm_api3('Campaign', 'delete', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function campaign_delete_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'values' => 1,
- );
+ ];
return $expectedResult;
}
* API result array
*/
function campaign_get_example() {
- $params = array(
+ $params = [
'title' => 'campaign title',
'description' => 'Call people, ask for money',
'created_date' => 'first sat of July 2008',
- );
+ ];
try{
$result = civicrm_api3('Campaign', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function campaign_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 2,
- 'values' => array(
- '2' => array(
+ 'values' => [
+ '2' => [
'id' => '2',
'name' => 'campaign_title',
'title' => 'campaign title',
'description' => 'Call people, ask for money',
'is_active' => '1',
'created_date' => '2013-07-28 08:49:19',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function case_create_example() {
- $params = array(
+ $params = [
'subject' => 'Test case',
'contact_id' => 17,
'case_type' => 'housing_support',
- );
+ ];
try{
$result = civicrm_api3('Case', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function case_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 2,
- 'values' => array(
- '2' => array(
+ 'values' => [
+ '2' => [
'id' => '2',
'case_type_id' => '1',
'subject' => 'Test case',
'details' => '',
'status_id' => '1',
'is_deleted' => '',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function case_contact_get_example() {
- $params = array(
+ $params = [
'contact_id' => 19,
- );
+ ];
try{
$result = civicrm_api3('CaseContact', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function case_contact_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 2,
- 'values' => array(
- '2' => array(
+ 'values' => [
+ '2' => [
'id' => '2',
'case_id' => '2',
'contact_id' => '19',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function constant_get_example() {
- $params = array(
+ $params = [
'name' => 'activityType',
- );
+ ];
try{
$result = civicrm_api3('Constant', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function constant_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 36,
- 'values' => array(
+ 'values' => [
'1' => 'Meeting',
'2' => 'Phone Call',
'3' => 'Email',
'52' => 'Contact Deleted by Merge',
'53' => 'Failed Payment',
'54' => 'Close Accounting Period',
- ),
+ ],
'deprecated' => 'The Constant api is deprecated as of CiviCRM 4.4. Please use the getoptions api action instead.',
- );
+ ];
return $expectedResult;
}
* API result array
*/
function contact_get_example() {
- $params = array(
+ $params = [
'id' => 3,
- 'api.website.get' => array(),
- 'api.Contribution.get' => array(
+ 'api.website.get' => [],
+ 'api.Contribution.get' => [
'total_amount' => '120.00',
- ),
+ ],
'api.CustomValue.get' => 1,
'api.Note.get' => 1,
- );
+ ];
try{
$result = civicrm_api3('Contact', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function contact_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 3,
- 'values' => array(
- '3' => array(
+ 'values' => [
+ '3' => [
'contact_id' => '3',
'contact_type' => 'Individual',
'contact_sub_type' => '',
'state_province' => '',
'country' => '',
'id' => '3',
- 'api.website.get' => array(
+ 'api.website.get' => [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '0' => array(
+ 'values' => [
+ '0' => [
'id' => '1',
'contact_id' => '3',
'url' => 'http://civicrm.org',
- ),
- ),
- ),
- 'api.Contribution.get' => array(
+ ],
+ ],
+ ],
+ 'api.Contribution.get' => [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 2,
- 'values' => array(
- '0' => array(
+ 'values' => [
+ '0' => [
'contact_id' => '3',
'contact_type' => 'Individual',
'contact_sub_type' => '',
'instrument_id' => '1',
'id' => '2',
'contribution_type_id' => '1',
- ),
- ),
- ),
- 'api.CustomValue.get' => array(
+ ],
+ ],
+ ],
+ 'api.CustomValue.get' => [
'is_error' => 0,
'version' => 3,
'count' => 0,
- 'values' => array(),
- ),
- 'api.Note.get' => array(
+ 'values' => [],
+ ],
+ 'api.Note.get' => [
'is_error' => 0,
'version' => 3,
'count' => 0,
- 'values' => array(),
- ),
- ),
- ),
- );
+ 'values' => [],
+ ],
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function contact_get_example() {
- $params = array(
+ $params = [
'id' => 3,
- 'api.website.getValue' => array(
+ 'api.website.getValue' => [
'return' => 'url',
- ),
- 'api.Contribution.getCount' => array(),
+ ],
+ 'api.Contribution.getCount' => [],
'api.CustomValue.get' => 1,
'api.Note.get' => 1,
- 'api.Membership.getCount' => array(),
- );
+ 'api.Membership.getCount' => [],
+ ];
try{
$result = civicrm_api3('Contact', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function contact_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 3,
- 'values' => array(
- '3' => array(
+ 'values' => [
+ '3' => [
'contact_id' => '3',
'contact_type' => 'Individual',
'contact_sub_type' => '',
'id' => '3',
'api.website.getValue' => 'http://civicrm.org',
'api.Contribution.getCount' => 2,
- 'api.CustomValue.get' => array(
+ 'api.CustomValue.get' => [
'is_error' => 0,
'version' => 3,
'count' => 0,
- 'values' => array(),
- ),
- 'api.Note.get' => array(
+ 'values' => [],
+ ],
+ 'api.Note.get' => [
'is_error' => 0,
'version' => 3,
'count' => 0,
- 'values' => array(),
- ),
+ 'values' => [],
+ ],
'api.Membership.getCount' => 0,
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function contact_get_example() {
- $params = array(
+ $params = [
'id' => 3,
- 'api.website.getValue' => array(
+ 'api.website.getValue' => [
'return' => 'url',
- ),
- 'api.Contribution.getCount' => array(),
+ ],
+ 'api.Contribution.getCount' => [],
'api.CustomValue.get' => 1,
- );
+ ];
try{
$result = civicrm_api3('Contact', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function contact_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 3,
- 'values' => array(
- '3' => array(
+ 'values' => [
+ '3' => [
'contact_id' => '3',
'contact_type' => 'Individual',
'contact_sub_type' => '',
'id' => '3',
'api.website.getValue' => 'http://civicrm.org',
'api.Contribution.getCount' => 2,
- 'api.CustomValue.get' => array(
+ 'api.CustomValue.get' => [
'is_error' => 0,
'version' => 3,
'count' => 7,
- 'values' => array(
- '0' => array(
+ 'values' => [
+ '0' => [
'entity_id' => '3',
'entity_table' => 'Contact',
'latest' => 'value 4',
'id' => '1',
- ),
- '1' => array(
+ ],
+ '1' => [
'entity_id' => '3',
'entity_table' => 'Contact',
'latest' => 'value 3',
'id' => '2',
'1' => 'value 2',
'2' => 'value 3',
- ),
- '2' => array(
+ ],
+ '2' => [
'entity_id' => '3',
'entity_table' => 'Contact',
'latest' => '',
'id' => '3',
'1' => 'warm beer',
'2' => '',
- ),
- '3' => array(
+ ],
+ '3' => [
'entity_id' => '3',
'entity_table' => 'Contact',
'latest' => '',
'id' => '4',
'1' => '',
'2' => '',
- ),
- '4' => array(
+ ],
+ '4' => [
'entity_id' => '3',
'entity_table' => 'Contact',
'latest' => 'defaultValue',
'id' => '5',
'1' => 'defaultValue',
- ),
- '5' => array(
+ ],
+ '5' => [
'entity_id' => '3',
'entity_table' => 'Contact',
'latest' => 'vegemite',
'id' => '6',
'1' => 'vegemite',
- ),
- '6' => array(
+ ],
+ '6' => [
'entity_id' => '3',
'entity_table' => 'Contact',
'latest' => '',
'id' => '7',
'1' => '',
- ),
- ),
- ),
- ),
- ),
- );
+ ],
+ ],
+ ],
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function contact_create_example() {
- $params = array(
+ $params = [
'display_name' => 'batman',
'contact_type' => 'Individual',
- 'api.tag.create' => array(
+ 'api.tag.create' => [
'name' => '$value.id',
'description' => '$value.display_name',
'format.only_id' => 1,
- ),
- 'api.entity_tag.create' => array(
+ ],
+ 'api.entity_tag.create' => [
'tag_id' => '$value.api.tag.create',
- ),
- );
+ ],
+ ];
try{
$result = civicrm_api3('Contact', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function contact_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 3,
- 'values' => array(
- '3' => array(
+ 'values' => [
+ '3' => [
'id' => '3',
'contact_type' => 'Individual',
'contact_sub_type' => '',
'created_date' => '2013-07-28 08:49:19',
'modified_date' => '2012-11-14 16:02:35',
'api.tag.create' => 6,
- 'api.entity_tag.create' => array(
+ 'api.entity_tag.create' => [
'is_error' => 0,
'not_added' => 1,
'added' => 1,
'total_count' => 2,
- ),
- ),
- ),
- );
+ ],
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function contact_create_example() {
- $params = array(
+ $params = [
'first_name' => 'abc3',
'last_name' => 'xyz3',
'contact_type' => 'Individual',
'email' => 'man3@yahoo.com',
- 'api.contribution.create' => array(
+ 'api.contribution.create' => [
'receive_date' => '2010-01-01',
'total_amount' => '100',
'financial_type_id' => 1,
'invoice_id' => 67990,
'source' => 'SSF',
'contribution_status_id' => 1,
- ),
- 'api.website.create' => array(
+ ],
+ 'api.website.create' => [
'url' => 'http://civicrm.org',
- ),
- 'api.website.create.2' => array(
+ ],
+ 'api.website.create.2' => [
'url' => 'http://chained.org',
- ),
- );
+ ],
+ ];
try{
$result = civicrm_api3('Contact', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function contact_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 3,
- 'values' => array(
- '3' => array(
+ 'values' => [
+ '3' => [
'id' => '3',
'contact_type' => 'Individual',
'contact_sub_type' => '',
'user_unique_id' => '',
'created_date' => '2013-07-28 08:49:19',
'modified_date' => '2012-11-14 16:02:35',
- 'api.contribution.create' => array(
+ 'api.contribution.create' => [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '0' => array(
+ 'values' => [
+ '0' => [
'id' => '1',
'contact_id' => '3',
'financial_type_id' => '1',
'tax_amount' => '',
'revenue_recognition_date' => '',
'contribution_type_id' => '1',
- ),
- ),
- ),
- 'api.website.create' => array(
+ ],
+ ],
+ ],
+ 'api.website.create' => [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '0' => array(
+ 'values' => [
+ '0' => [
'id' => '1',
'contact_id' => '3',
'url' => 'http://civicrm.org',
'website_type_id' => '',
- ),
- ),
- ),
- 'api.website.create.2' => array(
+ ],
+ ],
+ ],
+ 'api.website.create.2' => [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 2,
- 'values' => array(
- '0' => array(
+ 'values' => [
+ '0' => [
'id' => '2',
'contact_id' => '3',
'url' => 'http://chained.org',
'website_type_id' => '',
- ),
- ),
- ),
- ),
- ),
- );
+ ],
+ ],
+ ],
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function contact_create_example() {
- $params = array(
+ $params = [
'first_name' => 'abc3',
'last_name' => 'xyz3',
'contact_type' => 'Individual',
'email' => 'man3@yahoo.com',
- 'api.contribution.create' => array(
+ 'api.contribution.create' => [
'receive_date' => '2010-01-01',
'total_amount' => '100',
'financial_type_id' => 1,
'invoice_id' => 67890,
'source' => 'SSF',
'contribution_status_id' => 1,
- ),
- 'api.website.create' => array(
- '0' => array(
+ ],
+ 'api.website.create' => [
+ '0' => [
'url' => 'http://civicrm.org',
- ),
- '1' => array(
+ ],
+ '1' => [
'url' => 'http://chained.org',
'website_type_id' => 2,
- ),
- ),
- );
+ ],
+ ],
+ ];
try{
$result = civicrm_api3('Contact', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function contact_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 3,
- 'values' => array(
- '3' => array(
+ 'values' => [
+ '3' => [
'id' => '3',
'contact_type' => 'Individual',
'contact_sub_type' => '',
'user_unique_id' => '',
'created_date' => '2013-07-28 08:49:19',
'modified_date' => '2012-11-14 16:02:35',
- 'api.contribution.create' => array(
+ 'api.contribution.create' => [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '0' => array(
+ 'values' => [
+ '0' => [
'id' => '1',
'contact_id' => '3',
'financial_type_id' => '1',
'tax_amount' => '',
'revenue_recognition_date' => '',
'contribution_type_id' => '1',
- ),
- ),
- ),
- 'api.website.create' => array(
- '0' => array(
+ ],
+ ],
+ ],
+ 'api.website.create' => [
+ '0' => [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '0' => array(
+ 'values' => [
+ '0' => [
'id' => '1',
'contact_id' => '3',
'url' => 'http://civicrm.org',
'website_type_id' => '',
- ),
- ),
- ),
- '1' => array(
+ ],
+ ],
+ ],
+ '1' => [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 2,
- 'values' => array(
- '0' => array(
+ 'values' => [
+ '0' => [
'id' => '2',
'contact_id' => '3',
'url' => 'http://chained.org',
'website_type_id' => '2',
- ),
- ),
- ),
- ),
- ),
- ),
- );
+ ],
+ ],
+ ],
+ ],
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function contact_get_example() {
- $params = array(
+ $params = [
'id' => 'user_contact_id',
- );
+ ];
try{
$result = civicrm_api3('Contact', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function contact_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 3,
- 'values' => array(
- '3' => array(
+ 'values' => [
+ '3' => [
'contact_id' => '3',
'contact_type' => 'Individual',
'contact_sub_type' => '',
'state_province' => '',
'country' => '',
'id' => '3',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function contact_create_example() {
- $params = array(
+ $params = [
'first_name' => 'abc1',
'contact_type' => 'Individual',
'last_name' => 'xyz1',
'custom_1' => 'custom string',
- );
+ ];
try{
$result = civicrm_api3('Contact', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function contact_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 3,
- 'values' => array(
- '3' => array(
+ 'values' => [
+ '3' => [
'id' => '3',
'contact_type' => 'Individual',
'contact_sub_type' => '',
'user_unique_id' => '',
'created_date' => '2013-07-28 08:49:19',
'modified_date' => '2012-11-14 16:02:35',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function contact_create_example() {
- $params = array(
+ $params = [
'contact_type' => 'Individual',
'display_name' => 'dlobo',
- 'api.participant' => array(
+ 'api.participant' => [
'event_id' => 42,
'status_id' => 1,
'role_id' => 1,
'format.only_id' => 1,
- ),
- 'api.contribution.create' => array(
+ ],
+ 'api.contribution.create' => [
'financial_type_id' => 1,
'total_amount' => 100,
'format.only_id' => 1,
- ),
- 'api.participant_payment.create' => array(
+ ],
+ 'api.participant_payment.create' => [
'contribution_id' => '$value.api.contribution.create',
'participant_id' => '$value.api.participant',
- ),
- );
+ ],
+ ];
try{
$result = civicrm_api3('Contact', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function contact_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 5,
- 'values' => array(
- '5' => array(
+ 'values' => [
+ '5' => [
'id' => '5',
'contact_type' => 'Individual',
'contact_sub_type' => '',
'modified_date' => '2012-11-14 16:02:35',
'api.participant' => 4,
'api.contribution.create' => 1,
- 'api.participant_payment.create' => array(
+ 'api.participant_payment.create' => [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '0' => array(
+ 'values' => [
+ '0' => [
'id' => '1',
'participant_id' => '4',
'contribution_id' => '1',
- ),
- ),
- ),
- ),
- ),
- );
+ ],
+ ],
+ ],
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function contact_get_example() {
- $params = array(
+ $params = [
'return.custom_1' => 1,
'id' => 3,
- );
+ ];
try{
$result = civicrm_api3('Contact', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function contact_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 3,
- 'values' => array(
- '3' => array(
+ 'values' => [
+ '3' => [
'contact_id' => '3',
'civicrm_value_testgetwithcu_1_id' => '1',
'custom_1' => 'custom string',
'id' => '3',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function contact_get_example() {
- $params = array(
+ $params = [
'return' => 'custom_1',
'id' => 3,
- );
+ ];
try{
$result = civicrm_api3('Contact', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function contact_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 3,
- 'values' => array(
- '3' => array(
+ 'values' => [
+ '3' => [
'contact_id' => '3',
'civicrm_value_testgetwithcu_1_id' => '1',
'custom_1' => 'custom string',
'id' => '3',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function contact_delete_example() {
- $params = array(
+ $params = [
'id' => 3,
- );
+ ];
try{
$result = civicrm_api3('Contact', 'delete', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function contact_delete_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'values' => 1,
- );
+ ];
return $expectedResult;
}
* API result array
*/
function contact_create_example() {
- $params = array(
+ $params = [
'id' => 500,
'format.is_success' => 1,
- );
+ ];
try{
$result = civicrm_api3('Contact', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
* API result array
*/
function contact_get_example() {
- $params = array(
+ $params = [
'id' => 17,
'format.is_success' => 1,
- );
+ ];
try{
$result = civicrm_api3('Contact', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
* API result array
*/
function contact_get_example() {
- $params = array(
+ $params = [
'id' => 17,
'format.only_id' => 1,
- );
+ ];
try{
$result = civicrm_api3('Contact', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
* API result array
*/
function contact_getvalue_example() {
- $params = array(
+ $params = [
'id' => 17,
'return' => 'display_name',
- );
+ ];
try{
$result = civicrm_api3('Contact', 'getvalue', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
* API result array
*/
function contact_get_example() {
- $params = array(
+ $params = [
'email' => 'man2@yahoo.com',
- );
+ ];
try{
$result = civicrm_api3('Contact', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function contact_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 3,
- 'values' => array(
- '3' => array(
+ 'values' => [
+ '3' => [
'contact_id' => '3',
'contact_type' => 'Individual',
'contact_sub_type' => '',
'state_province' => '',
'country' => '',
'id' => '3',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function contact_getactions_example() {
- $params = array();
+ $params = [];
try{
$result = civicrm_api3('Contact', 'getactions', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function contact_getactions_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 20,
- 'values' => array(
+ 'values' => [
'0' => 'create',
'1' => 'delete',
'2' => 'duplicatecheck',
'17' => 'setvalue',
'18' => 'update',
'19' => 'validate',
- ),
- 'deprecated' => array(
+ ],
+ 'deprecated' => [
'getquick' => 'The "getquick" action is deprecated in favor of "getlist".',
'setvalue' => 'The "setvalue" action is deprecated. Use "create" with an id instead.',
'update' => 'The "update" action is deprecated. Use "create" with an id instead.',
- ),
- );
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function contact_getcount_example() {
- $params = array(
+ $params = [
'id' => 17,
- );
+ ];
try{
$result = civicrm_api3('Contact', 'getcount', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
* API result array
*/
function contact_getfields_example() {
- $params = array(
- 'options' => array(
+ $params = [
+ 'options' => [
'get_options' => 'custom_1',
- ),
+ ],
'action' => 'create',
- );
+ ];
try{
$result = civicrm_api3('Contact', 'getfields', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function contact_getfields_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 55,
- 'values' => array(
- 'id' => array(
+ 'values' => [
+ 'id' => [
'name' => 'id',
'type' => 1,
'title' => 'Contact ID',
'table_name' => 'civicrm_contact',
'entity' => 'Contact',
'bao' => 'CRM_Contact_BAO_Contact',
- 'api.aliases' => array(
+ 'api.aliases' => [
'0' => 'contact_id',
- ),
- ),
- 'contact_type' => array(
+ ],
+ ],
+ 'contact_type' => [
'name' => 'contact_type',
'type' => 2,
'title' => 'Contact Type',
'table_name' => 'civicrm_contact',
'entity' => 'Contact',
'bao' => 'CRM_Contact_BAO_Contact',
- 'html' => array(
+ 'html' => [
'type' => 'Select',
'maxlength' => 64,
'size' => 30,
- ),
- 'pseudoconstant' => array(
+ ],
+ 'pseudoconstant' => [
'table' => 'civicrm_contact_type',
'keyColumn' => 'name',
'labelColumn' => 'label',
'condition' => 'parent_id IS NULL',
- ),
+ ],
'api.required' => 1,
- ),
- 'contact_sub_type' => array(
+ ],
+ 'contact_sub_type' => [
'name' => 'contact_sub_type',
'type' => 2,
'title' => 'Contact Subtype',
'table_name' => 'civicrm_contact',
'entity' => 'Contact',
'bao' => 'CRM_Contact_BAO_Contact',
- 'html' => array(
+ 'html' => [
'type' => 'Select',
'maxlength' => 255,
'size' => 45,
- ),
- 'pseudoconstant' => array(
+ ],
+ 'pseudoconstant' => [
'table' => 'civicrm_contact_type',
'keyColumn' => 'name',
'labelColumn' => 'label',
'condition' => 'parent_id IS NOT NULL',
- ),
- ),
- 'do_not_email' => array(
+ ],
+ ],
+ 'do_not_email' => [
'name' => 'do_not_email',
'type' => 16,
'title' => 'Do Not Email',
'table_name' => 'civicrm_contact',
'entity' => 'Contact',
'bao' => 'CRM_Contact_BAO_Contact',
- 'html' => array(
+ 'html' => [
'type' => 'CheckBox',
- ),
- ),
- 'do_not_phone' => array(
+ ],
+ ],
+ 'do_not_phone' => [
'name' => 'do_not_phone',
'type' => 16,
'title' => 'Do Not Phone',
'table_name' => 'civicrm_contact',
'entity' => 'Contact',
'bao' => 'CRM_Contact_BAO_Contact',
- 'html' => array(
+ 'html' => [
'type' => 'CheckBox',
- ),
- ),
- 'do_not_mail' => array(
+ ],
+ ],
+ 'do_not_mail' => [
'name' => 'do_not_mail',
'type' => 16,
'title' => 'Do Not Mail',
'table_name' => 'civicrm_contact',
'entity' => 'Contact',
'bao' => 'CRM_Contact_BAO_Contact',
- 'html' => array(
+ 'html' => [
'type' => 'CheckBox',
- ),
- ),
- 'do_not_sms' => array(
+ ],
+ ],
+ 'do_not_sms' => [
'name' => 'do_not_sms',
'type' => 16,
'title' => 'Do Not Sms',
'table_name' => 'civicrm_contact',
'entity' => 'Contact',
'bao' => 'CRM_Contact_BAO_Contact',
- 'html' => array(
+ 'html' => [
'type' => 'CheckBox',
- ),
- ),
- 'do_not_trade' => array(
+ ],
+ ],
+ 'do_not_trade' => [
'name' => 'do_not_trade',
'type' => 16,
'title' => 'Do Not Trade',
'table_name' => 'civicrm_contact',
'entity' => 'Contact',
'bao' => 'CRM_Contact_BAO_Contact',
- 'html' => array(
+ 'html' => [
'type' => 'CheckBox',
- ),
- ),
- 'is_opt_out' => array(
+ ],
+ ],
+ 'is_opt_out' => [
'name' => 'is_opt_out',
'type' => 16,
'title' => 'No Bulk Emails (User Opt Out)',
'table_name' => 'civicrm_contact',
'entity' => 'Contact',
'bao' => 'CRM_Contact_BAO_Contact',
- 'html' => array(
+ 'html' => [
'type' => 'CheckBox',
- ),
- ),
- 'legal_identifier' => array(
+ ],
+ ],
+ 'legal_identifier' => [
'name' => 'legal_identifier',
'type' => 2,
'title' => 'Legal Identifier',
'table_name' => 'civicrm_contact',
'entity' => 'Contact',
'bao' => 'CRM_Contact_BAO_Contact',
- 'html' => array(
+ 'html' => [
'type' => 'Text',
'maxlength' => 32,
'size' => 20,
- ),
- ),
- 'external_identifier' => array(
+ ],
+ ],
+ 'external_identifier' => [
'name' => 'external_identifier',
'type' => 2,
'title' => 'External Identifier',
'table_name' => 'civicrm_contact',
'entity' => 'Contact',
'bao' => 'CRM_Contact_BAO_Contact',
- 'html' => array(
+ 'html' => [
'type' => 'Text',
'maxlength' => 64,
'size' => 8,
- ),
- ),
- 'sort_name' => array(
+ ],
+ ],
+ 'sort_name' => [
'name' => 'sort_name',
'type' => 2,
'title' => 'Sort Name',
'table_name' => 'civicrm_contact',
'entity' => 'Contact',
'bao' => 'CRM_Contact_BAO_Contact',
- 'html' => array(
+ 'html' => [
'type' => 'Text',
'maxlength' => 128,
'size' => 30,
- ),
- ),
- 'display_name' => array(
+ ],
+ ],
+ 'display_name' => [
'name' => 'display_name',
'type' => 2,
'title' => 'Display Name',
'table_name' => 'civicrm_contact',
'entity' => 'Contact',
'bao' => 'CRM_Contact_BAO_Contact',
- 'html' => array(
+ 'html' => [
'type' => 'Text',
'maxlength' => 128,
'size' => 30,
- ),
- ),
- 'nick_name' => array(
+ ],
+ ],
+ 'nick_name' => [
'name' => 'nick_name',
'type' => 2,
'title' => 'Nickname',
'table_name' => 'civicrm_contact',
'entity' => 'Contact',
'bao' => 'CRM_Contact_BAO_Contact',
- 'html' => array(
+ 'html' => [
'type' => 'Text',
'maxlength' => 128,
'size' => 30,
- ),
- ),
- 'legal_name' => array(
+ ],
+ ],
+ 'legal_name' => [
'name' => 'legal_name',
'type' => 2,
'title' => 'Legal Name',
'table_name' => 'civicrm_contact',
'entity' => 'Contact',
'bao' => 'CRM_Contact_BAO_Contact',
- 'html' => array(
+ 'html' => [
'type' => 'Text',
'maxlength' => 128,
'size' => 30,
- ),
- ),
- 'image_URL' => array(
+ ],
+ ],
+ 'image_URL' => [
'name' => 'image_URL',
'type' => 32,
'title' => 'Image Url',
'table_name' => 'civicrm_contact',
'entity' => 'Contact',
'bao' => 'CRM_Contact_BAO_Contact',
- 'html' => array(
+ 'html' => [
'type' => 'File',
'rows' => 2,
'cols' => 80,
- ),
- ),
- 'preferred_communication_method' => array(
+ ],
+ ],
+ 'preferred_communication_method' => [
'name' => 'preferred_communication_method',
'type' => 2,
'title' => 'Preferred Communication Method',
'table_name' => 'civicrm_contact',
'entity' => 'Contact',
'bao' => 'CRM_Contact_BAO_Contact',
- 'html' => array(
+ 'html' => [
'type' => 'Select',
'maxlength' => 255,
'size' => 45,
- ),
- 'pseudoconstant' => array(
+ ],
+ 'pseudoconstant' => [
'optionGroupName' => 'preferred_communication_method',
'optionEditPath' => 'civicrm/admin/options/preferred_communication_method',
- ),
- ),
- 'preferred_language' => array(
+ ],
+ ],
+ 'preferred_language' => [
'name' => 'preferred_language',
'type' => 2,
'title' => 'Preferred Language',
'table_name' => 'civicrm_contact',
'entity' => 'Contact',
'bao' => 'CRM_Contact_BAO_Contact',
- 'html' => array(
+ 'html' => [
'type' => 'Select',
'maxlength' => 5,
'size' => 6,
- ),
- 'pseudoconstant' => array(
+ ],
+ 'pseudoconstant' => [
'optionGroupName' => 'languages',
'keyColumn' => 'name',
'optionEditPath' => 'civicrm/admin/options/languages',
- ),
- ),
- 'preferred_mail_format' => array(
+ ],
+ ],
+ 'preferred_mail_format' => [
'name' => 'preferred_mail_format',
'type' => 2,
'title' => 'Preferred Mail Format',
'table_name' => 'civicrm_contact',
'entity' => 'Contact',
'bao' => 'CRM_Contact_BAO_Contact',
- 'html' => array(
+ 'html' => [
'type' => 'Select',
'maxlength' => 8,
'size' => 8,
- ),
- 'pseudoconstant' => array(
+ ],
+ 'pseudoconstant' => [
'callback' => 'CRM_Core_SelectValues::pmf',
- ),
- ),
- 'hash' => array(
+ ],
+ ],
+ 'hash' => [
'name' => 'hash',
'type' => 2,
'title' => 'Contact Hash',
'table_name' => 'civicrm_contact',
'entity' => 'Contact',
'bao' => 'CRM_Contact_BAO_Contact',
- ),
- 'api_key' => array(
+ ],
+ 'api_key' => [
'name' => 'api_key',
'type' => 2,
'title' => 'Api Key',
'table_name' => 'civicrm_contact',
'entity' => 'Contact',
'bao' => 'CRM_Contact_BAO_Contact',
- ),
- 'first_name' => array(
+ ],
+ 'first_name' => [
'name' => 'first_name',
'type' => 2,
'title' => 'First Name',
'table_name' => 'civicrm_contact',
'entity' => 'Contact',
'bao' => 'CRM_Contact_BAO_Contact',
- 'html' => array(
+ 'html' => [
'type' => 'Text',
'maxlength' => 64,
'size' => 30,
- ),
- ),
- 'middle_name' => array(
+ ],
+ ],
+ 'middle_name' => [
'name' => 'middle_name',
'type' => 2,
'title' => 'Middle Name',
'table_name' => 'civicrm_contact',
'entity' => 'Contact',
'bao' => 'CRM_Contact_BAO_Contact',
- 'html' => array(
+ 'html' => [
'type' => 'Text',
'maxlength' => 64,
'size' => 30,
- ),
- ),
- 'last_name' => array(
+ ],
+ ],
+ 'last_name' => [
'name' => 'last_name',
'type' => 2,
'title' => 'Last Name',
'table_name' => 'civicrm_contact',
'entity' => 'Contact',
'bao' => 'CRM_Contact_BAO_Contact',
- 'html' => array(
+ 'html' => [
'type' => 'Text',
'maxlength' => 64,
'size' => 30,
- ),
- ),
- 'prefix_id' => array(
+ ],
+ ],
+ 'prefix_id' => [
'name' => 'prefix_id',
'type' => 1,
'title' => 'Individual Prefix',
'table_name' => 'civicrm_contact',
'entity' => 'Contact',
'bao' => 'CRM_Contact_BAO_Contact',
- 'html' => array(
+ 'html' => [
'type' => 'Select',
'size' => 6,
'maxlength' => 14,
- ),
- 'pseudoconstant' => array(
+ ],
+ 'pseudoconstant' => [
'optionGroupName' => 'individual_prefix',
'optionEditPath' => 'civicrm/admin/options/individual_prefix',
- ),
- 'api.aliases' => array(
+ ],
+ 'api.aliases' => [
'0' => 'individual_prefix',
'1' => 'individual_prefix_id',
- ),
- ),
- 'suffix_id' => array(
+ ],
+ ],
+ 'suffix_id' => [
'name' => 'suffix_id',
'type' => 1,
'title' => 'Individual Suffix',
'table_name' => 'civicrm_contact',
'entity' => 'Contact',
'bao' => 'CRM_Contact_BAO_Contact',
- 'html' => array(
+ 'html' => [
'type' => 'Select',
'size' => 6,
'maxlength' => 14,
- ),
- 'pseudoconstant' => array(
+ ],
+ 'pseudoconstant' => [
'optionGroupName' => 'individual_suffix',
'optionEditPath' => 'civicrm/admin/options/individual_suffix',
- ),
- 'api.aliases' => array(
+ ],
+ 'api.aliases' => [
'0' => 'individual_suffix',
'1' => 'individual_suffix_id',
- ),
- ),
- 'formal_title' => array(
+ ],
+ ],
+ 'formal_title' => [
'name' => 'formal_title',
'type' => 2,
'title' => 'Formal Title',
'table_name' => 'civicrm_contact',
'entity' => 'Contact',
'bao' => 'CRM_Contact_BAO_Contact',
- 'html' => array(
+ 'html' => [
'type' => 'Text',
'maxlength' => 64,
'size' => 30,
- ),
- ),
- 'communication_style_id' => array(
+ ],
+ ],
+ 'communication_style_id' => [
'name' => 'communication_style_id',
'type' => 1,
'title' => 'Communication Style',
'table_name' => 'civicrm_contact',
'entity' => 'Contact',
'bao' => 'CRM_Contact_BAO_Contact',
- 'html' => array(
+ 'html' => [
'type' => 'Select',
'size' => 6,
'maxlength' => 14,
- ),
- 'pseudoconstant' => array(
+ ],
+ 'pseudoconstant' => [
'optionGroupName' => 'communication_style',
'optionEditPath' => 'civicrm/admin/options/communication_style',
- ),
- ),
- 'email_greeting_id' => array(
+ ],
+ ],
+ 'email_greeting_id' => [
'name' => 'email_greeting_id',
'type' => 1,
'title' => 'Email Greeting ID',
'table_name' => 'civicrm_contact',
'entity' => 'Contact',
'bao' => 'CRM_Contact_BAO_Contact',
- ),
- 'email_greeting_custom' => array(
+ ],
+ 'email_greeting_custom' => [
'name' => 'email_greeting_custom',
'type' => 2,
'title' => 'Email Greeting Custom',
'table_name' => 'civicrm_contact',
'entity' => 'Contact',
'bao' => 'CRM_Contact_BAO_Contact',
- 'html' => array(
+ 'html' => [
'type' => 'Text',
'maxlength' => 128,
'size' => 45,
- ),
- ),
- 'email_greeting_display' => array(
+ ],
+ ],
+ 'email_greeting_display' => [
'name' => 'email_greeting_display',
'type' => 2,
'title' => 'Email Greeting',
'table_name' => 'civicrm_contact',
'entity' => 'Contact',
'bao' => 'CRM_Contact_BAO_Contact',
- 'html' => array(
+ 'html' => [
'type' => 'Text',
'maxlength' => 255,
'size' => 45,
- ),
- ),
- 'postal_greeting_id' => array(
+ ],
+ ],
+ 'postal_greeting_id' => [
'name' => 'postal_greeting_id',
'type' => 1,
'title' => 'Postal Greeting ID',
'table_name' => 'civicrm_contact',
'entity' => 'Contact',
'bao' => 'CRM_Contact_BAO_Contact',
- 'html' => array(
+ 'html' => [
'type' => 'Text',
'size' => 6,
'maxlength' => 14,
- ),
- ),
- 'postal_greeting_custom' => array(
+ ],
+ ],
+ 'postal_greeting_custom' => [
'name' => 'postal_greeting_custom',
'type' => 2,
'title' => 'Postal Greeting Custom',
'table_name' => 'civicrm_contact',
'entity' => 'Contact',
'bao' => 'CRM_Contact_BAO_Contact',
- 'html' => array(
+ 'html' => [
'type' => 'Text',
'maxlength' => 128,
'size' => 45,
- ),
- ),
- 'postal_greeting_display' => array(
+ ],
+ ],
+ 'postal_greeting_display' => [
'name' => 'postal_greeting_display',
'type' => 2,
'title' => 'Postal Greeting',
'table_name' => 'civicrm_contact',
'entity' => 'Contact',
'bao' => 'CRM_Contact_BAO_Contact',
- 'html' => array(
+ 'html' => [
'type' => 'Text',
'maxlength' => 255,
'size' => 45,
- ),
- ),
- 'addressee_id' => array(
+ ],
+ ],
+ 'addressee_id' => [
'name' => 'addressee_id',
'type' => 1,
'title' => 'Addressee ID',
'table_name' => 'civicrm_contact',
'entity' => 'Contact',
'bao' => 'CRM_Contact_BAO_Contact',
- ),
- 'addressee_custom' => array(
+ ],
+ 'addressee_custom' => [
'name' => 'addressee_custom',
'type' => 2,
'title' => 'Addressee Custom',
'table_name' => 'civicrm_contact',
'entity' => 'Contact',
'bao' => 'CRM_Contact_BAO_Contact',
- 'html' => array(
+ 'html' => [
'type' => 'Text',
'maxlength' => 128,
'size' => 45,
- ),
- ),
- 'addressee_display' => array(
+ ],
+ ],
+ 'addressee_display' => [
'name' => 'addressee_display',
'type' => 2,
'title' => 'Addressee',
'table_name' => 'civicrm_contact',
'entity' => 'Contact',
'bao' => 'CRM_Contact_BAO_Contact',
- 'html' => array(
+ 'html' => [
'type' => 'Text',
'maxlength' => 255,
'size' => 45,
- ),
- ),
- 'job_title' => array(
+ ],
+ ],
+ 'job_title' => [
'name' => 'job_title',
'type' => 2,
'title' => 'Job Title',
'table_name' => 'civicrm_contact',
'entity' => 'Contact',
'bao' => 'CRM_Contact_BAO_Contact',
- 'html' => array(
+ 'html' => [
'type' => 'Text',
'maxlength' => 255,
'size' => 30,
- ),
- ),
- 'gender_id' => array(
+ ],
+ ],
+ 'gender_id' => [
'name' => 'gender_id',
'type' => 1,
'title' => 'Gender',
'table_name' => 'civicrm_contact',
'entity' => 'Contact',
'bao' => 'CRM_Contact_BAO_Contact',
- 'html' => array(
+ 'html' => [
'type' => 'Select',
'size' => 6,
'maxlength' => 14,
- ),
- 'pseudoconstant' => array(
+ ],
+ 'pseudoconstant' => [
'optionGroupName' => 'gender',
'optionEditPath' => 'civicrm/admin/options/gender',
- ),
- 'api.aliases' => array(
+ ],
+ 'api.aliases' => [
'0' => 'gender',
- ),
- ),
- 'birth_date' => array(
+ ],
+ ],
+ 'birth_date' => [
'name' => 'birth_date',
'type' => 4,
'title' => 'Birth Date',
'table_name' => 'civicrm_contact',
'entity' => 'Contact',
'bao' => 'CRM_Contact_BAO_Contact',
- 'html' => array(
+ 'html' => [
'type' => 'Select Date',
'format' => 'birth',
- ),
- ),
- 'is_deceased' => array(
+ ],
+ ],
+ 'is_deceased' => [
'name' => 'is_deceased',
'type' => 16,
'title' => 'Deceased',
'table_name' => 'civicrm_contact',
'entity' => 'Contact',
'bao' => 'CRM_Contact_BAO_Contact',
- 'html' => array(
+ 'html' => [
'type' => 'CheckBox',
- ),
- ),
- 'deceased_date' => array(
+ ],
+ ],
+ 'deceased_date' => [
'name' => 'deceased_date',
'type' => 4,
'title' => 'Deceased Date',
'table_name' => 'civicrm_contact',
'entity' => 'Contact',
'bao' => 'CRM_Contact_BAO_Contact',
- 'html' => array(
+ 'html' => [
'type' => 'Select Date',
'format' => 'birth',
- ),
- ),
- 'household_name' => array(
+ ],
+ ],
+ 'household_name' => [
'name' => 'household_name',
'type' => 2,
'title' => 'Household Name',
'table_name' => 'civicrm_contact',
'entity' => 'Contact',
'bao' => 'CRM_Contact_BAO_Contact',
- 'html' => array(
+ 'html' => [
'type' => 'Text',
'maxlength' => 128,
'size' => 30,
- ),
- ),
- 'primary_contact_id' => array(
+ ],
+ ],
+ 'primary_contact_id' => [
'name' => 'primary_contact_id',
'type' => 1,
'title' => 'Household Primary Contact ID',
'entity' => 'Contact',
'bao' => 'CRM_Contact_BAO_Contact',
'FKClassName' => 'CRM_Contact_DAO_Contact',
- 'html' => array(
+ 'html' => [
'type' => 'Select',
'size' => 6,
'maxlength' => 14,
- ),
+ ],
'FKApiName' => 'Contact',
- ),
- 'organization_name' => array(
+ ],
+ 'organization_name' => [
'name' => 'organization_name',
'type' => 2,
'title' => 'Organization Name',
'table_name' => 'civicrm_contact',
'entity' => 'Contact',
'bao' => 'CRM_Contact_BAO_Contact',
- 'html' => array(
+ 'html' => [
'type' => 'Text',
'maxlength' => 128,
'size' => 30,
- ),
- ),
- 'sic_code' => array(
+ ],
+ ],
+ 'sic_code' => [
'name' => 'sic_code',
'type' => 2,
'title' => 'Sic Code',
'table_name' => 'civicrm_contact',
'entity' => 'Contact',
'bao' => 'CRM_Contact_BAO_Contact',
- 'html' => array(
+ 'html' => [
'type' => 'Text',
'maxlength' => 8,
'size' => 8,
- ),
- ),
- 'user_unique_id' => array(
+ ],
+ ],
+ 'user_unique_id' => [
'name' => 'user_unique_id',
'type' => 2,
'title' => 'Unique ID (OpenID)',
'table_name' => 'civicrm_contact',
'entity' => 'Contact',
'bao' => 'CRM_Contact_BAO_Contact',
- 'html' => array(
+ 'html' => [
'type' => 'Text',
'maxlength' => 255,
'size' => 45,
- ),
- ),
- 'created_date' => array(
+ ],
+ ],
+ 'created_date' => [
'name' => 'created_date',
'type' => 256,
'title' => 'Created Date',
'table_name' => 'civicrm_contact',
'entity' => 'Contact',
'bao' => 'CRM_Contact_BAO_Contact',
- ),
- 'modified_date' => array(
+ ],
+ 'modified_date' => [
'name' => 'modified_date',
'type' => 256,
'title' => 'Modified Date',
'table_name' => 'civicrm_contact',
'entity' => 'Contact',
'bao' => 'CRM_Contact_BAO_Contact',
- ),
- 'source' => array(
+ ],
+ 'source' => [
'name' => 'source',
'type' => 2,
'title' => 'Contact Source',
'table_name' => 'civicrm_contact',
'entity' => 'Contact',
'bao' => 'CRM_Contact_BAO_Contact',
- 'html' => array(
+ 'html' => [
'type' => 'Text',
'maxlength' => 255,
'size' => 30,
- ),
+ ],
'uniqueName' => 'contact_source',
- ),
- 'employer_id' => array(
+ ],
+ 'employer_id' => [
'name' => 'employer_id',
'type' => 1,
'title' => 'Current Employer',
'entity' => 'Contact',
'bao' => 'CRM_Contact_BAO_Contact',
'FKClassName' => 'CRM_Contact_DAO_Contact',
- 'html' => array(
+ 'html' => [
'type' => 'EntityRef',
'size' => 6,
'maxlength' => 14,
- ),
+ ],
'uniqueName' => 'current_employer_id',
'FKApiName' => 'Contact',
- ),
- 'is_deleted' => array(
+ ],
+ 'is_deleted' => [
'name' => 'is_deleted',
'type' => 16,
'title' => 'Contact is in Trash',
'table_name' => 'civicrm_contact',
'entity' => 'Contact',
'bao' => 'CRM_Contact_BAO_Contact',
- 'html' => array(
+ 'html' => [
'type' => 'CheckBox',
- ),
+ ],
'uniqueName' => 'contact_is_deleted',
- ),
- 'custom_1' => array(
+ ],
+ 'custom_1' => [
'label' => 'Our special field',
'groupTitle' => 'select_test_g',
'data_type' => 'String',
'is_required' => '1',
'table_name' => 'civicrm_value_select_test_g_1',
'column_name' => 'our_special_field_1',
- 'pseudoconstant' => array(
+ 'pseudoconstant' => [
'optionGroupName' => 'our_special_field_20170207021937',
'optionEditPath' => 'civicrm/admin/options/our_special_field_20170207021937',
- ),
+ ],
'name' => 'custom_1',
'title' => 'Our special field',
'type' => 2,
- 'options' => array(
+ 'options' => [
'1' => 'Label1',
'2' => 'Label2',
- ),
- ),
- 'current_employer' => array(
+ ],
+ ],
+ 'current_employer' => [
'title' => 'Current Employer',
'description' => 'Name of Current Employer',
'type' => 2,
'name' => 'current_employer',
- ),
- 'dupe_check' => array(
+ ],
+ 'dupe_check' => [
'title' => 'Check for Duplicates',
'description' => 'Throw error if contact create matches dedupe rule',
'type' => 16,
'name' => 'dupe_check',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function contact_getoptions_example() {
- $params = array(
+ $params = [
'field' => 'custom_1',
- );
+ ];
try{
$result = civicrm_api3('Contact', 'getoptions', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function contact_getoptions_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 2,
- 'values' => array(
+ 'values' => [
'1' => 'Label1',
'2' => 'Label2',
- ),
- );
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function contact_getsingle_example() {
- $params = array(
+ $params = [
'id' => 17,
- );
+ ];
try{
$result = civicrm_api3('Contact', 'getsingle', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function contact_getsingle_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'contact_id' => '17',
'contact_type' => 'Individual',
'contact_sub_type' => '',
'state_province' => '',
'country' => '',
'id' => '17',
- );
+ ];
return $expectedResult;
}
* API result array
*/
function contact_get_example() {
- $params = array(
- 'group' => array(
- 'IN' => array(
+ $params = [
+ 'group' => [
+ 'IN' => [
'0' => 'Test group C',
'1' => 'Test group D',
- ),
- ),
- );
+ ],
+ ],
+ ];
try{
$result = civicrm_api3('Contact', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function contact_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 3,
- 'values' => array(
- '3' => array(
+ 'values' => [
+ '3' => [
'contact_id' => '3',
'contact_type' => 'Individual',
'contact_sub_type' => '',
'state_province' => '',
'country' => '',
'id' => '3',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function contact_get_example() {
- $params = array(
+ $params = [
'id' => 10,
- 'api.email.replace' => array(
- 'values' => array(
- '0' => array(
+ 'api.email.replace' => [
+ 'values' => [
+ '0' => [
'location_type_id' => 20,
'email' => '1-1@example.com',
'is_primary' => 1,
- ),
- '1' => array(
+ ],
+ '1' => [
'location_type_id' => 20,
'email' => '1-2@example.com',
'is_primary' => 0,
- ),
- '2' => array(
+ ],
+ '2' => [
'location_type_id' => 20,
'email' => '1-3@example.com',
'is_primary' => 0,
- ),
- '3' => array(
+ ],
+ '3' => [
'location_type_id' => 21,
'email' => '2-1@example.com',
'is_primary' => 0,
- ),
- '4' => array(
+ ],
+ '4' => [
'location_type_id' => 21,
'email' => '2-2@example.com',
'is_primary' => 0,
- ),
- ),
- ),
- );
+ ],
+ ],
+ ],
+ ];
try{
$result = civicrm_api3('Contact', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function contact_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 10,
- 'values' => array(
- '10' => array(
+ 'values' => [
+ '10' => [
'contact_id' => '10',
'contact_type' => 'Organization',
'contact_sub_type' => '',
'state_province' => '',
'country' => '',
'id' => '10',
- 'api.email.replace' => array(
+ 'api.email.replace' => [
'is_error' => 0,
'version' => 3,
'count' => 5,
- 'values' => array(
- '0' => array(
+ 'values' => [
+ '0' => [
'id' => '18',
'contact_id' => '10',
'location_type_id' => '20',
'reset_date' => '',
'signature_text' => '',
'signature_html' => '',
- ),
- '1' => array(
+ ],
+ '1' => [
'id' => '19',
'contact_id' => '10',
'location_type_id' => '20',
'reset_date' => '',
'signature_text' => '',
'signature_html' => '',
- ),
- '2' => array(
+ ],
+ '2' => [
'id' => '20',
'contact_id' => '10',
'location_type_id' => '20',
'reset_date' => '',
'signature_text' => '',
'signature_html' => '',
- ),
- '3' => array(
+ ],
+ '3' => [
'id' => '21',
'contact_id' => '10',
'location_type_id' => '21',
'reset_date' => '',
'signature_text' => '',
'signature_html' => '',
- ),
- '4' => array(
+ ],
+ '4' => [
'id' => '22',
'contact_id' => '10',
'location_type_id' => '21',
'reset_date' => '',
'signature_text' => '',
'signature_html' => '',
- ),
- ),
- ),
- ),
- ),
- );
+ ],
+ ],
+ ],
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function contribution_create_example() {
- $params = array(
+ $params = [
'contact_id' => 28,
'receive_date' => '20120511',
'total_amount' => '100',
'source' => 'SSF',
'contribution_status_id' => 1,
'honor_contact_id' => 29,
- );
+ ];
try{
$result = civicrm_api3('Contribution', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function contribution_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'id' => '1',
'contact_id' => '28',
'financial_type_id' => '1',
'tax_amount' => '',
'revenue_recognition_date' => '',
'contribution_type_id' => '1',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function contribution_create_example() {
- $params = array(
+ $params = [
'contact_id' => 22,
'receive_date' => '2012-01-01',
'total_amount' => '100',
'source' => 'SSF',
'contribution_status_id' => 1,
'note' => 'my contribution note',
- );
+ ];
try{
$result = civicrm_api3('Contribution', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function contribution_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'id' => '1',
'contact_id' => '22',
'financial_type_id' => '1',
'tax_amount' => '',
'revenue_recognition_date' => '',
'contribution_type_id' => '1',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function contribution_create_example() {
- $params = array(
+ $params = [
'contact_id' => 24,
'receive_date' => '20120511',
'total_amount' => '100',
'net_amount' => '95',
'source' => 'SSF',
'contribution_status_id' => 1,
- 'soft_credit' => array(
- '1' => array(
+ 'soft_credit' => [
+ '1' => [
'contact_id' => 25,
'amount' => 50,
'soft_credit_type_id' => 3,
- ),
- ),
- );
+ ],
+ ],
+ ];
try{
$result = civicrm_api3('Contribution', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function contribution_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'id' => '1',
'contact_id' => '24',
'financial_type_id' => '1',
'tax_amount' => '',
'revenue_recognition_date' => '',
'contribution_type_id' => '1',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function contribution_create_example() {
- $params = array(
+ $params = [
'contact_id' => 26,
'receive_date' => '20120511',
'total_amount' => '100',
'source' => 'SSF',
'contribution_status_id' => 1,
'soft_credit_to' => 27,
- );
+ ];
try{
$result = civicrm_api3('Contribution', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function contribution_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'id' => '1',
'contact_id' => '26',
'financial_type_id' => '1',
'tax_amount' => '',
'revenue_recognition_date' => '',
'contribution_type_id' => '1',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function contribution_create_example() {
- $params = array(
+ $params = [
'contact_id' => 1,
'receive_date' => '20120511',
'total_amount' => '100',
'invoice_id' => 67890,
'source' => 'SSF',
'contribution_status_id' => 2,
- );
+ ];
try{
$result = civicrm_api3('Contribution', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function contribution_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'id' => '1',
'contact_id' => '1',
'financial_type_id' => '1',
'revenue_recognition_date' => '',
'contribution_type_id' => '1',
'invoice_number' => '',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function contribution_create_example() {
- $params = array(
+ $params = [
'contact_id' => 11,
'receive_date' => '20120511',
'total_amount' => '100',
'source' => 'SSF',
'contribution_status_id' => 1,
'skipLineItem' => 1,
- 'api.line_item.create' => array(
- '0' => array(
+ 'api.line_item.create' => [
+ '0' => [
'price_field_id' => 1,
'qty' => 2,
'line_total' => '20',
'unit_price' => '10',
- ),
- '1' => array(
+ ],
+ '1' => [
'price_field_id' => 1,
'qty' => 1,
'line_total' => '80',
'unit_price' => '80',
- ),
- ),
- );
+ ],
+ ],
+ ];
try{
$result = civicrm_api3('Contribution', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function contribution_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'id' => '1',
'contact_id' => '11',
'financial_type_id' => '1',
'tax_amount' => 0,
'revenue_recognition_date' => '',
'contribution_type_id' => '1',
- 'api.line_item.create' => array(
- '0' => array(
+ 'api.line_item.create' => [
+ '0' => [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '0' => array(
+ 'values' => [
+ '0' => [
'id' => '1',
'entity_table' => 'civicrm_contribution',
'entity_id' => '1',
'financial_type_id' => '',
'non_deductible_amount' => '',
'tax_amount' => '',
- ),
- ),
- ),
- '1' => array(
+ ],
+ ],
+ ],
+ '1' => [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 2,
- 'values' => array(
- '0' => array(
+ 'values' => [
+ '0' => [
'id' => '2',
'entity_table' => 'civicrm_contribution',
'entity_id' => '1',
'financial_type_id' => '',
'non_deductible_amount' => '',
'tax_amount' => '',
- ),
- ),
- ),
- ),
- ),
- ),
- );
+ ],
+ ],
+ ],
+ ],
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function contribution_delete_example() {
- $params = array(
+ $params = [
'id' => 1,
- );
+ ];
try{
$result = civicrm_api3('Contribution', 'delete', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function contribution_delete_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
+ 'values' => [
'1' => 1,
- ),
- );
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function contribution_get_example() {
- $params = array(
+ $params = [
'contribution_id' => 1,
- );
+ ];
try{
$result = civicrm_api3('Contribution', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function contribution_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'contact_id' => '3',
'contact_type' => 'Individual',
'contact_sub_type' => '',
'check_number' => '',
'id' => '1',
'contribution_type_id' => '1',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function contribution_page_create_example() {
- $params = array(
+ $params = [
'title' => 'Test Contribution Page',
'financial_type_id' => 1,
'currency' => 'NZD',
'is_email_receipt' => TRUE,
'receipt_from_email' => 'yourconscience@donate.com',
'receipt_from_name' => 'Ego Freud',
- );
+ ];
try{
$result = civicrm_api3('ContributionPage', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function contribution_page_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'id' => '1',
'title' => 'Test Contribution Page',
'intro_text' => '',
'campaign_id' => '',
'is_share' => '',
'is_billing_required' => '',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function contribution_page_delete_example() {
- $params = array(
+ $params = [
'id' => 1,
- );
+ ];
try{
$result = civicrm_api3('ContributionPage', 'delete', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function contribution_page_delete_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'values' => 1,
- );
+ ];
return $expectedResult;
}
* API result array
*/
function contribution_page_get_example() {
- $params = array(
+ $params = [
'currency' => 'NZD',
'financial_type_id' => 1,
- );
+ ];
try{
$result = civicrm_api3('ContributionPage', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function contribution_page_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'id' => '1',
'title' => 'Test Contribution Page',
'financial_type_id' => '1',
'is_share' => '1',
'is_billing_required' => 0,
'contribution_type_id' => '1',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function contribution_page_submit_example() {
- $params = array(
+ $params = [
'id' => 1,
- 'pledge_amount' => array(
+ 'pledge_amount' => [
'2' => 1,
- ),
+ ],
'billing_first_name' => 'Billy',
'billing_middle_name' => 'Goat',
'billing_last_name' => 'Gruff',
'payment_processor_id' => 1,
'credit_card_number' => '4111111111111111',
'credit_card_type' => 'Visa',
- 'credit_card_exp_date' => array(
+ 'credit_card_exp_date' => [
'M' => 9,
'Y' => 2040,
- ),
+ ],
'cvv2' => 123,
'pledge_id' => '1',
'cid' => '83',
'amount' => '100',
'is_pledge' => TRUE,
'pledge_block_id' => 2,
- );
+ ];
try{
$result = civicrm_api3('ContributionPage', 'submit', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function contribution_page_submit_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 0,
'values' => '',
- );
+ ];
return $expectedResult;
}
* API result array
*/
function contribution_recur_create_example() {
- $params = array(
+ $params = [
'contact_id' => 3,
'installments' => '12',
'frequency_interval' => '1',
'start_date' => '2012-01-01 00:00:00',
'currency' => 'USD',
'frequency_unit' => 'day',
- );
+ ];
try{
$result = civicrm_api3('ContributionRecur', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function contribution_recur_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'id' => '1',
'contact_id' => '3',
'amount' => '500',
'payment_instrument_id' => '',
'campaign_id' => '',
'is_email_receipt' => '',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function contribution_recur_delete_example() {
- $params = array(
+ $params = [
'id' => 4,
- );
+ ];
try{
$result = civicrm_api3('ContributionRecur', 'delete', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function contribution_recur_delete_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'values' => 1,
- );
+ ];
return $expectedResult;
}
* API result array
*/
function contribution_recur_get_example() {
- $params = array(
+ $params = [
'amount' => '500',
- );
+ ];
try{
$result = civicrm_api3('ContributionRecur', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function contribution_recur_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 2,
- 'values' => array(
- '2' => array(
+ 'values' => [
+ '2' => [
'id' => '2',
'contact_id' => '4',
'amount' => '500.00',
'failure_count' => 0,
'auto_renew' => 0,
'is_email_receipt' => '1',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function contribution_soft_create_example() {
- $params = array(
+ $params = [
'contribution_id' => 6,
'contact_id' => 19,
'amount' => '10',
'currency' => 'USD',
'soft_credit_type_id' => 5,
- );
+ ];
try{
$result = civicrm_api3('ContributionSoft', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function contribution_soft_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 5,
- 'values' => array(
- '5' => array(
+ 'values' => [
+ '5' => [
'id' => '5',
'contribution_id' => '6',
'contact_id' => '19',
'pcp_roll_nickname' => '',
'pcp_personal_note' => '',
'soft_credit_type_id' => '5',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function contribution_soft_delete_example() {
- $params = array(
+ $params = [
'id' => 7,
- );
+ ];
try{
$result = civicrm_api3('ContributionSoft', 'delete', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
* API result array
*/
function contribution_soft_get_example() {
- $params = array(
+ $params = [
'id' => 1,
- );
+ ];
try{
$result = civicrm_api3('ContributionSoft', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function contribution_soft_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'id' => '1',
'contribution_id' => '1',
'contact_id' => '4',
'currency' => 'USD',
'pcp_display_in_roll' => 0,
'soft_credit_type_id' => '4',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function country_create_example() {
- $params = array(
+ $params = [
'name' => 'Made Up Land',
'iso_code' => 'ZZ',
'region_id' => 1,
- );
+ ];
try{
$result = civicrm_api3('Country', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function country_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1254,
- 'values' => array(
- '1254' => array(
+ 'values' => [
+ '1254' => [
'id' => '1254',
'name' => 'Made Up Land',
'iso_code' => 'ZZ',
'ndd_prefix' => '',
'region_id' => '1',
'is_province_abbreviated' => '',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function country_delete_example() {
- $params = array(
+ $params = [
'id' => 1255,
- );
+ ];
try{
$result = civicrm_api3('Country', 'delete', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function country_delete_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'values' => 1,
- );
+ ];
return $expectedResult;
}
* API result array
*/
function country_get_example() {
- $params = array(
+ $params = [
'iso_code' => 'ZZ',
- );
+ ];
try{
$result = civicrm_api3('Country', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function country_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1256,
- 'values' => array(
- '1256' => array(
+ 'values' => [
+ '1256' => [
'id' => '1256',
'name' => 'Made Up Land',
'iso_code' => 'ZZ',
'region_id' => '1',
'is_province_abbreviated' => 0,
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function custom_field_create_example() {
- $params = array(
+ $params = [
'custom_group_id' => 1,
'name' => 'test_textfield2',
'label' => 'Name1',
'is_required' => 1,
'is_searchable' => 0,
'is_active' => 1,
- );
+ ];
try{
$result = civicrm_api3('CustomField', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function custom_field_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'id' => '1',
'custom_group_id' => '1',
'name' => 'test_textfield2',
'option_group_id' => '',
'filter' => '',
'in_selector' => 0,
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function custom_field_delete_example() {
- $params = array(
+ $params = [
'id' => 1,
- );
+ ];
try{
$result = civicrm_api3('CustomField', 'delete', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function custom_field_delete_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'values' => 1,
- );
+ ];
return $expectedResult;
}
* API result array
*/
function custom_group_create_example() {
- $params = array(
+ $params = [
'title' => 'Test_Group_1',
'name' => 'test_group_1',
- 'extends' => array(
+ 'extends' => [
'0' => 'Individual',
- ),
+ ],
'weight' => 4,
'collapse_display' => 1,
'style' => 'Inline',
'help_pre' => 'This is Pre Help For Test Group 1',
'help_post' => 'This is Post Help For Test Group 1',
'is_active' => 1,
- );
+ ];
try{
$result = civicrm_api3('CustomGroup', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function custom_group_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'id' => '1',
'name' => 'test_group_1',
'title' => 'Test_Group_1',
'created_id' => '',
'created_date' => '',
'is_reserved' => '',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function custom_group_delete_example() {
- $params = array(
+ $params = [
'id' => 1,
- );
+ ];
try{
$result = civicrm_api3('CustomGroup', 'delete', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function custom_group_delete_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'values' => 1,
- );
+ ];
return $expectedResult;
}
* API result array
*/
function custom_group_get_example() {
- $params = array();
+ $params = [];
try{
$result = civicrm_api3('CustomGroup', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function custom_group_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'id' => '1',
'name' => 'test_group_1',
'title' => 'Test_Group_1',
'is_multiple' => 0,
'collapse_adv_display' => 0,
'is_reserved' => 0,
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function custom_value_create_example() {
- $params = array(
+ $params = [
'custom_1' => 'customString',
'entity_id' => 3,
- );
+ ];
try{
$result = civicrm_api3('CustomValue', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'error' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function custom_value_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'values' => TRUE,
- );
+ ];
return $expectedResult;
}
* API result array
*/
function custom_value_get_example() {
- $params = array(
+ $params = [
'id' => 2,
'entity_id' => 2,
'format.field_names' => 1,
- );
+ ];
try{
$result = civicrm_api3('CustomValue', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'error' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function custom_value_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 7,
- 'values' => array(
- 'mySingleField' => array(
+ 'values' => [
+ 'mySingleField' => [
'entity_id' => '2',
'latest' => 'value 1',
'id' => 'mySingleField',
- ),
- 'field_12' => array(
+ ],
+ 'field_12' => [
'entity_id' => '2',
'latest' => 'value 3',
'id' => 'field_12',
'1' => 'value 2',
'2' => 'value 3',
- ),
- 'field_22' => array(
+ ],
+ 'field_22' => [
'entity_id' => '2',
'latest' => '',
'id' => 'field_22',
'1' => 'warm beer',
'2' => '',
- ),
- 'field_32' => array(
+ ],
+ 'field_32' => [
'entity_id' => '2',
'latest' => '',
'id' => 'field_32',
'1' => 'fl* w*',
'2' => '',
- ),
- 'field_13' => array(
+ ],
+ 'field_13' => [
'entity_id' => '2',
'latest' => 'coffee',
'id' => 'field_13',
'1' => 'defaultValue',
'2' => 'coffee',
- ),
- 'field_23' => array(
+ ],
+ 'field_23' => [
'entity_id' => '2',
'latest' => 'value 4',
'id' => 'field_23',
'1' => '',
'2' => 'value 4',
- ),
- 'field_33' => array(
+ ],
+ 'field_33' => [
'entity_id' => '2',
'latest' => '',
'id' => 'field_33',
'1' => 'vegemite',
'2' => '',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function custom_value_get_example() {
- $params = array(
+ $params = [
'id' => 2,
'entity_id' => 2,
- );
+ ];
try{
$result = civicrm_api3('CustomValue', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'error' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function custom_value_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 7,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'entity_id' => '2',
'latest' => 'value 1',
'id' => '1',
- ),
- '2' => array(
+ ],
+ '2' => [
'entity_id' => '2',
'latest' => 'value 3',
'id' => '2',
'1' => 'value 2',
'2' => 'value 3',
- ),
- '3' => array(
+ ],
+ '3' => [
'entity_id' => '2',
'latest' => '',
'id' => '3',
'1' => 'warm beer',
'2' => '',
- ),
- '4' => array(
+ ],
+ '4' => [
'entity_id' => '2',
'latest' => '',
'id' => '4',
'1' => 'fl* w*',
'2' => '',
- ),
- '5' => array(
+ ],
+ '5' => [
'entity_id' => '2',
'latest' => 'coffee',
'id' => '5',
'1' => 'defaultValue',
'2' => 'coffee',
- ),
- '6' => array(
+ ],
+ '6' => [
'entity_id' => '2',
'latest' => 'value 4',
'id' => '6',
'1' => '',
'2' => 'value 4',
- ),
- '7' => array(
+ ],
+ '7' => [
'entity_id' => '2',
'latest' => '',
'id' => '7',
'1' => 'vegemite',
'2' => '',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function domain_create_example() {
- $params = array(
+ $params = [
'name' => 'A-team domain',
'description' => 'domain of chaos',
'domain_version' => '4.2',
'contact_id' => 6,
- );
+ ];
try{
$result = civicrm_api3('Domain', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function domain_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 3,
- 'values' => array(
- '3' => array(
+ 'values' => [
+ '3' => [
'id' => '3',
'name' => 'A-team domain',
'description' => 'domain of chaos',
'locales' => '',
'locale_custom_strings' => '',
'domain_version' => '4.2',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function domain_get_example() {
- $params = array(
+ $params = [
'sequential' => 1,
- );
+ ];
try{
$result = civicrm_api3('Domain', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function domain_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 2,
- 'values' => array(
- '0' => array(
+ 'values' => [
+ '0' => [
'id' => '1',
'name' => 'Default Domain Name',
'version' => '4.6.alpha1',
'contact_id' => '3',
'locale_custom_strings' => 'a:1:{s:5:\"en_US\";a:0:{}}',
'domain_email' => 'my@email.com',
- 'domain_phone' => array(
+ 'domain_phone' => [
'phone_type' => 'Phone',
'phone' => '456-456',
- ),
- 'domain_address' => array(
+ ],
+ 'domain_address' => [
'street_address' => '45 Penny Lane',
'supplemental_address_1' => '',
'supplemental_address_2' => '',
'country_id' => '',
'geo_code_1' => '',
'geo_code_2' => '',
- ),
+ ],
'from_email' => 'info@EXAMPLE.ORG',
'from_name' => 'FIXME',
'domain_version' => '4.6.alpha1',
- ),
- '1' => array(
+ ],
+ '1' => [
'id' => '2',
'name' => 'Second Domain',
'version' => '4.6.alpha1',
'contact_id' => '2',
'domain_email' => '\"Domain Email\" <domainemail2@example.org>',
- 'domain_phone' => array(
+ 'domain_phone' => [
'phone_type' => 'Phone',
'phone' => '204 555-1001',
- ),
- 'domain_address' => array(
+ ],
+ 'domain_address' => [
'street_address' => '15 Main St',
'supplemental_address_1' => '',
'supplemental_address_2' => '',
'country_id' => '1228',
'geo_code_1' => '41.8328',
'geo_code_2' => '-72.9253',
- ),
+ ],
'from_email' => 'info@EXAMPLE.ORG',
'from_name' => 'FIXME',
'domain_version' => '4.6.alpha1',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function email_create_example() {
- $params = array(
+ $params = [
'contact_id' => 3,
'location_type_id' => 6,
'email' => 'api@a-team.com',
'is_primary' => 1,
- );
+ ];
try{
$result = civicrm_api3('Email', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function email_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 3,
- 'values' => array(
- '3' => array(
+ 'values' => [
+ '3' => [
'id' => '3',
'contact_id' => '3',
'location_type_id' => '6',
'reset_date' => '',
'signature_text' => '',
'signature_html' => '',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function email_delete_example() {
- $params = array(
+ $params = [
'id' => 11,
- );
+ ];
try{
$result = civicrm_api3('Email', 'delete', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function email_delete_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'values' => 1,
- );
+ ];
return $expectedResult;
}
* API result array
*/
function email_replace_example() {
- $params = array(
+ $params = [
'contact_id' => 9,
- 'values' => array(
- '0' => array(
+ 'values' => [
+ '0' => [
'location_type_id' => 18,
'email' => '1-1@example.com',
'is_primary' => 1,
- ),
- '1' => array(
+ ],
+ '1' => [
'location_type_id' => 18,
'email' => '1-2@example.com',
'is_primary' => 0,
- ),
- '2' => array(
+ ],
+ '2' => [
'location_type_id' => 18,
'email' => '1-3@example.com',
'is_primary' => 0,
- ),
- '3' => array(
+ ],
+ '3' => [
'location_type_id' => 19,
'email' => '2-1@example.com',
'is_primary' => 0,
- ),
- '4' => array(
+ ],
+ '4' => [
'location_type_id' => 19,
'email' => '2-2@example.com',
'is_primary' => 0,
- ),
- ),
- );
+ ],
+ ],
+ ];
try{
$result = civicrm_api3('Email', 'replace', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function email_replace_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 5,
- 'values' => array(
- '12' => array(
+ 'values' => [
+ '12' => [
'id' => '12',
'contact_id' => '9',
'location_type_id' => '18',
'reset_date' => '',
'signature_text' => '',
'signature_html' => '',
- ),
- '13' => array(
+ ],
+ '13' => [
'id' => '13',
'contact_id' => '9',
'location_type_id' => '18',
'reset_date' => '',
'signature_text' => '',
'signature_html' => '',
- ),
- '14' => array(
+ ],
+ '14' => [
'id' => '14',
'contact_id' => '9',
'location_type_id' => '18',
'reset_date' => '',
'signature_text' => '',
'signature_html' => '',
- ),
- '15' => array(
+ ],
+ '15' => [
'id' => '15',
'contact_id' => '9',
'location_type_id' => '19',
'reset_date' => '',
'signature_text' => '',
'signature_html' => '',
- ),
- '16' => array(
+ ],
+ '16' => [
'id' => '16',
'contact_id' => '9',
'location_type_id' => '19',
'reset_date' => '',
'signature_text' => '',
'signature_html' => '',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function entity_batch_create_example() {
- $params = array(
+ $params = [
'entity_id' => 1,
'batch_id' => 1,
'entity_table' => 'civicrm_financial_trxn',
- );
+ ];
try{
$result = civicrm_api3('EntityBatch', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function entity_batch_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'id' => '1',
'entity_table' => 'civicrm_financial_trxn',
'entity_id' => '1',
'batch_id' => '1',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function entity_batch_delete_example() {
- $params = array(
+ $params = [
'id' => 3,
- );
+ ];
try{
$result = civicrm_api3('EntityBatch', 'delete', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function entity_batch_delete_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'values' => 1,
- );
+ ];
return $expectedResult;
}
* API result array
*/
function entity_batch_get_example() {
- $params = array(
+ $params = [
'entity_id' => 2,
'batch_id' => 2,
'entity_table' => 'civicrm_financial_trxn',
- );
+ ];
try{
$result = civicrm_api3('EntityBatch', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function entity_batch_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 2,
- 'values' => array(
- '2' => array(
+ 'values' => [
+ '2' => [
'id' => '2',
'entity_table' => 'civicrm_financial_trxn',
'entity_id' => '2',
'batch_id' => '2',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function entity_tag_create_example() {
- $params = array(
+ $params = [
'contact_id' => 3,
'tag_id' => '6',
- );
+ ];
try{
$result = civicrm_api3('EntityTag', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'error' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function entity_tag_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'not_added' => 0,
'added' => 1,
'total_count' => 1,
- );
+ ];
return $expectedResult;
}
* API result array
*/
function entity_tag_delete_example() {
- $params = array(
+ $params = [
'contact_id_h' => 31,
'tag_id' => '15',
- );
+ ];
try{
$result = civicrm_api3('EntityTag', 'delete', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function entity_tag_delete_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'not_removed' => 0,
'removed' => 1,
'total_count' => 1,
- );
+ ];
return $expectedResult;
}
* API result array
*/
function entity_tag_get_example() {
- $params = array(
+ $params = [
'contact_id' => 15,
- );
+ ];
try{
$result = civicrm_api3('EntityTag', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function entity_tag_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 5,
- 'values' => array(
- '5' => array(
+ 'values' => [
+ '5' => [
'id' => '5',
'entity_table' => 'civicrm_contact',
'entity_id' => '15',
'tag_id' => '10',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function event_get_example() {
- $params = array(
+ $params = [
'return.custom_2' => 1,
'custom_2' => 4,
- );
+ ];
try{
$result = civicrm_api3('Event', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function event_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 3,
- 'values' => array(
- '3' => array(
+ 'values' => [
+ '3' => [
'id' => '3',
'title' => 'My test event.',
'event_title' => 'My test event.',
'custom_1' => 'defaultValue',
'custom_2_id' => '4',
'custom_2' => 'Contact, Test',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function event_create_example() {
- $params = array(
+ $params = [
'title' => 'Annual CiviCRM meet',
'summary' => 'If you have any CiviCRM realted issues or want to track where CiviCRM is heading, Sign up now',
'description' => 'This event is intended to give brief idea about progess of CiviCRM and giving solutions to common user issues',
'is_monetary' => 0,
'is_active' => 1,
'is_show_location' => 0,
- );
+ ];
try{
$result = civicrm_api3('Event', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function event_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 3,
- 'values' => array(
- '3' => array(
+ 'values' => [
+ '3' => [
'id' => '3',
'title' => 'Annual CiviCRM meet',
'summary' => 'If you have any CiviCRM realted issues or want to track where CiviCRM is heading, Sign up now',
'slot_label_id' => '',
'dedupe_rule_group_id' => '',
'is_billing_required' => '',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function event_delete_example() {
- $params = array(
+ $params = [
'id' => 1,
- );
+ ];
try{
$result = civicrm_api3('Event', 'delete', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function event_delete_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'values' => 1,
- );
+ ];
return $expectedResult;
}
* API result array
*/
function event_get_example() {
- $params = array(
+ $params = [
'event_title' => 'Annual CiviCRM meet',
'sequential' => TRUE,
- );
+ ];
try{
$result = civicrm_api3('Event', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function event_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '0' => array(
+ 'values' => [
+ '0' => [
'id' => '1',
'title' => 'Annual CiviCRM meet',
'event_title' => 'Annual CiviCRM meet',
'is_share' => '1',
'is_confirm_enabled' => '1',
'is_billing_required' => 0,
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function event_get_example() {
- $params = array(
+ $params = [
'isCurrent' => 1,
- );
+ ];
try{
$result = civicrm_api3('Event', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function event_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 3,
- 'values' => array(
- '3' => array(
+ 'values' => [
+ '3' => [
'id' => '3',
'title' => 'Annual CiviCRM meet 2',
'event_title' => 'Annual CiviCRM meet 2',
'is_share' => '1',
'is_confirm_enabled' => '1',
'is_billing_required' => 0,
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function event_getsingle_example() {
- $params = array(
+ $params = [
'id' => 1,
'return.is_full' => 1,
- );
+ ];
try{
$result = civicrm_api3('Event', 'getsingle', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function event_getsingle_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'id' => '1',
'title' => 'Annual CiviCRM meet',
'event_title' => 'Annual CiviCRM meet',
'is_billing_required' => 0,
'available_places' => 0,
'is_full' => '1',
- );
+ ];
return $expectedResult;
}
* API result array
*/
function grant_create_example() {
- $params = array(
+ $params = [
'contact_id' => 3,
'application_received_date' => 'now',
'decision_date' => 'next Monday',
'rationale' => 'Just Because',
'currency' => 'USD',
'grant_type_id' => 1,
- );
+ ];
try{
$result = civicrm_api3('Grant', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function grant_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'id' => '1',
'contact_id' => '3',
'application_received_date' => '20130728084957',
'rationale' => 'Just Because',
'status_id' => '1',
'financial_type_id' => '',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function grant_delete_example() {
- $params = array(
+ $params = [
'id' => 1,
- );
+ ];
try{
$result = civicrm_api3('Grant', 'delete', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function grant_delete_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'values' => 1,
- );
+ ];
return $expectedResult;
}
* API result array
*/
function grant_get_example() {
- $params = array(
+ $params = [
'rationale' => 'Just Because',
- );
+ ];
try{
$result = civicrm_api3('Grant', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function grant_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'id' => '1',
'contact_id' => '5',
'application_received_date' => '20130728084957',
'currency' => 'USD',
'rationale' => 'Just Because',
'status_id' => '1',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function group_get_example() {
- $params = array(
+ $params = [
'name' => 'Test Group 1',
- );
+ ];
try{
$result = civicrm_api3('Group', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function group_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 4,
- 'values' => array(
- '4' => array(
+ 'values' => [
+ '4' => [
'id' => '4',
'name' => 'Test Group 1',
'title' => 'New Test Group Created',
'where_clause' => ' ( `civicrm_group_contact-4`.group_id IN ( 4 ) ) ',
'select_tables' => 'a:8:{s:15:\"civicrm_contact\";i:1;s:15:\"civicrm_address\";i:1;s:15:\"civicrm_country\";i:1;s:13:\"civicrm_email\";i:1;s:13:\"civicrm_phone\";i:1;s:10:\"civicrm_im\";i:1;s:19:\"civicrm_worldregion\";i:1;s:25:\"`civicrm_group_contact-4`\";s:165:\" LEFT JOIN civicrm_group_contact `civicrm_group_contact-4` ON (contact_a.id = `civicrm_group_contact-4`.contact_id AND `civicrm_group_contact-4`.status IN (\'Added\'))\";}',
'where_tables' => 'a:2:{s:15:\"civicrm_contact\";i:1;s:25:\"`civicrm_group_contact-4`\";s:165:\" LEFT JOIN civicrm_group_contact `civicrm_group_contact-4` ON (contact_a.id = `civicrm_group_contact-4`.contact_id AND `civicrm_group_contact-4`.status IN (\'Added\'))\";}',
- 'group_type' => array(
+ 'group_type' => [
'0' => '1',
'1' => '2',
- ),
+ ],
'is_hidden' => 0,
'is_reserved' => 0,
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function group_getfields_example() {
- $params = array(
+ $params = [
'action' => 'create',
- );
+ ];
try{
$result = civicrm_api3('Group', 'getfields', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function group_getfields_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 20,
- 'values' => array(
- 'id' => array(
+ 'values' => [
+ 'id' => [
'name' => 'id',
'type' => 1,
'title' => 'Group ID',
'table_name' => 'civicrm_group',
'entity' => 'Group',
'bao' => 'CRM_Contact_BAO_Group',
- 'api.aliases' => array(
+ 'api.aliases' => [
'0' => 'group_id',
- ),
- ),
- 'name' => array(
+ ],
+ ],
+ 'name' => [
'name' => 'name',
'type' => 2,
'title' => 'Group Name',
'table_name' => 'civicrm_group',
'entity' => 'Group',
'bao' => 'CRM_Contact_BAO_Group',
- ),
- 'title' => array(
+ ],
+ 'title' => [
'name' => 'title',
'type' => 2,
'title' => 'Group Title',
'entity' => 'Group',
'bao' => 'CRM_Contact_BAO_Group',
'api.required' => 1,
- ),
- 'description' => array(
+ ],
+ 'description' => [
'name' => 'description',
'type' => 32,
'title' => 'Group Description',
'table_name' => 'civicrm_group',
'entity' => 'Group',
'bao' => 'CRM_Contact_BAO_Group',
- 'html' => array(
+ 'html' => [
'type' => 'TextArea',
'rows' => 2,
'cols' => 60,
- ),
- ),
- 'source' => array(
+ ],
+ ],
+ 'source' => [
'name' => 'source',
'type' => 2,
'title' => 'Group Source',
'table_name' => 'civicrm_group',
'entity' => 'Group',
'bao' => 'CRM_Contact_BAO_Group',
- ),
- 'saved_search_id' => array(
+ ],
+ 'saved_search_id' => [
'name' => 'saved_search_id',
'type' => 1,
'title' => 'Saved Search ID',
'bao' => 'CRM_Contact_BAO_Group',
'FKClassName' => 'CRM_Contact_DAO_SavedSearch',
'FKApiName' => 'SavedSearch',
- ),
- 'is_active' => array(
+ ],
+ 'is_active' => [
'name' => 'is_active',
'type' => 16,
'title' => 'Group Enabled',
'entity' => 'Group',
'bao' => 'CRM_Contact_BAO_Group',
'api.default' => 1,
- ),
- 'visibility' => array(
+ ],
+ 'visibility' => [
'name' => 'visibility',
'type' => 2,
'title' => 'Group Visibility Setting',
'table_name' => 'civicrm_group',
'entity' => 'Group',
'bao' => 'CRM_Contact_BAO_Group',
- 'html' => array(
+ 'html' => [
'type' => 'Select',
'maxlength' => 24,
'size' => 20,
- ),
- 'pseudoconstant' => array(
+ ],
+ 'pseudoconstant' => [
'callback' => 'CRM_Core_SelectValues::groupVisibility',
- ),
- ),
- 'where_clause' => array(
+ ],
+ ],
+ 'where_clause' => [
'name' => 'where_clause',
'type' => 32,
'title' => 'Group Where Clause',
'table_name' => 'civicrm_group',
'entity' => 'Group',
'bao' => 'CRM_Contact_BAO_Group',
- ),
- 'select_tables' => array(
+ ],
+ 'select_tables' => [
'name' => 'select_tables',
'type' => 32,
'title' => 'Tables For Select Clause',
'table_name' => 'civicrm_group',
'entity' => 'Group',
'bao' => 'CRM_Contact_BAO_Group',
- ),
- 'where_tables' => array(
+ ],
+ 'where_tables' => [
'name' => 'where_tables',
'type' => 32,
'title' => 'Tables For Where Clause',
'table_name' => 'civicrm_group',
'entity' => 'Group',
'bao' => 'CRM_Contact_BAO_Group',
- ),
- 'group_type' => array(
+ ],
+ 'group_type' => [
'name' => 'group_type',
'type' => 2,
'title' => 'Group Type',
'table_name' => 'civicrm_group',
'entity' => 'Group',
'bao' => 'CRM_Contact_BAO_Group',
- 'pseudoconstant' => array(
+ 'pseudoconstant' => [
'optionGroupName' => 'group_type',
'optionEditPath' => 'civicrm/admin/options/group_type',
- ),
- ),
- 'cache_date' => array(
+ ],
+ ],
+ 'cache_date' => [
'name' => 'cache_date',
'type' => 256,
'title' => 'Group Cache Date',
'table_name' => 'civicrm_group',
'entity' => 'Group',
'bao' => 'CRM_Contact_BAO_Group',
- ),
- 'refresh_date' => array(
+ ],
+ 'refresh_date' => [
'name' => 'refresh_date',
'type' => 256,
'title' => 'Next Group Refresh Time',
'table_name' => 'civicrm_group',
'entity' => 'Group',
'bao' => 'CRM_Contact_BAO_Group',
- ),
- 'parents' => array(
+ ],
+ 'parents' => [
'name' => 'parents',
'type' => 32,
'title' => 'Group Parents',
'table_name' => 'civicrm_group',
'entity' => 'Group',
'bao' => 'CRM_Contact_BAO_Group',
- ),
- 'children' => array(
+ ],
+ 'children' => [
'name' => 'children',
'type' => 32,
'title' => 'Group Children',
'table_name' => 'civicrm_group',
'entity' => 'Group',
'bao' => 'CRM_Contact_BAO_Group',
- ),
- 'is_hidden' => array(
+ ],
+ 'is_hidden' => [
'name' => 'is_hidden',
'type' => 16,
'title' => 'Group is Hidden',
'table_name' => 'civicrm_group',
'entity' => 'Group',
'bao' => 'CRM_Contact_BAO_Group',
- ),
- 'is_reserved' => array(
+ ],
+ 'is_reserved' => [
'name' => 'is_reserved',
'type' => 16,
'title' => 'Group is Reserved',
'table_name' => 'civicrm_group',
'entity' => 'Group',
'bao' => 'CRM_Contact_BAO_Group',
- ),
- 'created_id' => array(
+ ],
+ 'created_id' => [
'name' => 'created_id',
'type' => 1,
'title' => 'Group Created By',
'bao' => 'CRM_Contact_BAO_Group',
'FKClassName' => 'CRM_Contact_DAO_Contact',
'FKApiName' => 'Contact',
- ),
- 'modified_id' => array(
+ ],
+ 'modified_id' => [
'name' => 'modified_id',
'type' => 1,
'title' => 'Group Modified By',
'bao' => 'CRM_Contact_BAO_Group',
'FKClassName' => 'CRM_Contact_DAO_Contact',
'FKApiName' => 'Contact',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function group_contact_create_example() {
- $params = array(
+ $params = [
'contact_id' => 8,
'contact_id.2' => 9,
'group_id' => 11,
- );
+ ];
try{
$result = civicrm_api3('GroupContact', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function group_contact_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'total_count' => 2,
'added' => 1,
'not_added' => 1,
- );
+ ];
return $expectedResult;
}
* API result array
*/
function group_contact_delete_example() {
- $params = array(
+ $params = [
'id' => 9,
'skip_undelete' => TRUE,
- );
+ ];
try{
$result = civicrm_api3('GroupContact', 'delete', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function group_contact_delete_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'total_count' => 1,
'removed' => 0,
'not_removed' => 0,
- );
+ ];
return $expectedResult;
}
* API result array
*/
function group_contact_get_example() {
- $params = array(
+ $params = [
'contact_id' => 3,
- );
+ ];
try{
$result = civicrm_api3('GroupContact', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function group_contact_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'id' => '1',
'group_id' => '1',
'title' => 'New Test Group Created',
'is_hidden' => 0,
'in_date' => '2013-07-28 08:50:19',
'in_method' => 'API',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function group_contact_get_example() {
- $params = array(
+ $params = [
'group_id' => 3,
'api.group.get' => 1,
'sequential' => 1,
- );
+ ];
try{
$result = civicrm_api3('GroupContact', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function group_contact_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 2,
- 'values' => array(
- '0' => array(
+ 'values' => [
+ '0' => [
'id' => '2',
'group_id' => '3',
'contact_id' => '4',
'status' => 'Added',
- 'api.group.get' => array(
+ 'api.group.get' => [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 3,
- 'values' => array(
- '0' => array(
+ 'values' => [
+ '0' => [
'id' => '3',
'name' => 'Test Group 1',
'title' => 'New Test Group Created',
'where_clause' => ' ( `civicrm_group_contact-3`.group_id IN ( 3 ) ) ',
'select_tables' => 'a:8:{s:15:\"civicrm_contact\";i:1;s:15:\"civicrm_address\";i:1;s:15:\"civicrm_country\";i:1;s:13:\"civicrm_email\";i:1;s:13:\"civicrm_phone\";i:1;s:10:\"civicrm_im\";i:1;s:19:\"civicrm_worldregion\";i:1;s:25:\"`civicrm_group_contact-3`\";s:165:\" LEFT JOIN civicrm_group_contact `civicrm_group_contact-3` ON (contact_a.id = `civicrm_group_contact-3`.contact_id AND `civicrm_group_contact-3`.status IN (\'Added\'))\";}',
'where_tables' => 'a:2:{s:15:\"civicrm_contact\";i:1;s:25:\"`civicrm_group_contact-3`\";s:165:\" LEFT JOIN civicrm_group_contact `civicrm_group_contact-3` ON (contact_a.id = `civicrm_group_contact-3`.contact_id AND `civicrm_group_contact-3`.status IN (\'Added\'))\";}',
- 'group_type' => array(
+ 'group_type' => [
'0' => '1',
'1' => '2',
- ),
+ ],
'is_hidden' => 0,
'is_reserved' => 0,
- ),
- ),
- ),
- ),
- ),
- );
+ ],
+ ],
+ ],
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function group_nesting_create_example() {
- $params = array(
+ $params = [
'parent_group_id' => 1,
'child_group_id' => 3,
- );
+ ];
try{
$result = civicrm_api3('GroupNesting', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function group_nesting_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 'is_error',
- 'values' => array(
+ 'values' => [
'is_error' => 0,
- ),
- );
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function group_nesting_delete_example() {
- $params = array(
+ $params = [
'id' => 1,
- );
+ ];
try{
$result = civicrm_api3('GroupNesting', 'delete', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function group_nesting_delete_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'values' => 1,
- );
+ ];
return $expectedResult;
}
* API result array
*/
function group_nesting_get_example() {
- $params = array(
+ $params = [
'parent_group_id' => 1,
'child_group_id' => 2,
- );
+ ];
try{
$result = civicrm_api3('GroupNesting', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function group_nesting_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'id' => '1',
'child_group_id' => '2',
'parent_group_id' => '1',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function group_organization_create_example() {
- $params = array(
+ $params = [
'organization_id' => 8,
'group_id' => 6,
- );
+ ];
try{
$result = civicrm_api3('GroupOrganization', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function group_organization_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 3,
'id' => 3,
- 'values' => array(
+ 'values' => [
'id' => '3',
'group_id' => '6',
'organization_id' => '8',
- ),
- );
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function group_organization_delete_example() {
- $params = array(
+ $params = [
'id' => 5,
- );
+ ];
try{
$result = civicrm_api3('GroupOrganization', 'delete', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function group_organization_delete_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'values' => 'Deleted Group Organization successfully',
- );
+ ];
return $expectedResult;
}
* API result array
*/
function group_organization_get_example() {
- $params = array(
+ $params = [
'organization_id' => 1,
- );
+ ];
try{
$result = civicrm_api3('GroupOrganization', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function group_organization_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 0,
- 'values' => array(),
- );
+ 'values' => [],
+ ];
return $expectedResult;
}
* API result array
*/
function im_create_example() {
- $params = array(
+ $params = [
'contact_id' => 3,
'name' => 'My Yahoo IM Handle',
'location_type_id' => 1,
'provider_id' => 1,
- );
+ ];
try{
$result = civicrm_api3('Im', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function im_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'id' => '1',
'contact_id' => '3',
'location_type_id' => '1',
'provider_id' => '1',
'is_primary' => '',
'is_billing' => '',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function im_delete_example() {
- $params = array(
+ $params = [
'id' => 3,
- );
+ ];
try{
$result = civicrm_api3('Im', 'delete', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function im_delete_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'values' => 1,
- );
+ ];
return $expectedResult;
}
* API result array
*/
function im_get_example() {
- $params = array(
+ $params = [
'contact_id' => 4,
'name' => 'My Yahoo IM Handle',
'location_type_id' => 1,
'provider_id' => 1,
- );
+ ];
try{
$result = civicrm_api3('Im', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function im_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 2,
- 'values' => array(
- '2' => array(
+ 'values' => [
+ '2' => [
'id' => '2',
'contact_id' => '4',
'location_type_id' => '1',
'provider_id' => '1',
'is_primary' => 0,
'is_billing' => 0,
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function job_create_example() {
- $params = array(
+ $params = [
'sequential' => 1,
'name' => 'API_Test_Job',
'description' => 'A long description written by hand in cursive',
'api_action' => 'apitestaction',
'parameters' => 'Semi-formal explanation of runtime job parameters',
'is_active' => 1,
- );
+ ];
try{
$result = civicrm_api3('Job', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function job_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 30,
- 'values' => array(
- '0' => array(
+ 'values' => [
+ '0' => [
'id' => '30',
'domain_id' => '1',
'run_frequency' => 'Daily',
'api_action' => 'apitestaction',
'parameters' => 'Semi-formal explanation of runtime job parameters',
'is_active' => '1',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function job_delete_example() {
- $params = array(
+ $params = [
'id' => 31,
- );
+ ];
try{
$result = civicrm_api3('Job', 'delete', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
* API result array
*/
function line_item_create_example() {
- $params = array(
+ $params = [
'price_field_value_id' => 1,
'price_field_id' => 1,
'entity_table' => 'civicrm_contribution',
'unit_price' => 50,
'line_total' => 50,
'debug' => 1,
- );
+ ];
try{
$result = civicrm_api3('LineItem', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function line_item_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 2,
- 'values' => array(
- '2' => array(
+ 'values' => [
+ '2' => [
'id' => '2',
'entity_table' => 'civicrm_contribution',
'entity_id' => '1',
'financial_type_id' => '',
'non_deductible_amount' => '',
'tax_amount' => '',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function line_item_delete_example() {
- $params = array(
+ $params = [
'id' => 4,
- );
+ ];
try{
$result = civicrm_api3('LineItem', 'delete', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function line_item_delete_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'values' => 1,
- );
+ ];
return $expectedResult;
}
* API result array
*/
function line_item_get_example() {
- $params = array(
+ $params = [
'entity_table' => 'civicrm_contribution',
- );
+ ];
try{
$result = civicrm_api3('LineItem', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function line_item_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 3,
- 'values' => array(
- '3' => array(
+ 'values' => [
+ '3' => [
'id' => '3',
'entity_table' => 'civicrm_contribution',
'entity_id' => '2',
'financial_type_id' => '1',
'non_deductible_amount' => '0.00',
'contribution_type_id' => '1',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function loc_block_create_example() {
- $params = array(
+ $params = [
'address_id' => 2,
'phone_id' => 2,
'email_id' => 3,
- );
+ ];
try{
$result = civicrm_api3('LocBlock', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function loc_block_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 2,
- 'values' => array(
- '2' => array(
+ 'values' => [
+ '2' => [
'id' => '2',
'address_id' => '2',
'email_id' => '3',
'email_2_id' => '',
'phone_2_id' => '',
'im_2_id' => '',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function loc_block_create_example() {
- $params = array(
- 'email' => array(
+ $params = [
+ 'email' => [
'location_type_id' => 1,
'email' => 'test2@loc.block',
- ),
- 'phone' => array(
+ ],
+ 'phone' => [
'location_type_id' => 1,
'phone' => '987654321',
- ),
- 'phone_2' => array(
+ ],
+ 'phone_2' => [
'location_type_id' => 1,
'phone' => '456-7890',
- ),
- 'address' => array(
+ ],
+ 'address' => [
'location_type_id' => 1,
'street_address' => '987654321',
- ),
- );
+ ],
+ ];
try{
$result = civicrm_api3('LocBlock', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function loc_block_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 3,
- 'values' => array(
- '3' => array(
- 'address' => array(
+ 'values' => [
+ '3' => [
+ 'address' => [
'id' => '3',
'location_type_id' => '1',
'is_primary' => 0,
'is_billing' => 0,
'street_address' => '987654321',
'manual_geo_code' => 0,
- ),
- 'email' => array(
+ ],
+ 'email' => [
'id' => '4',
'contact_id' => '',
'location_type_id' => '1',
'reset_date' => '',
'signature_text' => '',
'signature_html' => '',
- ),
- 'phone' => array(
+ ],
+ 'phone' => [
'id' => '3',
'contact_id' => '',
'location_type_id' => '1',
'phone_ext' => '',
'phone_numeric' => '',
'phone_type_id' => '',
- ),
- 'phone_2' => array(
+ ],
+ 'phone_2' => [
'id' => '4',
'contact_id' => '',
'location_type_id' => '1',
'phone_ext' => '',
'phone_numeric' => '',
'phone_type_id' => '',
- ),
+ ],
'id' => '3',
'address_id' => '3',
'email_id' => '4',
'email_2_id' => '',
'phone_2_id' => '4',
'im_2_id' => '',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function loc_block_get_example() {
- $params = array(
+ $params = [
'id' => 3,
'return' => 'all',
- );
+ ];
try{
$result = civicrm_api3('LocBlock', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function loc_block_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 3,
- 'values' => array(
- '3' => array(
+ 'values' => [
+ '3' => [
'id' => '3',
'address_id' => '3',
'email_id' => '4',
'phone_id' => '3',
'phone_2_id' => '4',
- 'address' => array(
+ 'address' => [
'id' => '3',
'location_type_id' => '1',
'is_primary' => 0,
'is_billing' => 0,
'street_address' => '987654321',
'manual_geo_code' => 0,
- ),
- 'email' => array(
+ ],
+ 'email' => [
'id' => '4',
'location_type_id' => '1',
'email' => 'test2@loc.block',
'is_billing' => 0,
'on_hold' => 0,
'is_bulkmail' => 0,
- ),
- 'phone' => array(
+ ],
+ 'phone' => [
'id' => '3',
'location_type_id' => '1',
'is_primary' => 0,
'is_billing' => 0,
'phone' => '987654321',
'phone_numeric' => '987654321',
- ),
- 'phone_2' => array(
+ ],
+ 'phone_2' => [
'id' => '4',
'location_type_id' => '1',
'is_primary' => 0,
'is_billing' => 0,
'phone' => '456-7890',
'phone_numeric' => '4567890',
- ),
- ),
- ),
- );
+ ],
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function logging_get_example() {
- $params = array(
+ $params = [
'log_conn_id' => 'wooty wop wop',
- );
+ ];
try{
$result = civicrm_api3('Logging', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function logging_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 17,
- 'values' => array(
- '0' => array(
+ 'values' => [
+ '0' => [
'action' => 'Update',
'id' => '3',
'field' => 'sort_name',
'table' => 'civicrm_contact',
'log_date' => '2017-02-07 02:36:46',
'log_conn_id' => 'wooty wop wop',
- ),
- '1' => array(
+ ],
+ '1' => [
'action' => 'Update',
'id' => '3',
'field' => 'display_name',
'table' => 'civicrm_contact',
'log_date' => '2017-02-07 02:36:46',
'log_conn_id' => 'wooty wop wop',
- ),
- '2' => array(
+ ],
+ '2' => [
'action' => 'Update',
'id' => '3',
'field' => 'first_name',
'table' => 'civicrm_contact',
'log_date' => '2017-02-07 02:36:46',
'log_conn_id' => 'wooty wop wop',
- ),
- '3' => array(
+ ],
+ '3' => [
'action' => 'Update',
'id' => '3',
'field' => 'last_name',
'table' => 'civicrm_contact',
'log_date' => '2017-02-07 02:36:46',
'log_conn_id' => 'wooty wop wop',
- ),
- '4' => array(
+ ],
+ '4' => [
'action' => 'Update',
'id' => '3',
'field' => 'modified_date',
'table' => 'civicrm_contact',
'log_date' => '2017-02-07 02:36:46',
'log_conn_id' => 'wooty wop wop',
- ),
- '5' => array(
+ ],
+ '5' => [
'action' => 'Insert',
'id' => '2',
'field' => 'id',
'table' => 'civicrm_email',
'log_date' => '2017-02-07 02:36:46',
'log_conn_id' => 'wooty wop wop',
- ),
- '6' => array(
+ ],
+ '6' => [
'action' => 'Insert',
'id' => '2',
'field' => 'contact_id',
'table' => 'civicrm_email',
'log_date' => '2017-02-07 02:36:46',
'log_conn_id' => 'wooty wop wop',
- ),
- '7' => array(
+ ],
+ '7' => [
'action' => 'Insert',
'id' => '2',
'field' => 'location_type_id',
'table' => 'civicrm_email',
'log_date' => '2017-02-07 02:36:46',
'log_conn_id' => 'wooty wop wop',
- ),
- '8' => array(
+ ],
+ '8' => [
'action' => 'Insert',
'id' => '2',
'field' => 'email',
'table' => 'civicrm_email',
'log_date' => '2017-02-07 02:36:46',
'log_conn_id' => 'wooty wop wop',
- ),
- '9' => array(
+ ],
+ '9' => [
'action' => 'Insert',
'id' => '2',
'field' => 'is_primary',
'table' => 'civicrm_email',
'log_date' => '2017-02-07 02:36:46',
'log_conn_id' => 'wooty wop wop',
- ),
- '10' => array(
+ ],
+ '10' => [
'action' => 'Insert',
'id' => '2',
'field' => 'is_billing',
'table' => 'civicrm_email',
'log_date' => '2017-02-07 02:36:46',
'log_conn_id' => 'wooty wop wop',
- ),
- '11' => array(
+ ],
+ '11' => [
'action' => 'Insert',
'id' => '2',
'field' => 'on_hold',
'table' => 'civicrm_email',
'log_date' => '2017-02-07 02:36:46',
'log_conn_id' => 'wooty wop wop',
- ),
- '12' => array(
+ ],
+ '12' => [
'action' => 'Insert',
'id' => '2',
'field' => 'is_bulkmail',
'table' => 'civicrm_email',
'log_date' => '2017-02-07 02:36:46',
'log_conn_id' => 'wooty wop wop',
- ),
- '13' => array(
+ ],
+ '13' => [
'action' => 'Insert',
'id' => '2',
'field' => 'hold_date',
'table' => 'civicrm_email',
'log_date' => '2017-02-07 02:36:46',
'log_conn_id' => 'wooty wop wop',
- ),
- '14' => array(
+ ],
+ '14' => [
'action' => 'Insert',
'id' => '2',
'field' => 'reset_date',
'table' => 'civicrm_email',
'log_date' => '2017-02-07 02:36:46',
'log_conn_id' => 'wooty wop wop',
- ),
- '15' => array(
+ ],
+ '15' => [
'action' => 'Insert',
'id' => '2',
'field' => 'signature_text',
'table' => 'civicrm_email',
'log_date' => '2017-02-07 02:36:46',
'log_conn_id' => 'wooty wop wop',
- ),
- '16' => array(
+ ],
+ '16' => [
'action' => 'Insert',
'id' => '2',
'field' => 'signature_html',
'table' => 'civicrm_email',
'log_date' => '2017-02-07 02:36:46',
'log_conn_id' => 'wooty wop wop',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function logging_revert_example() {
- $params = array(
+ $params = [
'log_conn_id' => 'woot',
'log_date' => '2017-02-07 02:35:06',
- );
+ ];
try{
$result = civicrm_api3('Logging', 'revert', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function logging_revert_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'values' => 1,
- );
+ ];
return $expectedResult;
}
* API result array
*/
function mail_settings_get_example() {
- $params = array(
+ $params = [
'title' => 'MailSettings title',
'api.MailSettings.delete' => 1,
- );
+ ];
try{
$result = civicrm_api3('MailSettings', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function mail_settings_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 2,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'id' => '1',
'domain_id' => '1',
'name' => 'default',
'is_default' => 0,
'domain' => 'EXAMPLE.ORG',
- 'api.MailSettings.delete' => array(
+ 'api.MailSettings.delete' => [
'is_error' => 0,
'version' => 3,
'count' => 1,
'values' => 1,
- ),
- ),
- '6' => array(
+ ],
+ ],
+ '6' => [
'id' => '6',
'domain_id' => '1',
'name' => 'my mail setting',
'username' => 'sue',
'password' => 'pass',
'is_ssl' => 0,
- 'api.MailSettings.delete' => array(
+ 'api.MailSettings.delete' => [
'is_error' => 0,
'version' => 3,
'count' => 1,
'values' => 1,
- ),
- ),
- ),
- );
+ ],
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function mail_settings_create_example() {
- $params = array(
+ $params = [
'domain_id' => 1,
'name' => 'my mail setting',
'domain' => 'setting.com',
'username' => 'sue',
'password' => 'pass',
'is_default' => 1,
- );
+ ];
try{
$result = civicrm_api3('MailSettings', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function mail_settings_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 5,
- 'values' => array(
- '5' => array(
+ 'values' => [
+ '5' => [
'id' => '5',
'domain_id' => '1',
'name' => 'my mail setting',
'password' => 'pass',
'is_ssl' => '',
'source' => '',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function mail_settings_delete_example() {
- $params = array(
+ $params = [
'id' => 5,
- );
+ ];
try{
$result = civicrm_api3('MailSettings', 'delete', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function mail_settings_delete_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'values' => 1,
- );
+ ];
return $expectedResult;
}
* API result array
*/
function mail_settings_get_example() {
- $params = array(
+ $params = [
'domain_id' => 1,
'name' => 'my mail setting',
'domain' => 'setting.com',
'username' => 'sue',
'password' => 'pass',
'is_default' => 1,
- );
+ ];
try{
$result = civicrm_api3('MailSettings', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function mail_settings_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 4,
- 'values' => array(
- '4' => array(
+ 'values' => [
+ '4' => [
'id' => '4',
'domain_id' => '1',
'name' => 'my mail setting',
'username' => 'sue',
'password' => 'pass',
'is_ssl' => 0,
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function mail_settings_getoptions_example() {
- $params = array(
+ $params = [
'field' => 'protocol',
- );
+ ];
try{
$result = civicrm_api3('MailSettings', 'getoptions', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function mail_settings_getoptions_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 4,
- 'values' => array(
+ 'values' => [
'1' => 'IMAP',
'2' => 'Maildir',
'3' => 'POP3',
'4' => 'Localdir',
- ),
- );
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function mailing_clone_example() {
- $params = array(
+ $params = [
'id' => 21,
- );
+ ];
try{
$result = civicrm_api3('Mailing', 'clone', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function mailing_clone_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 22,
- 'values' => array(
- '22' => array(
+ 'values' => [
+ '22' => [
'id' => '22',
'domain_id' => '1',
'header_id' => '1',
'location_type_id' => '',
'email_selection_method' => 'automatic',
'language' => '',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function mailing_create_example() {
- $params = array(
+ $params = [
'subject' => 'Hello {contact.display_name}',
'body_text' => 'This is {contact.display_name}.
https://civicrm.org
'created_id' => 3,
'header_id' => '',
'footer_id' => '',
- 'groups' => array(
- 'include' => array(
+ 'groups' => [
+ 'include' => [
'0' => 2,
- ),
- 'exclude' => array(
+ ],
+ 'exclude' => [
'0' => 3,
- ),
- ),
- 'mailings' => array(
- 'include' => array(),
- 'exclude' => array(),
- ),
- 'options' => array(
+ ],
+ ],
+ 'mailings' => [
+ 'include' => [],
+ 'exclude' => [],
+ ],
+ 'options' => [
'force_rollback' => 1,
- ),
+ ],
'api.mailing_job.create' => 1,
- 'api.MailingRecipients.get' => array(
+ 'api.MailingRecipients.get' => [
'mailing_id' => '$value.id',
- 'api.contact.getvalue' => array(
+ 'api.contact.getvalue' => [
'return' => 'display_name',
- ),
- 'api.email.getvalue' => array(
+ ],
+ 'api.email.getvalue' => [
'return' => 'email',
- ),
- ),
- );
+ ],
+ ],
+ ];
try{
$result = civicrm_api3('Mailing', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function mailing_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'id' => '1',
'domain_id' => '1',
'header_id' => '',
'location_type_id' => '',
'email_selection_method' => '',
'language' => '',
- 'api.mailing_job.create' => array(
+ 'api.mailing_job.create' => [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '0' => array(
+ 'values' => [
+ '0' => [
'id' => '1',
'mailing_id' => '1',
'scheduled_date' => '20130728085413',
'parent_id' => '',
'job_offset' => '',
'job_limit' => '',
- ),
- ),
- ),
- 'api.MailingRecipients.get' => array(
+ ],
+ ],
+ ],
+ 'api.MailingRecipients.get' => [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '0' => array(
+ 'values' => [
+ '0' => [
'id' => '1',
'mailing_id' => '1',
'contact_id' => '4',
'email_id' => '4',
'api.contact.getvalue' => 'Mr. Includer Person II',
'api.email.getvalue' => 'include.me@example.org',
- ),
- ),
- ),
- ),
- ),
- );
+ ],
+ ],
+ ],
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function mailing_delete_example() {
- $params = array(
+ $params = [
'id' => 20,
- );
+ ];
try{
$result = civicrm_api3('Mailing', 'delete', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function mailing_delete_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'values' => 1,
- );
+ ];
return $expectedResult;
}
* API result array
*/
function mailing_gettokens_example() {
- $params = array(
- 'entity' => array(
+ $params = [
+ 'entity' => [
'0' => 'Contact',
'1' => 'Mailing',
- ),
- );
+ ],
+ ];
try{
$result = civicrm_api3('Mailing', 'gettokens', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function mailing_gettokens_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 82,
- 'values' => array(
+ 'values' => [
'{action.unsubscribe}' => 'Unsubscribe via email',
'{action.unsubscribeUrl}' => 'Unsubscribe via web page',
'{action.resubscribe}' => 'Resubscribe via email',
'{contact.url}' => 'Website',
'{contact.checksum}' => 'Checksum',
'{contact.contact_id}' => 'Internal Contact ID',
- ),
- );
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function mailing_submit_example() {
- $params = array(
+ $params = [
'scheduled_date' => '2014-12-13 10:00:00',
'approval_date' => '2014-12-13 00:00:00',
'id' => 18,
- );
+ ];
try{
$result = civicrm_api3('Mailing', 'submit', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function mailing_submit_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 18,
- 'values' => array(
- '18' => array(
+ 'values' => [
+ '18' => [
'id' => '18',
'domain_id' => '1',
'header_id' => '',
'location_type_id' => '',
'email_selection_method' => 'automatic',
'language' => '',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function mailing_a_b_create_example() {
- $params = array(
+ $params = [
'mailing_id_a' => 1,
'mailing_id_b' => 2,
'mailing_id_c' => 3,
'winner_criteria' => 'open',
'declare_winning_time' => '+2 days',
'group_percentage' => 10,
- );
+ ];
try{
$result = civicrm_api3('MailingAB', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function mailing_a_b_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'id' => '1',
'name' => '',
'status' => '',
'group_percentage' => '10',
'created_id' => '3',
'created_date' => '2013-07-28 08:49:19',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function mailing_event_subscribe_create_example() {
- $params = array(
+ $params = [
'email' => 'test@test.test',
'group_id' => 2,
'contact_id' => 3,
'hash' => 'b15de8b64e2cec34',
'time_stamp' => '20101212121212',
- );
+ ];
try{
$result = civicrm_api3('MailingEventSubscribe', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function mailing_event_subscribe_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'contact_id' => '3',
'subscribe_id' => '1',
'hash' => '67eac7789eaee00',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function mailing_group_subscribe_example() {
- $params = array(
+ $params = [
'email' => 'test@test.test',
'group_id' => 2,
'contact_id' => 3,
'hash' => 'b15de8b64e2cec34',
'time_stamp' => '20101212121212',
- );
+ ];
try{
$result = civicrm_api3('mailing_group', 'subscribe', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'error' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function mailing_group_subscribe_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'contact_id' => '3',
'subscribe_id' => '1',
'hash' => '67eac7789eaee00',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function mapping_create_example() {
- $params = array(
+ $params = [
'name' => 'Mapping name',
'description' => 'Mapping description',
'mapping_type_id' => 7,
- );
+ ];
try{
$result = civicrm_api3('Mapping', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function mapping_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'id' => '1',
'name' => 'Mapping name',
'description' => 'Mapping description',
'mapping_type_id' => '7',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function mapping_delete_example() {
- $params = array(
+ $params = [
'id' => 3,
- );
+ ];
try{
$result = civicrm_api3('Mapping', 'delete', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function mapping_delete_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'values' => 1,
- );
+ ];
return $expectedResult;
}
* API result array
*/
function mapping_get_example() {
- $params = array(
+ $params = [
'name' => 'Mapping name',
'description' => 'Mapping description',
'mapping_type_id' => 7,
- );
+ ];
try{
$result = civicrm_api3('Mapping', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function mapping_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 2,
- 'values' => array(
- '2' => array(
+ 'values' => [
+ '2' => [
'id' => '2',
'name' => 'Mapping name',
'description' => 'Mapping description',
'mapping_type_id' => '7',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function mapping_field_create_example() {
- $params = array(
+ $params = [
'mapping_id' => 1,
'name' => 'last_name',
'contact_type' => 'Individual',
'column_number' => 2,
'grouping' => 1,
- );
+ ];
try{
$result = civicrm_api3('MappingField', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function mapping_field_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'id' => '1',
'mapping_id' => '1',
'name' => 'last_name',
'grouping' => '1',
'operator' => '',
'value' => '',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function mapping_field_delete_example() {
- $params = array(
+ $params = [
'id' => 3,
- );
+ ];
try{
$result = civicrm_api3('MappingField', 'delete', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function mapping_field_delete_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'values' => 1,
- );
+ ];
return $expectedResult;
}
* API result array
*/
function mapping_field_get_example() {
- $params = array(
+ $params = [
'mapping_id' => 2,
'name' => 'last_name',
'contact_type' => 'Individual',
'column_number' => 2,
'grouping' => 1,
- );
+ ];
try{
$result = civicrm_api3('MappingField', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function mapping_field_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 2,
- 'values' => array(
- '2' => array(
+ 'values' => [
+ '2' => [
'id' => '2',
'mapping_id' => '2',
'name' => 'last_name',
'contact_type' => 'Individual',
'column_number' => '2',
'grouping' => '1',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function membership_create_example() {
- $params = array(
+ $params = [
'contact_id' => 79,
'membership_type_id' => 47,
'join_date' => '2006-01-21',
'source' => 'Payment',
'is_override' => 1,
'status_id' => 30,
- );
+ ];
try{
$result = civicrm_api3('Membership', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function membership_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'id' => '1',
'contact_id' => '79',
'membership_type_id' => '47',
'is_pay_later' => '',
'contribution_recur_id' => '',
'campaign_id' => '',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function membership_create_example() {
- $params = array(
+ $params = [
'contact_id' => 91,
'membership_type_id' => 55,
'join_date' => '2009-01-21',
'is_override' => 1,
'status_id' => 34,
'custom_1' => 'custom string',
- );
+ ];
try{
$result = civicrm_api3('Membership', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function membership_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'id' => '1',
'contact_id' => '91',
'membership_type_id' => '55',
'is_pay_later' => '',
'contribution_recur_id' => '',
'campaign_id' => '',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function membership_delete_example() {
- $params = array(
+ $params = [
'id' => 1,
'preserve_contribution' => 1,
- );
+ ];
try{
$result = civicrm_api3('Membership', 'delete', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function membership_delete_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'values' => TRUE,
- );
+ ];
return $expectedResult;
}
* API result array
*/
function membership_get_example() {
- $params = array(
+ $params = [
'contact_id' => 47,
- 'filters' => array(
+ 'filters' => [
'is_current' => 1,
- ),
- );
+ ],
+ ];
try{
$result = civicrm_api3('Membership', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function membership_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'id' => '1',
'contact_id' => '47',
'membership_type_id' => '29',
'is_pay_later' => 0,
'membership_name' => 'General',
'relationship_name' => 'Child of',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function membership_get_example() {
- $params = array(
+ $params = [
'membership_type_id' => 23,
- );
+ ];
try{
$result = civicrm_api3('Membership', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function membership_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'id' => '1',
'contact_id' => '38',
'membership_type_id' => '23',
'membership_name' => 'General',
'relationship_name' => 'Child of',
'custom_1_1' => 'custom string',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function membership_create_example() {
- $params = array(
+ $params = [
'contact_id' => 94,
'membership_type_id' => 57,
'join_date' => '2009-01-21',
'source' => 'Payment',
'is_override' => 1,
'status_id' => 35,
- );
+ ];
try{
$result = civicrm_api3('Membership', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function membership_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'id' => '1',
'contact_id' => '94',
'membership_type_id' => '57',
'is_pay_later' => '',
'contribution_recur_id' => '',
'campaign_id' => '',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function membership_create_example() {
- $params = array(
+ $params = [
'contact_id' => 112,
'membership_type_id' => 69,
'join_date' => '2009-01-21',
'is_override' => 1,
'status_id' => 41,
'custom_1' => 'custom string',
- );
+ ];
try{
$result = civicrm_api3('Membership', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function membership_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'id' => '1',
'contact_id' => '112',
'membership_type_id' => '69',
'is_pay_later' => '',
'contribution_recur_id' => '',
'campaign_id' => '',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function membership_payment_create_example() {
- $params = array(
+ $params = [
'contribution_id' => 2,
'membership_id' => 1,
- );
+ ];
try{
$result = civicrm_api3('MembershipPayment', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function membership_payment_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'id' => '1',
'membership_id' => '1',
'contribution_id' => '2',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function membership_payment_get_example() {
- $params = array(
+ $params = [
'contribution_id' => 4,
'membership_id' => 2,
- );
+ ];
try{
$result = civicrm_api3('MembershipPayment', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function membership_payment_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 2,
- 'values' => array(
- '2' => array(
+ 'values' => [
+ '2' => [
'id' => '2',
'membership_id' => '2',
'contribution_id' => '4',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function membership_status_create_example() {
- $params = array(
+ $params = [
'name' => 'test membership status',
- );
+ ];
try{
$result = civicrm_api3('MembershipStatus', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function membership_status_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 15,
- 'values' => array(
- '15' => array(
+ 'values' => [
+ '15' => [
'id' => '15',
'name' => 'test membership status',
'label' => 'test membership status',
'is_default' => '',
'is_active' => '',
'is_reserved' => '',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function membership_status_get_example() {
- $params = array(
+ $params = [
'name' => 'test status',
- );
+ ];
try{
$result = civicrm_api3('MembershipStatus', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function membership_status_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 9,
- 'values' => array(
- '9' => array(
+ 'values' => [
+ '9' => [
'id' => '9',
'name' => 'test status',
'label' => 'test status',
'is_default' => 0,
'is_active' => '1',
'is_reserved' => 0,
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function membership_type_create_example() {
- $params = array(
+ $params = [
'name' => '40+ Membership',
'description' => 'people above 40 are given health instructions',
'member_of_contact_id' => 7,
'duration_interval' => '10',
'period_type' => 'rolling',
'visibility' => 'public',
- );
+ ];
try{
$result = civicrm_api3('MembershipType', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function membership_type_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 2,
- 'values' => array(
- '2' => array(
+ 'values' => [
+ '2' => [
'id' => '2',
'domain_id' => '1',
'name' => '40+ Membership',
'auto_renew' => '',
'is_active' => '1',
'contribution_type_id' => '1',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function membership_type_delete_example() {
- $params = array(
+ $params = [
'id' => 4,
- );
+ ];
try{
$result = civicrm_api3('MembershipType', 'delete', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function membership_type_delete_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'values' => 1,
- );
+ ];
return $expectedResult;
}
* API result array
*/
function membership_type_get_example() {
- $params = array(
+ $params = [
'id' => 1,
- );
+ ];
try{
$result = civicrm_api3('MembershipType', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function membership_type_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'id' => '1',
'domain_id' => '1',
'name' => 'General',
'auto_renew' => 0,
'is_active' => '1',
'contribution_type_id' => '2',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function message_template_create_example() {
- $params = array(
+ $params = [
'msg_title' => 'msg_title_284',
'msg_subject' => 'msg_subject_284',
'msg_text' => 'msg_text_284',
'workflow_id' => 284,
'is_default' => '1',
'is_reserved' => 1,
- );
+ ];
try{
$result = civicrm_api3('MessageTemplate', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function message_template_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 69,
- 'values' => array(
- '69' => array(
+ 'values' => [
+ '69' => [
'id' => '69',
'msg_title' => 'msg_title_284',
'msg_subject' => 'msg_subject_284',
'is_reserved' => '1',
'is_sms' => '',
'pdf_format_id' => '',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function message_template_delete_example() {
- $params = array(
+ $params = [
'id' => 72,
- );
+ ];
try{
$result = civicrm_api3('MessageTemplate', 'delete', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function message_template_delete_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'values' => 1,
- );
+ ];
return $expectedResult;
}
* API result array
*/
function message_template_get_example() {
- $params = array(
+ $params = [
'msg_title' => 'msg_title_285',
'msg_subject' => 'msg_subject_285',
'msg_text' => 'msg_text_285',
'workflow_id' => 285,
'is_default' => '1',
'is_reserved' => 1,
- );
+ ];
try{
$result = civicrm_api3('MessageTemplate', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function message_template_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 70,
- 'values' => array(
- '70' => array(
+ 'values' => [
+ '70' => [
'id' => '70',
'msg_title' => 'msg_title_285',
'msg_subject' => 'msg_subject_285',
'is_reserved' => '1',
'is_sms' => '1',
'pdf_format_id' => '285',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function note_create_example() {
- $params = array(
+ $params = [
'entity_table' => 'civicrm_contact',
'entity_id' => 9,
'note' => 'Hello!!! m testing Note',
'contact_id' => 9,
'modified_date' => '2011-01-31',
'subject' => 'Test Note',
- );
+ ];
try{
$result = civicrm_api3('Note', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function note_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 8,
- 'values' => array(
- '8' => array(
+ 'values' => [
+ '8' => [
'id' => '8',
'entity_table' => 'civicrm_contact',
'entity_id' => '9',
'modified_date' => '2012-11-14 16:02:35',
'subject' => 'Test Note',
'privacy' => 0,
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function note_delete_example() {
- $params = array(
+ $params = [
'id' => 19,
- );
+ ];
try{
$result = civicrm_api3('Note', 'delete', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function note_delete_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'values' => 1,
- );
+ ];
return $expectedResult;
}
* API result array
*/
function note_get_example() {
- $params = array(
+ $params = [
'entity_table' => 'civicrm_contact',
'entity_id' => 3,
- );
+ ];
try{
$result = civicrm_api3('Note', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function note_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 0,
- 'values' => array(),
- );
+ 'values' => [],
+ ];
return $expectedResult;
}
* API result array
*/
function open_i_d_create_example() {
- $params = array(
+ $params = [
'contact_id' => 3,
'openid' => 'My OpenID handle',
'location_type_id' => 1,
- );
+ ];
try{
$result = civicrm_api3('OpenID', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function open_i_d_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'id' => '1',
'contact_id' => '3',
'location_type_id' => '1',
'openid' => 'My OpenID handle',
'allowed_to_login' => '',
'is_primary' => '',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function open_i_d_delete_example() {
- $params = array(
+ $params = [
'id' => 3,
- );
+ ];
try{
$result = civicrm_api3('OpenID', 'delete', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function open_i_d_delete_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'values' => 1,
- );
+ ];
return $expectedResult;
}
* API result array
*/
function open_i_d_get_example() {
- $params = array(
+ $params = [
'contact_id' => 4,
'openid' => 'My OpenID handle',
'location_type_id' => 1,
- );
+ ];
try{
$result = civicrm_api3('OpenID', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function open_i_d_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 2,
- 'values' => array(
- '2' => array(
+ 'values' => [
+ '2' => [
'id' => '2',
'contact_id' => '4',
'location_type_id' => '1',
'openid' => 'My OpenID handle',
'allowed_to_login' => 0,
'is_primary' => 0,
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function option_group_create_example() {
- $params = array(
+ $params = [
'sequential' => 1,
'name' => 'civicrm_event.amount.560',
'is_reserved' => 1,
'is_active' => 1,
- 'api.OptionValue.create' => array(
+ 'api.OptionValue.create' => [
'label' => 'workshop',
'value' => 35,
'is_default' => 1,
'is_active' => 1,
'format.only_id' => 1,
- ),
- );
+ ],
+ ];
try{
$result = civicrm_api3('OptionGroup', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function option_group_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 92,
- 'values' => array(
- '0' => array(
+ 'values' => [
+ '0' => [
'id' => '92',
'name' => 'civicrm_event.amount.560',
'title' => '',
'is_active' => '1',
'is_locked' => '',
'api.OptionValue.create' => 849,
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function option_group_delete_example() {
- $params = array(
+ $params = [
'id' => 97,
- );
+ ];
try{
$result = civicrm_api3('OptionGroup', 'delete', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function option_group_delete_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'values' => 1,
- );
+ ];
return $expectedResult;
}
* API result array
*/
function option_group_get_example() {
- $params = array(
+ $params = [
'name' => 'preferred_communication_method',
- );
+ ];
try{
$result = civicrm_api3('OptionGroup', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function option_group_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'id' => '1',
'name' => 'preferred_communication_method',
'title' => 'Preferred Communication Method',
'is_reserved' => '1',
'is_active' => '1',
'is_locked' => 0,
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function option_value_get_example() {
- $params = array(
+ $params = [
'option_group_id' => 1,
- );
+ ];
try{
$result = civicrm_api3('OptionValue', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function option_value_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 5,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'id' => '1',
'option_group_id' => '1',
'label' => 'Phone',
'is_optgroup' => 0,
'is_reserved' => 0,
'is_active' => '1',
- ),
- '2' => array(
+ ],
+ '2' => [
'id' => '2',
'option_group_id' => '1',
'label' => 'Email',
'is_optgroup' => 0,
'is_reserved' => 0,
'is_active' => '1',
- ),
- '3' => array(
+ ],
+ '3' => [
'id' => '3',
'option_group_id' => '1',
'label' => 'Postal Mail',
'is_optgroup' => 0,
'is_reserved' => 0,
'is_active' => '1',
- ),
- '4' => array(
+ ],
+ '4' => [
'id' => '4',
'option_group_id' => '1',
'label' => 'SMS',
'is_optgroup' => 0,
'is_reserved' => 0,
'is_active' => '1',
- ),
- '5' => array(
+ ],
+ '5' => [
'id' => '5',
'option_group_id' => '1',
'label' => 'Fax',
'is_optgroup' => 0,
'is_reserved' => 0,
'is_active' => '1',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function option_value_getsingle_example() {
- $params = array(
+ $params = [
'option_group_id' => 1,
- 'options' => array(
+ 'options' => [
'sort' => 'label DESC',
'limit' => 1,
- ),
- );
+ ],
+ ];
try{
$result = civicrm_api3('OptionValue', 'getsingle', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function option_value_getsingle_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'id' => '4',
'option_group_id' => '1',
'label' => 'SMS',
'is_optgroup' => 0,
'is_reserved' => 0,
'is_active' => '1',
- );
+ ];
return $expectedResult;
}
* API result array
*/
function order_cancel_example() {
- $params = array(
+ $params = [
'contribution_id' => 1,
- );
+ ];
try{
$result = civicrm_api3('Order', 'cancel', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function order_cancel_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'id' => '1',
'contact_id' => '16',
'financial_type_id' => '1',
'tax_amount' => '',
'revenue_recognition_date' => '',
'contribution_type_id' => '1',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function order_create_example() {
- $params = array(
+ $params = [
'contact_id' => 8,
'receive_date' => '2010-01-20',
'total_amount' => 200,
'financial_type_id' => 1,
'contribution_status_id' => 1,
- 'line_items' => array(
- '0' => array(
- 'line_item' => array(
- '0' => array(
+ 'line_items' => [
+ '0' => [
+ 'line_item' => [
+ '0' => [
'price_field_id' => '4',
'price_field_value_id' => '5',
'label' => 'Price Field 2',
'financial_type_id' => '4',
'entity_table' => 'civicrm_membership',
'membership_type_id' => 1,
- ),
- ),
- 'params' => array(
+ ],
+ ],
+ 'params' => [
'contact_id' => 8,
'membership_type_id' => 2,
'join_date' => '2006-01-21',
'source' => 'Payment',
'is_override' => 1,
'status_id' => 1,
- ),
- ),
- ),
- );
+ ],
+ ],
+ ],
+ ];
try{
$result = civicrm_api3('Order', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function order_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'id' => '1',
'contact_id' => '8',
'financial_type_id' => '1',
'tax_amount' => '',
'revenue_recognition_date' => '',
'contribution_type_id' => '1',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function order_create_example() {
- $params = array(
+ $params = [
'contact_id' => 11,
'receive_date' => '2010-01-20',
'total_amount' => 300,
'financial_type_id' => 1,
'contribution_status_id' => 1,
- 'line_items' => array(
- '0' => array(
- 'line_item' => array(
- '2' => array(
+ 'line_items' => [
+ '0' => [
+ 'line_item' => [
+ '2' => [
'price_field_id' => '2',
'price_field_value_id' => '2',
'label' => 'Price Field 1',
'line_total' => '100',
'financial_type_id' => '4',
'entity_table' => 'civicrm_participant',
- ),
- '3' => array(
+ ],
+ '3' => [
'price_field_id' => '2',
'price_field_value_id' => '3',
'label' => 'Price Field 2',
'line_total' => '200',
'financial_type_id' => '4',
'entity_table' => 'civicrm_participant',
- ),
- ),
- 'params' => array(
+ ],
+ ],
+ 'params' => [
'contact_id' => 11,
'event_id' => 1,
'status_id' => 1,
'role_id' => 1,
'register_date' => '2007-07-21 00:00:00',
'source' => 'Online Event Registration: API Testing',
- ),
- ),
- ),
- );
+ ],
+ ],
+ ],
+ ];
try{
$result = civicrm_api3('Order', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function order_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'id' => '1',
'contact_id' => '11',
'financial_type_id' => '1',
'tax_amount' => '',
'revenue_recognition_date' => '',
'contribution_type_id' => '1',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function order_delete_example() {
- $params = array(
+ $params = [
'contribution_id' => 1,
- );
+ ];
try{
$result = civicrm_api3('Order', 'delete', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function order_delete_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
+ 'values' => [
'1' => 1,
- ),
- );
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function order_get_example() {
- $params = array(
+ $params = [
'contribution_id' => 1,
- );
+ ];
try{
$result = civicrm_api3('Order', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function order_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'contact_id' => '3',
'contact_type' => 'Individual',
'contact_sub_type' => '',
'check_number' => '',
'id' => '1',
'contribution_type_id' => '1',
- 'line_items' => array(
- '0' => array(
+ 'line_items' => [
+ '0' => [
'id' => '1',
'entity_table' => 'civicrm_contribution',
'entity_id' => '1',
'financial_type_id' => '1',
'non_deductible_amount' => '0.00',
'contribution_type_id' => '1',
- ),
- ),
- ),
- ),
- );
+ ],
+ ],
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function participant_create_example() {
- $params = array(
+ $params = [
'contact_id' => 2,
'event_id' => 2,
'status_id' => 1,
'register_date' => '2007-07-21 00:00:00',
'source' => 'Online Event Registration: API Testing',
'custom_1' => 'custom string',
- );
+ ];
try{
$result = civicrm_api3('Participant', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function participant_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 4,
- 'values' => array(
- '4' => array(
+ 'values' => [
+ '4' => [
'id' => '4',
'contact_id' => '2',
'event_id' => '2',
'cart_id' => '',
'must_wait' => '',
'transferred_to_contact_id' => '',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function participant_get_example() {
- $params = array(
+ $params = [
'id' => 1,
- );
+ ];
try{
$result = civicrm_api3('Participant', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function participant_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'contact_id' => '2',
'contact_type' => 'Individual',
'contact_sub_type' => '',
'participant_discount_name' => '',
'participant_campaign_id' => '',
'id' => '1',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function participant_get_example() {
- $params = array(
+ $params = [
'contact_id' => 4,
'api.participant.delete' => 1,
- );
+ ];
try{
$result = civicrm_api3('Participant', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function participant_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 2,
- 'values' => array(
- '2' => array(
+ 'values' => [
+ '2' => [
'contact_id' => '4',
'contact_type' => 'Individual',
'contact_sub_type' => '',
'participant_discount_name' => '',
'participant_campaign_id' => '',
'id' => '2',
- 'api.participant.delete' => array(
+ 'api.participant.delete' => [
'is_error' => 0,
'version' => 3,
'count' => 1,
'values' => 1,
- ),
- ),
- '3' => array(
+ ],
+ ],
+ '3' => [
'contact_id' => '4',
'contact_type' => 'Individual',
'contact_sub_type' => '',
'participant_discount_name' => '',
'participant_campaign_id' => '',
'id' => '3',
- 'api.participant.delete' => array(
+ 'api.participant.delete' => [
'is_error' => 0,
'version' => 3,
'count' => 1,
'values' => 1,
- ),
- ),
- ),
- );
+ ],
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function participant_get_example() {
- $params = array(
+ $params = [
'id' => 1,
'api.event.get' => 1,
- );
+ ];
try{
$result = civicrm_api3('Participant', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function participant_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'contact_id' => '2',
'contact_type' => 'Individual',
'contact_sub_type' => '',
'participant_discount_name' => '',
'participant_campaign_id' => '',
'id' => '1',
- 'api.event.get' => array(
+ 'api.event.get' => [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 7,
- 'values' => array(
- '0' => array(
+ 'values' => [
+ '0' => [
'id' => '7',
'title' => 'Annual CiviCRM meet',
'event_title' => 'Annual CiviCRM meet',
'is_share' => '1',
'is_confirm_enabled' => '1',
'is_billing_required' => 0,
- ),
- ),
- ),
- ),
- ),
- );
+ ],
+ ],
+ ],
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function participant_payment_create_example() {
- $params = array(
+ $params = [
'participant_id' => 13,
'contribution_id' => 1,
- );
+ ];
try{
$result = civicrm_api3('ParticipantPayment', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function participant_payment_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'id' => '1',
'participant_id' => '13',
'contribution_id' => '1',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function participant_payment_delete_example() {
- $params = array(
+ $params = [
'id' => 5,
- );
+ ];
try{
$result = civicrm_api3('ParticipantPayment', 'delete', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function participant_payment_delete_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'values' => 1,
- );
+ ];
return $expectedResult;
}
* API result array
*/
function participant_payment_get_example() {
- $params = array(
+ $params = [
'participant_id' => 64,
'contribution_id' => 6,
- );
+ ];
try{
$result = civicrm_api3('ParticipantPayment', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function participant_payment_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 6,
- 'values' => array(
- '6' => array(
+ 'values' => [
+ '6' => [
'id' => '6',
'participant_id' => '64',
'contribution_id' => '6',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function participant_status_type_create_example() {
- $params = array(
+ $params = [
'name' => 'test status',
'label' => 'I am a test',
'class' => 'Positive',
'is_counted' => 1,
'visibility_id' => 1,
'weight' => 10,
- );
+ ];
try{
$result = civicrm_api3('ParticipantStatusType', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function participant_status_type_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 18,
- 'values' => array(
- '18' => array(
+ 'values' => [
+ '18' => [
'id' => '18',
'name' => 'test status',
'label' => 'I am a test',
'is_counted' => '1',
'weight' => '10',
'visibility_id' => '1',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function participant_status_type_delete_example() {
- $params = array(
+ $params = [
'id' => 19,
- );
+ ];
try{
$result = civicrm_api3('ParticipantStatusType', 'delete', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function participant_status_type_delete_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'values' => TRUE,
- );
+ ];
return $expectedResult;
}
* API result array
*/
function participant_status_type_get_example() {
- $params = array(
+ $params = [
'name' => 'test status',
'label' => 'I am a test',
'class' => 'Positive',
'is_counted' => 1,
'visibility_id' => 1,
'weight' => 10,
- );
+ ];
try{
$result = civicrm_api3('ParticipantStatusType', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function participant_status_type_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 18,
- 'values' => array(
- '18' => array(
+ 'values' => [
+ '18' => [
'id' => '18',
'name' => 'test status',
'label' => 'I am a test',
'is_counted' => '1',
'weight' => '10',
'visibility_id' => '1',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function payment_cancel_example() {
- $params = array(
+ $params = [
'id' => 2,
'check_permissions' => TRUE,
- );
+ ];
try{
$result = civicrm_api3('Payment', 'cancel', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function payment_cancel_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 3,
- 'values' => array(
- '3' => array(
+ 'values' => [
+ '3' => [
'id' => 3,
'from_financial_account_id' => '7',
'to_financial_account_id' => '6',
'trxn_result_code' => '',
'status_id' => '7',
'payment_processor_id' => '',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function payment_create_example() {
- $params = array(
+ $params = [
'contribution_id' => 1,
'total_amount' => 50,
- );
+ ];
try{
$result = civicrm_api3('Payment', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function payment_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 3,
- 'values' => array(
- '3' => array(
+ 'values' => [
+ '3' => [
'id' => '3',
'from_financial_account_id' => '7',
'to_financial_account_id' => '6',
'trxn_result_code' => '',
'status_id' => '1',
'payment_processor_id' => '',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function payment_create_example() {
- $params = array(
+ $params = [
'contribution_id' => 1,
'total_amount' => 50,
- 'line_item' => array(
- '0' => array(
+ 'line_item' => [
+ '0' => [
'1' => 10,
- ),
- '1' => array(
+ ],
+ '1' => [
'2' => 40,
- ),
- ),
- );
+ ],
+ ],
+ ];
try{
$result = civicrm_api3('Payment', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function payment_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 3,
- 'values' => array(
- '3' => array(
+ 'values' => [
+ '3' => [
'id' => '3',
'from_financial_account_id' => '7',
'to_financial_account_id' => '6',
'trxn_result_code' => '',
'status_id' => '1',
'payment_processor_id' => '',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function payment_delete_example() {
- $params = array(
+ $params = [
'id' => 2,
'check_permissions' => TRUE,
- );
+ ];
try{
$result = civicrm_api3('Payment', 'delete', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function payment_delete_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'values' => 1,
- );
+ ];
return $expectedResult;
}
* API result array
*/
function payment_get_example() {
- $params = array(
+ $params = [
'contribution_id' => 1,
'check_permissions' => TRUE,
- );
+ ];
try{
$result = civicrm_api3('Payment', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function payment_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'id' => '1',
'to_financial_account_id' => '6',
'trxn_date' => '2010-01-20 00:00:00',
'status_id' => '1',
'payment_instrument_id' => '4',
'contribution_id' => '1',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function payment_create_example() {
- $params = array(
+ $params = [
'contribution_id' => 1,
'total_amount' => 100,
'id' => 3,
'check_permissions' => TRUE,
- );
+ ];
try{
$result = civicrm_api3('Payment', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function payment_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 5,
- 'values' => array(
- '5' => array(
+ 'values' => [
+ '5' => [
'id' => '5',
'from_financial_account_id' => '7',
'to_financial_account_id' => '6',
'trxn_result_code' => '',
'status_id' => '1',
'payment_processor_id' => '',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function payment_processor_create_example() {
- $params = array(
+ $params = [
'name' => 'API Test PP',
'payment_processor_type_id' => 1,
'class_name' => 'CRM_Core_Payment_APITest',
'is_recur' => 0,
'domain_id' => 1,
- );
+ ];
try{
$result = civicrm_api3('PaymentProcessor', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function payment_processor_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 2,
- 'values' => array(
- '2' => array(
+ 'values' => [
+ '2' => [
'id' => '2',
'domain_id' => '1',
'name' => 'API Test PP',
'payment_type' => '1',
'payment_instrument_id' => '1',
'accepted_credit_cards' => '',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function payment_processor_delete_example() {
- $params = array(
+ $params = [
'id' => 2,
- );
+ ];
try{
$result = civicrm_api3('PaymentProcessor', 'delete', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function payment_processor_delete_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'values' => 1,
- );
+ ];
return $expectedResult;
}
* API result array
*/
function payment_processor_type_create_example() {
- $params = array(
+ $params = [
'sequential' => 1,
'name' => 'API_Test_PP',
'title' => 'API Test Payment Processor',
'class_name' => 'CRM_Core_Payment_APITest',
'billing_mode' => 'form',
'is_recur' => 0,
- );
+ ];
try{
$result = civicrm_api3('PaymentProcessorType', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function payment_processor_type_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 13,
- 'values' => array(
- '0' => array(
+ 'values' => [
+ '0' => [
'id' => '13',
'name' => 'API_Test_PP',
'title' => 'API Test Payment Processor',
'is_recur' => 0,
'payment_type' => '',
'payment_instrument_id' => '1',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function payment_processor_type_delete_example() {
- $params = array(
+ $params = [
'id' => 15,
- );
+ ];
try{
$result = civicrm_api3('PaymentProcessorType', 'delete', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function payment_processor_type_delete_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'values' => TRUE,
- );
+ ];
return $expectedResult;
}
* API result array
*/
function payment_token_create_example() {
- $params = array(
+ $params = [
'token' => 'fancy-token-xxxx',
'contact_id' => 3,
'created_id' => 3,
'payment_processor_id' => 1,
- );
+ ];
try{
$result = civicrm_api3('PaymentToken', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function payment_token_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'id' => '1',
'contact_id' => '3',
'payment_processor_id' => '1',
'billing_last_name' => '',
'masked_account_number' => '',
'ip_address' => '',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function payment_token_delete_example() {
- $params = array(
+ $params = [
'id' => 3,
- );
+ ];
try{
$result = civicrm_api3('PaymentToken', 'delete', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function payment_token_delete_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'values' => 1,
- );
+ ];
return $expectedResult;
}
* API result array
*/
function payment_token_get_example() {
- $params = array(
+ $params = [
'token' => 'fancy-token-xxxx',
'contact_id' => 4,
'created_id' => 4,
'payment_processor_id' => 2,
- );
+ ];
try{
$result = civicrm_api3('PaymentToken', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function payment_token_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 2,
- 'values' => array(
- '2' => array(
+ 'values' => [
+ '2' => [
'id' => '2',
'contact_id' => '4',
'payment_processor_id' => '2',
'token' => 'fancy-token-xxxx',
'created_date' => '2013-07-28 08:49:19',
'created_id' => '4',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function pcp_create_example() {
- $params = array(
+ $params = [
'title' => 'Pcp title',
'contact_id' => 1,
'page_id' => 1,
'pcp_block_id' => 1,
- );
+ ];
try{
$result = civicrm_api3('Pcp', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function pcp_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'id' => '1',
'contact_id' => '1',
'status_id' => 0,
'currency' => 'USD',
'is_active' => '',
'is_notify' => '',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function phone_create_example() {
- $params = array(
+ $params = [
'contact_id' => 3,
'location_type_id' => 6,
'phone' => '(123) 456-7890',
'is_primary' => 1,
'phone_type_id' => 1,
- );
+ ];
try{
$result = civicrm_api3('Phone', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function phone_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 2,
- 'values' => array(
- '2' => array(
+ 'values' => [
+ '2' => [
'id' => '2',
'contact_id' => '3',
'location_type_id' => '6',
'phone_ext' => '',
'phone_numeric' => '',
'phone_type_id' => '1',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function phone_delete_example() {
- $params = array(
+ $params = [
'id' => 3,
- );
+ ];
try{
$result = civicrm_api3('Phone', 'delete', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function phone_delete_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'values' => 1,
- );
+ ];
return $expectedResult;
}
* API result array
*/
function phone_get_example() {
- $params = array(
+ $params = [
'contact_id' => 7,
'phone' => '(123) 456-7890',
- );
+ ];
try{
$result = civicrm_api3('Phone', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function phone_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 4,
- 'values' => array(
- '4' => array(
+ 'values' => [
+ '4' => [
'id' => '4',
'contact_id' => '7',
'location_type_id' => '10',
'phone' => '(123) 456-7890',
'phone_numeric' => '1234567890',
'phone_type_id' => '1',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function phone_getoptions_example() {
- $params = array(
+ $params = [
'field' => 'phone_type_id',
- );
+ ];
try{
$result = civicrm_api3('Phone', 'getoptions', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function phone_getoptions_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 5,
- 'values' => array(
+ 'values' => [
'1' => 'Phone',
'2' => 'Mobile',
'3' => 'Fax',
'4' => 'Pager',
'5' => 'Voicemail',
- ),
- );
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function pledge_create_example() {
- $params = array(
+ $params = [
'contact_id' => 11,
'pledge_create_date' => '20170207',
'start_date' => '20170207',
'frequency_day' => 15,
'installments' => 5,
'sequential' => 1,
- );
+ ];
try{
$result = civicrm_api3('Pledge', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function pledge_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '0' => array(
+ 'values' => [
+ '0' => [
'id' => '1',
'contact_id' => '11',
'financial_type_id' => '1',
'status_id' => '2',
'is_test' => '',
'campaign_id' => '',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function pledge_delete_example() {
- $params = array(
+ $params = [
'id' => 1,
- );
+ ];
try{
$result = civicrm_api3('Pledge', 'delete', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function pledge_delete_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 'id',
- 'values' => array(
+ 'values' => [
'id' => 1,
- ),
- );
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function pledge_get_example() {
- $params = array(
+ $params = [
'pledge_id' => 1,
- );
+ ];
try{
$result = civicrm_api3('Pledge', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function pledge_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'contact_id' => '5',
'contact_type' => 'Individual',
'contact_sub_type' => '',
'pledge_campaign_id' => '',
'pledge_currency' => 'USD',
'id' => '1',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function pledge_get_example() {
- $params = array(
+ $params = [
'pledge_start_date_high' => '20170205024740',
- );
+ ];
try{
$result = civicrm_api3('Pledge', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function pledge_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 2,
- 'values' => array(
- '2' => array(
+ 'values' => [
+ '2' => [
'contact_id' => '8',
'contact_type' => 'Individual',
'contact_sub_type' => '',
'pledge_campaign_id' => '',
'pledge_currency' => 'USD',
'id' => '2',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function pledge_payment_create_example() {
- $params = array(
+ $params = [
'contact_id' => 1,
'pledge_id' => 1,
'contribution_id' => 1,
'status_id' => 1,
'actual_amount' => 20,
- );
+ ];
try{
$result = civicrm_api3('PledgePayment', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function pledge_payment_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'id' => '1',
'pledge_id' => '1',
'contribution_id' => '1',
'reminder_date' => '',
'reminder_count' => '',
'status_id' => '1',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function pledge_payment_delete_example() {
- $params = array(
+ $params = [
'id' => 1,
- );
+ ];
try{
$result = civicrm_api3('PledgePayment', 'delete', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function pledge_payment_delete_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 'id',
- 'values' => array(
+ 'values' => [
'id' => 1,
- ),
- );
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function pledge_payment_get_example() {
- $params = array();
+ $params = [];
try{
$result = civicrm_api3('PledgePayment', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function pledge_payment_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 5,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'id' => '1',
'pledge_id' => '1',
'scheduled_amount' => '20.00',
'scheduled_date' => '20130728085413',
'reminder_count' => 0,
'status_id' => '2',
- ),
- '2' => array(
+ ],
+ '2' => [
'id' => '2',
'pledge_id' => '1',
'scheduled_amount' => '20.00',
'scheduled_date' => '20130728085413',
'reminder_count' => 0,
'status_id' => '2',
- ),
- '3' => array(
+ ],
+ '3' => [
'id' => '3',
'pledge_id' => '1',
'scheduled_amount' => '20.00',
'scheduled_date' => '20130728085413',
'reminder_count' => 0,
'status_id' => '2',
- ),
- '4' => array(
+ ],
+ '4' => [
'id' => '4',
'pledge_id' => '1',
'scheduled_amount' => '20.00',
'scheduled_date' => '20130728085413',
'reminder_count' => 0,
'status_id' => '2',
- ),
- '5' => array(
+ ],
+ '5' => [
'id' => '5',
'pledge_id' => '1',
'scheduled_amount' => '20.00',
'scheduled_date' => '20130728085413',
'reminder_count' => 0,
'status_id' => '2',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function pledge_payment_update_example() {
- $params = array(
+ $params = [
'id' => 1,
'status_id' => 1,
- );
+ ];
try{
$result = civicrm_api3('PledgePayment', 'update', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function pledge_payment_update_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'id' => '1',
'pledge_id' => '1',
'contribution_id' => '1',
'reminder_date' => '',
'reminder_count' => 0,
'status_id' => '1',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function price_field_create_example() {
- $params = array(
+ $params = [
'price_set_id' => 3,
'name' => 'grassvariety',
'label' => 'Grass Variety',
'html_type' => 'Text',
'is_enter_qty' => 1,
'is_active' => 1,
- );
+ ];
try{
$result = civicrm_api3('PriceField', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function price_field_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 2,
- 'values' => array(
- '2' => array(
+ 'values' => [
+ '2' => [
'id' => '2',
'price_set_id' => '3',
'name' => 'grassvariety',
'expire_on' => '',
'javascript' => '',
'visibility_id' => '',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function price_field_delete_example() {
- $params = array(
+ $params = [
'id' => 4,
- );
+ ];
try{
$result = civicrm_api3('PriceField', 'delete', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function price_field_delete_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'values' => 1,
- );
+ ];
return $expectedResult;
}
* API result array
*/
function price_field_get_example() {
- $params = array(
+ $params = [
'name' => 'contribution_amount',
- );
+ ];
try{
$result = civicrm_api3('PriceField', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function price_field_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'id' => '1',
'price_set_id' => '1',
'name' => 'contribution_amount',
'is_active' => '1',
'is_required' => '1',
'visibility_id' => '1',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function price_field_value_create_example() {
- $params = array(
+ $params = [
'price_field_id' => 13,
'membership_type_id' => 5,
'name' => 'memType1',
'membership_num_terms' => 2,
'is_active' => 1,
'financial_type_id' => 2,
- );
+ ];
try{
$result = civicrm_api3('PriceFieldValue', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function price_field_value_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 10,
- 'values' => array(
- '10' => array(
+ 'values' => [
+ '10' => [
'id' => '10',
'price_field_id' => '13',
'name' => 'memType1',
'financial_type_id' => '2',
'non_deductible_amount' => '',
'contribution_type_id' => '2',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function price_field_value_delete_example() {
- $params = array(
+ $params = [
'id' => 7,
- );
+ ];
try{
$result = civicrm_api3('PriceFieldValue', 'delete', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function price_field_value_delete_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'values' => 1,
- );
+ ];
return $expectedResult;
}
* API result array
*/
function price_field_value_get_example() {
- $params = array(
+ $params = [
'name' => 'contribution_amount',
- );
+ ];
try{
$result = civicrm_api3('PriceFieldValue', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function price_field_value_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'id' => '1',
'price_field_id' => '1',
'name' => 'contribution_amount',
'financial_type_id' => '1',
'non_deductible_amount' => '0.00',
'contribution_type_id' => '1',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function price_set_create_example() {
- $params = array(
+ $params = [
'entity_table' => 'civicrm_event',
'entity_id' => 1,
'name' => 'event price',
'title' => 'event price',
'extends' => 1,
- );
+ ];
try{
$result = civicrm_api3('PriceSet', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function price_set_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 18,
- 'values' => array(
- '18' => array(
+ 'values' => [
+ '18' => [
'id' => '18',
'domain_id' => '',
'name' => 'event price',
'is_quick_config' => '',
'is_reserved' => '',
'min_amount' => '',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function price_set_delete_example() {
- $params = array(
+ $params = [
'id' => 19,
- );
+ ];
try{
$result = civicrm_api3('PriceSet', 'delete', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function price_set_delete_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'values' => 1,
- );
+ ];
return $expectedResult;
}
* API result array
*/
function price_set_get_example() {
- $params = array(
+ $params = [
'name' => 'default_contribution_amount',
- );
+ ];
try{
$result = civicrm_api3('PriceSet', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function price_set_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'id' => '1',
'name' => 'default_contribution_amount',
'title' => 'Contribution Amount',
'is_quick_config' => '1',
'is_reserved' => '1',
'min_amount' => 0,
- 'entity' => array(),
- ),
- ),
- );
+ 'entity' => [],
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function profile_apply_example() {
- $params = array(
+ $params = [
'profile_id' => 31,
'contact_id' => 3,
'first_name' => 'abc2',
'phone-1-1' => '022 321 826',
'country-1' => '1013',
'state_province-1' => '1000',
- );
+ ];
try{
$result = civicrm_api3('Profile', 'apply', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function profile_apply_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 11,
- 'values' => array(
+ 'values' => [
'contact_type' => 'Individual',
'contact_sub_type' => '',
'contact_id' => 3,
'profile_id' => 31,
'first_name' => 'abc2',
'last_name' => 'xyz2',
- 'email' => array(
- '1' => array(
+ 'email' => [
+ '1' => [
'location_type_id' => '1',
'is_primary' => 1,
'email' => 'abc2.xyz2@gmail.com',
- ),
- ),
- 'phone' => array(
- '2' => array(
+ ],
+ ],
+ 'phone' => [
+ '2' => [
'location_type_id' => '1',
'is_primary' => 1,
'phone_type_id' => '1',
'phone' => '022 321 826',
- ),
- ),
- 'address' => array(
- '1' => array(
+ ],
+ ],
+ 'address' => [
+ '1' => [
'location_type_id' => '1',
'is_primary' => 1,
'country_id' => '1013',
'state_province_id' => '1000',
- ),
- ),
- ),
- );
+ ],
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function profile_get_example() {
- $params = array(
- 'profile_id' => array(
+ $params = [
+ 'profile_id' => [
'0' => 15,
'1' => 1,
'2' => 'Billing',
- ),
+ ],
'contact_id' => 3,
- );
+ ];
try{
$result = civicrm_api3('Profile', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function profile_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 3,
- 'values' => array(
- '15' => array(
+ 'values' => [
+ '15' => [
'postal_code-1' => '90210',
'state_province-1' => '1021',
'country-1' => '1228',
'last_name' => 'xyz1',
'first_name' => 'abc1',
'email-primary' => 'abc1.xyz1@yahoo.com',
- ),
- '1' => array(
+ ],
+ '1' => [
'first_name' => 'abc1',
'last_name' => 'xyz1',
'street_address-1' => '5 Saint Helier St',
'postal_code-1' => '90210',
'country-1' => '1228',
'state_province-1' => '1021',
- ),
- 'Billing' => array(
+ ],
+ 'Billing' => [
'billing_first_name' => 'abc1',
'billing_middle_name' => 'J.',
'billing_last_name' => 'xyz1',
'billing_postal_code-5' => '90210',
'billing-email-5' => 'abc1.xyz1@yahoo.com',
'email-5' => 'abc1.xyz1@yahoo.com',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function profile_getfields_example() {
- $params = array(
+ $params = [
'action' => 'submit',
'profile_id' => 27,
- );
+ ];
try{
$result = civicrm_api3('Profile', 'getfields', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function profile_getfields_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 9,
- 'values' => array(
- 'custom_1' => array(
+ 'values' => [
+ 'custom_1' => [
'label' => '_addCustomFieldToProfile',
'groupTitle' => '_addCustomFie',
'data_type' => 'String',
'help_post' => '',
'entity' => 'contact',
'weight' => '1',
- 'api.aliases' => array(),
- ),
- 'postal_code-1' => array(
+ 'api.aliases' => [],
+ ],
+ 'postal_code-1' => [
'name' => 'postal_code',
'type' => 2,
'title' => 'State Province',
'table_name' => 'civicrm_address',
'entity' => 'address',
'bao' => 'CRM_Core_BAO_Address',
- 'html' => array(
+ 'html' => [
'type' => 'Text',
'maxlength' => 64,
'size' => 6,
- ),
+ ],
'api.required' => 0,
'help_pre' => '',
'help_post' => '',
'weight' => '2',
- 'api.aliases' => array(),
- ),
- 'state_province-1' => array(
+ 'api.aliases' => [],
+ ],
+ 'state_province-1' => [
'name' => 'state_province_id',
'type' => 1,
'title' => 'State Province',
'entity' => 'address',
'bao' => 'CRM_Core_BAO_Address',
'FKClassName' => 'CRM_Core_DAO_StateProvince',
- 'html' => array(
+ 'html' => [
'type' => 'ChainSelect',
'size' => 6,
'maxlength' => 14,
- ),
- 'pseudoconstant' => array(
+ ],
+ 'pseudoconstant' => [
'table' => 'civicrm_state_province',
'keyColumn' => 'id',
'labelColumn' => 'name',
- ),
+ ],
'FKApiName' => 'StateProvince',
'api.required' => '1',
'help_pre' => '',
'help_post' => '',
'weight' => '3',
- 'api.aliases' => array(),
- ),
- 'country-1' => array(
+ 'api.aliases' => [],
+ ],
+ 'country-1' => [
'name' => 'country_id',
'type' => 1,
'title' => 'Country',
'entity' => 'address',
'bao' => 'CRM_Core_BAO_Address',
'FKClassName' => 'CRM_Core_DAO_Country',
- 'html' => array(
+ 'html' => [
'type' => 'Select',
'size' => 6,
'maxlength' => 14,
- ),
- 'pseudoconstant' => array(
+ ],
+ 'pseudoconstant' => [
'table' => 'civicrm_country',
'keyColumn' => 'id',
'labelColumn' => 'name',
'nameColumn' => 'iso_code',
- ),
+ ],
'FKApiName' => 'Country',
'api.required' => '1',
'help_pre' => '',
'help_post' => '',
'weight' => '4',
- 'api.aliases' => array(),
- ),
- 'phone-1-1' => array(
+ 'api.aliases' => [],
+ ],
+ 'phone-1-1' => [
'name' => 'phone',
'type' => 2,
'title' => 'Phone',
'table_name' => 'civicrm_phone',
'entity' => 'phone',
'bao' => 'CRM_Core_BAO_Phone',
- 'html' => array(
+ 'html' => [
'type' => 'Text',
'maxlength' => 32,
'size' => 20,
- ),
+ ],
'api.required' => '1',
'help_pre' => '',
'help_post' => '',
'weight' => '5',
- 'api.aliases' => array(),
- ),
- 'email-primary' => array(
+ 'api.aliases' => [],
+ ],
+ 'email-primary' => [
'name' => 'email',
'type' => 2,
'title' => 'Email',
'table_name' => 'civicrm_email',
'entity' => 'email',
'bao' => 'CRM_Core_BAO_Email',
- 'html' => array(
+ 'html' => [
'type' => 'Text',
'maxlength' => 254,
'size' => 30,
- ),
+ ],
'api.required' => '1',
'help_pre' => '',
'help_post' => '',
'weight' => '6',
- 'api.aliases' => array(
+ 'api.aliases' => [
'0' => 'email-Primary',
- ),
- ),
- 'last_name' => array(
+ ],
+ ],
+ 'last_name' => [
'name' => 'last_name',
'type' => 2,
'title' => 'Last Name',
'table_name' => 'civicrm_contact',
'entity' => 'contact',
'bao' => 'CRM_Contact_BAO_Contact',
- 'html' => array(
+ 'html' => [
'type' => 'Text',
'maxlength' => 64,
'size' => 30,
- ),
+ ],
'api.required' => '1',
'help_pre' => '',
'help_post' => '',
'weight' => '7',
- 'api.aliases' => array(),
- ),
- 'first_name' => array(
+ 'api.aliases' => [],
+ ],
+ 'first_name' => [
'name' => 'first_name',
'type' => 2,
'title' => 'First Name',
'table_name' => 'civicrm_contact',
'entity' => 'contact',
'bao' => 'CRM_Contact_BAO_Contact',
- 'html' => array(
+ 'html' => [
'type' => 'Text',
'maxlength' => 64,
'size' => 30,
- ),
+ ],
'api.required' => '1',
'help_pre' => '',
'help_post' => '',
'weight' => '8',
- 'api.aliases' => array(),
- ),
- 'profile_id' => array(
+ 'api.aliases' => [],
+ ],
+ 'profile_id' => [
'api.required' => TRUE,
'title' => 'Profile ID',
'name' => 'profile_id',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function profile_submit_example() {
- $params = array(
+ $params = [
'profile_id' => 29,
'contact_id' => 3,
'first_name' => 'abc2',
'phone-1-1' => '022 321 826',
'country-1' => '1013',
'state_province-1' => '1000',
- );
+ ];
try{
$result = civicrm_api3('Profile', 'submit', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function profile_submit_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 3,
- 'values' => array(
- '3' => array(
+ 'values' => [
+ '3' => [
'id' => '3',
'contact_type' => 'Individual',
'contact_sub_type' => '',
'user_unique_id' => '',
'created_date' => '2013-07-28 08:49:19',
'modified_date' => '2012-11-14 16:02:35',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function relationship_get_example() {
- $params = array(
- 'relationship_type_id' => array(
- 'BETWEEN' => array(
+ $params = [
+ 'relationship_type_id' => [
+ 'BETWEEN' => [
'0' => 36,
'1' => 38,
- ),
- ),
- );
+ ],
+ ],
+ ];
try{
$result = civicrm_api3('Relationship', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function relationship_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 3,
- 'values' => array(
- '2' => array(
+ 'values' => [
+ '2' => [
'id' => '2',
'contact_id_a' => '99',
'contact_id_b' => '101',
'is_active' => '1',
'is_permission_a_b' => 0,
'is_permission_b_a' => 0,
- ),
- '3' => array(
+ ],
+ '3' => [
'id' => '3',
'contact_id_a' => '99',
'contact_id_b' => '101',
'is_active' => '1',
'is_permission_a_b' => 0,
'is_permission_b_a' => 0,
- ),
- '4' => array(
+ ],
+ '4' => [
'id' => '4',
'contact_id_a' => '99',
'contact_id_b' => '101',
'is_active' => '1',
'is_permission_a_b' => 0,
'is_permission_b_a' => 0,
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function relationship_create_example() {
- $params = array(
+ $params = [
'contact_id_a' => 31,
'contact_id_b' => 33,
'relationship_type_id' => 18,
'end_date' => '2010-12-30',
'is_active' => 1,
'note' => 'note',
- );
+ ];
try{
$result = civicrm_api3('Relationship', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function relationship_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'id' => '1',
'contact_id_a' => '31',
'contact_id_b' => '33',
'is_permission_a_b' => 0,
'is_permission_b_a' => 0,
'case_id' => '',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function relationship_delete_example() {
- $params = array(
+ $params = [
'id' => 1,
- );
+ ];
try{
$result = civicrm_api3('Relationship', 'delete', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function relationship_delete_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'values' => 'Deleted relationship successfully',
- );
+ ];
return $expectedResult;
}
* API result array
*/
function relationship_get_example() {
- $params = array(
+ $params = [
'id' => 1,
- );
+ ];
try{
$result = civicrm_api3('Relationship', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function relationship_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'id' => '1',
'contact_id_a' => '47',
'contact_id_b' => '49',
'is_permission_b_a' => 0,
'custom_1' => 'custom string',
'custom_1_1' => 'custom string',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function relationship_get_example() {
- $params = array(
- 'relationship_type_id' => array(
- 'IN' => array(
+ $params = [
+ 'relationship_type_id' => [
+ 'IN' => [
'0' => 36,
'1' => 37,
- ),
- ),
- );
+ ],
+ ],
+ ];
try{
$result = civicrm_api3('Relationship', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function relationship_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 2,
- 'values' => array(
- '2' => array(
+ 'values' => [
+ '2' => [
'id' => '2',
'contact_id_a' => '99',
'contact_id_b' => '101',
'is_active' => '1',
'is_permission_a_b' => 0,
'is_permission_b_a' => 0,
- ),
- '3' => array(
+ ],
+ '3' => [
'id' => '3',
'contact_id_a' => '99',
'contact_id_b' => '101',
'is_active' => '1',
'is_permission_a_b' => 0,
'is_permission_b_a' => 0,
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function relationship_get_example() {
- $params = array(
- 'relationship_type_id' => array(
- 'NOT BETWEEN' => array(
+ $params = [
+ 'relationship_type_id' => [
+ 'NOT BETWEEN' => [
'0' => 36,
'1' => 38,
- ),
- ),
- );
+ ],
+ ],
+ ];
try{
$result = civicrm_api3('Relationship', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function relationship_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'id' => '1',
'contact_id_a' => '99',
'contact_id_b' => '101',
'is_active' => '1',
'is_permission_a_b' => 0,
'is_permission_b_a' => 0,
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function relationship_get_example() {
- $params = array(
- 'relationship_type_id' => array(
- 'NOT IN' => array(
+ $params = [
+ 'relationship_type_id' => [
+ 'NOT IN' => [
'0' => 36,
'1' => 37,
- ),
- ),
- );
+ ],
+ ],
+ ];
try{
$result = civicrm_api3('Relationship', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function relationship_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 2,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'id' => '1',
'contact_id_a' => '99',
'contact_id_b' => '101',
'is_active' => '1',
'is_permission_a_b' => 0,
'is_permission_b_a' => 0,
- ),
- '4' => array(
+ ],
+ '4' => [
'id' => '4',
'contact_id_a' => '99',
'contact_id_b' => '101',
'is_active' => '1',
'is_permission_a_b' => 0,
'is_permission_b_a' => 0,
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function relationship_get_example() {
- $params = array(
- 'filters' => array(
+ $params = [
+ 'filters' => [
'is_current' => 1,
- ),
- );
+ ],
+ ];
try{
$result = civicrm_api3('Relationship', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function relationship_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 2,
- 'values' => array(
- '2' => array(
+ 'values' => [
+ '2' => [
'id' => '2',
'contact_id_a' => '95',
'contact_id_b' => '97',
'is_active' => '1',
'is_permission_a_b' => 0,
'is_permission_b_a' => 0,
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function relationship_type_create_example() {
- $params = array(
+ $params = [
'name_a_b' => 'Relation 1 for relationship type create',
'name_b_a' => 'Relation 2 for relationship type create',
'contact_type_a' => 'Individual',
'is_reserved' => 1,
'is_active' => 1,
'sequential' => 1,
- );
+ ];
try{
$result = civicrm_api3('RelationshipType', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function relationship_type_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '0' => array(
+ 'values' => [
+ '0' => [
'id' => '1',
'name_a_b' => 'Relation 1 for relationship type create',
'label_a_b' => 'Relation 1 for relationship type create',
'contact_sub_type_b' => '',
'is_reserved' => '1',
'is_active' => '1',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function relationship_type_delete_example() {
- $params = array(
+ $params = [
'id' => 1,
- );
+ ];
try{
$result = civicrm_api3('RelationshipType', 'delete', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function relationship_type_delete_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'values' => 1,
- );
+ ];
return $expectedResult;
}
* API result array
*/
function report_template_getrows_example() {
- $params = array(
+ $params = [
'report_id' => 'contact/summary',
- 'options' => array(
- 'metadata' => array(
+ 'options' => [
+ 'metadata' => [
'0' => 'labels',
'1' => 'title',
- ),
- ),
- );
+ ],
+ ],
+ ];
try{
$result = civicrm_api3('ReportTemplate', 'getrows', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function report_template_getrows_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 2,
- 'values' => array(
- '0' => array(
+ 'values' => [
+ '0' => [
'civicrm_contact_sort_name' => 'Second Domain',
'civicrm_contact_id' => '2',
'civicrm_contact_sort_name_link' => '/index.php?q=civicrm/report/contact/detail&reset=1&force=1&id_op=eq&id_value=2',
'civicrm_contact_sort_name_hover' => 'View Contact Detail Report for this contact',
- ),
- '1' => array(
+ ],
+ '1' => [
'civicrm_contact_sort_name' => 'Unit Test Organization',
'civicrm_contact_id' => '1',
'civicrm_contact_sort_name_link' => '/index.php?q=civicrm/report/contact/detail&reset=1&force=1&id_op=eq&id_value=1',
'civicrm_contact_sort_name_hover' => 'View Contact Detail Report for this contact',
- ),
- ),
- 'metadata' => array(
+ ],
+ ],
+ 'metadata' => [
'title' => 'ERROR: Title is not Set',
- 'labels' => array(
+ 'labels' => [
'civicrm_contact_sort_name' => 'Contact Name',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function report_template_getstatistics_example() {
- $params = array(
+ $params = [
'report_id' => 'contribute/deferredrevenue',
- );
+ ];
try{
$result = civicrm_api3('ReportTemplate', 'getstatistics', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function report_template_getstatistics_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 0,
'values' => '',
- );
+ ];
return $expectedResult;
}
* API result array
*/
function saved_search_create_example() {
- $params = array(
- 'form_values' => array(
+ $params = [
+ 'form_values' => [
'relation_type_id' => '6_a_b',
'relation_target_name' => 'Default Organization',
- ),
- 'api.Group.create' => array(
+ ],
+ 'api.Group.create' => [
'name' => 'my_smartgroup',
'title' => 'my smartgroup',
'description' => 'Volunteers for the default organization',
'visibility' => 'User and User Admin Only',
'is_hidden' => 0,
'is_reserved' => 0,
- ),
- );
+ ],
+ ];
try{
$result = civicrm_api3('SavedSearch', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function saved_search_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 3,
- 'values' => array(
- '3' => array(
+ 'values' => [
+ '3' => [
'id' => '3',
- 'form_values' => array(
+ 'form_values' => [
'relation_type_id' => '6_a_b',
'relation_target_name' => 'Default Organization',
- ),
+ ],
'mapping_id' => '',
'search_custom_id' => '',
'where_clause' => '',
'select_tables' => '',
'where_tables' => '',
- 'api.Group.create' => array(
+ 'api.Group.create' => [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '0' => array(
+ 'values' => [
+ '0' => [
'id' => '1',
'name' => 'my_smartgroup',
'title' => 'my smartgroup',
'is_reserved' => 0,
'created_id' => '',
'modified_id' => '',
- ),
- ),
- ),
- ),
- ),
- );
+ ],
+ ],
+ ],
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function saved_search_delete_example() {
- $params = array(
+ $params = [
'id' => 4,
- );
+ ];
try{
$result = civicrm_api3('SavedSearch', 'delete', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function saved_search_delete_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'values' => 1,
- );
+ ];
return $expectedResult;
}
* API result array
*/
function saved_search_get_example() {
- $params = array(
+ $params = [
'id' => 2,
- );
+ ];
try{
$result = civicrm_api3('SavedSearch', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function saved_search_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 2,
- 'values' => array(
- '2' => array(
+ 'values' => [
+ '2' => [
'id' => '2',
- 'form_values' => array(
+ 'form_values' => [
'relation_type_id' => '6_a_b',
'relation_target_name' => 'Default Organization',
- ),
- ),
- ),
- );
+ ],
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function setting_create_example() {
- $params = array(
+ $params = [
'domain_id' => 2,
'uniq_email_per_site' => 1,
- );
+ ];
try{
$result = civicrm_api3('Setting', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function setting_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 2,
- 'values' => array(
- '2' => array(
+ 'values' => [
+ '2' => [
'uniq_email_per_site' => '1',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function setting_create_example() {
- $params = array(
+ $params = [
'domain_id' => 'all',
'uniq_email_per_site' => 1,
- );
+ ];
try{
$result = civicrm_api3('Setting', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function setting_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 3,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'uniq_email_per_site' => '1',
- ),
- '2' => array(
+ ],
+ '2' => [
'uniq_email_per_site' => '1',
- ),
- '3' => array(
+ ],
+ '3' => [
'uniq_email_per_site' => '1',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function setting_create_example() {
- $params = array(
+ $params = [
'uniq_email_per_site' => 1,
- );
+ ];
try{
$result = civicrm_api3('Setting', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function setting_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'uniq_email_per_site' => '1',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function setting_create_example() {
- $params = array(
- 'domain_id' => array(
+ $params = [
+ 'domain_id' => [
'0' => 1,
'1' => 3,
- ),
+ ],
'uniq_email_per_site' => 0,
- );
+ ];
try{
$result = civicrm_api3('Setting', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function setting_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 2,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'uniq_email_per_site' => 0,
- ),
- '3' => array(
+ ],
+ '3' => [
'uniq_email_per_site' => 0,
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function setting_get_example() {
- $params = array(
+ $params = [
'domain_id' => 2,
'return' => 'uniq_email_per_site',
- );
+ ];
try{
$result = civicrm_api3('Setting', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function setting_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 2,
- 'values' => array(
- '2' => array(
+ 'values' => [
+ '2' => [
'uniq_email_per_site' => '1',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function setting_get_example() {
- $params = array(
+ $params = [
'domain_id' => 'all',
'return' => 'uniq_email_per_site',
- );
+ ];
try{
$result = civicrm_api3('Setting', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function setting_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 3,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'uniq_email_per_site' => '1',
- ),
- '2' => array(
+ ],
+ '2' => [
'uniq_email_per_site' => '1',
- ),
- '3' => array(
+ ],
+ '3' => [
'uniq_email_per_site' => '1',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function setting_getdefaults_example() {
- $params = array(
+ $params = [
'name' => 'address_format',
- );
+ ];
try{
$result = civicrm_api3('Setting', 'getdefaults', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function setting_getdefaults_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'address_format' => '{contact.address_name}
{contact.street_address}
{contact.supplemental_address_1}
{contact.supplemental_address_3}
{contact.city}{, }{contact.state_province}{ }{contact.postal_code}
{contact.country}',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function setting_getfields_example() {
- $params = array();
+ $params = [];
try{
$result = civicrm_api3('Setting', 'getfields', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function setting_getfields_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 157,
- 'values' => array(
- 'address_standardization_provider' => array(
+ 'values' => [
+ 'address_standardization_provider' => [
'group_name' => 'Address Preferences',
'group' => 'address',
'name' => 'address_standardization_provider',
'is_contact' => 0,
'description' => '',
'help_text' => 'CiviCRM includes an optional plugin for interfacing with the United States Postal Services (USPS) Address Standardization web service. You must register to use the USPS service at https://www.usps.com/business/web-tools-apis/address-information.htm. If you are approved, they will provide you with a User ID and the URL for the service. Plugins for other address standardization services may be available from 3rd party developers. If installed, they will be included in the drop-down below. ',
- ),
- 'address_standardization_userid' => array(
+ ],
+ 'address_standardization_userid' => [
'group_name' => 'Address Preferences',
'group' => 'address',
'name' => 'address_standardization_userid',
'is_contact' => 0,
'description' => '',
'help_text' => '',
- ),
- 'address_standardization_url' => array(
+ ],
+ 'address_standardization_url' => [
'group_name' => 'Address Preferences',
'group' => 'address',
'name' => 'address_standardization_url',
'description' => '',
'help_text' => 'Web Service URL',
'validate_callback' => 'CRM_Utils_Rule::url',
- ),
- 'hideCountryMailingLabels' => array(
+ ],
+ 'hideCountryMailingLabels' => [
'group_name' => 'Address Preferences',
'group' => 'address',
'name' => 'hideCountryMailingLabels',
'is_contact' => 0,
'description' => 'Do not display the country field in mailing labels when the country is the same as that of the domain',
'help_text' => '',
- ),
- 'tag_unconfirmed' => array(
+ ],
+ 'tag_unconfirmed' => [
'group_name' => 'Campaign Preferences',
'group' => 'campaign',
'name' => 'tag_unconfirmed',
'is_contact' => 0,
'description' => '',
'help_text' => 'If set, new contacts that are created when signing a petition are assigned a tag of this name.',
- ),
- 'petition_contacts' => array(
+ ],
+ 'petition_contacts' => [
'group_name' => 'Campaign Preferences',
'group' => 'campaign',
'name' => 'petition_contacts',
'is_contact' => 0,
'description' => '',
'help_text' => 'If set, new contacts that are created when signing a petition are assigned a tag of this name.',
- ),
- 'civicaseRedactActivityEmail' => array(
+ ],
+ 'civicaseRedactActivityEmail' => [
'group_name' => 'CiviCRM Preferences',
'group' => 'core',
'name' => 'civicaseRedactActivityEmail',
'type' => 'String',
'quick_form_type' => 'Select',
'html_type' => 'Select',
- 'html_attributes' => array(),
+ 'html_attributes' => [],
'default' => 'default',
'add' => '4.7',
'title' => 'Redact Activity Email',
'is_domain' => 1,
'is_contact' => 0,
- 'pseudoconstant' => array(
+ 'pseudoconstant' => [
'callback' => 'CRM_Case_Info::getRedactOptions',
- ),
+ ],
'description' => 'Should activity emails be redacted? (Set \"Default\" to load setting from the legacy \"Settings.xml\" file.)',
'help_text' => '',
- ),
- 'civicaseAllowMultipleClients' => array(
+ ],
+ 'civicaseAllowMultipleClients' => [
'group_name' => 'CiviCRM Preferences',
'group' => 'core',
'name' => 'civicaseAllowMultipleClients',
'type' => 'String',
'quick_form_type' => 'Select',
'html_type' => 'Select',
- 'html_attributes' => array(),
+ 'html_attributes' => [],
'default' => 'default',
'add' => '4.7',
'title' => 'Allow Multiple Case Clients',
'is_domain' => 1,
'is_contact' => 0,
- 'pseudoconstant' => array(
+ 'pseudoconstant' => [
'callback' => 'CRM_Case_Info::getMultiClientOptions',
- ),
+ ],
'description' => 'How many clients may be associated with a given case? (Set \"Default\" to load setting from the legacy \"Settings.xml\" file.)',
'help_text' => '',
- ),
- 'civicaseNaturalActivityTypeSort' => array(
+ ],
+ 'civicaseNaturalActivityTypeSort' => [
'group_name' => 'CiviCRM Preferences',
'group' => 'core',
'name' => 'civicaseNaturalActivityTypeSort',
'type' => 'String',
'quick_form_type' => 'Select',
'html_type' => 'Select',
- 'html_attributes' => array(),
+ 'html_attributes' => [],
'default' => 'default',
'add' => '4.7',
'title' => 'Activity Type Sorting',
'is_domain' => 1,
'is_contact' => 0,
- 'pseudoconstant' => array(
+ 'pseudoconstant' => [
'callback' => 'CRM_Case_Info::getSortOptions',
- ),
+ ],
'description' => 'How to sort activity-types on the \"Manage Case\" screen? (Set \"Default\" to load setting from the legacy \"Settings.xml\" file.)',
'help_text' => '',
- ),
- 'cvv_backoffice_required' => array(
+ ],
+ 'cvv_backoffice_required' => [
'group_name' => 'Contribute Preferences',
'group' => 'contribute',
'name' => 'cvv_backoffice_required',
'is_contact' => 0,
'description' => 'Is the CVV code required for back office credit card transactions',
'help_text' => 'If set it back-office credit card transactions will required a cvv code. Leave as required unless you have a very strong reason to change',
- ),
- 'contribution_invoice_settings' => array(
+ ],
+ 'contribution_invoice_settings' => [
'group_name' => 'Contribute Preferences',
'group' => 'contribute',
'name' => 'contribution_invoice_settings',
'type' => 'Array',
- 'default' => array(
+ 'default' => [
'invoice_prefix' => 'INV_',
'credit_notes_prefix' => 'CN_',
'due_date' => '10',
'notes' => '',
'tax_term' => 'Sales Tax',
'tax_display_settings' => 'Inclusive',
- ),
+ ],
'add' => '4.7',
'title' => 'Contribution Invoice Settings',
'is_domain' => 1,
'is_contact' => 0,
'description' => '',
'help_text' => '',
- ),
- 'invoicing' => array(
+ ],
+ 'invoicing' => [
'group_name' => 'Contribute Preferences',
'group' => 'contribute',
'name' => 'invoicing',
'is_contact' => 0,
'description' => '',
'help_text' => '',
- ),
- 'acl_financial_type' => array(
+ ],
+ 'acl_financial_type' => [
'group_name' => 'Contribute Preferences',
'group' => 'contribute',
'name' => 'acl_financial_type',
'is_contact' => 0,
'description' => '',
'help_text' => '',
- ),
- 'deferred_revenue_enabled' => array(
+ ],
+ 'deferred_revenue_enabled' => [
'group_name' => 'Contribute Preferences',
'group' => 'contribute',
'name' => 'deferred_revenue_enabled',
'is_contact' => 0,
'description' => '',
'help_text' => '',
- ),
- 'default_invoice_page' => array(
+ ],
+ 'default_invoice_page' => [
'group_name' => 'Contribute Preferences',
'group' => 'contribute',
'name' => 'default_invoice_page',
'type' => 'Integer',
'quick_form_type' => 'Element',
'default' => '',
- 'pseudoconstant' => array(
+ 'pseudoconstant' => [
'name' => 'contributionPage',
- ),
+ ],
'html_type' => 'select',
'add' => '4.7',
'title' => 'Default invoice payment page',
'is_contact' => 0,
'description' => '',
'help_text' => '',
- ),
- 'always_post_to_accounts_receivable' => array(
+ ],
+ 'always_post_to_accounts_receivable' => [
'group_name' => 'Contribute Preferences',
'group' => 'contribute',
'name' => 'always_post_to_accounts_receivable',
'is_contact' => 0,
'description' => '',
'help_text' => '',
- ),
- 'update_contribution_on_membership_type_change' => array(
+ ],
+ 'update_contribution_on_membership_type_change' => [
'group_name' => 'Contribute Preferences',
'group' => 'contribute',
'name' => 'update_contribution_on_membership_type_change',
'is_contact' => 0,
'description' => 'Enabling this setting will update related contribution of membership(s) except if the membership is paid for with a recurring contribution.',
'help_text' => '',
- ),
- 'contact_view_options' => array(
+ ],
+ 'contact_view_options' => [
'group_name' => 'CiviCRM Preferences',
'group' => 'core',
'name' => 'contact_view_options',
'type' => 'String',
'html_type' => 'checkboxes',
- 'pseudoconstant' => array(
+ 'pseudoconstant' => [
'optionGroupName' => 'contact_view_options',
- ),
+ ],
'default' => '\ 11\ 12\ 13\ 14\ 15\ 16\ 17\ 18\ 19\ 110\ 111\ 113\ 1',
'add' => '4.1',
'title' => 'Viewing Contacts',
'is_contact' => 0,
'description' => '',
'help_text' => '',
- ),
- 'contact_edit_options' => array(
+ ],
+ 'contact_edit_options' => [
'group_name' => 'CiviCRM Preferences',
'group' => 'core',
'name' => 'contact_edit_options',
'type' => 'String',
'html_type' => 'checkboxes',
- 'pseudoconstant' => array(
+ 'pseudoconstant' => [
'optionGroupName' => 'contact_edit_options',
- ),
+ ],
'default' => '\ 11\ 12\ 13\ 14\ 15\ 16\ 17\ 18\ 19\ 111\ 112\ 114\ 115\ 116\ 117\ 1',
'add' => '4.1',
'title' => 'Editing Contacts',
'is_contact' => 0,
'description' => '',
'help_text' => '',
- ),
- 'advanced_search_options' => array(
+ ],
+ 'advanced_search_options' => [
'group_name' => 'CiviCRM Preferences',
'name' => 'advanced_search_options',
'type' => 'String',
'html_type' => 'checkboxes',
- 'pseudoconstant' => array(
+ 'pseudoconstant' => [
'optionGroupName' => 'advanced_search_options',
- ),
+ ],
'default' => '\ 11\ 12\ 13\ 14\ 15\ 16\ 17\ 18\ 19\ 110\ 111\ 112\ 113\ 115\ 116\ 117\ 118\ 119\ 1',
'add' => '4.1',
'title' => 'Contact Search',
'is_contact' => 0,
'description' => '',
'help_text' => '',
- ),
- 'user_dashboard_options' => array(
+ ],
+ 'user_dashboard_options' => [
'group_name' => 'CiviCRM Preferences',
'group' => 'core',
'name' => 'user_dashboard_options',
'type' => 'String',
'html_type' => 'checkboxes',
- 'pseudoconstant' => array(
+ 'pseudoconstant' => [
'optionGroupName' => 'user_dashboard_options',
- ),
+ ],
'default' => '\ 11\ 12\ 13\ 14\ 15\ 17\ 18\ 1',
'add' => '4.1',
'title' => 'Contact Dashboard',
'is_contact' => 0,
'description' => '',
'help_text' => '',
- ),
- 'address_options' => array(
+ ],
+ 'address_options' => [
'group_name' => 'CiviCRM Preferences',
'group' => 'core',
'name' => 'address_options',
'type' => 'String',
'html_type' => 'Text',
- 'pseudoconstant' => array(
+ 'pseudoconstant' => [
'optionGroupName' => 'address_options',
- ),
+ ],
'default' => '\ 11\ 12\ 13\ 14\ 15\ 16\ 18\ 19\ 110\ 111\ 1',
'add' => '4.1',
'title' => 'Addressing Options',
'is_contact' => 0,
'description' => '',
'help_text' => '',
- ),
- 'address_format' => array(
+ ],
+ 'address_format' => [
'group_name' => 'CiviCRM Preferences',
'group' => 'core',
'name' => 'address_format',
'is_contact' => 0,
'description' => '',
'help_text' => '',
- ),
- 'mailing_format' => array(
+ ],
+ 'mailing_format' => [
'group_name' => 'CiviCRM Preferences',
'group' => 'core',
'name' => 'mailing_format',
'is_contact' => 0,
'description' => '',
'help_text' => '',
- ),
- 'display_name_format' => array(
+ ],
+ 'display_name_format' => [
'group_name' => 'CiviCRM Preferences',
'group' => 'core',
'name' => 'display_name_format',
'is_contact' => 0,
'description' => '',
'help_text' => '',
- ),
- 'sort_name_format' => array(
+ ],
+ 'sort_name_format' => [
'group_name' => 'CiviCRM Preferences',
'group' => 'core',
'name' => 'sort_name_format',
'is_contact' => 0,
'description' => '',
'help_text' => '',
- ),
- 'remote_profile_submissions' => array(
+ ],
+ 'remote_profile_submissions' => [
'group_name' => 'CiviCRM Preferences',
'group' => 'core',
'name' => 'remote_profile_submissions',
'is_contact' => 0,
'description' => 'If enabled, CiviCRM will permit submissions from external sites to profiles. This is disabled by default to limit abuse.',
'help_text' => '',
- ),
- 'allow_alert_autodismissal' => array(
+ ],
+ 'allow_alert_autodismissal' => [
'group_name' => 'CiviCRM Preferences',
'group' => 'core',
'name' => 'allow_alert_autodismissal',
'is_contact' => 0,
'description' => 'If disabled, alert messages in CiviCRM will never be automatically dismissed after 10 seconds.',
'help_text' => '',
- ),
- 'editor_id' => array(
+ ],
+ 'editor_id' => [
'group_name' => 'CiviCRM Preferences',
'group' => 'core',
'name' => 'editor_id',
'is_contact' => 0,
'description' => '',
'help_text' => '',
- ),
- 'contact_ajax_check_similar' => array(
+ ],
+ 'contact_ajax_check_similar' => [
'group_name' => 'CiviCRM Preferences',
'group' => 'core',
'name' => 'contact_ajax_check_similar',
'is_contact' => 0,
'description' => '',
'help_text' => '',
- ),
- 'ajaxPopupsEnabled' => array(
+ ],
+ 'ajaxPopupsEnabled' => [
'group_name' => 'CiviCRM Preferences',
'group' => 'core',
'name' => 'ajaxPopupsEnabled',
'is_contact' => 0,
'description' => '',
'help_text' => '',
- ),
- 'activity_assignee_notification' => array(
+ ],
+ 'activity_assignee_notification' => [
'group_name' => 'CiviCRM Preferences',
'group' => 'core',
'name' => 'activity_assignee_notification',
'is_contact' => 0,
'description' => '',
'help_text' => '',
- ),
- 'activity_assignee_notification_ics' => array(
+ ],
+ 'activity_assignee_notification_ics' => [
'group_name' => 'CiviCRM Preferences',
'group' => 'core',
'name' => 'activity_assignee_notification_ics',
'is_contact' => 0,
'description' => '',
'help_text' => '',
- ),
- 'contact_autocomplete_options' => array(
+ ],
+ 'contact_autocomplete_options' => [
'group_name' => 'CiviCRM Preferences',
'group' => 'core',
'name' => 'contact_autocomplete_options',
'type' => 'String',
'quick_form_type' => 'CheckBox',
- 'pseudoconstant' => array(
+ 'pseudoconstant' => [
'callback' => 'CRM_Admin_Form_Setting_Search::getContactAutocompleteOptions',
- ),
+ ],
'default' => '\ 11\ 12\ 1',
'add' => '4.1',
'title' => 'Autocomplete Contact Search',
'is_contact' => 0,
'description' => 'Selected fields will be displayed in back-office autocomplete dropdown search results (Quick Search, etc.). Contact Name is always included.',
'help_text' => '',
- ),
- 'contact_reference_options' => array(
+ ],
+ 'contact_reference_options' => [
'group_name' => 'CiviCRM Preferences',
'group' => 'core',
'name' => 'contact_reference_options',
'type' => 'String',
'quick_form_type' => 'CheckBox',
- 'pseudoconstant' => array(
+ 'pseudoconstant' => [
'callback' => 'CRM_Admin_Form_Setting_Search::getContactReferenceOptions',
- ),
+ ],
'default' => '\ 11\ 12\ 1',
'add' => '4.1',
'title' => 'Contact Reference Options',
'is_contact' => 0,
'description' => 'Selected fields will be displayed in autocomplete dropdown search results for \'Contact Reference\' custom fields. Contact Name is always included. NOTE: You must assign \'access contact reference fields\' permission to the anonymous role if you want to use custom contact reference fields in profiles on public pages. For most situations, you should use the \'Limit List to Group\' setting when configuring a contact reference field which will be used in public forms to prevent exposing your entire contact list.',
'help_text' => '',
- ),
- 'contact_smart_group_display' => array(
+ ],
+ 'contact_smart_group_display' => [
'group_name' => 'CiviCRM Preferences',
'group' => 'core',
'name' => 'contact_smart_group_display',
'is_contact' => 0,
'description' => '',
'help_text' => '',
- ),
- 'smart_group_cache_refresh_mode' => array(
+ ],
+ 'smart_group_cache_refresh_mode' => [
'group_name' => 'CiviCRM Preferences',
'group' => 'core',
'name' => 'smart_group_cache_refresh_mode',
'title' => 'Smart Group Refresh Mode',
'is_domain' => 1,
'is_contact' => 0,
- 'pseudoconstant' => array(
+ 'pseudoconstant' => [
'callback' => 'CRM_Contact_BAO_GroupContactCache::getModes',
- ),
+ ],
'description' => 'Should the smart groups be by cron jobs or user actions',
'help_text' => 'In \"Opportunistic Flush\" mode, caches are flushed in response to user actions; this mode is broadly compatible but may add latency during form-submissions. In \"Cron Flush\" mode, you should schedule a cron job to flush caches; this can improve latency on form-submissions but requires more setup.',
- ),
- 'installed' => array(
+ ],
+ 'installed' => [
'bootstrap_comment' => 'This is a boot setting which may be loaded during bootstrap. Defaults are loaded via SettingsBag::getSystemDefaults().',
'group_name' => 'CiviCRM Preferences',
'group' => 'core',
'is_contact' => 0,
'description' => 'A flag indicating whether this system has run a post-installation routine',
'help_text' => '',
- ),
- 'max_attachments' => array(
+ ],
+ 'max_attachments' => [
'group_name' => 'CiviCRM Preferences',
'group' => 'core',
'name' => 'max_attachments',
'type' => 'Integer',
'quick_form_type' => 'Element',
'html_type' => 'text',
- 'html_attributes' => array(
+ 'html_attributes' => [
'size' => 2,
'maxlength' => 8,
- ),
+ ],
'default' => 3,
'add' => '4.3',
'title' => 'Maximum Attachments',
'is_contact' => 0,
'description' => 'Maximum number of files (documents, images, etc.) which can attached to emails or activities.',
'help_text' => '',
- ),
- 'maxFileSize' => array(
+ ],
+ 'maxFileSize' => [
'group_name' => 'CiviCRM Preferences',
'group' => 'core',
'name' => 'maxFileSize',
'type' => 'Integer',
'quick_form_type' => 'Element',
'html_type' => 'text',
- 'html_attributes' => array(
+ 'html_attributes' => [
'size' => 2,
'maxlength' => 8,
- ),
+ ],
'default' => 3,
'add' => '4.3',
'title' => 'Maximum File Size (in MB)',
'is_contact' => 0,
'description' => 'Maximum Size of file (documents, images, etc.) which can attached to emails or activities.<br />Note: php.ini should support this file size.',
'help_text' => '',
- ),
- 'contact_undelete' => array(
+ ],
+ 'contact_undelete' => [
'group_name' => 'CiviCRM Preferences',
'group' => 'core',
'name' => 'contact_undelete',
'is_contact' => 0,
'description' => 'If enabled, deleted contacts will be moved to trash (instead of being destroyed). Users with the proper permission are able to search for the deleted contacts and restore them (or delete permanently).',
'help_text' => '',
- ),
- 'allowPermDeleteFinancial' => array(
+ ],
+ 'allowPermDeleteFinancial' => [
'group_name' => 'CiviCRM Preferences',
'group' => 'core',
'name' => 'allowPermDeleteFinancial',
'is_contact' => 0,
'description' => 'Allow Permanent Delete for contacts who are linked to live financial transactions',
'help_text' => '',
- ),
- 'securityAlert' => array(
+ ],
+ 'securityAlert' => [
'group_name' => 'CiviCRM Preferences',
'group' => 'core',
'name' => 'securityAlert',
'is_contact' => 0,
'description' => 'If enabled, CiviCRM will display pop-up notifications (no more than once per day) for security and misconfiguration issues identified in the system check.',
'help_text' => '',
- ),
- 'doNotAttachPDFReceipt' => array(
+ ],
+ 'doNotAttachPDFReceipt' => [
'group_name' => 'CiviCRM Preferences',
'group' => 'core',
'name' => 'doNotAttachPDFReceipt',
'is_contact' => 0,
'description' => 'If enabled, CiviCRM sends PDF receipt as an attachment during event signup or online contribution.',
'help_text' => '',
- ),
- 'recordGeneratedLetters' => array(
+ ],
+ 'recordGeneratedLetters' => [
'group_name' => 'CiviCRM Preferences',
'group' => 'core',
'name' => 'recordGeneratedLetters',
'type' => 'String',
'quick_form_type' => 'Select',
'html_type' => 'Select',
- 'html_attributes' => array(
+ 'html_attributes' => [
'class' => 'crm-select2',
- ),
+ ],
'default' => 'multiple',
'add' => '4.7',
'title' => 'Record generated letters',
'is_contact' => 0,
'description' => 'When generating a letter (PDF/Word) via mail-merge, how should the letter be recorded?',
'help_text' => '',
- 'pseudoconstant' => array(
+ 'pseudoconstant' => [
'callback' => 'CRM_Contact_Form_Task_PDFLetterCommon::getLoggingOptions',
- ),
- ),
- 'wkhtmltopdfPath' => array(
+ ],
+ ],
+ 'wkhtmltopdfPath' => [
'group_name' => 'CiviCRM Preferences',
'group' => 'core',
'name' => 'wkhtmltopdfPath',
'type' => 'String',
'quick_form_type' => 'Element',
- 'html_attributes' => array(
+ 'html_attributes' => [
'size' => 64,
'maxlength' => 256,
- ),
+ ],
'html_type' => 'Text',
'default' => '',
'add' => '4.3',
'is_contact' => 0,
'description' => '',
'help_text' => '',
- ),
- 'recaptchaOptions' => array(
+ ],
+ 'recaptchaOptions' => [
'group_name' => 'CiviCRM Preferences',
'group' => 'core',
'name' => 'recaptchaOptions',
'type' => 'String',
'quick_form_type' => 'Element',
- 'html_attributes' => array(
+ 'html_attributes' => [
'size' => 64,
'maxlength' => 64,
- ),
+ ],
'html_type' => 'Text',
'default' => '',
'add' => '4.3',
'is_contact' => 0,
'description' => 'You can specify the reCAPTCHA theme options as comma separated data.(eg: theme:\'blackglass\', lang : \'fr\' ). Check the available options at <a href=\"https://developers.google.com/recaptcha/docs/display#config\">Customizing the Look and Feel of reCAPTCHA</a>.',
'help_text' => '',
- ),
- 'recaptchaPublicKey' => array(
+ ],
+ 'recaptchaPublicKey' => [
'group_name' => 'CiviCRM Preferences',
'group' => 'core',
'name' => 'recaptchaPublicKey',
'type' => 'String',
'quick_form_type' => 'Element',
- 'html_attributes' => array(
+ 'html_attributes' => [
'size' => 64,
'maxlength' => 64,
- ),
+ ],
'html_type' => 'Text',
'default' => '',
'add' => '4.3',
'is_contact' => 0,
'description' => '',
'help_text' => '',
- ),
- 'recaptchaPrivateKey' => array(
+ ],
+ 'recaptchaPrivateKey' => [
'group_name' => 'CiviCRM Preferences',
'group' => 'core',
'name' => 'recaptchaPrivateKey',
'type' => 'String',
'quick_form_type' => 'Element',
- 'html_attributes' => array(
+ 'html_attributes' => [
'size' => 64,
'maxlength' => 64,
- ),
+ ],
'html_type' => 'Text',
'default' => '',
'add' => '4.3',
'is_contact' => 0,
'description' => '',
'help_text' => '',
- ),
- 'checksum_timeout' => array(
+ ],
+ 'checksum_timeout' => [
'group_name' => 'CiviCRM Preferences',
'group' => 'core',
'name' => 'checksum_timeout',
'type' => 'Integer',
'quick_form_type' => 'Element',
- 'html_attributes' => array(
+ 'html_attributes' => [
'size' => 2,
'maxlength' => 8,
- ),
+ ],
'html_type' => 'Text',
'default' => 7,
'add' => '4.3',
'is_contact' => 0,
'description' => '',
'help_text' => '',
- ),
- 'blogUrl' => array(
+ ],
+ 'blogUrl' => [
'group_name' => 'CiviCRM Preferences',
'group' => 'core',
'name' => 'blogUrl',
'type' => 'String',
'quick_form_type' => 'Element',
- 'html_attributes' => array(
+ 'html_attributes' => [
'size' => 64,
'maxlength' => 128,
- ),
+ ],
'html_type' => 'Text',
'default' => '*default*',
'add' => '4.3',
'is_contact' => 0,
'description' => 'Blog feed URL used by the blog dashlet',
'help_text' => 'Use \"*default*\" for the system default or override with a custom URL',
- ),
- 'communityMessagesUrl' => array(
+ ],
+ 'communityMessagesUrl' => [
'group_name' => 'CiviCRM Preferences',
'group' => 'core',
'name' => 'communityMessagesUrl',
'type' => 'String',
'quick_form_type' => 'Element',
- 'html_attributes' => array(
+ 'html_attributes' => [
'size' => 64,
'maxlength' => 128,
- ),
+ ],
'html_type' => 'Text',
'default' => '*default*',
'add' => '4.3',
'is_contact' => 0,
'description' => 'Service providing CiviCRM community messages',
'help_text' => 'Use \"*default*\" for the system default or override with a custom URL',
- ),
- 'gettingStartedUrl' => array(
+ ],
+ 'gettingStartedUrl' => [
'group_name' => 'CiviCRM Preferences',
'group' => 'core',
'name' => 'gettingStartedUrl',
'type' => 'String',
'quick_form_type' => 'Element',
- 'html_attributes' => array(
+ 'html_attributes' => [
'size' => 64,
'maxlength' => 128,
- ),
+ ],
'html_type' => 'Text',
'default' => '*default*',
'add' => '4.3',
'is_contact' => 0,
'description' => 'Service providing the Getting Started data',
'help_text' => 'Use \"*default*\" for the system default or override with a custom URL',
- ),
- 'resCacheCode' => array(
+ ],
+ 'resCacheCode' => [
'group_name' => 'CiviCRM Preferences',
'group' => 'core',
'name' => 'resCacheCode',
'is_contact' => 0,
'description' => 'Code appended to resource URLs (JS/CSS) to coerce HTTP caching',
'help_text' => '',
- ),
- 'verifySSL' => array(
+ ],
+ 'verifySSL' => [
'group_name' => 'CiviCRM Preferences',
'group' => 'core',
'name' => 'verifySSL',
'is_contact' => 0,
'description' => 'If disabled, outbound web-service requests will allow unverified, insecure HTTPS connections',
'help_text' => 'Unless you are absolutely unable to configure your server to check the SSL certificate of the remote server you should leave this set to Yes',
- ),
- 'enableSSL' => array(
+ ],
+ 'enableSSL' => [
'group_name' => 'CiviCRM Preferences',
'group' => 'core',
'name' => 'enableSSL',
'is_contact' => 0,
'description' => 'If enabled, inbound HTTP requests for sensitive pages will be redirected to HTTPS.',
'help_text' => 'If enabled, inbound HTTP requests for sensitive pages will be redirected to HTTPS.',
- ),
- 'wpBasePage' => array(
+ ],
+ 'wpBasePage' => [
'group_name' => 'CiviCRM Preferences',
'group' => 'core',
'name' => 'wpBasePage',
'is_contact' => 0,
'description' => 'If set, CiviCRM will use this setting as the base url.',
'help_text' => 'By default, CiviCRM will generate front-facing pages using the home page at http://wp/ as its base. If you want to use a different template for CiviCRM pages, set the path here.',
- ),
- 'secondDegRelPermissions' => array(
+ ],
+ 'secondDegRelPermissions' => [
'group_name' => 'CiviCRM Preferences',
'group' => 'core',
'name' => 'secondDegRelPermissions',
'is_contact' => 0,
'description' => 'If enabled, contacts with the permission to edit a related contact will inherit that contact\'s permission to edit other related contacts',
'help_text' => '',
- ),
- 'enable_components' => array(
+ ],
+ 'enable_components' => [
'bootstrap_comment' => 'This is a boot setting which may be loaded during bootstrap. Defaults are loaded via SettingsBag::getSystemDefaults().',
'group_name' => 'CiviCRM Preferences',
'group' => 'core',
'type' => 'Array',
'quick_form_type' => 'Element',
'html_type' => 'advmultiselect',
- 'html_attributes' => array(
+ 'html_attributes' => [
'size' => 5,
'style' => 'width:150px',
'class' => 'advmultiselect',
- ),
+ ],
'default' => '',
'add' => '4.4',
'title' => 'Enable Components',
'is_contact' => 0,
'description' => '',
'help_text' => '',
- 'on_change' => array(
+ 'on_change' => [
'0' => 'CRM_Case_Info::onToggleComponents',
'1' => 'CRM_Core_Component::flushEnabledComponents',
'2' => 'call://resources/resetCacheCode',
- ),
- ),
- 'disable_core_css' => array(
+ ],
+ ],
+ 'disable_core_css' => [
'group_name' => 'CiviCRM Preferences',
'group' => 'core',
'name' => 'disable_core_css',
'is_contact' => 0,
'description' => 'Prevent the stylesheet \"civicrm.css\" from being loaded.',
'help_text' => '',
- ),
- 'empoweredBy' => array(
+ ],
+ 'empoweredBy' => [
'group_name' => 'CiviCRM Preferences',
'group' => 'core',
'name' => 'empoweredBy',
'is_contact' => 0,
'description' => 'When enabled, \"empowered by CiviCRM\" is displayed at the bottom of public forms.',
'help_text' => '',
- ),
- 'logging_no_trigger_permission' => array(
+ ],
+ 'logging_no_trigger_permission' => [
'add' => '4.7',
'is_domain' => 1,
'is_contact' => 0,
'default' => 0,
'title' => '(EXPERIMENTAL) MySQL user does not have trigger permissions',
'description' => 'Set this when you intend to manage trigger creation outside of CiviCRM',
- ),
- 'logging' => array(
+ ],
+ 'logging' => [
'add' => '4.7',
'help_text' => '',
'is_domain' => 1,
'title' => 'Logging',
'description' => 'If enabled, all actions will be logged with a complete record of changes.',
'validate_callback' => 'CRM_Logging_Schema::checkLoggingSupport',
- 'on_change' => array(
+ 'on_change' => [
'0' => 'CRM_Logging_Schema::onToggle',
- ),
- ),
- 'logging_uniqueid_date' => array(
+ ],
+ ],
+ 'logging_uniqueid_date' => [
'add' => '4.7',
'help_text' => 'This is the date when CRM-18193 was implemented',
'is_domain' => 1,
'default' => '',
'title' => 'Logging Unique ID not recorded before',
'description' => 'This is the date when CRM-18193 was implemented',
- ),
- 'logging_all_tables_uniquid' => array(
+ ],
+ 'logging_all_tables_uniquid' => [
'add' => '4.7',
'help_text' => 'This indicates there are no tables holdng pre-uniqid log_conn_id values (CRM-18193)',
'is_domain' => 1,
'default' => 0,
'title' => 'All tables use Unique Connection ID',
'description' => 'Do some tables pre-date CRM-18193?',
- ),
- 'userFrameworkUsersTableName' => array(
+ ],
+ 'userFrameworkUsersTableName' => [
'add' => '4.7',
'help_text' => '',
'is_domain' => 1,
'type' => 'String',
'quick_form_type' => 'Element',
'html_type' => 'text',
- 'html_attributes' => array(
+ 'html_attributes' => [
'size' => '32',
'maxlength' => '64',
- ),
+ ],
'default' => '',
'title' => 'CMS Users Table Name',
'description' => '',
- ),
- 'wpLoadPhp' => array(
+ ],
+ 'wpLoadPhp' => [
'group_name' => 'CiviCRM Preferences',
'group' => 'core',
'name' => 'wpLoadPhp',
'is_contact' => 0,
'description' => 'CiviCRM will use this setting as path to bootstrap WP.',
'help_text' => '',
- ),
- 'secure_cache_timeout_minutes' => array(
+ ],
+ 'secure_cache_timeout_minutes' => [
'group_name' => 'CiviCRM Preferences',
'group' => 'core',
'name' => 'secure_cache_timeout_minutes',
'type' => 'Integer',
'quick_form_type' => 'Element',
'html_type' => 'text',
- 'html_attributes' => array(
+ 'html_attributes' => [
'size' => 2,
'maxlength' => 8,
- ),
+ ],
'default' => 20,
'add' => '4.7',
'title' => 'Secure Cache Timeout',
'is_contact' => 0,
'description' => 'Maximum number of minutes that secure form data should linger',
'help_text' => '',
- ),
- 'site_id' => array(
+ ],
+ 'site_id' => [
'group_name' => 'CiviCRM Preferences',
'group' => 'core',
'name' => 'site_id',
'is_contact' => 0,
'description' => '',
'help_text' => '',
- ),
- 'recentItemsMaxCount' => array(
+ ],
+ 'recentItemsMaxCount' => [
'group_name' => 'CiviCRM Preferences',
'group' => 'core',
'name' => 'recentItemsMaxCount',
'type' => 'Integer',
'quick_form_type' => 'Element',
'html_type' => 'text',
- 'html_attributes' => array(
+ 'html_attributes' => [
'size' => 2,
'maxlength' => 3,
- ),
+ ],
'default' => 20,
'add' => '4.7',
'title' => 'Size of \"Recent Items\" stack',
'is_contact' => 0,
'description' => 'How many items should CiviCRM store in it\'s \"Recently viewed\" list.',
'help_text' => '',
- ),
- 'recentItemsProviders' => array(
+ ],
+ 'recentItemsProviders' => [
'group_name' => 'CiviCRM Preferences',
'group' => 'core',
'name' => 'recentItemsProviders',
'type' => 'Array',
'html_type' => 'Select',
'quick_form_type' => 'Select',
- 'html_attributes' => array(
+ 'html_attributes' => [
'multiple' => 1,
'class' => 'crm-select2',
- ),
+ ],
'default' => '',
'add' => '4.7',
'title' => 'Recent Items Providers',
'is_contact' => 0,
'description' => 'What providers may save views in CiviCRM\'s \"Recently viewed\" list. If empty, all are in.',
'help_text' => '',
- 'pseudoconstant' => array(
+ 'pseudoconstant' => [
'callback' => 'CRM_Utils_Recent::getProviders',
- ),
- ),
- 'dedupe_default_limit' => array(
+ ],
+ ],
+ 'dedupe_default_limit' => [
'group_name' => 'CiviCRM Preferences',
'group' => 'core',
'name' => 'dedupe_default_limit',
'is_contact' => 0,
'description' => 'Default to only loading matches against this number of contacts',
'help_text' => 'Deduping larger databases can crash the server. By configuring a limit other than 0 here the dedupe query will only search for matches against a limited number of contacts.',
- ),
- 'syncCMSEmail' => array(
+ ],
+ 'syncCMSEmail' => [
'group_name' => 'CiviCRM Preferences',
'group' => 'core',
'name' => 'syncCMSEmail',
'is_contact' => 0,
'description' => 'If enabled, then CMS email id will be syncronised with CiviCRM contacts\'s primary email.',
'help_text' => '',
- ),
- 'preserve_activity_tab_filter' => array(
+ ],
+ 'preserve_activity_tab_filter' => [
'group_name' => 'CiviCRM Preferences',
'group' => 'core',
'name' => 'preserve_activity_tab_filter',
'is_contact' => 0,
'description' => 'When enabled, any filter settings a user selects on the contact\'s Activity tab will be remembered as they visit other contacts',
'help_text' => '',
- ),
- 'assetCache' => array(
+ ],
+ 'assetCache' => [
'group_name' => 'Developer Preferences',
'group' => 'developer',
'name' => 'assetCache',
'type' => 'String',
'quick_form_type' => 'Select',
'html_type' => 'Select',
- 'html_attributes' => array(),
+ 'html_attributes' => [],
'default' => 'auto',
'add' => '4.7',
'title' => 'Asset Caching',
'is_contact' => 0,
'description' => 'Store computed JS/CSS content in cache files? (Note: In \"Auto\" mode, the \"Debug\" setting will determine whether to activate the cache.)',
'help_text' => '',
- 'pseudoconstant' => array(
+ 'pseudoconstant' => [
'callback' => '\Civi\Core\AssetBuilder::getCacheModes',
- ),
- ),
- 'userFrameworkLogging' => array(
+ ],
+ ],
+ 'userFrameworkLogging' => [
'group_name' => 'Developer Preferences',
'group' => 'developer',
'name' => 'userFrameworkLogging',
'is_contact' => 0,
'description' => 'Set this value to Yes if you want CiviCRM error/debugging messages to appear in the Drupal error logs',
'help_text' => 'Set this value to Yes if you want CiviCRM error/debugging messages the appear in your CMS\' error log. In the case of Drupal, this will cause all CiviCRM error messages to appear in the watchdog (assuming you have Drupal\'s watchdog enabled)',
- ),
- 'debug_enabled' => array(
+ ],
+ 'debug_enabled' => [
'group_name' => 'Developer Preferences',
'group' => 'developer',
'name' => 'debug_enabled',
'is_contact' => 0,
'description' => 'Set this value to Yes if you want to use one of CiviCRM\'s debugging tools. This feature should NOT be enabled for production sites',
'help_text' => 'Do not turn this on on production sites',
- ),
- 'backtrace' => array(
+ ],
+ 'backtrace' => [
'group_name' => 'Developer Preferences',
'group' => 'developer',
'name' => 'backtrace',
'is_domain' => 1,
'is_contact' => 0,
'description' => 'Set this value to Yes if you want to display a backtrace listing when a fatal error is encountered. This feature should NOT be enabled for production sites',
- ),
- 'fatalErrorHandler' => array(
+ ],
+ 'fatalErrorHandler' => [
'group_name' => 'Developer Preferences',
'group' => 'developer',
'name' => 'fatalErrorHandler',
'is_domain' => 1,
'is_contact' => 0,
'description' => 'Enter the path and class for a custom PHP error-handling function if you want to override built-in CiviCRM error handling for your site.',
- ),
- 'uploadDir' => array(
+ ],
+ 'uploadDir' => [
'bootstrap_comment' => 'This is a boot setting which may be loaded during bootstrap. Defaults are loaded via SettingsBag::getSystemDefaults().',
'group_name' => 'Directory Preferences',
'group' => 'directory',
'is_contact' => 0,
'description' => '',
'help_text' => 'File system path where temporary CiviCRM files - such as import data files - are uploaded.',
- ),
- 'imageUploadDir' => array(
+ ],
+ 'imageUploadDir' => [
'bootstrap_comment' => 'This is a boot setting which may be loaded during bootstrap. Defaults are loaded via SettingsBag::getSystemDefaults().',
'group_name' => 'Directory Preferences',
'group' => 'directory',
'is_contact' => 0,
'description' => 'File system path where image files are uploaded. Currently, this path is used for images associated with premiums (CiviContribute thank-you gifts).',
'help_text' => '',
- ),
- 'customFileUploadDir' => array(
+ ],
+ 'customFileUploadDir' => [
'bootstrap_comment' => 'This is a boot setting which may be loaded during bootstrap. Defaults are loaded via SettingsBag::getSystemDefaults().',
'group_name' => 'Directory Preferences',
'group' => 'directory',
'is_contact' => 0,
'description' => 'Path where documents and images which are attachments to contact records are stored (e.g. contact photos, resumes, contracts, etc.). These attachments are defined using \'file\' type custom fields.',
'help_text' => '',
- ),
- 'customTemplateDir' => array(
+ ],
+ 'customTemplateDir' => [
'bootstrap_comment' => 'This is a boot setting which may be loaded during bootstrap. Defaults are loaded via SettingsBag::getSystemDefaults().',
'group_name' => 'Directory Preferences',
'group' => 'directory',
'is_contact' => 0,
'description' => 'Path where site specific templates are stored if any. This directory is searched first if set. Custom JavaScript code can be added to templates by creating files named templateFile.extra.tpl. (learn more...)',
'help_text' => '',
- ),
- 'customPHPPathDir' => array(
+ ],
+ 'customPHPPathDir' => [
'bootstrap_comment' => 'This is a boot setting which may be loaded during bootstrap. Defaults are loaded via SettingsBag::getSystemDefaults().',
'group_name' => 'Directory Preferences',
'group' => 'directory',
'is_contact' => 0,
'description' => 'Path where site specific PHP code files are stored if any. This directory is searched first if set.',
'help_text' => '',
- ),
- 'extensionsDir' => array(
+ ],
+ 'extensionsDir' => [
'bootstrap_comment' => 'This is a boot setting which may be loaded during bootstrap. Defaults are loaded via SettingsBag::getSystemDefaults().',
'group_name' => 'Directory Preferences',
'group' => 'directory',
'is_contact' => 0,
'description' => 'Path where CiviCRM extensions are stored.',
'help_text' => '',
- ),
- 'enable_cart' => array(
+ ],
+ 'enable_cart' => [
'name' => 'enable_cart',
'group_name' => 'Event Preferences',
'group' => 'event',
'is_contact' => 0,
'description' => 'WRITE ME',
'help_text' => 'WRITE ME',
- ),
- 'show_events' => array(
+ ],
+ 'show_events' => [
'name' => 'show_events',
'group_name' => 'Event Preferences',
'group' => 'event',
'is_contact' => 0,
'description' => 'Configure how many events should be shown on the dashboard. This overrides the default value of 10 entries.',
'help_text' => '',
- ),
- 'ext_repo_url' => array(
+ ],
+ 'ext_repo_url' => [
'group_name' => 'Extension Preferences',
'group' => 'ext',
'name' => 'ext_repo_url',
'type' => 'String',
'quick_form_type' => 'Element',
- 'html_attributes' => array(
+ 'html_attributes' => [
'size' => 64,
'maxlength' => 128,
- ),
+ ],
'html_type' => 'Text',
'default' => 'https://civicrm.org/extdir/ver={ver}|cms={uf}',
'add' => '4.3',
'is_contact' => 0,
'description' => '',
'help_text' => '',
- ),
- 'customTranslateFunction' => array(
+ ],
+ 'customTranslateFunction' => [
'add' => '4.7',
'help_text' => '',
'is_domain' => 1,
'type' => 'String',
'quick_form_type' => 'Element',
'html_type' => 'text',
- 'html_attributes' => array(
+ 'html_attributes' => [
'size' => '30',
'maxlength' => '100',
- ),
+ ],
'default' => '',
'title' => 'Custom Translate Function',
'description' => '',
- ),
- 'monetaryThousandSeparator' => array(
+ ],
+ 'monetaryThousandSeparator' => [
'group_name' => 'Localization Preferences',
'group' => 'localization',
'name' => 'monetaryThousandSeparator',
'type' => 'String',
'quick_form_type' => 'Element',
'html_type' => 'text',
- 'html_attributes' => array(
+ 'html_attributes' => [
'size' => 2,
- ),
+ ],
'default' => ',',
'add' => '4.3',
'title' => 'Thousands Separator',
'is_contact' => 0,
'description' => '',
'help_text' => '',
- ),
- 'monetaryDecimalPoint' => array(
+ ],
+ 'monetaryDecimalPoint' => [
'group_name' => 'Localization Preferences',
'group' => 'localization',
'name' => 'monetaryDecimalPoint',
'type' => 'String',
'quick_form_type' => 'Element',
'html_type' => 'text',
- 'html_attributes' => array(
+ 'html_attributes' => [
'size' => 2,
- ),
+ ],
'default' => '.',
'add' => '4.3',
'title' => 'Decimal Delimiter',
'is_contact' => 0,
'description' => '',
'help_text' => '',
- ),
- 'moneyformat' => array(
+ ],
+ 'moneyformat' => [
'group_name' => 'Localization Preferences',
'group' => 'localization',
'name' => 'moneyformat',
'is_contact' => 0,
'description' => '',
'help_text' => '',
- ),
- 'moneyvalueformat' => array(
+ ],
+ 'moneyvalueformat' => [
'group_name' => 'Localization Preferences',
'group' => 'localization',
'name' => 'moneyvalueformat',
'is_contact' => 0,
'description' => '',
'help_text' => '',
- ),
- 'defaultCurrency' => array(
+ ],
+ 'defaultCurrency' => [
'group_name' => 'Localization Preferences',
'group' => 'localization',
'name' => 'defaultCurrency',
'type' => 'String',
'quick_form_type' => 'Select',
'html_type' => 'Select',
- 'html_attributes' => array(
+ 'html_attributes' => [
'class' => 'crm-select2',
- ),
+ ],
'default' => 'USD',
'add' => '4.3',
'title' => 'Default Currency',
'is_contact' => 0,
'description' => 'Default currency assigned to contributions and other monetary transactions.',
'help_text' => '',
- 'pseudoconstant' => array(
+ 'pseudoconstant' => [
'callback' => 'CRM_Admin_Form_Setting_Localization::getCurrencySymbols',
- ),
- 'on_change' => array(
+ ],
+ 'on_change' => [
'0' => 'CRM_Admin_Form_Setting_Localization::onChangeDefaultCurrency',
- ),
- ),
- 'defaultContactCountry' => array(
+ ],
+ ],
+ 'defaultContactCountry' => [
'group_name' => 'Localization Preferences',
'group' => 'localization',
'name' => 'defaultContactCountry',
'type' => 'String',
'quick_form_type' => 'Select',
'html_type' => 'Select',
- 'html_attributes' => array(),
+ 'html_attributes' => [],
'default' => '1228',
'add' => '4.4',
'title' => 'Default Country',
'is_contact' => 0,
'description' => 'This value is selected by default when adding a new contact address.',
'help_text' => '',
- 'pseudoconstant' => array(
+ 'pseudoconstant' => [
'callback' => 'CRM_Admin_Form_Setting_Localization::getAvailableCountries',
- ),
- ),
- 'defaultContactStateProvince' => array(
+ ],
+ ],
+ 'defaultContactStateProvince' => [
'add' => '4.7',
'help_text' => '',
'is_domain' => 1,
'default' => '',
'title' => 'Default State/Province',
'description' => 'This value is selected by default when adding a new contact address.',
- ),
- 'countryLimit' => array(
+ ],
+ 'countryLimit' => [
'group_name' => 'Localization Preferences',
'group' => 'localization',
'name' => 'countryLimit',
'type' => 'Array',
'quick_form_type' => 'Element',
'html_type' => 'advmultiselect',
- 'html_attributes' => array(
+ 'html_attributes' => [
'size' => 5,
'style' => 'width:150px',
'class' => 'advmultiselect',
- ),
- 'default' => array(),
+ ],
+ 'default' => [],
'add' => '4.3',
'title' => 'Available Countries',
'is_domain' => 1,
'is_contact' => 0,
'description' => '',
'help_text' => '',
- 'pseudoconstant' => array(
+ 'pseudoconstant' => [
'callback' => 'CRM_Admin_Form_Setting_Localization::getAvailableCountries',
- ),
- ),
- 'provinceLimit' => array(
+ ],
+ ],
+ 'provinceLimit' => [
'group_name' => 'Localization Preferences',
'group' => 'localization',
'name' => 'provinceLimit',
'type' => 'Array',
'quick_form_type' => 'Element',
'html_type' => 'advmultiselect',
- 'html_attributes' => array(
+ 'html_attributes' => [
'size' => 5,
'style' => 'width:150px',
'class' => 'advmultiselect',
- ),
- 'default' => array(),
+ ],
+ 'default' => [],
'add' => '4.3',
'title' => 'Available States and Provinces (by Country)',
'is_domain' => 1,
'is_contact' => 0,
'description' => '',
'help_text' => '',
- 'pseudoconstant' => array(
+ 'pseudoconstant' => [
'callback' => 'CRM_Admin_Form_Setting_Localization::getAvailableCountries',
- ),
- ),
- 'inheritLocale' => array(
+ ],
+ ],
+ 'inheritLocale' => [
'group_name' => 'Localization Preferences',
'group' => 'localization',
'name' => 'inheritLocale',
'is_contact' => 0,
'description' => '',
'help_text' => '',
- ),
- 'dateformatDatetime' => array(
+ ],
+ 'dateformatDatetime' => [
'group_name' => 'Localization Preferences',
'group' => 'localization',
'name' => 'dateformatDatetime',
'is_contact' => 0,
'description' => '',
'help_text' => '',
- ),
- 'dateformatFull' => array(
+ ],
+ 'dateformatFull' => [
'group_name' => 'Localization Preferences',
'group' => 'localization',
'name' => 'dateformatFull',
'is_contact' => 0,
'description' => '',
'help_text' => '',
- ),
- 'dateformatPartial' => array(
+ ],
+ 'dateformatPartial' => [
'group_name' => 'Localization Preferences',
'group' => 'localization',
'name' => 'dateformatPartial',
'is_contact' => 0,
'description' => '',
'help_text' => '',
- ),
- 'dateformatTime' => array(
+ ],
+ 'dateformatTime' => [
'add' => '4.7',
'help_text' => '',
'is_domain' => 1,
'type' => 'String',
'quick_form_type' => 'Element',
'html_type' => 'text',
- 'html_attributes' => array(
+ 'html_attributes' => [
'size' => '12',
'maxlength' => '60',
- ),
+ ],
'default' => '%l:%M %P',
'title' => 'Date Format: Time Only',
'description' => '',
- ),
- 'dateformatYear' => array(
+ ],
+ 'dateformatYear' => [
'add' => '4.7',
'help_text' => '',
'is_domain' => 1,
'type' => 'String',
'quick_form_type' => 'Element',
'html_type' => 'text',
- 'html_attributes' => array(
+ 'html_attributes' => [
'size' => '12',
'maxlength' => '60',
- ),
+ ],
'default' => '%Y',
'title' => 'Date Format: Year Only',
'description' => '',
- ),
- 'dateformatFinancialBatch' => array(
+ ],
+ 'dateformatFinancialBatch' => [
'add' => '4.7',
'help_text' => '',
'is_domain' => 1,
'type' => 'String',
'quick_form_type' => 'Element',
'html_type' => 'text',
- 'html_attributes' => array(
+ 'html_attributes' => [
'size' => '12',
'maxlength' => '60',
- ),
+ ],
'default' => '%m/%d/%Y',
'title' => 'Date Format: Financial Batch',
'description' => '',
- ),
- 'dateformatshortdate' => array(
+ ],
+ 'dateformatshortdate' => [
'add' => '4.7',
'help_text' => '',
'is_domain' => 1,
'type' => 'String',
'quick_form_type' => 'Element',
'html_type' => 'text',
- 'html_attributes' => array(
+ 'html_attributes' => [
'size' => '12',
'maxlength' => '60',
- ),
+ ],
'default' => '%m/%d/%Y',
'title' => 'Date Format: Short date Month Day Year',
'description' => '',
- ),
- 'dateInputFormat' => array(
+ ],
+ 'dateInputFormat' => [
'add' => '4.7',
'help_text' => '',
'is_domain' => 1,
'type' => 'String',
'quick_form_type' => 'Select',
'html_type' => 'Select',
- 'pseudoconstant' => array(
+ 'pseudoconstant' => [
'callback' => 'CRM_Core_SelectValues::getDatePluginInputFormats',
- ),
+ ],
'default' => 'mm/dd/yy',
'title' => 'Date Input Format',
'description' => '',
- ),
- 'fieldSeparator' => array(
+ ],
+ 'fieldSeparator' => [
'add' => '4.7',
'help_text' => '',
'is_domain' => 1,
'type' => 'String',
'quick_form_type' => 'Element',
'html_type' => 'text',
- 'html_attributes' => array(
+ 'html_attributes' => [
'size' => '2',
'maxlength' => '8',
- ),
+ ],
'default' => ',',
'title' => 'Import / Export Field Separator',
'description' => 'Global CSV separator character. Modify this setting to enable import and export of different kinds of CSV files (for example: \',\' \';\' \':\' \'|\' ).',
- ),
- 'fiscalYearStart' => array(
+ ],
+ 'fiscalYearStart' => [
'add' => '4.7',
'help_text' => '',
'is_domain' => 1,
'type' => 'Array',
'quick_form_type' => 'MonthDay',
'html_type' => 'MonthDay',
- 'default' => array(
+ 'default' => [
'M' => 1,
'd' => 1,
- ),
+ ],
'title' => 'Fiscal Year Start',
'description' => '',
- ),
- 'languageLimit' => array(
+ ],
+ 'languageLimit' => [
'group_name' => 'Localization Preferences',
'group' => 'localization',
'name' => 'languageLimit',
'type' => 'Array',
'quick_form_type' => 'Select',
'html_type' => 'Select',
- 'html_attributes' => array(
+ 'html_attributes' => [
'multiple' => 1,
'class' => 'crm-select2',
- ),
+ ],
'default' => '',
'add' => '4.3',
'title' => 'Available Languages (Multi-lingual)',
'is_contact' => 0,
'description' => '',
'help_text' => '',
- 'pseudoconstant' => array(
+ 'pseudoconstant' => [
'callback' => 'CRM_Core_I18n::languages',
- ),
- ),
- 'lcMessages' => array(
+ ],
+ ],
+ 'lcMessages' => [
'group_name' => 'Localization Preferences',
'group' => 'localization',
'name' => 'lcMessages',
'type' => 'String',
'quick_form_type' => 'Select',
'html_type' => 'Select',
- 'html_attributes' => array(
+ 'html_attributes' => [
'class' => 'crm-select2',
- ),
+ ],
'default' => 'en_US',
'add' => '4.3',
'title' => 'Default Language',
'is_contact' => 0,
'description' => '',
'help_text' => '',
- 'pseudoconstant' => array(
+ 'pseudoconstant' => [
'callback' => 'CRM_Admin_Form_Setting_Localization::getDefaultLocaleOptions',
- ),
- 'on_change' => array(
+ ],
+ 'on_change' => [
'0' => 'CRM_Admin_Form_Setting_Localization::onChangeLcMessages',
- ),
- ),
- 'legacyEncoding' => array(
+ ],
+ ],
+ 'legacyEncoding' => [
'add' => '4.7',
'help_text' => '',
'is_domain' => 1,
'type' => 'String',
'quick_form_type' => 'Element',
'html_type' => 'text',
- 'html_attributes' => array(
+ 'html_attributes' => [
'size' => '12',
'maxlength' => '30',
- ),
+ ],
'default' => 'Windows-1252',
'title' => 'Legacy Encoding',
'description' => 'If import files are NOT encoded as UTF-8, specify an alternate character encoding for these files. The default of Windows-1252 will work for Excel-created .CSV files on many computers.',
- ),
- 'timeInputFormat' => array(
+ ],
+ 'timeInputFormat' => [
'add' => '4.7',
'help_text' => '',
'is_domain' => 1,
'type' => 'String',
'quick_form_type' => 'Select',
'html_type' => 'Select',
- 'pseudoconstant' => array(
+ 'pseudoconstant' => [
'callback' => 'CRM_Core_SelectValues::getTimeFormats',
- ),
+ ],
'default' => '1',
'title' => 'Time Input Format',
'description' => '',
- 'on_change' => array(
+ 'on_change' => [
'0' => 'CRM_Core_BAO_PreferencesDate::onChangeSetting',
- ),
- ),
- 'weekBegins' => array(
+ ],
+ ],
+ 'weekBegins' => [
'group_name' => 'Localization Preferences',
'group' => 'localization',
'name' => 'weekBegins',
'type' => 'String',
'quick_form_type' => 'Select',
'html_type' => 'Select',
- 'pseudoconstant' => array(
+ 'pseudoconstant' => [
'callback' => 'CRM_Utils_Date::getFullWeekdayNames',
- ),
+ ],
'default' => 0,
'add' => '4.7',
'title' => 'Week begins on',
'is_contact' => 0,
'description' => '',
'help_text' => '',
- ),
- 'contact_default_language' => array(
+ ],
+ 'contact_default_language' => [
'group_name' => 'Localization Preferences',
'group' => 'localization',
'name' => 'contact_default_language',
'type' => 'String',
'quick_form_type' => 'Select',
'html_type' => 'Select',
- 'html_attributes' => array(
+ 'html_attributes' => [
'class' => 'crm-select2',
- ),
- 'pseudoconstant' => array(
+ ],
+ 'pseudoconstant' => [
'callback' => 'CRM_Admin_Form_Setting_Localization::getDefaultLanguageOptions',
- ),
+ ],
'default' => '*default*',
'add' => '4.7',
'title' => 'Default Language for contacts',
'is_contact' => 0,
'description' => 'Default language (if any) for contact records',
'help_text' => 'If a contact is created with no language this setting will determine the language data (if any) to save.You may or may not wish to make an assumption here about whether it matches the site language',
- ),
- 'profile_double_optin' => array(
+ ],
+ 'profile_double_optin' => [
'group_name' => 'Mailing Preferences',
'group' => 'mailing',
'name' => 'profile_double_optin',
'is_contact' => 0,
'description' => 'When CiviMail is enabled, users who \"subscribe\" to a group from a profile Group(s) checkbox will receive a confirmation email. They must respond (opt-in) before they are added to the group.',
'help_text' => '',
- ),
- 'track_civimail_replies' => array(
+ ],
+ 'track_civimail_replies' => [
'group_name' => 'Mailing Preferences',
'group' => 'mailing',
'name' => 'track_civimail_replies',
'description' => 'If checked, mailings will default to tracking replies using VERP-ed Reply-To. ',
'help_text' => '',
'validate_callback' => 'CRM_Core_BAO_Setting::validateBoolSetting',
- ),
- 'civimail_workflow' => array(
+ ],
+ 'civimail_workflow' => [
'group_name' => 'Mailing Preferences',
'group' => 'mailing',
'name' => 'civimail_workflow',
'is_contact' => 0,
'description' => 'When CiviMail is enabled, users who \"subscribe\" to a group from a profile Group(s) checkbox will receive a confirmation email. They must respond (opt-in) before they are added to the group.',
'help_text' => '',
- ),
- 'civimail_server_wide_lock' => array(
+ ],
+ 'civimail_server_wide_lock' => [
'group_name' => 'Mailing Preferences',
'group' => 'mailing',
'name' => 'civimail_server_wide_lock',
'is_contact' => 0,
'description' => '',
'help_text' => '',
- ),
- 'replyTo' => array(
+ ],
+ 'replyTo' => [
'group_name' => 'Mailing Preferences',
'group' => 'mailing',
'name' => 'replyTo',
'is_contact' => 0,
'description' => 'Allow CiviMail users to send mailings with a custom Reply-To header',
'help_text' => '',
- ),
- 'mailing_backend' => array(
+ ],
+ 'mailing_backend' => [
'group_name' => 'Mailing Preferences',
'group' => 'mailing',
'name' => 'mailing_backend',
'type' => 'Array',
'html_type' => 'checkbox',
- 'default' => array(
+ 'default' => [
'outBound_option' => '3',
- ),
+ ],
'add' => '4.1',
'title' => 'Mailing Backend',
'is_domain' => 1,
'is_contact' => 0,
'description' => '',
'help_text' => '',
- ),
- 'profile_add_to_group_double_optin' => array(
+ ],
+ 'profile_add_to_group_double_optin' => [
'group_name' => 'Mailing Preferences',
'group' => 'mailing',
'name' => 'profile_add_to_group_double_optin',
'is_contact' => 0,
'description' => 'When CiviMail is enabled, users who \"subscribe\" to a group from a profile Group(s) checkbox will receive a confirmation email. They must respond (opt-in) before they are added to the group.',
'help_text' => '',
- ),
- 'disable_mandatory_tokens_check' => array(
+ ],
+ 'disable_mandatory_tokens_check' => [
'group_name' => 'Mailing Preferences',
'group' => 'mailing',
'name' => 'disable_mandatory_tokens_check',
'is_contact' => 0,
'description' => 'Don\'t check for presence of mandatory tokens (domain address; unsubscribe/opt-out) before sending mailings. WARNING: Mandatory tokens are a safe-guard which facilitate compliance with the US CAN-SPAM Act. They should only be disabled if your organization adopts other mechanisms for compliance or if your organization is not subject to CAN-SPAM.',
'help_text' => '',
- ),
- 'dedupe_email_default' => array(
+ ],
+ 'dedupe_email_default' => [
'group_name' => 'Mailing Preferences',
'group' => 'mailing',
'name' => 'dedupe_email_default',
'is_contact' => 0,
'description' => 'Set the \"dedupe e-mail\" option when sending a new mailing to \"true\" by default.',
'help_text' => '',
- ),
- 'hash_mailing_url' => array(
+ ],
+ 'hash_mailing_url' => [
'group_name' => 'Mailing Preferences',
'group' => 'mailing',
'name' => 'hash_mailing_url',
'is_contact' => 0,
'description' => 'If enabled, a randomized hash key will be used to reference the mailing URL in the mailing.viewUrl token, instead of the mailing ID',
'help_text' => '',
- ),
- 'civimail_multiple_bulk_emails' => array(
+ ],
+ 'civimail_multiple_bulk_emails' => [
'group_name' => 'Mailing Preferences',
'group' => 'mailing',
'name' => 'civimail_multiple_bulk_emails',
'is_contact' => 0,
'description' => 'If enabled, CiviMail will deliver a copy of the email to each bulk email listed for the contact.',
'help_text' => '',
- ),
- 'include_message_id' => array(
+ ],
+ 'include_message_id' => [
'group_name' => 'Mailing Preferences',
'group' => 'mailing',
'name' => 'include_message_id',
'is_contact' => 0,
'description' => '',
'help_text' => '',
- ),
- 'mailerBatchLimit' => array(
+ ],
+ 'mailerBatchLimit' => [
'group_name' => 'Mailing Preferences',
'group' => 'mailing',
'name' => 'mailerBatchLimit',
'type' => 'Integer',
'quick_form_type' => 'Element',
'html_type' => 'text',
- 'html_attributes' => array(
+ 'html_attributes' => [
'size' => 4,
'maxlength' => 8,
- ),
+ ],
'default' => 0,
'add' => '4.7',
'title' => 'Mailer Batch Limit',
'is_contact' => 0,
'description' => 'Throttle email delivery by setting the maximum number of emails sent during each CiviMail run (0 = unlimited).',
'help_text' => '',
- ),
- 'mailerJobSize' => array(
+ ],
+ 'mailerJobSize' => [
'group_name' => 'Mailing Preferences',
'group' => 'mailing',
'name' => 'mailerJobSize',
'type' => 'Integer',
'quick_form_type' => 'Element',
'html_type' => 'text',
- 'html_attributes' => array(
+ 'html_attributes' => [
'size' => 4,
'maxlength' => 8,
- ),
+ ],
'default' => 0,
'add' => '4.7',
'title' => 'Mailer Job Size',
'is_contact' => 0,
'description' => 'If you want to utilize multi-threading enter the size you want your sub jobs to be split into. Recommended values are between 1,000 and 10,000. Use a lower value if your server has multiple cron jobs running simultaneously, but do not use values smaller than 1,000. Enter \"0\" to disable multi-threading and process mail as one single job - batch limits still apply.',
'help_text' => '',
- ),
- 'mailerJobsMax' => array(
+ ],
+ 'mailerJobsMax' => [
'group_name' => 'Mailing Preferences',
'group' => 'mailing',
'name' => 'mailerJobsMax',
'type' => 'Integer',
'quick_form_type' => 'Element',
'html_type' => 'text',
- 'html_attributes' => array(
+ 'html_attributes' => [
'size' => 4,
'maxlength' => 8,
- ),
+ ],
'default' => 0,
'add' => '4.7',
'title' => 'Mailer Cron Job Limit',
'is_contact' => 0,
'description' => 'The maximum number of mailer delivery jobs executing simultaneously (0 = allow as many processes to execute as started by cron)',
'help_text' => '',
- ),
- 'mailThrottleTime' => array(
+ ],
+ 'mailThrottleTime' => [
'group_name' => 'Mailing Preferences',
'group' => 'mailing',
'name' => 'mailThrottleTime',
'type' => 'Integer',
'quick_form_type' => 'Element',
'html_type' => 'text',
- 'html_attributes' => array(
+ 'html_attributes' => [
'size' => 4,
'maxlength' => 8,
- ),
+ ],
'default' => 0,
'add' => '4.7',
'title' => 'Mailer Throttle Time',
'is_contact' => 0,
'description' => 'The time to sleep in between each e-mail in micro seconds. Setting this above 0 allows you to control the rate at which e-mail messages are sent to the mail server, avoiding filling up the mail queue very quickly. Set to 0 to disable.',
'help_text' => '',
- ),
- 'verpSeparator' => array(
+ ],
+ 'verpSeparator' => [
'group_name' => 'Mailing Preferences',
'group' => 'mailing',
'name' => 'verpSeparator',
'type' => 'String',
'quick_form_type' => 'Element',
'html_type' => 'text',
- 'html_attributes' => array(
+ 'html_attributes' => [
'size' => 4,
'maxlength' => 32,
- ),
+ ],
'default' => '.',
'add' => '4.7',
'title' => 'VERP Separator',
'is_contact' => 0,
'description' => 'Separator character used when CiviMail generates VERP (variable envelope return path) Mail-From addresses.',
'help_text' => '',
- ),
- 'write_activity_record' => array(
+ ],
+ 'write_activity_record' => [
'group_name' => 'Mailing Preferences',
'group' => 'mailing',
'name' => 'write_activity_record',
'is_contact' => 0,
'description' => '',
'help_text' => '',
- ),
- 'simple_mail_limit' => array(
+ ],
+ 'simple_mail_limit' => [
'group_name' => 'Mailing Preferences',
'group' => 'mailing',
'name' => 'simple_mail_limit',
'type' => 'Integer',
'quick_form_type' => 'Element',
'html_type' => 'text',
- 'html_attributes' => array(
+ 'html_attributes' => [
'size' => 4,
'maxlength' => 8,
- ),
+ ],
'default' => 50,
'title' => 'Simple mail limit',
'is_domain' => 1,
'is_contact' => 0,
'description' => 'The number of emails sendable via simple mail. Make sure you understand the implications for your spam reputation and legal requirements for bulk emails before editing. As there is some risk both to your spam reputation and the products if this is misused it is a hidden setting',
'help_text' => 'CiviCRM forces users sending more than this number of mails to use CiviMails. CiviMails have additional precautions: not sending to contacts who do not want bulk mail, adding domain name and opt out links. You should familiarise yourself with the law relevant to you on bulk mailings if changing this setting. For the US https://en.wikipedia.org/wiki/CAN-SPAM_Act_of_2003 is a good place to start.',
- ),
- 'geoAPIKey' => array(
+ ],
+ 'geoAPIKey' => [
'add' => '4.7',
'help_text' => '',
'is_domain' => 1,
'type' => 'String',
'quick_form_type' => 'Element',
'html_type' => 'text',
- 'html_attributes' => array(
+ 'html_attributes' => [
'size' => '32',
'maxlength' => '64',
- ),
+ ],
'default' => '',
'title' => 'Geo Provider Key',
'description' => 'Enter the API key or Application ID associated with your geocoding provider (not required for Yahoo).',
- ),
- 'geoProvider' => array(
+ ],
+ 'geoProvider' => [
'add' => '4.7',
'help_text' => '',
'is_domain' => 1,
'type' => 'String',
'quick_form_type' => 'Select',
'html_type' => 'Select',
- 'html_attributes' => array(
+ 'html_attributes' => [
'class' => 'crm-select2',
- ),
- 'pseudoconstant' => array(
+ ],
+ 'pseudoconstant' => [
'callback' => 'CRM_Core_SelectValues::geoProvider',
- ),
+ ],
'default' => '',
'title' => 'Geocoding Provider',
'description' => 'This can be the same or different from the mapping provider selected.',
- ),
- 'mapAPIKey' => array(
+ ],
+ 'mapAPIKey' => [
'add' => '4.7',
'help_text' => '',
'is_domain' => 1,
'type' => 'String',
'quick_form_type' => 'Element',
'html_type' => 'text',
- 'html_attributes' => array(
+ 'html_attributes' => [
'size' => '32',
'maxlength' => '64',
- ),
+ ],
'default' => '',
'title' => 'Map Provider Key',
'description' => 'Enter your API Key or Application ID. An API Key is required for the Google Maps API. Refer to developers.google.com for the latest information.',
- ),
- 'mapProvider' => array(
+ ],
+ 'mapProvider' => [
'add' => '4.7',
'help_text' => '',
'is_domain' => 1,
'type' => 'String',
'quick_form_type' => 'Select',
'html_type' => 'Select',
- 'html_attributes' => array(
+ 'html_attributes' => [
'class' => 'crm-select2',
- ),
- 'pseudoconstant' => array(
+ ],
+ 'pseudoconstant' => [
'callback' => 'CRM_Core_SelectValues::mapProvider',
- ),
+ ],
'default' => '',
'title' => 'Mapping Provider',
'description' => 'Choose the mapping provider that has the best coverage for the majority of your contact addresses.',
- ),
- 'default_renewal_contribution_page' => array(
+ ],
+ 'default_renewal_contribution_page' => [
'group_name' => 'Member Preferences',
'group' => 'member',
'name' => 'default_renewal_contribution_page',
'type' => 'Integer',
'html_type' => 'Select',
'default' => '',
- 'pseudoconstant' => array(
+ 'pseudoconstant' => [
'name' => 'contributionPage',
- ),
+ ],
'add' => '4.1',
'title' => 'Default online membership renewal page',
'is_domain' => 1,
'is_contact' => 0,
'description' => 'If you select a default online contribution page for self-service membership renewals, a \"renew\" link pointing to that page will be displayed on the Contact Dashboard for memberships which were entered offline. You will need to ensure that the membership block for the selected online contribution page includes any currently available memberships.',
'help_text' => '',
- ),
- 'is_enabled' => array(
+ ],
+ 'is_enabled' => [
'group_name' => 'Multi Site Preferences',
'group' => 'multisite',
'name' => 'is_enabled',
'is_contact' => 0,
'description' => 'Multisite is enabled',
'help_text' => '',
- ),
- 'domain_group_id' => array(
+ ],
+ 'domain_group_id' => [
'group_name' => 'Multi Site Preferences',
'group' => 'multisite',
'name' => 'domain_group_id',
'is_contact' => 0,
'description' => '',
'help_text' => '',
- ),
- 'event_price_set_domain_id' => array(
+ ],
+ 'event_price_set_domain_id' => [
'group_name' => 'Multi Site Preferences',
'group' => 'multisite',
'name' => 'event_price_set_domain_id',
'is_contact' => 0,
'description' => '',
'help_text' => '',
- ),
- 'uniq_email_per_site' => array(
+ ],
+ 'uniq_email_per_site' => [
'group_name' => 'Multi Site Preferences',
'group' => 'multisite',
'name' => 'uniq_email_per_site',
'is_contact' => 0,
'description' => '',
'help_text' => '',
- ),
- 'search_autocomplete_count' => array(
+ ],
+ 'search_autocomplete_count' => [
'group_name' => 'Search Preferences',
'group' => 'Search Preferences',
'name' => 'search_autocomplete_count',
'type' => 'Integer',
'quick_form_type' => 'Element',
'html_type' => 'text',
- 'html_attributes' => array(
+ 'html_attributes' => [
'size' => 2,
'maxlength' => 2,
- ),
+ ],
'default' => 10,
'add' => '4.3',
'title' => 'Autocomplete Results',
'is_contact' => 0,
'description' => 'The maximum number of contacts to show at a time when typing in an autocomplete field.',
'help_text' => '',
- ),
- 'enable_innodb_fts' => array(
+ ],
+ 'enable_innodb_fts' => [
'group_name' => 'Search Preferences',
'group' => 'Search Preferences',
'name' => 'enable_innodb_fts',
'is_contact' => 0,
'description' => 'Enable InnoDB full-text search optimizations. (Requires MySQL 5.6+)',
'help_text' => '',
- 'on_change' => array(
- '0' => array(
+ 'on_change' => [
+ '0' => [
'0' => 'CRM_Core_InnoDBIndexer',
'1' => 'onToggleFts',
- ),
- ),
- ),
- 'fts_query_mode' => array(
+ ],
+ ],
+ ],
+ 'fts_query_mode' => [
'group_name' => 'Search Preferences',
'group' => 'Search Preferences',
'name' => 'fts_query_mode',
'type' => 'String',
'quick_form_type' => 'Element',
- 'html_attributes' => array(
+ 'html_attributes' => [
'size' => 64,
'maxlength' => 64,
- ),
+ ],
'html_type' => 'Text',
'default' => 'simple',
'add' => '4.5',
'is_contact' => 0,
'description' => '',
'help_text' => '',
- ),
- 'includeOrderByClause' => array(
+ ],
+ 'includeOrderByClause' => [
'group_name' => 'Search Preferences',
'group' => 'Search Preferences',
'name' => 'includeOrderByClause',
'is_contact' => 0,
'description' => 'If disabled, the search results will not be ordered. This may improve response time on search results on large datasets',
'help_text' => '',
- ),
- 'includeWildCardInName' => array(
+ ],
+ 'includeWildCardInName' => [
'group_name' => 'Search Preferences',
'group' => 'Search Preferences',
'name' => 'includeWildCardInName',
'is_contact' => 0,
'description' => 'If enabled, wildcards are automatically added to the beginning AND end of the search term when users search for contacts by Name. EXAMPLE: Searching for \'ada\' will return any contact whose name includes those letters - e.g. \'Adams, Janet\', \'Nadal, Jorge\', etc. If disabled, a wildcard is added to the end of the search term only. EXAMPLE: Searching for \'ada\' will return any contact whose last name begins with those letters - e.g. \'Adams, Janet\' but NOT \'Nadal, Jorge\'. Disabling this feature will speed up search significantly for larger databases, but users must manually enter wildcards (\'%\' or \'_\') to the beginning of the search term if they want to find all records which contain those letters. EXAMPLE: \'%ada\' will return \'Nadal, Jorge\'.',
'help_text' => '',
- ),
- 'includeEmailInName' => array(
+ ],
+ 'includeEmailInName' => [
'group_name' => 'Search Preferences',
'group' => 'Search Preferences',
'name' => 'includeEmailInName',
'is_contact' => 0,
'description' => 'If enabled, email addresses are automatically included when users search by Name. Disabling this feature will speed up search significantly for larger databases, but users will need to use the Email search fields (from Advanced Search, Search Builder, or Profiles) to find contacts by email address.',
'help_text' => '',
- ),
- 'includeNickNameInName' => array(
+ ],
+ 'includeNickNameInName' => [
'group_name' => 'Search Preferences',
'group' => 'Search Preferences',
'name' => 'includeNickNameInName',
'is_contact' => 0,
'description' => 'If enabled, nicknames are automatically included when users search by Name.',
'help_text' => '',
- ),
- 'includeAlphabeticalPager' => array(
+ ],
+ 'includeAlphabeticalPager' => [
'group_name' => 'Search Preferences',
'group' => 'Search Preferences',
'name' => 'includeAlphabeticalPager',
'is_contact' => 0,
'description' => 'If disabled, the alphabetical pager will not be displayed on the search screens. This will improve response time on search results on large datasets.',
'help_text' => '',
- ),
- 'smartGroupCacheTimeout' => array(
+ ],
+ 'smartGroupCacheTimeout' => [
'group_name' => 'Search Preferences',
'group' => 'Search Preferences',
'name' => 'smartGroupCacheTimeout',
'is_contact' => 0,
'description' => 'The number of minutes to cache smart group contacts. We strongly recommend that this value be greater than zero, since a value of zero means no caching at all. If your contact data changes frequently, you should set this value to at least 5 minutes.',
'help_text' => '',
- ),
- 'defaultSearchProfileID' => array(
+ ],
+ 'defaultSearchProfileID' => [
'group_name' => 'Search Preferences',
'group' => 'Search Preferences',
'name' => 'defaultSearchProfileID',
'type' => 'Integer',
'quick_form_type' => 'Select',
'html_type' => 'Select',
- 'html_attributes' => array(
+ 'html_attributes' => [
'class' => 'crm-select2',
- ),
- 'pseudoconstant' => array(
+ ],
+ 'pseudoconstant' => [
'callback' => 'CRM_Admin_Form_Setting_Search::getAvailableProfiles',
- ),
+ ],
'default' => '',
'add' => '4.6',
'title' => 'Default Contact Search Profile',
'is_contact' => 0,
'description' => 'If set, this will be the default profile used for contact search.',
'help_text' => '',
- ),
- 'searchPrimaryDetailsOnly' => array(
+ ],
+ 'searchPrimaryDetailsOnly' => [
'group_name' => 'Search Preferences',
'group' => 'Search Preferences',
'name' => 'searchPrimaryDetailsOnly',
'is_contact' => 0,
'description' => 'If enabled, only primary details (eg contact\'s primary email, phone, etc) will be included in Basic and Advanced Search results. Disabling this feature will allow users to match contacts using any email, phone etc detail.',
'help_text' => '',
- ),
- 'userFrameworkResourceURL' => array(
+ ],
+ 'userFrameworkResourceURL' => [
'bootstrap_comment' => 'This is a boot setting which may be loaded during bootstrap. Defaults are loaded via SettingsBag::getSystemDefaults().',
'group' => 'url',
'group_name' => 'URL Preferences',
'description' => 'Absolute URL of the location where the civicrm module or component has been installed.',
'help_text' => '',
'validate_callback' => 'CRM_Utils_Rule::urlish',
- ),
- 'imageUploadURL' => array(
+ ],
+ 'imageUploadURL' => [
'bootstrap_comment' => 'This is a boot setting which may be loaded during bootstrap. Defaults are loaded via SettingsBag::getSystemDefaults().',
'group' => 'url',
'group_name' => 'URL Preferences',
'description' => 'URL of the location for uploaded image files.',
'help_text' => '',
'validate_callback' => 'CRM_Utils_Rule::urlish',
- ),
- 'customCSSURL' => array(
+ ],
+ 'customCSSURL' => [
'bootstrap_comment' => 'This is a boot setting which may be loaded during bootstrap. Defaults are loaded via SettingsBag::getSystemDefaults().',
'group' => 'url',
'group_name' => 'URL Preferences',
'description' => 'You can modify the look and feel of CiviCRM by adding your own stylesheet. For small to medium sized modifications, use your css file to override some of the styles in civicrm.css. Or if you need to make drastic changes, you can choose to disable civicrm.css completely.',
'help_text' => '',
'validate_callback' => 'CRM_Utils_Rule::urlish',
- ),
- 'extensionsURL' => array(
+ ],
+ 'extensionsURL' => [
'bootstrap_comment' => 'This is a boot setting which may be loaded during bootstrap. Defaults are loaded via SettingsBag::getSystemDefaults().',
'group' => 'url',
'group_name' => 'URL Preferences',
'description' => 'Base URL for extension resources (images, stylesheets, etc). This should match extensionsDir.',
'help_text' => '',
'validate_callback' => 'CRM_Utils_Rule::urlish',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function setting_get_example() {
- $params = array(
+ $params = [
'return' => 'uniq_email_per_site',
- );
+ ];
try{
$result = civicrm_api3('Setting', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function setting_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'uniq_email_per_site' => 0,
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function setting_get_example() {
- $params = array(
- 'domain_id' => array(
+ $params = [
+ 'domain_id' => [
'0' => 1,
'1' => 2,
- ),
- 'return' => array(
+ ],
+ 'return' => [
'0' => 'uniq_email_per_site',
- ),
- );
+ ],
+ ];
try{
$result = civicrm_api3('Setting', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function setting_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 2,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'uniq_email_per_site' => 0,
- ),
- '2' => array(
+ ],
+ '2' => [
'uniq_email_per_site' => '1',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function setting_getvalue_example() {
- $params = array(
+ $params = [
'name' => 'petition_contacts',
'group' => 'Campaign Preferences',
- );
+ ];
try{
$result = civicrm_api3('Setting', 'getvalue', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
* API result array
*/
function setting_revert_example() {
- $params = array(
+ $params = [
'name' => 'address_format',
- );
+ ];
try{
$result = civicrm_api3('Setting', 'revert', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function setting_revert_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 5,
'id' => 1,
- 'values' => array(
+ 'values' => [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'address_format' => '{contact.address_name}
{contact.street_address}
{contact.supplemental_address_1}
{contact.supplemental_address_3}
{contact.city}{, }{contact.state_province}{ }{contact.postal_code}
{contact.country}',
- ),
- ),
- ),
- );
+ ],
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function state_province_create_example() {
- $params = array(
+ $params = [
'name' => 'Wessex',
'abbreviation' => 'WEX',
'country_id' => 1226,
- );
+ ];
try{
$result = civicrm_api3('StateProvince', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function state_province_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 13947,
- 'values' => array(
- '13947' => array(
+ 'values' => [
+ '13947' => [
'id' => '13947',
'name' => 'Wessex',
'abbreviation' => 'WEX',
'country_id' => '1226',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function state_province_delete_example() {
- $params = array(
+ $params = [
'id' => 13948,
- );
+ ];
try{
$result = civicrm_api3('StateProvince', 'delete', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function state_province_delete_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'values' => 1,
- );
+ ];
return $expectedResult;
}
* API result array
*/
function state_province_get_example() {
- $params = array(
+ $params = [
'name' => 'Wessex',
- );
+ ];
try{
$result = civicrm_api3('StateProvince', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function state_province_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 13949,
- 'values' => array(
- '13949' => array(
+ 'values' => [
+ '13949' => [
'id' => '13949',
'name' => 'Wessex',
'abbreviation' => 'WEX',
'country_id' => '1226',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function status_preference_create_example() {
- $params = array(
+ $params = [
'name' => 'test_check',
'domain_id' => 1,
'hush_until' => '20151212',
'ignore_severity' => 'cRItical',
'check_info' => '',
- );
+ ];
try{
$result = civicrm_api3('StatusPreference', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function status_preference_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 4,
- 'values' => array(
- '4' => array(
+ 'values' => [
+ '4' => [
'id' => '4',
'domain_id' => '1',
'name' => 'test_check',
'ignore_severity' => '5',
'prefs' => '',
'check_info' => '',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function status_preference_delete_example() {
- $params = array(
+ $params = [
'id' => 2,
- );
+ ];
try{
$result = civicrm_api3('StatusPreference', 'delete', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function status_preference_delete_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'values' => 1,
- );
+ ];
return $expectedResult;
}
* API result array
*/
function status_preference_get_example() {
- $params = array(
+ $params = [
'id' => 3,
- );
+ ];
try{
$result = civicrm_api3('StatusPreference', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function status_preference_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 3,
- 'values' => array(
- '3' => array(
+ 'values' => [
+ '3' => [
'id' => '3',
'domain_id' => '1',
'name' => 'test_check',
'hush_until' => '2015-12-12',
'ignore_severity' => '4',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function survey_get_example() {
- $params = array(
+ $params = [
'title' => 'survey title',
'api.survey.delete' => 1,
- );
+ ];
try{
$result = civicrm_api3('Survey', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function survey_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 4,
- 'values' => array(
- '4' => array(
+ 'values' => [
+ '4' => [
'id' => '4',
'title' => 'survey title',
'activity_type_id' => '30',
'created_date' => '2013-07-28 08:49:19',
'bypass_confirm' => 0,
'is_share' => '1',
- 'api.survey.delete' => array(
+ 'api.survey.delete' => [
'is_error' => 0,
'version' => 3,
'count' => 1,
'values' => 1,
- ),
- ),
- ),
- );
+ ],
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function survey_create_example() {
- $params = array(
+ $params = [
'title' => 'survey title',
'activity_type_id' => '30',
'max_number_of_contacts' => 12,
'instructions' => 'Call people, ask for money',
- );
+ ];
try{
$result = civicrm_api3('Survey', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function survey_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'id' => '1',
'title' => 'survey title',
'campaign_id' => '',
'thankyou_title' => '',
'thankyou_text' => '',
'is_share' => '',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function survey_delete_example() {
- $params = array(
+ $params = [
'id' => 3,
- );
+ ];
try{
$result = civicrm_api3('Survey', 'delete', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function survey_delete_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'values' => 1,
- );
+ ];
return $expectedResult;
}
* API result array
*/
function survey_get_example() {
- $params = array(
+ $params = [
'title' => 'survey title',
'activity_type_id' => '30',
'max_number_of_contacts' => 12,
'instructions' => 'Call people, ask for money',
- );
+ ];
try{
$result = civicrm_api3('Survey', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function survey_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 2,
- 'values' => array(
- '2' => array(
+ 'values' => [
+ '2' => [
'id' => '2',
'title' => 'survey title',
'activity_type_id' => '30',
'created_date' => '2013-07-28 08:49:19',
'bypass_confirm' => 0,
'is_share' => '1',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function survey_respondant_get_example() {
- $params = array(
+ $params = [
'sequential' => '1',
'survey_id' => 1,
- );
+ ];
try{
$result = civicrm_api3('SurveyRespondant', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function survey_respondant_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 0,
- 'values' => array(),
+ 'values' => [],
'deprecated' => 'The SurveyRespondant api is not currently supported.',
- );
+ ];
return $expectedResult;
}
* API result array
*/
function system_flush_example() {
- $params = array();
+ $params = [];
try{
$result = civicrm_api3('System', 'flush', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function system_flush_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'values' => 1,
- );
+ ];
return $expectedResult;
}
* API result array
*/
function tag_create_example() {
- $params = array(
+ $params = [
'name' => 'Super Heros',
'description' => 'Outside undie-wearers',
- );
+ ];
try{
$result = civicrm_api3('Tag', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function tag_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 12,
- 'values' => array(
- '12' => array(
+ 'values' => [
+ '12' => [
'id' => '12',
'name' => 'Super Heros',
'description' => 'Outside undie-wearers',
'created_id' => '',
'color' => '',
'created_date' => '2013-07-28 08:49:19',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function tag_delete_example() {
- $params = array(
+ $params = [
'id' => '17',
- );
+ ];
try{
$result = civicrm_api3('Tag', 'delete', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function tag_delete_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'values' => 1,
- );
+ ];
return $expectedResult;
}
* API result array
*/
function tag_get_example() {
- $params = array(
+ $params = [
'id' => '7',
'name' => 'New Tag3',
- );
+ ];
try{
$result = civicrm_api3('Tag', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function tag_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 7,
- 'values' => array(
- '7' => array(
+ 'values' => [
+ '7' => [
'id' => '7',
'name' => 'New Tag3',
'description' => 'This is description for Our New Tag ',
'is_tagset' => 0,
'used_for' => 'civicrm_contact',
'created_date' => '2013-07-28 08:49:19',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function tag_getfields_example() {
- $params = array(
+ $params = [
'action' => 'create',
- );
+ ];
try{
$result = civicrm_api3('Tag', 'getfields', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function tag_getfields_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 11,
- 'values' => array(
- 'id' => array(
+ 'values' => [
+ 'id' => [
'name' => 'id',
'type' => 1,
'title' => 'Tag ID',
'table_name' => 'civicrm_tag',
'entity' => 'Tag',
'bao' => 'CRM_Core_BAO_Tag',
- 'api.aliases' => array(
+ 'api.aliases' => [
'0' => 'tag',
- ),
- ),
- 'name' => array(
+ ],
+ ],
+ 'name' => [
'name' => 'name',
'type' => 2,
'title' => 'Tag Name',
'entity' => 'Tag',
'bao' => 'CRM_Core_BAO_Tag',
'api.required' => 1,
- ),
- 'description' => array(
+ ],
+ 'description' => [
'name' => 'description',
'type' => 2,
'title' => 'Description',
'table_name' => 'civicrm_tag',
'entity' => 'Tag',
'bao' => 'CRM_Core_BAO_Tag',
- ),
- 'parent_id' => array(
+ ],
+ 'parent_id' => [
'name' => 'parent_id',
'type' => 1,
'title' => 'Parent Tag',
'bao' => 'CRM_Core_BAO_Tag',
'FKClassName' => 'CRM_Core_DAO_Tag',
'FKApiName' => 'Tag',
- ),
- 'is_selectable' => array(
+ ],
+ 'is_selectable' => [
'name' => 'is_selectable',
'type' => 16,
'title' => 'Display Tag?',
'table_name' => 'civicrm_tag',
'entity' => 'Tag',
'bao' => 'CRM_Core_BAO_Tag',
- ),
- 'is_reserved' => array(
+ ],
+ 'is_reserved' => [
'name' => 'is_reserved',
'type' => 16,
'title' => 'Reserved',
'table_name' => 'civicrm_tag',
'entity' => 'Tag',
'bao' => 'CRM_Core_BAO_Tag',
- ),
- 'is_tagset' => array(
+ ],
+ 'is_tagset' => [
'name' => 'is_tagset',
'type' => 16,
'title' => 'Tagset',
'table_name' => 'civicrm_tag',
'entity' => 'Tag',
'bao' => 'CRM_Core_BAO_Tag',
- ),
- 'used_for' => array(
+ ],
+ 'used_for' => [
'name' => 'used_for',
'type' => 2,
'title' => 'Used For',
'table_name' => 'civicrm_tag',
'entity' => 'Tag',
'bao' => 'CRM_Core_BAO_Tag',
- 'html' => array(
+ 'html' => [
'type' => 'Select',
'maxlength' => 64,
'size' => 30,
- ),
- 'pseudoconstant' => array(
+ ],
+ 'pseudoconstant' => [
'optionGroupName' => 'tag_used_for',
'optionEditPath' => 'civicrm/admin/options/tag_used_for',
- ),
+ ],
'api.default' => 'civicrm_contact',
- ),
- 'created_id' => array(
+ ],
+ 'created_id' => [
'name' => 'created_id',
'type' => 1,
'title' => 'Tag Created By',
'bao' => 'CRM_Core_BAO_Tag',
'FKClassName' => 'CRM_Contact_DAO_Contact',
'FKApiName' => 'Contact',
- ),
- 'color' => array(
+ ],
+ 'color' => [
'name' => 'color',
'type' => 2,
'title' => 'Color',
'table_name' => 'civicrm_tag',
'entity' => 'Tag',
'bao' => 'CRM_Core_BAO_Tag',
- ),
- 'created_date' => array(
+ ],
+ 'created_date' => [
'name' => 'created_date',
'type' => 12,
'title' => 'Tag Created Date',
'table_name' => 'civicrm_tag',
'entity' => 'Tag',
'bao' => 'CRM_Core_BAO_Tag',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function tag_getlist_example() {
- $params = array(
+ $params = [
'input' => 'New Tag3',
- 'extra' => array(
+ 'extra' => [
'0' => 'used_for',
- ),
- );
+ ],
+ ];
try{
$result = civicrm_api3('Tag', 'getlist', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function tag_getlist_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 0,
- 'values' => array(
- '0' => array(
+ 'values' => [
+ '0' => [
'id' => '19',
'label' => 'New Tag3',
- 'description' => array(
+ 'description' => [
'0' => 'This is description for Our New Tag ',
- ),
- 'extra' => array(
+ ],
+ 'extra' => [
'used_for' => 'civicrm_contact',
- ),
- ),
- ),
+ ],
+ ],
+ ],
'page_num' => 1,
'more_results' => '',
- );
+ ];
return $expectedResult;
}
* API result array
*/
function tag_get_example() {
- $params = array(
+ $params = [
'id' => '8',
'name' => 'New Tag3',
- 'return' => array(
+ 'return' => [
'0' => 'name',
- ),
- );
+ ],
+ ];
try{
$result = civicrm_api3('Tag', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function tag_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 8,
- 'values' => array(
- '8' => array(
+ 'values' => [
+ '8' => [
'id' => '8',
'name' => 'New Tag3',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function tax_contribution_page_create_example() {
- $params = array(
+ $params = [
'contact_id' => 1,
'receive_date' => '20120511',
'total_amount' => '100',
'invoice_id' => 67890,
'source' => 'SSF',
'contribution_status_id' => 2,
- );
+ ];
try{
$result = civicrm_api3('tax_contribution_page', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'error' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function tax_contribution_page_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'id' => '1',
'contact_id' => '1',
'financial_type_id' => '11',
'creditnote_id' => '',
'tax_amount' => '20',
'contribution_type_id' => '11',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function tax_contribution_page_create_example() {
- $params = array(
+ $params = [
'contact_id' => 1,
'receive_date' => '20120511',
'total_amount' => '400',
'source' => 'SSF',
'contribution_status_id' => 1,
'skipLineItem' => 1,
- 'api.line_item.create' => array(
- '0' => array(
- 'price_field_id' => array(
+ 'api.line_item.create' => [
+ '0' => [
+ 'price_field_id' => [
'0' => 3,
- ),
+ ],
'qty' => 1,
'line_total' => '100',
'unit_price' => '100',
'financial_type_id' => 7,
- ),
- '1' => array(
- 'price_field_id' => array(
+ ],
+ '1' => [
+ 'price_field_id' => [
'0' => 3,
- ),
+ ],
'qty' => 1,
'line_total' => '300',
'unit_price' => '300',
'financial_type_id' => 8,
- ),
- ),
- );
+ ],
+ ],
+ ];
try{
$result = civicrm_api3('tax_contribution_page', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'error' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function tax_contribution_page_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'id' => '1',
'contact_id' => '1',
'financial_type_id' => '7',
'creditnote_id' => '',
'tax_amount' => '35',
'contribution_type_id' => '7',
- 'api.line_item.create' => array(
- '0' => array(
+ 'api.line_item.create' => [
+ '0' => [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '0' => array(
+ 'values' => [
+ '0' => [
'id' => '1',
'entity_table' => 'civicrm_contribution',
'entity_id' => '1',
'contribution_id' => '1',
- 'price_field_id' => array(
+ 'price_field_id' => [
'0' => '3',
- ),
+ ],
'label' => 'line item',
'qty' => '1',
'unit_price' => '100',
'financial_type_id' => '7',
'deductible_amount' => '',
'tax_amount' => '20',
- ),
- ),
- ),
- '1' => array(
+ ],
+ ],
+ ],
+ '1' => [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 2,
- 'values' => array(
- '0' => array(
+ 'values' => [
+ '0' => [
'id' => '2',
'entity_table' => 'civicrm_contribution',
'entity_id' => '1',
'contribution_id' => '1',
- 'price_field_id' => array(
+ 'price_field_id' => [
'0' => '3',
- ),
+ ],
'label' => 'line item',
'qty' => '1',
'unit_price' => '300',
'financial_type_id' => '8',
'deductible_amount' => '',
'tax_amount' => '15',
- ),
- ),
- ),
- ),
- ),
- ),
- );
+ ],
+ ],
+ ],
+ ],
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function tax_contribution_page_delete_example() {
- $params = array(
+ $params = [
'id' => 1,
- );
+ ];
try{
$result = civicrm_api3('tax_contribution_page', 'delete', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'error' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function tax_contribution_page_delete_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
+ 'values' => [
'1' => 1,
- ),
- );
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function uf_field_create_example() {
- $params = array(
+ $params = [
'field_name' => 'phone',
'field_type' => 'Contact',
'visibility' => 'Public Pages and Listings',
'location_type_id' => 1,
'phone_type_id' => 1,
'uf_group_id' => 11,
- );
+ ];
try{
$result = civicrm_api3('UFField', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function uf_field_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'id' => '1',
'uf_group_id' => '11',
'field_name' => 'phone',
'field_type' => 'Contact',
'is_reserved' => '',
'is_multi_summary' => '',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function uf_field_delete_example() {
- $params = array(
+ $params = [
'field_id' => 1,
- );
+ ];
try{
$result = civicrm_api3('UFField', 'delete', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function uf_field_delete_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'values' => TRUE,
- );
+ ];
return $expectedResult;
}
* API result array
*/
function uf_field_get_example() {
- $params = array();
+ $params = [];
try{
$result = civicrm_api3('UFField', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function uf_field_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'id' => '1',
'uf_group_id' => '11',
'field_name' => 'phone',
'label' => 'Test Phone',
'field_type' => 'Contact',
'is_multi_summary' => 0,
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function uf_field_replace_example() {
- $params = array(
+ $params = [
'uf_group_id' => 11,
'option.autoweight' => '',
- 'values' => array(
- '0' => array(
+ 'values' => [
+ '0' => [
'field_name' => 'first_name',
'field_type' => 'Contact',
'visibility' => 'Public Pages and Listings',
'label' => 'Test First Name',
'is_searchable' => 1,
'is_active' => 1,
- ),
- '1' => array(
+ ],
+ '1' => [
'field_name' => 'country',
'field_type' => 'Contact',
'visibility' => 'Public Pages and Listings',
'is_searchable' => 1,
'is_active' => 1,
'location_type_id' => 1,
- ),
- '2' => array(
+ ],
+ '2' => [
'field_name' => 'phone',
'field_type' => 'Contact',
'visibility' => 'Public Pages and Listings',
'is_active' => 1,
'location_type_id' => 1,
'phone_type_id' => 1,
- ),
- ),
+ ],
+ ],
'check_permissions' => TRUE,
- );
+ ];
try{
$result = civicrm_api3('UFField', 'replace', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function uf_field_replace_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 3,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'id' => '1',
'uf_group_id' => '11',
'field_name' => 'first_name',
'field_type' => 'Contact',
'is_reserved' => '',
'is_multi_summary' => '',
- ),
- '2' => array(
+ ],
+ '2' => [
'id' => '2',
'uf_group_id' => '11',
'field_name' => 'country',
'field_type' => 'Contact',
'is_reserved' => '',
'is_multi_summary' => '',
- ),
- '3' => array(
+ ],
+ '3' => [
'id' => '3',
'uf_group_id' => '11',
'field_name' => 'phone',
'field_type' => 'Contact',
'is_reserved' => '',
'is_multi_summary' => '',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function uf_group_create_example() {
- $params = array(
+ $params = [
'add_captcha' => 1,
'add_contact_to_group' => 1,
'group' => 1,
'notify' => 'admin@example.org',
'post_URL' => 'http://example.org/post',
'title' => 'Test Group',
- );
+ ];
try{
$result = civicrm_api3('UFGroup', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function uf_group_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 2,
- 'values' => array(
- '2' => array(
+ 'values' => [
+ '2' => [
'id' => '2',
'is_active' => 0,
'group_type' => 'Individual,Contact',
'created_id' => '1',
'created_date' => '2013-07-28 08:49:19',
'is_proximity_search' => '',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function uf_group_delete_example() {
- $params = array(
+ $params = [
'id' => 2,
- );
+ ];
try{
$result = civicrm_api3('UFGroup', 'delete', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function uf_group_delete_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'values' => 1,
- );
+ ];
return $expectedResult;
}
* API result array
*/
function uf_group_get_example() {
- $params = array(
+ $params = [
'id' => 2,
- );
+ ];
try{
$result = civicrm_api3('UFGroup', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function uf_group_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 2,
- 'values' => array(
- '2' => array(
+ 'values' => [
+ '2' => [
'id' => '2',
'is_active' => 0,
'group_type' => 'Individual,Contact',
'created_id' => '1',
'created_date' => '2013-07-28 08:49:19',
'is_proximity_search' => 0,
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function uf_join_create_example() {
- $params = array(
+ $params = [
'module' => 'CiviCampaign',
'entity_table' => 'civicrm_survey',
'entity_id' => 1,
'uf_group_id' => 11,
'is_active' => 1,
'sequential' => 1,
- );
+ ];
try{
$result = civicrm_api3('UFJoin', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function uf_join_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 0,
- 'values' => array(
- '0' => array(
+ 'values' => [
+ '0' => [
'id' => '1',
'is_active' => '1',
'module' => 'CiviCampaign',
'weight' => '1',
'uf_group_id' => '11',
'module_data' => '',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function uf_join_get_example() {
- $params = array(
+ $params = [
'entity_table' => 'civicrm_contribution_page',
'entity_id' => 1,
'sequential' => 1,
- );
+ ];
try{
$result = civicrm_api3('UFJoin', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function uf_join_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '0' => array(
+ 'values' => [
+ '0' => [
'id' => '1',
'is_active' => '1',
'module' => 'CiviContribute',
'entity_id' => '1',
'weight' => '1',
'uf_group_id' => '11',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function uf_match_get_example() {
- $params = array(
+ $params = [
'contact_id' => 69,
- );
+ ];
try{
$result = civicrm_api3('UFMatch', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function uf_match_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'id' => '1',
'domain_id' => '1',
'uf_id' => '42',
'contact_id' => '69',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function website_create_example() {
- $params = array(
+ $params = [
'contact_id' => 3,
'url' => 'website.com',
'website_type_id' => 1,
- );
+ ];
try{
$result = civicrm_api3('Website', 'create', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function website_create_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 1,
- 'values' => array(
- '1' => array(
+ 'values' => [
+ '1' => [
'id' => '1',
'contact_id' => '3',
'url' => 'website.com',
'website_type_id' => '1',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function website_delete_example() {
- $params = array(
+ $params = [
'id' => 3,
- );
+ ];
try{
$result = civicrm_api3('Website', 'delete', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function website_delete_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'values' => 1,
- );
+ ];
return $expectedResult;
}
* API result array
*/
function website_get_example() {
- $params = array(
+ $params = [
'contact_id' => 4,
'url' => 'website.com',
'website_type_id' => 1,
- );
+ ];
try{
$result = civicrm_api3('Website', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function website_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 1,
'id' => 2,
- 'values' => array(
- '2' => array(
+ 'values' => [
+ '2' => [
'id' => '2',
'contact_id' => '4',
'url' => 'website.com',
'website_type_id' => '1',
- ),
- ),
- );
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function website_getfields_example() {
- $params = array(
+ $params = [
'action' => 'get',
- );
+ ];
try{
$result = civicrm_api3('Website', 'getfields', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function website_getfields_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 4,
- 'values' => array(
- 'id' => array(
+ 'values' => [
+ 'id' => [
'name' => 'id',
'type' => 1,
'title' => 'Website ID',
'table_name' => 'civicrm_website',
'entity' => 'Website',
'bao' => 'CRM_Core_BAO_Website',
- 'api.aliases' => array(
+ 'api.aliases' => [
'0' => 'website_id',
- ),
- ),
- 'contact_id' => array(
+ ],
+ ],
+ 'contact_id' => [
'name' => 'contact_id',
'type' => 1,
'title' => 'Contact',
'bao' => 'CRM_Core_BAO_Website',
'FKClassName' => 'CRM_Contact_DAO_Contact',
'FKApiName' => 'Contact',
- ),
- 'url' => array(
+ ],
+ 'url' => [
'name' => 'url',
'type' => 2,
'title' => 'Website',
'table_name' => 'civicrm_website',
'entity' => 'Website',
'bao' => 'CRM_Core_BAO_Website',
- 'html' => array(
+ 'html' => [
'type' => 'Text',
'maxlength' => 128,
'size' => 30,
- ),
- ),
- 'website_type_id' => array(
+ ],
+ ],
+ 'website_type_id' => [
'name' => 'website_type_id',
'type' => 1,
'title' => 'Website Type',
'table_name' => 'civicrm_website',
'entity' => 'Website',
'bao' => 'CRM_Core_BAO_Website',
- 'html' => array(
+ 'html' => [
'type' => 'Select',
'size' => 6,
'maxlength' => 14,
- ),
- 'pseudoconstant' => array(
+ ],
+ 'pseudoconstant' => [
'optionGroupName' => 'website_type',
'optionEditPath' => 'civicrm/admin/options/website_type',
- ),
- ),
- ),
- );
+ ],
+ ],
+ ],
+ ];
return $expectedResult;
}
* API result array
*/
function website_get_example() {
- $params = array(
- 'options' => array(
- 'metadata' => array(
+ $params = [
+ 'options' => [
+ 'metadata' => [
'0' => 'fields',
- ),
- ),
- );
+ ],
+ ],
+ ];
try{
$result = civicrm_api3('Website', 'get', $params);
$errorMessage = $e->getMessage();
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
- return array(
+ return [
'is_error' => 1,
'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
- );
+ ];
}
return $result;
*/
function website_get_expectedresult() {
- $expectedResult = array(
+ $expectedResult = [
'is_error' => 0,
'version' => 3,
'count' => 0,
- 'values' => array(),
- 'metadata' => array(
- 'fields' => array(
- 'id' => array(
+ 'values' => [],
+ 'metadata' => [
+ 'fields' => [
+ 'id' => [
'name' => 'id',
'type' => '1',
'title' => 'Website ID',
'table_name' => 'civicrm_website',
'entity' => 'Website',
'bao' => 'CRM_Core_BAO_Website',
- 'api.aliases' => array(
+ 'api.aliases' => [
'0' => 'website_id',
- ),
- ),
- 'contact_id' => array(
+ ],
+ ],
+ 'contact_id' => [
'name' => 'contact_id',
'type' => '1',
'title' => 'Contact',
'bao' => 'CRM_Core_BAO_Website',
'FKClassName' => 'CRM_Contact_DAO_Contact',
'FKApiName' => 'Contact',
- ),
- 'url' => array(
+ ],
+ 'url' => [
'name' => 'url',
'type' => '2',
'title' => 'Website',
'table_name' => 'civicrm_website',
'entity' => 'Website',
'bao' => 'CRM_Core_BAO_Website',
- 'html' => array(
+ 'html' => [
'type' => 'Text',
'maxlength' => '128',
'size' => '30',
- ),
- ),
- 'website_type_id' => array(
+ ],
+ ],
+ 'website_type_id' => [
'name' => 'website_type_id',
'type' => '1',
'title' => 'Website Type',
'table_name' => 'civicrm_website',
'entity' => 'Website',
'bao' => 'CRM_Core_BAO_Website',
- 'html' => array(
+ 'html' => [
'type' => 'Select',
'size' => '6',
'maxlength' => '14',
- ),
- 'pseudoconstant' => array(
+ ],
+ 'pseudoconstant' => [
'optionGroupName' => 'website_type',
'optionEditPath' => 'civicrm/admin/options/website_type',
- ),
- ),
- ),
- ),
- );
+ ],
+ ],
+ ],
+ ],
+ ];
return $expectedResult;
}
* @param array $keyoptions
* List of required fields options. One of the options is required.
*/
-function civicrm_api3_verify_one_mandatory($params, $daoName = NULL, $keyoptions = array()) {
- $keys = array(array());
+function civicrm_api3_verify_one_mandatory($params, $daoName = NULL, $keyoptions = []) {
+ $keys = [[]];
foreach ($keyoptions as $key) {
$keys[0][] = $key;
}
*
* @throws \API_Exception
*/
-function civicrm_api3_verify_mandatory($params, $daoName = NULL, $keys = array(), $verifyDAO = TRUE) {
- $unmatched = array();
+function civicrm_api3_verify_mandatory($params, $daoName = NULL, $keys = [], $verifyDAO = TRUE) {
+ $unmatched = [];
if (!empty($params['id'])) {
- $keys = array('version');
+ $keys = ['version'];
}
else {
if (!in_array('version', $keys)) {
foreach ($keys as $key) {
if (is_array($key)) {
$match = 0;
- $optionset = array();
+ $optionset = [];
foreach ($key as $subkey) {
if (!array_key_exists($subkey, $params) || empty($params[$subkey])) {
$optionset[] = $subkey;
}
}
if (!empty($unmatched)) {
- throw new API_Exception("Mandatory key(s) missing from params array: " . implode(", ", $unmatched), "mandatory_missing", array("fields" => $unmatched));
+ throw new API_Exception("Mandatory key(s) missing from params array: " . implode(", ", $unmatched), "mandatory_missing", ["fields" => $unmatched]);
}
}
*
* @return array
*/
-function civicrm_api3_create_error($msg, $data = array()) {
+function civicrm_api3_create_error($msg, $data = []) {
$data['is_error'] = 1;
$data['error_message'] = $msg;
*
* @return array
*/
-function civicrm_api3_create_success($values = 1, $params = array(), $entity = NULL, $action = NULL, &$dao = NULL, $extraReturnValues = array()) {
- $result = array();
+function civicrm_api3_create_success($values = 1, $params = [], $entity = NULL, $action = NULL, &$dao = NULL, $extraReturnValues = []) {
+ $result = [];
$lowercase_entity = _civicrm_api_get_entity_name_from_camel($entity);
// TODO: This shouldn't be necessary but this fn sometimes gets called with lowercase entity
$entity = _civicrm_api_get_camel_name($entity);
if (is_array($params) && !empty($params['debug'])) {
if (is_string($action) && $action != 'getfields') {
- $apiFields = civicrm_api($entity, 'getfields', array('version' => 3, 'action' => $action) + $params);
+ $apiFields = civicrm_api($entity, 'getfields', ['version' => 3, 'action' => $action] + $params);
}
elseif ($action != 'getfields') {
- $apiFields = civicrm_api($entity, 'getfields', array('version' => 3) + $params);
+ $apiFields = civicrm_api($entity, 'getfields', ['version' => 3] + $params);
}
else {
$apiFields = FALSE;
}
- $allFields = array();
+ $allFields = [];
if ($action != 'getfields' && is_array($apiFields) && is_array(CRM_Utils_Array::value('values', $apiFields))) {
$allFields = array_keys($apiFields['values']);
}
$paramFields = array_keys($params);
- $undefined = array_diff($paramFields, $allFields, array_keys($_COOKIE), array(
+ $undefined = array_diff($paramFields, $allFields, array_keys($_COOKIE), [
'action',
'entity',
'debug',
'option_sort',
'options',
'prettyprint',
- ));
+ ]);
if ($undefined) {
$result['undefined_fields'] = array_merge($undefined);
}
if (!empty($params['options']['metadata'])) {
// We've made metadata an array but only supporting 'fields' atm.
if (in_array('fields', (array) $params['options']['metadata']) && $action !== 'getfields') {
- $fields = civicrm_api3($entity, 'getfields', array(
+ $fields = civicrm_api3($entity, 'getfields', [
'action' => substr($action, 0, 3) == 'get' ? 'get' : 'create',
- ));
+ ]);
$result['metadata']['fields'] = $fields['values'];
}
}
$deprecated = _civicrm_api3_deprecation_check($entity, $result);
// Always report "setvalue" action as deprecated.
if (!is_string($deprecated) && ($action == 'getactions' || $action == 'setvalue')) {
- $deprecated = ((array) $deprecated) + array('setvalue' => 'The "setvalue" action is deprecated. Use "create" with an id instead.');
+ $deprecated = ((array) $deprecated) + ['setvalue' => 'The "setvalue" action is deprecated. Use "create" with an id instead.'];
}
// Always report "update" action as deprecated.
if (!is_string($deprecated) && ($action == 'getactions' || $action == 'update')) {
- $deprecated = ((array) $deprecated) + array('update' => 'The "update" action is deprecated. Use "create" with an id instead.');
+ $deprecated = ((array) $deprecated) + ['update' => 'The "update" action is deprecated. Use "create" with an id instead.'];
}
if ($deprecated) {
// Metadata-level deprecations or wholesale entity deprecations.
* @param array $values
*/
function _civicrm_api3_filter_fields_for_bao($entity, &$params, &$values) {
- $fields = civicrm_api($entity, 'getfields', array('version' => 3, 'action' => 'create'));
+ $fields = civicrm_api($entity, 'getfields', ['version' => 3, 'action' => 'create']);
$fields = $fields['values'];
_civicrm_api3_store_values($fields, $params, $values);
}
* @return array
*/
function _civicrm_api3_field_names($fields) {
- $result = array();
+ $result = [];
foreach ($fields as $key => $value) {
if (!empty($value['name'])) {
$result[] = $value['name'];
* @return array
* @throws API_Exception
*/
-function _civicrm_api3_get_using_query_object($entity, $params, $additional_options = array(), $getCount = NULL, $mode = 1, $defaultReturnProperties = NULL) {
+function _civicrm_api3_get_using_query_object($entity, $params, $additional_options = [], $getCount = NULL, $mode = 1, $defaultReturnProperties = NULL) {
$lowercase_entity = _civicrm_api_get_entity_name_from_camel($entity);
// Convert id to e.g. contact_id
if (empty($params[$lowercase_entity . '_id']) && isset($params['id'])) {
$options = _civicrm_api3_get_options_from_params($params, TRUE);
$inputParams = array_merge(
- CRM_Utils_Array::value('input_params', $options, array()),
- CRM_Utils_Array::value('input_params', $additional_options, array())
+ CRM_Utils_Array::value('input_params', $options, []),
+ CRM_Utils_Array::value('input_params', $additional_options, [])
);
$returnProperties = array_merge(
- CRM_Utils_Array::value('return', $options, array()),
- CRM_Utils_Array::value('return', $additional_options, array())
+ CRM_Utils_Array::value('return', $options, []),
+ CRM_Utils_Array::value('return', $additional_options, [])
);
if (empty($returnProperties)) {
$returnProperties = $defaultReturnProperties;
}
if (!empty($params['check_permissions'])) {
// we will filter query object against getfields
- $fields = civicrm_api($entity, 'getfields', array('version' => 3, 'action' => 'get'));
+ $fields = civicrm_api($entity, 'getfields', ['version' => 3, 'action' => 'get']);
// we need to add this in as earlier in this function 'id' was unset in favour of $entity_id
- $fields['values'][$lowercase_entity . '_id'] = array();
- $varsToFilter = array('returnProperties', 'inputParams');
+ $fields['values'][$lowercase_entity . '_id'] = [];
+ $varsToFilter = ['returnProperties', 'inputParams'];
foreach ($varsToFilter as $varToFilter) {
if (!is_array($$varToFilter)) {
continue;
$sort = CRM_Utils_Array::value('sort', $options, NULL);
$offset = CRM_Utils_Array::value('offset', $options);
$rowCount = CRM_Utils_Array::value('limit', $options);
- $inputParams = CRM_Utils_Array::value('input_params', $options, array());
+ $inputParams = CRM_Utils_Array::value('input_params', $options, []);
$returnProperties = CRM_Utils_Array::value('return', $options, NULL);
if (empty($returnProperties)) {
$returnProperties = CRM_Contribute_BAO_Query::defaultReturnProperties($mode);
$sql .= " LIMIT $offset, $rowCount ";
}
$dao = CRM_Core_DAO::executeQuery($sql);
- return array($dao, $query);
+ return [$dao, $query];
}
/**
* @throws API_Exception
* @throws Exception
*/
-function _civicrm_api3_dao_set_filter(&$dao, $params, $unique = TRUE, $extraSql = array()) {
+function _civicrm_api3_dao_set_filter(&$dao, $params, $unique = TRUE, $extraSql = []) {
$entity = _civicrm_api_get_entity_name_from_dao($dao);
$lowercase_entity = _civicrm_api_get_entity_name_from_camel($entity);
if (!empty($params[$lowercase_entity . "_id"]) && empty($params['id'])) {
}
}
if (!$fields) {
- $fields = array();
+ $fields = [];
}
foreach ($fields as $field) {
$sort = CRM_Utils_Array::value('sort', $params['options'], $sort);
}
- $returnProperties = array();
+ $returnProperties = [];
// handle the format return =sort_name,display_name...
if (array_key_exists('return', $params)) {
if (is_array($params['return'])) {
}
}
- $options = array(
+ $options = [
'offset' => CRM_Utils_Rule::integer($offset) ? $offset : NULL,
'limit' => (!$is_count && CRM_Utils_Rule::integer($limit)) ? $limit : NULL,
'is_count' => $is_count,
- 'return' => !empty($returnProperties) ? $returnProperties : array(),
- );
+ 'return' => !empty($returnProperties) ? $returnProperties : [],
+ ];
- $finalSort = array();
+ $finalSort = [];
$options['sort'] = NULL;
if (!empty($sort)) {
if (!is_array($sort)) {
}
//here comes the legacy support for $returnProperties, $inputParams e.g for contat_get
// if the query object is being used this should be used
- $inputParams = array();
- $legacyreturnProperties = array();
- $otherVars = array(
+ $inputParams = [];
+ $legacyreturnProperties = [];
+ $otherVars = [
'sort', 'offset', 'rowCount', 'options', 'return',
'version', 'prettyprint', 'check_permissions', 'sequential',
- );
+ ];
foreach ($params as $n => $v) {
if (substr($n, 0, 7) == 'return.') {
$legacyreturnProperties[substr($n, 7)] = $v;
* @return array
*/
function _civicrm_api3_dao_to_array($dao, $params = NULL, $uniqueFields = TRUE, $entity = "", $autoFind = TRUE) {
- $result = array();
+ $result = [];
if (isset($params['options']) && !empty($params['options']['is_count'])) {
return $dao->count();
}
if (empty($dao)) {
- return array();
+ return [];
}
if ($autoFind && !$dao->find()) {
- return array();
+ return [];
}
if (isset($dao->count)) {
$fields = array_keys(_civicrm_api3_build_fields_array($dao, FALSE));
while ($dao->fetch()) {
- $tmp = array();
+ $tmp = [];
foreach ($fields as $key) {
if (array_key_exists($key, $dao)) {
// not sure on that one
* ID of entity per $extends.
*/
function _civicrm_api3_custom_format_params($params, &$values, $extends, $entityId = NULL) {
- $values['custom'] = array();
+ $values['custom'] = [];
$checkCheckBoxField = FALSE;
$entity = $extends;
- if (in_array($extends, array('Household', 'Individual', 'Organization'))) {
+ if (in_array($extends, ['Household', 'Individual', 'Organization'])) {
$entity = 'Contact';
}
- $fields = civicrm_api($entity, 'getfields', array('version' => 3, 'action' => 'create'));
+ $fields = civicrm_api($entity, 'getfields', ['version' => 3, 'action' => 'create']);
if (!$fields['is_error']) {
// not sure if fields could be error - maybe change to using civicrm_api3 wrapper later - this is conservative
$fields = $fields['values'];
* @param $entity
*/
function _civicrm_api3_format_params_for_create(&$params, $entity) {
- $nonGenericEntities = array('Contact', 'Individual', 'Household', 'Organization');
+ $nonGenericEntities = ['Contact', 'Individual', 'Household', 'Organization'];
$customFieldEntities = array_diff_key(CRM_Core_SelectValues::customGroupExtends(), array_fill_keys($nonGenericEntities, 1));
if (!array_key_exists($entity, $customFieldEntities)) {
return;
}
- $values = array();
+ $values = [];
_civicrm_api3_custom_format_params($params, $values, $entity);
$params = array_merge($params, $values);
}
// We can assume it's pre-formatted.
return;
}
- $options = civicrm_api($entity, 'getoptions', array('field' => $customFieldLabel, 'version' => 3));
+ $options = civicrm_api($entity, 'getoptions', ['field' => $customFieldLabel, 'version' => 3]);
if (!empty($options['is_error'])) {
// The check is precautionary - can probably be removed later.
return;
$query = new \Civi\API\Api3SelectQuery($entity, CRM_Utils_Array::value('check_permissions', $params, FALSE));
$query->where = $params;
if ($options['is_count']) {
- $query->select = array('count_rows');
+ $query->select = ['count_rows'];
}
else {
$query->select = array_keys(array_filter($options['return']));
_civicrm_api3_format_params_for_create($params, $entity);
$args = array(&$params);
if ($entity) {
- $ids = array($entity => CRM_Utils_Array::value('id', $params));
+ $ids = [$entity => CRM_Utils_Array::value('id', $params)];
$args[] = &$ids;
}
if (method_exists($bao_name, 'create')) {
$fct = 'create';
$fct_name = $bao_name . '::' . $fct;
- $bao = call_user_func_array(array($bao_name, $fct), $args);
+ $bao = call_user_func_array([$bao_name, $fct], $args);
}
elseif (method_exists($bao_name, 'add')) {
$fct = 'add';
$fct_name = $bao_name . '::' . $fct;
- $bao = call_user_func_array(array($bao_name, $fct), $args);
+ $bao = call_user_func_array([$bao_name, $fct], $args);
}
else {
$fct_name = '_civicrm_api3_basic_create_fallback';
if (isset($params['custom']) && empty(CRM_Core_BAO_CustomQuery::$extendsMap[$entity])) {
CRM_Core_BAO_CustomValueTable::store($params['custom'], CRM_Core_DAO_AllCoreTables::getTableForClass(CRM_Core_DAO_AllCoreTables::getFullName($entity)), $bao->id);
}
- $values = array();
+ $values = [];
_civicrm_api3_object_to_array($bao, $values[$bao->id]);
return civicrm_api3_create_success($values, $params, $entity, 'create', $bao);
}
}
$entityName = CRM_Core_DAO_AllCoreTables::getBriefName($dao_name);
if (empty($entityName)) {
- throw new API_Exception("Class \"$bao_name\" does not map to an entity name", "unmapped_class_to_entity", array(
+ throw new API_Exception("Class \"$bao_name\" does not map to an entity name", "unmapped_class_to_entity", [
'class_name' => $bao_name,
- ));
+ ]);
}
$hook = empty($params['id']) ? 'create' : 'edit';
* @throws \Civi\API\Exception\UnauthorizedException
*/
function _civicrm_api3_basic_delete($bao_name, &$params) {
- civicrm_api3_verify_mandatory($params, NULL, array('id'));
- _civicrm_api3_check_edit_permissions($bao_name, array('id' => $params['id']));
+ civicrm_api3_verify_mandatory($params, NULL, ['id']);
+ _civicrm_api3_check_edit_permissions($bao_name, ['id' => $params['id']]);
$args = array(&$params['id']);
if (method_exists($bao_name, 'del')) {
$dao = new $bao_name();
$dao->id = $params['id'];
if ($dao->find()) {
- $bao = call_user_func_array(array($bao_name, 'del'), $args);
+ $bao = call_user_func_array([$bao_name, 'del'], $args);
if ($bao !== FALSE) {
return civicrm_api3_create_success();
}
$checkPermission
);
$groupTree = CRM_Core_BAO_CustomGroup::formatGroupTree($groupTree, 1);
- $customValues = array();
+ $customValues = [];
CRM_Core_BAO_CustomGroup::setDefaults($groupTree, $customValues);
- $fieldInfo = array();
+ $fieldInfo = [];
foreach ($groupTree as $set) {
$fieldInfo += $set['fields'];
}
* @return array $errors
*/
function _civicrm_api3_validate($entity, $action, $params) {
- $errors = array();
- $fields = civicrm_api3($entity, 'getfields', array('sequential' => 1, 'api_action' => $action));
+ $errors = [];
+ $fields = civicrm_api3($entity, 'getfields', ['sequential' => 1, 'api_action' => $action]);
$fields = $fields['values'];
// Check for required fields.
foreach ($fields as $values) {
if (!empty($values['api.required']) && empty($params[$values['name']])) {
- $errors[$values['name']] = array(
+ $errors[$values['name']] = [
'message' => "Mandatory key(s) missing from params array: " . $values['name'],
'code' => "mandatory_missing",
- );
+ ];
}
}
// Select only the fields which have been input as a param.
- $finalfields = array();
+ $finalfields = [];
foreach ($fields as $values) {
if (array_key_exists($values['name'], $params)) {
$finalfields[] = $values;
_civicrm_api3_validate_switch_cases($fieldName, $fieldInfo, $entity, $params);
}
catch (Exception $e) {
- $errors[$fieldName] = array(
+ $errors[$fieldName] = [
'message' => $e->getMessage(),
'code' => 'incorrect_value',
- );
+ ];
}
}
- return array($errors);
+ return [$errors];
}
/**
if (strpos($op, 'NULL') !== FALSE || strpos($op, 'EMPTY') !== FALSE) {
return;
}
- $existing = civicrm_api($params['entity'], 'get', array(
+ $existing = civicrm_api($params['entity'], 'get', [
'version' => $params['version'],
$fieldName => $fieldValue,
- ));
+ ]);
// an entry already exists for this unique field
if ($existing['count'] == 1) {
// question - could this ever be a security issue?
}
// Save the new/updated records
- $creates = array();
+ $creates = [];
foreach ($params['values'] as $replacement) {
// Sugar: Don't force clients to duplicate the 'key' data
$replacement = array_merge($baseParams, $replacement);
array_keys($creates)
);
foreach ($staleIDs as $staleID) {
- $delete = civicrm_api($entity, 'delete', array(
+ $delete = civicrm_api($entity, 'delete', [
'version' => $params['version'],
'id' => $staleID,
- ));
+ ]);
if (civicrm_error($delete)) {
$transaction->rollback();
return $delete;
*
* @return array
*/
-function _civicrm_api_get_fields($entity, $unique = FALSE, &$params = array()) {
- $unsetIfEmpty = array(
+function _civicrm_api_get_fields($entity, $unique = FALSE, &$params = []) {
+ $unsetIfEmpty = [
'dataPattern',
'headerPattern',
'default',
'export',
'import',
- );
+ ];
$dao = _civicrm_api3_get_DAO($entity);
if (empty($dao)) {
- return array();
+ return [];
}
$d = new $dao();
$fields = $d->fields();
FALSE
);
- $ret = array();
+ $ret = [];
foreach ($customfields as $key => $value) {
// Regular fields have a 'name' property
if (!is_numeric($fieldValue) && is_scalar($fieldValue)) {
$realContactId = _civicrm_api3_resolve_contactID($fieldValue);
if ('unknown-user' === $realContactId) {
- throw new API_Exception("\"$fieldName\" \"{$fieldValue}\" cannot be resolved to a contact ID", 2002, array('error_field' => $fieldName, "type" => "integer"));
+ throw new API_Exception("\"$fieldName\" \"{$fieldValue}\" cannot be resolved to a contact ID", 2002, ['error_field' => $fieldName, "type" => "integer"]);
}
elseif (is_numeric($realContactId)) {
$fieldValue = $realContactId;
}
}
if (!empty($fieldInfo['pseudoconstant']) || !empty($fieldInfo['options'])) {
- _civicrm_api3_api_match_pseudoconstant($fieldValue, $entity, $fieldName, $fieldInfo, $op);
+ $additional_lookup_params = [];
+ if (strtolower($entity) == 'address' && $fieldName == 'state_province_id' && !empty($params['country_id'])) {
+ $additional_lookup_params = ['country_id' => $params['country_id']];
+ }
+ _civicrm_api3_api_match_pseudoconstant($fieldValue, $entity, $fieldName, $fieldInfo, $op, $additional_lookup_params);
}
// After swapping options, ensure we have an integer(s)
foreach ((array) ($fieldValue) as $value) {
if ($value && !is_numeric($value) && $value !== 'null' && $value !== NULL && !is_array($value)) {
- throw new API_Exception("$fieldName is not a valid integer", 2001, array('error_field' => $fieldName, "type" => "integer"));
+ throw new API_Exception("$fieldName is not a valid integer", 2001, ['error_field' => $fieldName, "type" => "integer"]);
}
}
if (is_string($fieldValue) && !empty($fieldInfo['maxlength']) && strlen($fieldValue) > $fieldInfo['maxlength']
) {
throw new API_Exception($fieldValue . " is " . strlen($fieldValue) . " characters - longer than $fieldName length" . $fieldInfo['maxlength'] . ' characters',
- 2100, array('field' => $fieldName, "max_length" => $fieldInfo['maxlength'])
+ 2100, ['field' => $fieldName, "max_length" => $fieldInfo['maxlength']]
);
}
}
}
if ($fieldValue) {
if (!CRM_Utils_Rule::xssString($fieldValue)) {
- throw new API_Exception('Input contains illegal SCRIPT tag.', array("field" => $fieldName, "error_code" => "xss"));
+ throw new API_Exception('Input contains illegal SCRIPT tag.', ["field" => $fieldName, "error_code" => "xss"]);
}
}
}
// Check our field length
elseif (is_string($fieldValue) && !empty($fieldInfo['maxlength']) && strlen(utf8_decode($fieldValue)) > $fieldInfo['maxlength']) {
throw new API_Exception("Value for $fieldName is " . strlen(utf8_decode($value)) . " characters - This field has a maxlength of {$fieldInfo['maxlength']} characters.",
- 2100, array('field' => $fieldName)
+ 2100, ['field' => $fieldName]
);
}
* @param string $fieldName : field name used in api call (not necessarily the canonical name)
* @param array $fieldInfo : getfields meta-data
* @param string $op
+ * @param array $additional_lookup_params
*
* @throws \API_Exception
*/
-function _civicrm_api3_api_match_pseudoconstant(&$fieldValue, $entity, $fieldName, $fieldInfo, $op = '=') {
- if (in_array($op, array('>', '<', '>=', '<=', 'LIKE', 'NOT LIKE'))) {
+function _civicrm_api3_api_match_pseudoconstant(&$fieldValue, $entity, $fieldName, $fieldInfo, $op = '=', $additional_lookup_params = []) {
+ if (in_array($op, ['>', '<', '>=', '<=', 'LIKE', 'NOT LIKE'])) {
return;
}
// We need to get the options from the entity the field relates to.
$entity = $fieldInfo['entity'];
}
- $options = civicrm_api($entity, 'getoptions', array(
+ $options_lookup_params = [
'version' => 3,
'field' => $fieldInfo['name'],
'context' => 'validate',
- ));
- $options = CRM_Utils_Array::value('values', $options, array());
+ ];
+ if (!empty($additional_lookup_params)) {
+ $options_lookup_params = array_merge($additional_lookup_params, $options_lookup_params);
+ }
+ $options = civicrm_api($entity, 'getoptions', $options_lookup_params);
+
+ $options = CRM_Utils_Array::value('values', $options, []);
}
// If passed a value-separated string, explode to an array, then re-implode after matching values.
// CiviMagic syntax for Nulling out the field - let it through.
return;
}
- throw new API_Exception("'$value' is not a valid option for field $fieldName", 2001, array('error_field' => $fieldName));
+ throw new API_Exception("'$value' is not a valid option for field $fieldName", 2001, ['error_field' => $fieldName]);
}
$value = $newValue;
}
if ($fieldName == _civicrm_api_get_entity_name_from_camel($entity) . '_id') {
return 'id';
}
- $result = civicrm_api($entity, 'getfields', array(
+ $result = civicrm_api($entity, 'getfields', [
'version' => 3,
'action' => $action,
- ));
+ ]);
$meta = $result['values'];
if (!isset($meta[$fieldName]['name']) && isset($meta[$fieldName . '_id'])) {
$fieldName = $fieldName . '_id';
if ($fieldName == $info['name'] || $fieldName == CRM_Utils_Array::value('uniqueName', $info)) {
return $info['name'];
}
- if (array_search($fieldName, CRM_Utils_Array::value('api.aliases', $info, array())) !== FALSE) {
+ if (array_search($fieldName, CRM_Utils_Array::value('api.aliases', $info, [])) !== FALSE) {
return $info['name'];
}
}
*
* @return string|array|null
*/
-function _civicrm_api3_deprecation_check($entity, $result = array()) {
+function _civicrm_api3_deprecation_check($entity, $result = []) {
if ($entity) {
$apiFile = "api/v3/$entity.php";
if (CRM_Utils_File::isIncludable($apiFile)) {
$op = key($fieldValue);
$fieldValue = CRM_Utils_Array::value($op, $fieldValue);
}
- return array($fieldValue, $op);
+ return [$fieldValue, $op];
}
/**
$offset = CRM_Utils_Array::value('offset', $options);
$limit = CRM_Utils_Array::value('limit', $options);
- $matches = array();
+ $matches = [];
$currentOffset = 0;
foreach ($records as $record) {
}
}
- $return = CRM_Utils_Array::value('return', $options, array());
+ $return = CRM_Utils_Array::value('return', $options, []);
if (!empty($return)) {
$return['id'] = 1;
$matches = CRM_Utils_Array::filterColumns($matches, array_keys($return));
// For lack of something more clever, here's a whitelist of entities whos permissions
// are inherited from a contact record.
// Note, when adding here, also remember to modify _civicrm_api3_permissions()
- $contactEntities = array(
+ $contactEntities = [
'CRM_Core_BAO_Email',
'CRM_Core_BAO_Phone',
'CRM_Core_BAO_Address',
'CRM_Core_BAO_IM',
'CRM_Core_BAO_Website',
'CRM_Core_BAO_OpenID',
- );
+ ];
if (!empty($params['check_permissions']) && in_array($bao_name, $contactEntities)) {
$cid = !empty($params['contact_id']) ? $params['contact_id'] : CRM_Core_DAO::getFieldValue($bao_name, $params['id'], 'contact_id');
if (!CRM_Contact_BAO_Contact_Permission::allow($cid, CRM_Core_Permission::EDIT)) {
* @return bool
*/
function _civicrm_api3_compare_timestamps($modifiedDate, $id, $entity) {
- $currentDbInfo = civicrm_api3($entity, 'getsingle', array('id' => $id));
+ $currentDbInfo = civicrm_api3($entity, 'getsingle', ['id' => $id]);
if (strtotime($currentDbInfo['modified_date']) <= strtotime($modifiedDate)) {
return TRUE;
}
"zetacomponents/mail": "dev-1.8-civi",
"marcj/topsort": "~1.1",
"phpoffice/phpword": "^0.15.0",
- "pear/Validate_Finance_CreditCard": "dev-master",
+ "pear/validate_finance_creditcard": "dev-master",
"civicrm/civicrm-cxn-rpc": "~0.19.01.08",
- "pear/Auth_SASL": "1.1.0",
- "pear/Net_SMTP": "1.6.*",
- "pear/Net_socket": "1.0.*",
+ "pear/auth_sasl": "1.1.0",
+ "pear/net_smtp": "1.6.*",
+ "pear/net_socket": "1.0.*",
"pear/mail": "^1.4",
"civicrm/civicrm-setup": "~0.2.0",
"guzzlehttp/guzzle": "^6.3",
"psr/simple-cache": "~1.0.1",
"cweagans/composer-patches": "~1.0",
- "pear/log": "1.13.1"
+ "pear/log": "1.13.1",
+ "ezyang/htmlpurifier": "4.10"
},
"repositories": [
{
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "17588dc1a1e09a5f449c38e1169c4209",
+ "content-hash": "bf8e79e6741fa30ccbc5bd59416f9f16",
"packages": [
{
"name": "civicrm/civicrm-cxn-rpc",
"homepage": "http://code.google.com/p/phpquery/",
"time": "2013-03-21T12:39:33+00:00"
},
+ {
+ "name": "ezyang/htmlpurifier",
+ "version": "v4.10.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/ezyang/htmlpurifier.git",
+ "reference": "d85d39da4576a6934b72480be6978fb10c860021"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/ezyang/htmlpurifier/zipball/d85d39da4576a6934b72480be6978fb10c860021",
+ "reference": "d85d39da4576a6934b72480be6978fb10c860021",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.2"
+ },
+ "require-dev": {
+ "simpletest/simpletest": "^1.1"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-0": {
+ "HTMLPurifier": "library/"
+ },
+ "files": [
+ "library/HTMLPurifier.composer.php"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "LGPL"
+ ],
+ "authors": [
+ {
+ "name": "Edward Z. Yang",
+ "email": "admin@htmlpurifier.org",
+ "homepage": "http://ezyang.com"
+ }
+ ],
+ "description": "Standards compliant HTML filter written in PHP",
+ "homepage": "http://htmlpurifier.org/",
+ "keywords": [
+ "html"
+ ],
+ "time": "2018-02-23T01:58:20+00:00"
+ },
{
"name": "guzzlehttp/guzzle",
"version": "6.3.0",
};
$el.on('select2-open.crmEntity', function() {
var $el = $(this);
- renderEntityRefFilterValue($el);
$('#select2-drop')
.off('.crmEntity')
.on('click.crmEntity', 'a.crm-add-entity', function(e) {
filter.value = $(this).val();
$(this).toggleClass('active', !!filter.value);
$el.data('user-filter', filter);
- if (filter.value) {
+ if (filter.value && $(this).is('select')) {
// Once a filter has been chosen, rerender create links and refocus the search box
$el.select2('close');
$el.select2('open');
'<select class="crm-entityref-filter-key' + (filter.key ? ' active' : '') + '">' +
'<option value="">' + _.escape(ts('Refine search...')) + '</option>' +
CRM.utils.renderOptions(filters, filter.key) +
- '</select>' + entityRefFilterValueMarkup(filter, filterSpec) + '</div>';
+ '</select>' + entityRefFilterValueMarkup($el, filter, filterSpec) + '</div>';
return markup;
}
/**
* Provide markup for entity ref filter value field
*/
- function entityRefFilterValueMarkup(filter, filterSpec) {
+ function entityRefFilterValueMarkup($el, filter, filterSpec) {
var markup = '';
if (filterSpec) {
var attrs = '',
attrs += ' ' + attr + '="' + val + '"';
});
if (filterSpec.type === 'select') {
- markup = '<select' + attrs + '><option value="">' + _.escape(ts('- select -')) + '</option></select>';
+ var fieldName = _.last(filter.key.split('.')),
+ options = [{key: '', value: ts('- select -')}];
+ if (filterSpec.options) {
+ options = options.concat(getEntityRefFilterOptions(fieldName, $el, filterSpec));
+ }
+ markup = '<select' + attrs + '>' + CRM.utils.renderOptions(options, filter.value) + '</select>';
} else {
markup = '<input' + attrs + '/>';
}
$valField = null;
if (filterSpec) {
$('.crm-entityref-filter-value', '#select2-drop').remove();
- $valField = $(entityRefFilterValueMarkup(filter, filterSpec));
+ $valField = $(entityRefFilterValueMarkup($el, filter, filterSpec));
$keyField.after($valField);
if (filterSpec.type === 'select') {
loadEntityRefFilterOptions(filter, filterSpec, $valField, $el);
*/
function loadEntityRefFilterOptions(filter, filterSpec, $valField, $el) {
// Fieldname may be prefixed with joins - strip those out
- var fieldName = _.last(filter.key.split('.')),
- params = $.extend({params: {}}, $el.data('api-params') || {}).params;
+ var fieldName = _.last(filter.key.split('.'));
if (filterSpec.options) {
- setEntityRefFilterOptions($valField, fieldName, params, filterSpec);
+ CRM.utils.setOptions($valField, getEntityRefFilterOptions(fieldName, $el, filterSpec), false, filter.value);
return;
}
$('.crm-entityref-filters select', '#select2-drop').prop('disabled', true);
// Store options globally so we don't have to look them up again
filterSpec.options = result.values;
$('.crm-entityref-filters select', '#select2-drop').prop('disabled', false);
- setEntityRefFilterOptions($valField, fieldName, params, filterSpec);
- $valField.val(filter.value || '');
+ CRM.utils.setOptions($valField, getEntityRefFilterOptions(fieldName, $el, filterSpec), false, filter.value);
});
}
- function setEntityRefFilterOptions($valField, fieldName, params, filterSpec) {
- var values = _.cloneDeep(filterSpec.options);
+ function getEntityRefFilterOptions(fieldName, $el, filterSpec) {
+ var values = _.cloneDeep(filterSpec.options),
+ params = $.extend({params: {}}, $el.data('api-params') || {}).params;
if (fieldName === 'contact_type' && params.contact_type) {
values = _.remove(values, function(option) {
return option.key.indexOf(params.contact_type + '__') === 0;
});
}
- CRM.utils.setOptions($valField, values);
+ return values;
}
//CRM-15598 - Override url validator method to allow relative url's (e.g. /index.htm)
.addClass('crm-menubar-hidden')
.removeClass('crm-menubar-visible');
if (showMessage === true && $('#crm-notification-container').length && initialized) {
- var alert = CRM.alert('<a href="#" id="crm-restore-menu" style="text-align: center; margin-top: -8px;">' + _.escape(ts('Restore CiviCRM Menu')) + '</a>', '', 'none', {expires: 10000});
+ var alert = CRM.alert('<a href="#" id="crm-restore-menu" >' + _.escape(ts('Restore CiviCRM Menu')) + '</a>', ts('Menu hidden'), 'none', {expires: 10000});
$('#crm-restore-menu')
- .button({icons: {primary: 'fa-undo'}})
.click(function(e) {
e.preventDefault();
alert.close();
CRM.menubar.show(speed);
- })
- .parent().css('text-align', 'center').find('.ui-button-text').css({'padding-top': '4px', 'padding-bottom': '4px'});
+ });
}
},
open: function(itemName) {
<tr>
<td>
- {include file="CRM/Core/DatePickerRange.tpl" fieldName="activity_date_time" from='_low' to='_high'}
+ {include file="CRM/Core/DatePickerRange.tpl" fieldName="activity_date_time"}
</td>
</tr>
<tr>
{ts}Filter by Activity{/ts}</a>
</div><!-- /.crm-accordion-header -->
<div class="crm-accordion-body">
+ <form><!-- form element is here to fool the datepicker widget -->
<table class="no-border form-layout-compressed activity-search-options">
<tr>
<td class="crm-contact-form-block-activity_type_filter_id crm-inline-edit-field">
<td class="crm-contact-form-block-activity_type_exclude_filter_id crm-inline-edit-field">
{$form.activity_type_exclude_filter_id.label}<br /> {$form.activity_type_exclude_filter_id.html|crmAddClass:medium}
</td>
- {include file="CRM/Core/DateRange.tpl" fieldName="activity_date_time" from='_low' to='_high' label='<label>Date</label>'}
+ <td>
+ {include file="CRM/Core/DatePickerRange.tpl" fieldName="activity_date_time"}
+ </td>
<td class="crm-contact-form-block-activity_status_filter_id crm-inline-edit-field">
<label>{ts}Status{/ts}</label><br /> {$form.status_id.html|crmAddClass:medium}
</td>
</tr>
</table>
+ </form>
</div><!-- /.crm-accordion-body -->
</div><!-- /.crm-accordion-wrapper -->
<table class="contact-activity-selector-{$context} crm-ajax-table" style="width: 100%;">
{include file="CRM/common/enableDisableApi.tpl"}
<table class="selector row-highlight">
<tr class="columnheader">
- <th >{ts}Name{/ts}</th>
- <th >{ts}Processor Type{/ts}</th>
- <th >{ts}Description{/ts}</th>
- <th >{ts}Financial Account{/ts}</th>
- <th >{ts}Enabled?{/ts}</th>
- <th >{ts}Default?{/ts}</th>
- <th ></th>
+ <th>{ts}ID{/ts}</th>
+ <th>{ts}Test ID{/ts}</th>
+ <th>{ts}Name{/ts}</th>
+ <th>{ts}Processor Type{/ts}</th>
+ <th>{ts}Description{/ts}</th>
+ <th>{ts}Financial Account{/ts}</th>
+ <th>{ts}Enabled?{/ts}</th>
+ <th>{ts}Default?{/ts}</th>
+ <th></th>
</tr>
{foreach from=$rows item=row}
<tr id="payment_processor-{$row.id}" class="crm-entity {cycle values="odd-row,even-row"} {$row.class}{if NOT $row.is_active} disabled{/if}">
+ <td class="crmf-id center">{$row.id}</td>
+ <td class="crmf-test_id center">{$row.test_id}</td>
<td class="crmf-name">{$row.name}</td>
<td class="crmf-payment_processor_type">{$row.payment_processor_type}</td>
<td class="crmf-description">{$row.description}</td>
<td class="crmf-financial_account_id">{$row.financialAccount}</td>
- <td class="crmf-is_active">{if $row.is_active eq 1} {ts}Yes{/ts} {else} {ts}No{/ts} {/if}</td>
- <td class="crmf-is_default">
+ <td class="crmf-is_active center">{if $row.is_active eq 1} {ts}Yes{/ts} {else} {ts}No{/ts} {/if}</td>
+ <td class="crmf-is_default center">
{if $row.is_default eq 1}<img src="{$config->resourceBase}i/check.gif" alt="{ts}Default{/ts}"/>{/if}
</td>
<td>{$row.action|replace:'xx':$row.id}</td>
--- /dev/null
+{htxt id="activityAsgmtGrps"}
+ <p>
+ {ts}Selecting one or more groups here will limit the choices when assigning an activity.{/ts}
+ </p>
+{/htxt}
+
+{htxt id="restrictActivityAsgmtToCmsUser"}
+ <p>
+ {ts}This will limit the choices when selecting an activity assignee to contacts with a user account on this website.{/ts}
+ </p>
+{/htxt}
<table class="row-highlight">
<tr class="columnheader">
<th> </th>
- <th><a href="{crmURL p='civicrm/contact/view' q="reset=1&cid=$other_cid"}">{$other_name|escape}</a> ({ts}duplicate{/ts})</th>
+ <th>{$otherContactTypeIcon} <a href="{crmURL p='civicrm/contact/view' q="reset=1&cid=$other_cid"}">{$other_name|escape}</a> ({ts}duplicate{/ts})</th>
<th>{ts}Mark All{/ts}<br />=={$form.toggleSelect.html} ==></th>
- <th><a href="{crmURL p='civicrm/contact/view' q="reset=1&cid=$main_cid"}">{$main_name|escape}</a></th>
+ <th>{$mainContactTypeIcon}<a href="{crmURL p='civicrm/contact/view' q="reset=1&cid=$main_cid"}">{$main_name|escape}</a></th>
<th width="300">Add/overwrite?</th>
</tr>
- {crmAPI var='other_result' entity='Contact' action='get' return="modified_date" id=$other_cid}
- {crmAPI var='main_result' entity='Contact' action='get' return="modified_date" id=$main_cid}
-
- <tr>
- <td>Last modified</td>
- <td>{$other_result.values.0.modified_date|crmDate} {if $other_result.values.0.modified_date gt $main_result.values.0.modified_date} (Most recent) {/if}</td>
- <td></td>
- <td>{$main_result.values.0.modified_date|crmDate} {if $main_result.values.0.modified_date gt $other_result.values.0.modified_date} (Most recent) {/if}</td>
- <td></td>
- </tr>
+ {foreach from=$summary_rows item=summaryRow}
+ <tr>
+ <td>{$summaryRow.label}</td>
+ <td>{$summaryRow.other_contact_value}</td>
+ <td></td>
+ <td>{$summaryRow.main_contact_value}</td>
+ <td></td>
+ </tr>
+ {/foreach}
{foreach from=$rows item=row key=field}
<td>
{* @TODO check if this is ever an array or a fileName? *}
- {if $row.title|substr:0:5 == "Email" OR
- $row.title|substr:0:7 == "Address"}
+ {if $row.location_entity == "email" OR
+ $row.location_entity == "address"}
<span style="white-space: pre">
{else}
<span>
</td>
{* For location blocks *}
- {if $row.title|substr:0:5 == "Email" OR
- $row.title|substr:0:7 == "Address" OR
- $row.title|substr:0:2 == "IM" OR
- $row.title|substr:0:7 == "Website" OR
- $row.title|substr:0:5 == "Phone"}
+ {if $row.location_entity}
<td>
{strip}
- {if $row.title|substr:0:5 == "Email" OR
- $row.title|substr:0:7 == "Address"}
+ {if $row.location_entity == "email" OR
+ $row.location_entity == "address"}
<span style="white-space: pre" id="main_{$blockName|escape}_{$blockId|escape}">
{else}
<span id="main_{$blockName|escape}_{$blockId|escape}">
<div class="crm-contribution-page-id-{$contributionPageID} crm-block crm-contribution-confirm-form-block">
<div class="help">
- <p>{ts}Please verify the information below carefully. Click<strong>Go Back</strong>if you need to make changes.{/ts}
- {if $contributeMode EQ 'notify' and ! $is_pay_later}
- {ts 1=$paymentProcessor.name 2=$button}Click the
- <strong>%2</strong>
- button to go to %1, where you will select your payment method and complete the contribution.{/ts}
- {elseif ! $is_monetary or $amount LE 0.0 or $is_pay_later}
- {ts 1=$button}To complete this transaction, click the<strong>%1</strong>button below.{/ts}
- {else}
- {ts 1=$button}To complete your contribution, click the<strong>%1</strong>button below.{/ts}
- {/if}
+ <p>{ts}Please verify the information below carefully. Click <strong>Go Back</strong> if you need to make changes.{/ts}
+ {$continueText}
</p>
</div>
<div id="crm-submit-buttons" class="crm-submit-buttons">
*}
{*this is included inside a table row*}
{assign var=relativeName value=$fieldName|cat:"_relative"}
+{assign var='from' value=$from|default:'_low'}
+{assign var='to' value=$to|default:'_high'}
{$form.$relativeName.label}<br />
{$form.$relativeName.html}<br />
*}
{* This tpl is empty. Since notes is a simple form, the tpl is embedded within the parent tpl *}
{* This might change in the future *}
-
+{include file="CRM/Contact/Page/View/Note.tpl"}
);
$expectedFilters = array(
'activity_type_filter_id' => 1,
- 'activity_type_exclude_filter_id' => '',
);
list($activities, $activityFilter) = CRM_Activity_Page_AJAX::getContactActivity();
$this->assertContains('Meeting', $value['activity_type']);
}
unset($_GET['activity_type_id']);
- $expectedFilters['activity_type_filter_id'] = '';
$_GET['activity_type_exclude_id'] = $expectedFilters['activity_type_exclude_filter_id'] = 1;
list($activities, $activityFilter) = CRM_Activity_Page_AJAX::getContactActivity();
- $this->checkArrayEquals($expectedFilters, $activityFilter);
+ $this->assertEquals(['activity_type_exclude_filter_id' => 1], $activityFilter);
// None of the activities should be of type Meeting.
foreach ($activities['data'] as $value) {
$this->assertNotContains('Meeting', $value['activity_type']);
public function setUp() {
parent::setUp();
$students = 'indivi_student' . substr(sha1(rand()), 0, 7);
- $params = array(
+ $params = [
'label' => $students,
'name' => $students,
// Individual
'parent_id' => 1,
'is_active' => 1,
- );
+ ];
CRM_Contact_BAO_ContactType::add($params);
$this->student = $params['name'];
$parents = 'indivi_parent' . substr(sha1(rand()), 0, 7);
- $params = array(
+ $params = [
'label' => $parents,
'name' => $parents,
// Individual
'parent_id' => 1,
'is_active' => 1,
- );
+ ];
CRM_Contact_BAO_ContactType::add($params);
$this->parent = $params['name'];
$orgs = 'org_sponsor' . substr(sha1(rand()), 0, 7);
- $params = array(
+ $params = [
'label' => $orgs,
'name' => $orgs,
// Organization
'parent_id' => 3,
'is_active' => 1,
- );
+ ];
CRM_Contact_BAO_ContactType::add($params);
$this->sponsor = $params['name'];
- $this->indiviParams = array(
+ $this->indiviParams = [
'first_name' => 'Anne',
'last_name' => 'Grant',
'contact_type' => 'Individual',
- );
+ ];
$this->individual = $this->individualCreate($this->indiviParams);
- $this->individualStudentParams = array(
+ $this->individualStudentParams = [
'first_name' => 'Bill',
'last_name' => 'Adams',
'contact_type' => 'Individual',
'contact_sub_type' => $this->student,
- );
+ ];
$this->individualStudent = $this->individualCreate($this->individualStudentParams);
- $this->indiviParentParams = array(
+ $this->indiviParentParams = [
'first_name' => 'Alen',
'last_name' => 'Adams',
'contact_type' => 'Individual',
'contact_sub_type' => $this->parent,
- );
+ ];
$this->indiviParent = $this->individualCreate($this->indiviParentParams);
- $this->organizationParams = array(
+ $this->organizationParams = [
'organization_name' => 'Compumentor',
'contact_type' => 'Organization',
- );
+ ];
$this->organization = $this->organizationCreate($this->organizationParams);
- $this->orgSponsorParams = array(
+ $this->orgSponsorParams = [
'organization_name' => 'Conservation Corp',
'contact_type' => 'Organization',
'contact_sub_type' => $this->sponsor,
- );
+ ];
$this->orgSponsor = $this->organizationCreate($this->orgSponsorParams);
- $this->householdParams = array(
+ $this->householdParams = [
'household_name' => "John Doe's home",
'contact_type' => 'Household',
- );
+ ];
$this->household = $this->householdCreate($this->householdParams);
}
public function testSearchWithType() {
// for type:Individual
- $params = array('contact_type' => 'Individual', 'version' => 3);
+ $params = ['contact_type' => 'Individual', 'version' => 3];
$result = civicrm_api('contact', 'get', $params);
$individual = $result['values'][$this->individual];
$this->assertEquals(end($indiviParent['contact_sub_type']), $this->indiviParentParams['contact_sub_type']);
// for type:Organization
- $params = array('contact_type' => 'Organization', 'version' => 3);
+ $params = ['contact_type' => 'Organization', 'version' => 3];
$result = civicrm_api('contact', 'get', $params);
$organization = $result['values'][$this->organization];
$this->assertEquals(end($orgSponsor['contact_sub_type']), $this->orgSponsorParams['contact_sub_type']);
// for type:Household
- $params = array('contact_type' => 'Household', 'version' => 3);
+ $params = ['contact_type' => 'Household', 'version' => 3];
$result = civicrm_api('contact', 'get', $params);
$household = $result['values'][$this->household];
public function testSearchWithSubype() {
// for subtype:Student
- $params = array('contact_sub_type' => $this->student, 'version' => 3);
+ $params = ['contact_sub_type' => $this->student, 'version' => 3];
$result = civicrm_api('contact', 'get', $params);
$individualStudent = $result['values'][$this->individualStudent];
$this->assertNotContains($this->household, $result['values']);
// for subtype:Sponsor
- $params = array('contact_sub_type' => $this->sponsor, 'version' => 3);
+ $params = ['contact_sub_type' => $this->sponsor, 'version' => 3];
$result = civicrm_api('contact', 'get', $params);
$orgSponsor = $result['values'][$this->orgSponsor];
public function testSearchWithTypeSubype() {
// for type:individual subtype:Student
- $params = array('contact_sub_type' => $this->student, 'version' => 3);
+ $params = ['contact_sub_type' => $this->student, 'version' => 3];
$result = civicrm_api('contact', 'get', $params);
$individualStudent = $result['values'][$this->individualStudent];
$this->assertNotContains($this->household, $result['values']);
// for type:Organization subtype:Sponsor
- $params = array('contact_sub_type' => $this->sponsor, 'version' => 3);
+ $params = ['contact_sub_type' => $this->sponsor, 'version' => 3];
$result = civicrm_api('contact', 'get', $params);
$orgSponsor = $result['values'][$this->orgSponsor];
*/
public function testSearchWithInvalidData() {
// for invalid type
- $params = array('contact_type' => 'Invalid' . CRM_Core_DAO::VALUE_SEPARATOR . 'Invalid', 'version' => 3);
+ $params = [
+ 'contact_type' => 'Invalid' . CRM_Core_DAO::VALUE_SEPARATOR . 'Invalid',
+ 'version' => 3,
+ ];
$result = civicrm_api('contact', 'get', $params);
$this->assertEquals(empty($result['values']), TRUE);
// for invalid subtype
- $params = array('contact_sub_type' => 'Invalid', 'version' => 3);
+ $params = ['contact_sub_type' => 'Invalid', 'version' => 3];
$result = civicrm_api('contact', 'get', $params);
$this->assertEquals(empty($result['values']), TRUE);
// for invalid contact type as well as subtype
- $params = array('contact_type' => 'Invalid' . CRM_Core_DAO::VALUE_SEPARATOR . 'Invalid', 'version' => 3);
+ $params = [
+ 'contact_type' => 'Invalid' . CRM_Core_DAO::VALUE_SEPARATOR . 'Invalid',
+ 'version' => 3,
+ ];
$result = civicrm_api('contact', 'get', $params);
$this->assertEquals(empty($result['values']), TRUE);
// for valid type and invalid subtype
- $params = array('contact_type' => 'Individual' . CRM_Core_DAO::VALUE_SEPARATOR . 'Invalid', 'version' => 3);
+ $params = [
+ 'contact_type' => 'Individual' . CRM_Core_DAO::VALUE_SEPARATOR . 'Invalid',
+ 'version' => 3,
+ ];
$result = civicrm_api('contact', 'get', $params);
$this->assertEquals(empty($result['values']), TRUE);
// for invalid type and valid subtype
- $params = array('contact_type' => 'Invalid' . CRM_Core_DAO::VALUE_SEPARATOR . 'indivi_student', 'version' => 3);
+ $params = [
+ 'contact_type' => 'Invalid' . CRM_Core_DAO::VALUE_SEPARATOR . 'indivi_student',
+ 'version' => 3,
+ ];
$result = civicrm_api('contact', 'get', $params);
$this->assertEquals(empty($result['values']), TRUE);
}
public function testSearchWithWrongdData() {
// for type:Individual subtype:Sponsor
- $defaults = array();
- $params = array('contact_type' => 'Individual' . CRM_Core_DAO::VALUE_SEPARATOR . $this->sponsor, 'version' => 3);
+ $defaults = [];
+ $params = [
+ 'contact_type' => 'Individual' . CRM_Core_DAO::VALUE_SEPARATOR . $this->sponsor,
+ 'version' => 3,
+ ];
$result = civicrm_api('contact', 'get', $params);
$this->assertEquals(empty($result['values']), TRUE);
// for type:Orgaization subtype:Parent
- $params = array('contact_type' => 'Orgaization' . CRM_Core_DAO::VALUE_SEPARATOR . $this->parent, 'version' => 3);
+ $params = [
+ 'contact_type' => 'Orgaization' . CRM_Core_DAO::VALUE_SEPARATOR . $this->parent,
+ 'version' => 3,
+ ];
$result = civicrm_api('contact', 'get', $params, $defaults);
$this->assertEquals(empty($result['values']), TRUE);
// for type:Household subtype:Sponsor
- $params = array('contact_type' => 'Household' . CRM_Core_DAO::VALUE_SEPARATOR . $this->sponsor, 'version' => 3);
+ $params = [
+ 'contact_type' => 'Household' . CRM_Core_DAO::VALUE_SEPARATOR . $this->sponsor,
+ 'version' => 3,
+ ];
$result = civicrm_api('contact', 'get', $params, $defaults);
$this->assertEquals(empty($result['values']), TRUE);
// for type:Household subtype:Student
- $params = array('contact_type' => 'Household' . CRM_Core_DAO::VALUE_SEPARATOR . $this->student, 'version' => 3);
+ $params = [
+ 'contact_type' => 'Household' . CRM_Core_DAO::VALUE_SEPARATOR . $this->student,
+ 'version' => 3,
+ ];
$result = civicrm_api('contact', 'get', $params, $defaults);
$this->assertEquals(empty($result['values']), TRUE);
}
public function setUp() {
parent::setUp();
- $params = array(
+ $params = [
'label' => 'indiv_student',
'name' => 'indiv_student',
// Individual
'parent_id' => 1,
'is_active' => 1,
- );
+ ];
$result = CRM_Contact_BAO_ContactType::add($params);
$this->student = $params['name'];
- $params = array(
+ $params = [
'label' => 'indiv_parent',
'name' => 'indiv_parent',
// Individual
'parent_id' => 1,
'is_active' => 1,
- );
+ ];
$result = CRM_Contact_BAO_ContactType::add($params);
$this->parent = $params['name'];
- $params = array(
+ $params = [
'label' => 'org_sponsor',
'name' => 'org_sponsor',
// Organization
'parent_id' => 3,
'is_active' => 1,
- );
+ ];
$result = CRM_Contact_BAO_ContactType::add($params);
$this->sponsor = $params['name'];
- $params = array(
+ $params = [
'label' => 'org_team',
'name' => 'org_team',
// Organization
'parent_id' => 3,
'is_active' => 1,
- );
+ ];
$result = CRM_Contact_BAO_ContactType::add($params);
$this->team = $params['name'];
}
public function tearDown() {
- $this->quickCleanup(array('civicrm_contact'));
+ $this->quickCleanup(['civicrm_contact']);
$query = "
DELETE FROM civicrm_contact_type
WHERE name IN ('{$this->student}','{$this->parent}','{$this->sponsor}', '{$this->team}');";
*/
public function testCreateContact() {
//check for Type:Individual
- $params = array(
+ $params = [
'first_name' => 'Anne',
'last_name' => 'Grant',
'contact_type' => 'Individual',
- );
+ ];
try {
$contact = CRM_Contact_BAO_Contact::add($params);
}
CRM_Contact_BAO_Contact::deleteContact($contact->id);
//check for Type:Organization
- $params = array(
+ $params = [
'organization_name' => 'Compumentor',
'contact_type' => 'Organization',
- );
+ ];
try {
$contact = CRM_Contact_BAO_Contact::add($params);
}
CRM_Contact_BAO_Contact::deleteContact($contact->id);
//check for Type:Household
- $params = array(
+ $params = [
'household_name' => 'John Does home',
'contact_type' => 'Household',
- );
+ ];
try {
$contact = CRM_Contact_BAO_Contact::add($params);
}
CRM_Contact_BAO_Contact::deleteContact($contact->id);
//check for Type:Individual, Subtype:Student
- $params = array(
+ $params = [
'first_name' => 'Bill',
'last_name' => 'Adams',
'contact_type' => 'Individual',
'contact_sub_type' => $this->student,
- );
+ ];
try {
$contact = CRM_Contact_BAO_Contact::add($params);
}
CRM_Contact_BAO_Contact::deleteContact($contact->id);
//check for Type:Organization, Subtype:Sponsor
- $params = array(
+ $params = [
'organization_name' => 'Conservation Corp',
'contact_type' => 'Organization',
'contact_sub_type' => $this->sponsor,
- );
+ ];
try {
$contact = CRM_Contact_BAO_Contact::add($params);
}
* Success expected.
*/
public function testUpdateContactNoSubtypeToValid() {
- $params = array(
+ $params = [
'first_name' => 'Anne',
'last_name' => 'Grant',
'contact_type' => 'Individual',
- );
+ ];
try {
$contact = CRM_Contact_BAO_Contact::add($params);
}
catch (Exception$expected) {
}
- $updateParams = array(
+ $updateParams = [
'contact_sub_type' => $this->student,
'contact_type' => 'Individual',
'contact_id' => $contact->id,
- );
+ ];
try {
$updatedContact = CRM_Contact_BAO_Contact::add($updateParams);
}
$this->assertEquals(str_replace(CRM_Core_DAO::VALUE_SEPARATOR, '', $updatedContact->contact_sub_type), $this->student);
CRM_Contact_BAO_Contact::deleteContact($contact->id);
- $params = array(
+ $params = [
'organization_name' => 'Compumentor',
'contact_type' => 'Organization',
- );
+ ];
try {
$contact = CRM_Contact_BAO_Contact::add($params);
}
catch (Exception$expected) {
}
- $updateParams = array(
+ $updateParams = [
'contact_sub_type' => $this->sponsor,
'contact_type' => 'Organization',
'contact_id' => $contact->id,
- );
+ ];
try {
$updatedContact = CRM_Contact_BAO_Contact::add($updateParams);
}
* success expected
*/
public function testUpdateContactSubtype() {
- $params = array(
+ $params = [
'first_name' => 'Anne',
'last_name' => 'Grant',
'contact_type' => 'Individual',
'contact_sub_type' => $this->student,
- );
+ ];
try {
$contact = CRM_Contact_BAO_Contact::add($params);
}
catch (Exception$expected) {
}
- $updateParams = array(
+ $updateParams = [
'contact_sub_type' => $this->parent,
'contact_type' => 'Individual',
'contact_id' => $contact->id,
- );
+ ];
try {
$updatedContact = CRM_Contact_BAO_Contact::add($updateParams);
}
$this->assertEquals(str_replace(CRM_Core_DAO::VALUE_SEPARATOR, '', $updatedContact->contact_sub_type), $this->parent);
CRM_Contact_BAO_Contact::deleteContact($contact->id);
- $params = array(
+ $params = [
'organization_name' => 'Compumentor',
'contact_type' => 'Organization',
'contact_sub_type' => $this->sponsor,
- );
+ ];
try {
$contact = CRM_Contact_BAO_Contact::add($params);
}
catch (Exception$expected) {
}
- $updateParams = array(
+ $updateParams = [
'contact_sub_type' => $this->team,
'contact_type' => 'Organization',
'contact_id' => $contact->id,
- );
+ ];
try {
$updatedContact = CRM_Contact_BAO_Contact::add($updateParams);
}
$this->assertEquals(str_replace(CRM_Core_DAO::VALUE_SEPARATOR, '', $updatedContact->contact_sub_type), $this->team);
CRM_Contact_BAO_Contact::deleteContact($contact->id);
- $params = array(
+ $params = [
'first_name' => 'Anne',
'last_name' => 'Grant',
'contact_type' => 'Individual',
'contact_sub_type' => $this->student,
- );
+ ];
try {
$contact = CRM_Contact_BAO_Contact::add($params);
}
catch (Exception$expected) {
}
- $updateParams = array(
+ $updateParams = [
'contact_sub_type' => NULL,
'contact_type' => 'Individual',
'contact_id' => $contact->id,
- );
+ ];
try {
$updatedContact = CRM_Contact_BAO_Contact::add($updateParams);
}
* Success expected
*/
public function testCRM19133() {
- $subtypesToPreserve = array($this->student, $this->parent);
+ $subtypesToPreserve = [$this->student, $this->parent];
// Create custom group that extends student and parent subtype
- $apiParams = array(
+ $apiParams = [
'title' => 'custom group',
- 'extends' => array('Individual', $subtypesToPreserve),
+ 'extends' => ['Individual', $subtypesToPreserve],
'is_active' => TRUE,
- );
+ ];
$result = civicrm_api3('customGroup', 'create', $apiParams);
$customGroupId = $result['id'];
// Create desired custom field
- $apiParams = array(
+ $apiParams = [
'debug' => 1,
'custom_group_id' => $result['id'],
'label' => 'custom field',
'html_type' => 'Text',
'data_type' => 'String',
'is_active' => TRUE,
- );
+ ];
$result = civicrm_api3('custom_field', 'create', $apiParams);
$customFieldId = $result['id'];
// Create contact of subtype parent and student
- $params = array(
+ $params = [
'first_name' => 'Anne',
'last_name' => 'Grant',
'contact_type' => 'Individual',
- 'contact_sub_type' => array($this->student, $this->parent),
- );
+ 'contact_sub_type' => [$this->student, $this->parent],
+ ];
$contact = CRM_Contact_BAO_Contact::add($params);
// Record custom value for desired customGroup
- $this->callAPISuccess('CustomValue', 'create', array('entity_id' => $contact->id, 'custom_' . $customFieldId => 'value 1'));
+ $this->callAPISuccess('CustomValue', 'create', [
+ 'entity_id' => $contact->id,
+ 'custom_' . $customFieldId => 'value 1',
+ ]);
// Subtype to be removed from customGroup setting
- $subtypesToBeRemoved = array($this->student);
+ $subtypesToBeRemoved = [$this->student];
CRM_Contact_BAO_ContactType::deleteCustomRowsOfSubtype($customGroupId, $subtypesToBeRemoved, $subtypesToPreserve);
// Check with correct value to assert that custom data is not deleted
- $result = $this->callAPISuccess('Contact', 'Get', array('custom_' . $customFieldId => 'value 1'));
+ $result = $this->callAPISuccess('Contact', 'Get', ['custom_' . $customFieldId => 'value 1']);
$this->assertEquals(1, $result['count']);
$this->assertEquals($contact->id, $result['id']);
//Check with incorrect custom value that our previous assertion was correct
- $result = $this->callAPISuccess('Contact', 'Get', array('custom_' . $customFieldId => 'wrong value'));
+ $result = $this->callAPISuccess('Contact', 'Get', ['custom_' . $customFieldId => 'wrong value']);
$this->assertEquals(0, $result['count']);
}
public function setUp() {
parent::setUp();
$labelsub1 = 'sub1_individual' . substr(sha1(rand()), 0, 7);
- $params = array(
+ $params = [
'label' => $labelsub1,
'name' => $labelsub1,
// Individual
'parent_id' => 1,
'is_active' => 1,
- );
+ ];
$result = CRM_Contact_BAO_ContactType::add($params);
$this->subTypesIndividual[] = $params['name'];
$labelsub2 = 'sub2_individual' . substr(sha1(rand()), 0, 7);
- $params = array(
+ $params = [
'label' => $labelsub2,
'name' => $labelsub2,
// Individual
'parent_id' => 1,
'is_active' => 1,
- );
+ ];
$result = CRM_Contact_BAO_ContactType::add($params);
$this->subTypesIndividual[] = $params['name'];
$labelsub = 'sub_organization' . substr(sha1(rand()), 0, 7);
- $params = array(
+ $params = [
'label' => $labelsub,
'name' => $labelsub,
// Organization
'parent_id' => 3,
'is_active' => 1,
- );
+ ];
$result = CRM_Contact_BAO_ContactType::add($params);
$this->subTypesOrganization[] = $params['name'];
$labelhousehold = 'sub_household' . substr(sha1(rand()), 0, 7);
- $params = array(
+ $params = [
'label' => $labelhousehold,
'name' => $labelhousehold,
// Household
'parent_id' => 2,
'is_active' => 1,
- );
+ ];
$result = CRM_Contact_BAO_ContactType::add($params);
$this->subTypesHousehold[] = $params['name'];
}
public function testGetMethods() {
// check all contact types
- $contactTypes = array('Individual', 'Organization', 'Household');
+ $contactTypes = ['Individual', 'Organization', 'Household'];
$result = CRM_Contact_BAO_ContactType::contactTypes('Individual');
foreach ($contactTypes as $type) {
$this->assertEquals(in_array($type, $result), TRUE);
$result = CRM_Contact_BAO_ContactType::subTypes($params);
$this->assertEquals(empty($result), TRUE);
- $params = array('invalid');
+ $params = ['invalid'];
$result = CRM_Contact_BAO_ContactType::subTypes($params);
$this->assertEquals(empty($result), TRUE);
}
*/
public function testAdd() {
- $params = array(
+ $params = [
'label' => 'indiviSubType',
'name' => 'indiviSubType',
'parent_id' => 1,
'is_active' => 1,
- );
+ ];
$result = CRM_Contact_BAO_ContactType::add($params);
$this->assertEquals($result->label, $params['label']);
$this->assertEquals($result->name, $params['name']);
$this->assertEquals($result->is_active, $params['is_active']);
CRM_Contact_BAO_ContactType::del($result->id);
- $params = array(
+ $params = [
'label' => 'householdSubType',
'name' => 'householdSubType',
'parent_id' => 2,
'is_active' => 0,
- );
+ ];
$result = CRM_Contact_BAO_ContactType::add($params);
$this->assertEquals($result->label, $params['label']);
$this->assertEquals($result->name, $params['name']);
public function testAddInvalid1() {
// parent id does not exist in db
- $params = array(
+ $params = [
'label' => 'subType',
'name' => 'subType',
// non existent
'parent_id' => 100,
'is_active' => 1,
- );
+ ];
$result = CRM_Contact_BAO_ContactType::add($params);
$this->assertEquals($result, NULL);
}
public function testAddInvalid2() {
// params does not have name and label keys
- $params = array(
+ $params = [
'parent_id' => 1,
'is_active' => 1,
- );
+ ];
$result = CRM_Contact_BAO_ContactType::add($params);
$this->assertEquals($result, NULL);
}
public function testAddInvalid3() {
// params does not have parent_id
- $params = array(
+ $params = [
'label' => 'subType',
'name' => 'subType',
'is_active' => 1,
- );
+ ];
$result = CRM_Contact_BAO_ContactType::add($params);
$this->assertEquals($result, NULL, 'In line' . __LINE__);
}
*/
public function testDel() {
- $params = array(
+ $params = [
'label' => 'indiviSubType',
'name' => 'indiviSubType',
'parent_id' => 1,
'is_active' => 1,
- );
+ ];
$subtype = CRM_Contact_BAO_ContactType::add($params);
$del = CRM_Contact_BAO_ContactType::del($subtype->id);
parent::setUp();
//create contact subtypes
- $params = array(
+ $params = [
'label' => 'indivi_student',
'name' => 'indivi_student',
// Individual
'parent_id' => 1,
'is_active' => 1,
- );
+ ];
$result = CRM_Contact_BAO_ContactType::add($params);
$this->student = $params['name'];
- $params = array(
+ $params = [
'label' => 'indivi_parent',
'name' => 'indivi_parent',
// Individual
'parent_id' => 1,
'is_active' => 1,
- );
+ ];
$result = CRM_Contact_BAO_ContactType::add($params);
$this->parent = $params['name'];
- $params = array(
+ $params = [
'label' => 'org_sponsor',
'name' => 'org_sponsor',
// Organization
'parent_id' => 3,
'is_active' => 1,
- );
+ ];
$result = CRM_Contact_BAO_ContactType::add($params);
$this->sponsor = $params['name'];
//create contacts
- $params = array(
+ $params = [
'first_name' => 'Anne',
'last_name' => 'Grant',
'contact_type' => 'Individual',
- );
+ ];
$this->individual = $this->individualCreate($params);
- $params = array(
+ $params = [
'first_name' => 'Bill',
'last_name' => 'Adams',
'contact_type' => 'Individual',
'contact_sub_type' => $this->student,
- );
+ ];
$this->indivi_student = $this->individualCreate($params);
- $params = array(
+ $params = [
'first_name' => 'Alen',
'last_name' => 'Adams',
'contact_type' => 'Individual',
'contact_sub_type' => $this->parent,
- );
+ ];
$this->indivi_parent = $this->individualCreate($params);
- $params = array(
+ $params = [
'organization_name' => 'Compumentor',
'contact_type' => 'Organization',
- );
+ ];
$this->organization = $this->organizationCreate($params);
- $params = array(
+ $params = [
'organization_name' => 'Conservation Corp',
'contact_type' => 'Organization',
'contact_sub_type' => $this->sponsor,
- );
+ ];
$this->organization_sponsor = $this->organizationCreate($params);
}
public function tearDown() {
- $this->quickCleanup(array('civicrm_contact'));
+ $this->quickCleanup(['civicrm_contact']);
$query = "
DELETE FROM civicrm_contact_type
*/
public function testRelationshipTypeAddIndiviParent() {
//check Individual to Parent RelationshipType
- $params = array(
+ $params = [
'name_a_b' => 'indivToparent',
'name_b_a' => 'parentToindiv',
'contact_type_a' => 'Individual',
'contact_type_b' => 'Individual',
'contact_sub_type_b' => $this->parent,
- );
+ ];
$result = CRM_Contact_BAO_RelationshipType::add($params);
$this->assertEquals($result->name_a_b, 'indivToparent');
$this->assertEquals($result->contact_type_a, 'Individual');
public function testRelationshipTypeAddSponcorIndivi() {
//check Sponcor to Individual RelationshipType
- $params = array(
+ $params = [
'name_a_b' => 'SponsorToIndiv',
'name_b_a' => 'IndivToSponsor',
'contact_type_a' => 'Organization',
'contact_sub_type_a' => $this->sponsor,
'contact_type_b' => 'Individual',
- );
+ ];
$result = CRM_Contact_BAO_RelationshipType::add($params);
$this->assertEquals($result->name_a_b, 'SponsorToIndiv');
$this->assertEquals($result->contact_type_a, 'Organization');
public function testRelationshipTypeAddStudentSponcor() {
//check Student to Sponcer RelationshipType
- $params = array(
+ $params = [
'name_a_b' => 'StudentToSponser',
'name_b_a' => 'SponsorToStudent',
'contact_type_a' => 'Individual',
'contact_sub_type_a' => $this->student,
'contact_type_b' => 'Organization',
'contact_sub_type_b' => $this->sponsor,
- );
+ ];
$result = CRM_Contact_BAO_RelationshipType::add($params);
$this->assertEquals($result->name_a_b, 'StudentToSponser');
$this->assertEquals($result->contact_type_a, 'Individual');
*/
public function testRelationshipCreateInvalidWithinSameType() {
//check for Individual to Parent
- $relTypeParams = array(
+ $relTypeParams = [
'name_a_b' => 'indivToparent',
'name_b_a' => 'parentToindiv',
'contact_type_a' => 'Individual',
'contact_type_b' => 'Individual',
'contact_sub_type_b' => $this->parent,
- );
+ ];
$relType = CRM_Contact_BAO_RelationshipType::add($relTypeParams);
- $params = array(
+ $params = [
'relationship_type_id' => $relType->id . '_a_b',
- 'contact_check' => array($this->indivi_student => 1),
- );
- $ids = array('contact' => $this->individual);
+ 'contact_check' => [$this->indivi_student => 1],
+ ];
+ $ids = ['contact' => $this->individual];
list($valid, $invalid, $duplicate, $saved, $relationshipIds) = CRM_Contact_BAO_Relationship::legacyCreateMultiple($params, $ids);
*/
public function testRelCreateInvalidWithinDiffTypeSpocorIndivi() {
//check for Sponcer to Individual
- $relTypeParams = array(
+ $relTypeParams = [
'name_a_b' => 'SponsorToIndiv',
'name_b_a' => 'IndivToSponsor',
'contact_type_a' => 'Organization',
'contact_sub_type_a' => $this->sponsor,
'contact_type_b' => 'Individual',
- );
+ ];
$relType = CRM_Contact_BAO_RelationshipType::add($relTypeParams);
- $params = array(
+ $params = [
'relationship_type_id' => $relType->id . '_a_b',
- 'contact_check' => array($this->individual => 1),
- );
- $ids = array('contact' => $this->indivi_parent);
+ 'contact_check' => [$this->individual => 1],
+ ];
+ $ids = ['contact' => $this->indivi_parent];
list($valid, $invalid, $duplicate, $saved, $relationshipIds) = CRM_Contact_BAO_Relationship::legacyCreateMultiple($params, $ids);
public function testRelCreateInvalidWithinDiffTypeStudentSponcor() {
//check for Student to Sponcer
- $relTypeParams = array(
+ $relTypeParams = [
'name_a_b' => 'StudentToSponser',
'name_b_a' => 'SponsorToStudent',
'contact_type_a' => 'Individual',
'contact_sub_type_a' => $this->student,
'contact_type_b' => 'Organization',
'contact_sub_type_b' => 'Sponser',
- );
+ ];
$relType = CRM_Contact_BAO_RelationshipType::add($relTypeParams);
- $params = array(
+ $params = [
'relationship_type_id' => $relType->id . '_a_b',
- 'contact_check' => array($this->individual => 1),
- );
- $ids = array('contact' => $this->indivi_parent);
+ 'contact_check' => [$this->individual => 1],
+ ];
+ $ids = ['contact' => $this->indivi_parent];
list($valid, $invalid, $duplicate, $saved, $relationshipIds) = CRM_Contact_BAO_Relationship::legacyCreateMultiple($params, $ids);
*/
public function testRelationshipCreateWithinSameType() {
//check for Individual to Parent
- $relTypeParams = array(
+ $relTypeParams = [
'name_a_b' => 'indivToparent',
'name_b_a' => 'parentToindiv',
'contact_type_a' => 'Individual',
'contact_type_b' => 'Individual',
'contact_sub_type_b' => $this->parent,
- );
+ ];
$relType = CRM_Contact_BAO_RelationshipType::add($relTypeParams);
- $params = array(
+ $params = [
'relationship_type_id' => $relType->id . '_a_b',
'is_active' => 1,
- 'contact_check' => array($this->indivi_parent => $this->indivi_parent),
- );
- $ids = array('contact' => $this->individual);
+ 'contact_check' => [$this->indivi_parent => $this->indivi_parent],
+ ];
+ $ids = ['contact' => $this->individual];
list($valid, $invalid, $duplicate, $saved, $relationshipIds) = CRM_Contact_BAO_Relationship::legacyCreateMultiple($params, $ids);
$this->assertEquals($valid, 1);
*/
public function testRelCreateWithinDiffTypeSponsorIndivi() {
//check for Sponcer to Individual
- $relTypeParams = array(
+ $relTypeParams = [
'name_a_b' => 'SponsorToIndiv',
'name_b_a' => 'IndivToSponsor',
'contact_type_a' => 'Organization',
'contact_sub_type_a' => $this->sponsor,
'contact_type_b' => 'Individual',
- );
+ ];
$relType = CRM_Contact_BAO_RelationshipType::add($relTypeParams);
- $params = array(
+ $params = [
'relationship_type_id' => $relType->id . '_a_b',
'is_active' => 1,
- 'contact_check' => array($this->indivi_student => 1),
- );
- $ids = array('contact' => $this->organization_sponsor);
+ 'contact_check' => [$this->indivi_student => 1],
+ ];
+ $ids = ['contact' => $this->organization_sponsor];
list($valid, $invalid, $duplicate, $saved, $relationshipIds) = CRM_Contact_BAO_Relationship::legacyCreateMultiple($params, $ids);
$this->assertEquals($valid, 1);
public function testRelCreateWithinDiffTypeStudentSponsor() {
//check for Student to Sponcer
- $relTypeParams = array(
+ $relTypeParams = [
'name_a_b' => 'StudentToSponsor',
'name_b_a' => 'SponsorToStudent',
'contact_type_a' => 'Individual',
'contact_sub_type_a' => $this->student,
'contact_type_b' => 'Organization',
'contact_sub_type_b' => $this->sponsor,
- );
+ ];
$relType = CRM_Contact_BAO_RelationshipType::add($relTypeParams);
- $params = array(
+ $params = [
'relationship_type_id' => $relType->id . '_a_b',
'is_active' => 1,
- 'contact_check' => array($this->organization_sponsor => 1),
- );
- $ids = array('contact' => $this->indivi_student);
+ 'contact_check' => [$this->organization_sponsor => 1],
+ ];
+ $ids = ['contact' => $this->indivi_student];
list($valid, $invalid, $duplicate, $saved, $relationshipIds) = CRM_Contact_BAO_Relationship::legacyCreateMultiple($params, $ids);
$this->assertEquals($valid, 1);
public function testGetAnyToAnyRelTypes() {
// Create an any to any relationship.
- $relTypeParams = array(
+ $relTypeParams = [
'name_a_b' => 'MookieIs',
'name_b_a' => 'MookieOf',
'contact_type_a' => '',
'contact_type_b' => '',
- );
+ ];
$relType = CRM_Contact_BAO_RelationshipType::add($relTypeParams);
$indTypes = CRM_Contact_BAO_Relationship::getRelationType('Individual');
$orgTypes = CRM_Contact_BAO_Relationship::getRelationType('Organization');
$selector->contactIDQuery([], $sortOrder);
}
+ /**
+ * Test the sorting on the contact ID query works with a profile search.
+ *
+ * Checking for lack of fatal.
+ */
+ public function testContactIDQueryProfileSearchResults() {
+ $profile = $this->callAPISuccess('UFGroup', 'create', ['group_type' => 'Contact', 'name' => 'search', 'title' => 'search']);
+ $this->callAPISuccess('UFField', 'create', [
+ 'uf_group_id' => $profile['id'],
+ 'field_name' => 'postal_code',
+ 'field_type' => 'Contact',
+ 'in_selector' => TRUE,
+ 'is_searchable' => TRUE,
+ 'label' => 'postal code',
+ 'visibility' => 'Public Pages and Listings',
+ ]);
+ $selector = new CRM_Contact_Selector(NULL, ['radio_ts' => 'ts_all', 'uf_group_id' => $profile['id']], NULL, ['sort_name' => 1]);
+ $selector->contactIDQuery([], '2_d');
+ }
+
+ /**
+ * Get search options to reflect how a UI search would look.
+ *
+ * @return array
+ */
public function getSortOptions() {
return [
['1_d'],
$this->assertEquals("Contact Type In IndividualANDContact Subtype Like {$contactSubType}", $qill);
}
+ /**
+ * Test to search based on Group type.
+ * https://lab.civicrm.org/dev/core/issues/726
+ */
+ public function testContactSearchOnGroupType() {
+ $groupTypes = $this->callAPISuccess('OptionValue', 'get', [
+ 'return' => ["id", "name"],
+ 'option_group_id' => "group_type",
+ ])['values'];
+ $groupTypes = array_column($groupTypes, 'id', 'name');
+
+ // Create group with empty group type as Access Control.
+ $groupId = $this->groupCreate([
+ 'group_type' => [
+ $groupTypes['Access Control'] => 1,
+ ]
+ ]);
+ // Add random 5 contacts to a group.
+ $this->groupContactCreate($groupId, 5);
+
+ // Find Contacts of Group type == Access Control
+ $formValues['group_type'] = $groupTypes['Access Control'];
+ CRM_Contact_BAO_Query::convertFormValues($formValues);
+ $query = new CRM_Contact_BAO_Query(CRM_Contact_BAO_Query::convertFormValues($formValues));
+ list($select, $from, $where, $having) = $query->query();
+ // get and assert contact count
+ $contactsResult = CRM_Core_DAO::executeQuery(sprintf('SELECT DISTINCT contact_a.id %s %s', $from, $where));
+ // assert the contacts count
+ $this->assertEquals(5, $contactsResult->N);
+
+ // Find Contacts of Group type == Mailing List
+ $formValues['group_type'] = $groupTypes['Mailing List'];
+ CRM_Contact_BAO_Query::convertFormValues($formValues);
+ $query = new CRM_Contact_BAO_Query(CRM_Contact_BAO_Query::convertFormValues($formValues));
+ list($select, $from, $where, $having) = $query->query();
+ // get and assert contact count
+ $contactsResult = CRM_Core_DAO::executeQuery(sprintf('SELECT DISTINCT contact_a.id %s %s', $from, $where));
+ // assert the contacts count
+ $this->assertEquals(0, $contactsResult->N);
+ }
+
}
]);
$this->contributions[] = $this->contributionCreate([
'contact_id' => $this->contactID,
- 'receive_date' => '2018-11-21',
- 'receipt_date' => '2018-11-22',
+ 'receive_date' => '2018-11-22',
+ 'receipt_date' => '2018-11-23',
'trxn_id' => '',
'invoice_id' => '',
]);
]);
$this->contributions[] = $this->contributionCreate([
'contact_id' => $this->contactID,
- 'receive_date' => '2018-11-21',
+ 'receive_date' => '2018-11-20',
'amount_level' => 'high',
'contribution_status_id' => 'Cancelled',
'invoice_id' => NULL,
];
$this->assertPageContains($expectedStrings);
- $this->assertSmartyVariableArrayIncludes('contribute_rows', 0, [
+ $this->assertSmartyVariableArrayIncludes('contribute_rows', 1, [
'contact_id' => $this->contactID,
'contribution_id' => '1',
'total_amount' => '100.00',
}
}
+ /**
+ * Test contact contributions.
+ */
+ public function testContributionSearchWithContactID() {
+ $contactID = $this->individualCreate([], 1);
+ $fv = ['contact_id' => $contactID];
+ $queryParams = CRM_Contact_BAO_Query::convertFormValues($fv);
+ $selector = new CRM_Contribute_Selector_Search($queryParams, CRM_Core_Action::ADD);
+ list($select, $from, $where) = $selector->getQuery()->query();
+
+ // get and assert contribution count
+ $contributions = CRM_Core_DAO::executeQuery("{$select} {$from} {$where}")->fetchAll();
+ $this->assertEquals(count($contributions), 0);
+
+ $this->callAPISuccess('Contribution', 'create', [
+ 'financial_type_id' => "Donation",
+ 'receive_date' => date('Y-m-d'),
+ 'total_amount' => 10,
+ 'contact_id' => $contactID,
+ ]);
+ $selector = new CRM_Contribute_Selector_Search($queryParams, CRM_Core_Action::ADD);
+ list($select, $from, $where) = $selector->getQuery()->query();
+
+ // get and assert contribution count
+ $contributions = CRM_Core_DAO::executeQuery("{$select} {$from} {$where}")->fetchAll();
+ $this->assertEquals(count($contributions), 1);
+ }
+
/**
* Test CRM_Contribute_Form_Search Recurring Contribution Status Id filters
*/
$fieldID = CRM_Core_BAO_CustomField::getCustomFieldID('testFld', 'new custom group');
$this->assertEquals($this->customFieldID, $fieldID);
+
+ $fieldID = CRM_Core_BAO_CustomField::getCustomFieldID('testFld', 'new custom group', TRUE);
+ $this->assertEquals('custom_' . $this->customFieldID, $fieldID);
+
+ // create field with same name in a different group
+ $this->createCustomField('other custom group');
+ $otherFieldID = CRM_Core_BAO_CustomField::getCustomFieldID('testFld', 'other custom group');
+ // make sure it does not return the field ID of the first field
+ $this->assertNotEquals($fieldID, $otherFieldID);
}
/**
+ * Create a custom field
+ *
+ * @param string $groupTitle
+ *
* @return array
*/
- protected function createCustomField() {
- $customGroup = $this->customGroupCreate(array('extends' => 'Individual'));
+ protected function createCustomField($groupTitle = 'new custom group') {
+ $customGroup = $this->customGroupCreate([
+ 'extends' => 'Individual',
+ 'title' => $groupTitle,
+ ]);
$fields = array(
'label' => 'testFld',
'data_type' => 'String',
$this->assertFalse(is_array($result));
}
- /* @codingStandardsIgnoreStart
- * Test calls main functions in sequence per 'main' - I had hoped to test the functions more
- * fully but the calls to the POST happen in more than one function
- * keeping this as good example of data to bring back to life later
-
- public function testMainFunctionActions() {
- $ids = $objects = array( );
- $input['component'] = 'Contribute';
- $postedParams = array(
- 'x_response_code' => 1,
- 'x_response_reason_code' => 1,
- 'x_response_reason_text' => 'This transaction has been approved.',
- 'x_avs_code' => 'Y',
- 'x_auth_code' => 140454,
- 'x_trans_id' => 4353599599,
- 'x_method' => 'CC',
- 'x_card_type' => 'American Express',
- 'x_account_number' => 'XXXX2701',
- 'x_first_name' => 'Arthur',
- 'x_last_name' => 'Jacobs',
- 'x_company' => null,
- 'x_address' => '866 2166th St SN',
- 'x_city' => 'Edwardstown',
- 'x_state' => 'WA',
- 'x_zip' => 98026,
- 'x_country' => 'US',
- 'x_phone' => null,
- 'x_fax' => null,
- 'x_email' => null,
- 'x_invoice_num' => 'a9fb56c24576lk4c9490f6',
- 'x_description' => 'my desc',
- 'x_type' => 'auth_capture',
- 'x_cust_id' => 5191,
- 'x_ship_to_first_name' => null,
- 'x_ship_to_last_name' => null,
- 'x_ship_to_company' => null,
- 'x_ship_to_address' => null,
- 'x_ship_to_city' => null,
- 'x_ship_to_state' => null,
- 'x_ship_to_zip' => null,
- 'x_ship_to_country' => null,
- 'x_amount' => 60.00,
- 'x_tax' => 0.00,
- 'x_duty' => 0.00,
- 'x_freight' => 0.00,
- 'x_tax_exempt' => FALSE,
- 'x_po_num' => null,
- 'x_MD5_Hash' => '069ECAD13C8E15AC205CDF92B8B58CC7',
- 'x_cvv2_resp_code' => null,
- 'x_cavv_response' => null,
- 'x_test_request' => false,
- 'description' => 'my description'
- );
- $this->IPN->getInput( $input, $ids );
- $this->IPN->getIDs( $ids, $input );
-
- CRM_Core_Error::debug_var( '$ids', $ids );
- CRM_Core_Error::debug_var( '$input', $input );
-
- $paymentProcessorID = CRM_Core_DAO::getFieldValue( 'CRM_Financial_DAO_PaymentProcessorType',
- 'AuthNet', 'id', 'name' );
-
- if ( ! $this->IPN->validateData( $input, $ids, $objects, true, $paymentProcessorID ) ) {
- return false;
- }
-
- if ( $component == 'contribute' && $ids['contributionRecur'] ) {
- // check if first contribution is completed, else complete first contribution
- $first = true;
- if ( $objects['contribution']->contribution_status_id == 1 ) {
- $first = false;
- }
- return $this->IPN->recur( $input, $ids, $objects, $first );
- }
- }
- @codingStandardsIgnoreEnd */
+ public function testThatCancellingEventPaymentWillCancelAllAdditionalPendingParticipantsAndCreateCancellationActivities() {
+ $this->_setUpParticipantObjects('Pending from incomplete transaction');
+ $this->IPN->loadObjects($this->input, $this->ids, $this->objects, FALSE, $this->_processorId);
+ $additionalParticipantId = $this->participantCreate(array(
+ 'event_id' => $this->_eventId,
+ 'registered_by_id' => $this->_participantId,
+ 'status_id' => 'Pending from incomplete transaction',
+ ));
+
+ $transaction = new CRM_Core_Transaction();
+ $this->IPN->cancelled($this->objects, $transaction);
+
+ $cancelledParticipantsCount = civicrm_api3('Participant', 'get', [
+ 'sequential' => 1,
+ 'id' => ['IN' => [$this->_participantId, $additionalParticipantId]],
+ 'status_id' => 'Cancelled',
+ ])['count'];
+ $this->assertEquals(2, $cancelledParticipantsCount);
+
+ $cancelledActivatesCount = civicrm_api3('Activity', 'get', [
+ 'sequential' => 1,
+ 'activity_type_id' => 'Event Registration',
+ 'subject' => ['LIKE' => '%Cancelled%'],
+ 'source_record_id' => ['IN' => [$this->_participantId, $additionalParticipantId]],
+ ]);
+
+ $this->assertEquals(2, $cancelledActivatesCount['count']);
+ }
+
+ public function testThatFailedEventPaymentWillCancelAllAdditionalPendingParticipantsAndCreateCancellationActivities() {
+ $this->_setUpParticipantObjects('Pending from incomplete transaction');
+ $this->IPN->loadObjects($this->input, $this->ids, $this->objects, FALSE, $this->_processorId);
+ $additionalParticipantId = $this->participantCreate(array(
+ 'event_id' => $this->_eventId,
+ 'registered_by_id' => $this->_participantId,
+ 'status_id' => 'Pending from incomplete transaction',
+ ));
+
+ $transaction = new CRM_Core_Transaction();
+ $this->IPN->failed($this->objects, $transaction);
+
+ $cancelledParticipantsCount = civicrm_api3('Participant', 'get', [
+ 'sequential' => 1,
+ 'id' => ['IN' => [$this->_participantId, $additionalParticipantId]],
+ 'status_id' => 'Cancelled',
+ ])['count'];
+ $this->assertEquals(2, $cancelledParticipantsCount);
+
+ $cancelledActivatesCount = civicrm_api3('Activity', 'get', [
+ 'sequential' => 1,
+ 'activity_type_id' => 'Event Registration',
+ 'subject' => ['LIKE' => '%Cancelled%'],
+ 'source_record_id' => ['IN' => [$this->_participantId, $additionalParticipantId]],
+ ]);
+
+ $this->assertEquals(2, $cancelledActivatesCount['count']);
+ }
/**
* Prepare for contribution Test - involving only contribution objects
/**
* Set up participant requirements for test.
+ *
+ * @param string $participantStatus
+ * The participant to create status
*/
- public function _setUpParticipantObjects() {
+ public function _setUpParticipantObjects($participantStatus = 'Attended') {
$event = $this->eventCreate(array('is_email_confirm' => 1));
$this->_eventId = $event['id'];
$this->_participantId = $this->participantCreate(array(
'event_id' => $this->_eventId,
'contact_id' => $this->_contactId,
+ 'status_id' => $participantStatus,
));
$this->callAPISuccess('participant_payment', 'create', array(
--- /dev/null
+<?php
+
+/**
+ * Class CRM_Dedupe_BAO_RuleGroupTest
+ * @group headless
+ */
+class CRM_Dedupe_BAO_RuleGroupTest extends CiviUnitTestCase {
+
+ /**
+ * Test that sort_name is included in supported fields.
+ *
+ * This feels like kind of a brittle test but since I debated actually making it
+ * importable in the schema & bottled out at least some degree of test support
+ * to ensure the field remains 'hacked in' seems important.
+ *
+ * This will at least surface any changes that affect this function.
+ *
+ * In general we do have a bit of a problem with having overloaded the meaning of
+ * importable & exportable fields.
+ */
+ public function testSupportedFields() {
+ $fields = CRM_Dedupe_BAO_RuleGroup::supportedFields('Organization');
+
+ $this->assertEquals([
+ 'civicrm_address' =>
+ [
+ 'name' => 'Address Name',
+ 'city' => 'City',
+ 'country_id' => 'Country',
+ 'county_id' => 'County',
+ 'geo_code_1' => 'Latitude',
+ 'geo_code_2' => 'Longitude',
+ 'master_id' => 'Master Address Belongs To',
+ 'postal_code' => 'Postal Code',
+ 'postal_code_suffix' => 'Postal Code Suffix',
+ 'state_province_id' => 'State',
+ 'street_address' => 'Street Address',
+ 'supplemental_address_1' => 'Supplemental Address 1',
+ 'supplemental_address_2' => 'Supplemental Address 2',
+ 'supplemental_address_3' => 'Supplemental Address 3',
+ ],
+ 'civicrm_contact' =>
+ [
+ 'addressee_id' => 'Addressee',
+ 'addressee_custom' => 'Addressee Custom',
+ 'id' => 'Contact ID',
+ 'source' => 'Contact Source',
+ 'contact_sub_type' => 'Contact Subtype',
+ 'do_not_email' => 'Do Not Email',
+ 'do_not_mail' => 'Do Not Mail',
+ 'do_not_phone' => 'Do Not Phone',
+ 'do_not_sms' => 'Do Not Sms',
+ 'do_not_trade' => 'Do Not Trade',
+ 'email_greeting_id' => 'Email Greeting',
+ 'email_greeting_custom' => 'Email Greeting Custom',
+ 'external_identifier' => 'External Identifier',
+ 'image_URL' => 'Image Url',
+ 'legal_identifier' => 'Legal Identifier',
+ 'legal_name' => 'Legal Name',
+ 'nick_name' => 'Nickname',
+ 'is_opt_out' => 'No Bulk Emails (User Opt Out)',
+ 'organization_name' => 'Organization Name',
+ 'postal_greeting_id' => 'Postal Greeting',
+ 'postal_greeting_custom' => 'Postal Greeting Custom',
+ 'preferred_communication_method' => 'Preferred Communication Method',
+ 'preferred_language' => 'Preferred Language',
+ 'preferred_mail_format' => 'Preferred Mail Format',
+ 'sic_code' => 'Sic Code',
+ 'user_unique_id' => 'Unique ID (OpenID)',
+ 'sort_name' => 'Sort Name',
+ ],
+ 'civicrm_email' =>
+ [
+ 'email' => 'Email',
+ 'signature_html' => 'Signature Html',
+ 'signature_text' => 'Signature Text',
+ ],
+ 'civicrm_im' =>
+ [
+ 'name' => 'IM Screen Name',
+ ],
+ 'civicrm_note' =>
+ [
+ 'note' => 'Note',
+ ],
+ 'civicrm_openid' =>
+ [
+ 'openid' => 'OpenID',
+ ],
+ 'civicrm_phone' =>
+ [
+ 'phone_numeric' => 'Phone',
+ 'phone_ext' => 'Phone Extension',
+ ],
+ ], $fields);
+ }
+
+}
),
);
+ $this->hookClass->setHook('civicrm_findDuplicates', array($this, 'hook_civicrm_findDuplicates'));
+
$count = 1;
foreach ($params as $param) {
'street_address' => 'Ambachtstraat 23',
);
CRM_Core_TemporaryErrorScope::useException();
- $ids = CRM_Contact_BAO_Contact::getDuplicateContacts($fields, 'Individual', 'General');
+ $ids = CRM_Contact_BAO_Contact::getDuplicateContacts($fields, 'Individual', 'General', [], TRUE, NULL, ['event_id' => 1]);
// Check with default Individual-General rule
$this->assertEquals(count($ids), 2, 'Check Individual-General rule for dupesByParams().');
}
}
+ /**
+ * Implements hook_civicrm_findDuplicates().
+ *
+ * Locks in expected params
+ *
+ */
+ public function hook_civicrm_findDuplicates($dedupeParams, &$dedupeResults, $contextParams) {
+ $expectedDedupeParams = [
+ 'check_permission' => TRUE,
+ 'contact_type' => 'Individual',
+ 'rule' => 'General',
+ 'rule_group_id' => NULL,
+ 'excluded_contact_ids' => [],
+ ];
+ foreach ($expectedDedupeParams as $key => $value) {
+ $this->assertEquals($value, $dedupeParams[$key]);
+ }
+ $expectedDedupeResults = [
+ 'ids' => [],
+ 'handled' => FALSE,
+ ];
+ foreach ($expectedDedupeResults as $key => $value) {
+ $this->assertEquals($value, $dedupeResults[$key]);
+ }
+
+ $expectedContext = ['event_id' => 1];
+ foreach ($expectedContext as $key => $value) {
+ $this->assertEquals($value, $contextParams[$key]);
+ }
+
+ return $dedupeResults;
+ }
+
/**
* Set up a group of dedupable contacts.
*/
--- /dev/null
+<?php
+
+/**
+ * @group headless
+ */
+class CRM_Event_BAO_QueryTest extends CiviUnitTestCase {
+
+ public function setUp() {
+ parent::setUp();
+ }
+
+ public function testParticipantNote() {
+ $event = $this->eventCreate();
+ $this->individualCreate([
+ 'api.participant.create' => [
+ 'event_id' => $event['id'],
+ 'note' => 'some_note',
+ ]
+ ]);
+ $this->individualCreate([
+ 'api.participant.create' => [
+ 'event_id' => $event['id'],
+ 'note' => 'some_other_note',
+ ]
+ ]);
+ $params = [
+ [
+ 0 => 'participant_note',
+ 1 => '=',
+ 2 => 'some_note',
+ 3 => 1,
+ 4 => 0,
+ ]
+ ];
+
+ $query = new CRM_Contact_BAO_Query($params, NULL, NULL, FALSE, FALSE, CRM_Contact_BAO_Query::MODE_CONTACTS);
+ $sql = $query->query(FALSE);
+ $result = CRM_Core_DAO::executeQuery(implode(' ', $sql));
+ $this->assertEquals(1, $result->N);
+ }
+
+}
$this->assertEquals($expectedHeaders, $result[2]);
}
+ /**
+ * Test exported with data entry mis-fire.
+ *
+ * Not fatal error if data incomplete.
+ *
+ * https://lab.civicrm.org/dev/core/issues/819
+ */
+ public function testExportIncompleteSubmission() {
+ $this->setUpContactExportData();
+ $this->doExport([['Individual', '']], $this->contactIDs[1]);
+ }
+
/**
* Test exported with fields to output specified.
*
public function purifyHTMLProvider() {
$tests = [];
$tests[] = ['<span onmouseover=alert(0)>HOVER</span>', '<span>HOVER</span>'];
- $tests[] = ['<a href="https://civicrm.org" target="_blank" class="button-purple">hello</a>', '<a href="https://civicrm.org" target="_blank" class="button-purple">hello</a>'];
+ $tests[] = ['<a href="https://civicrm.org" target="_blank" class="button-purple">hello</a>', '<a href="https://civicrm.org" target="_blank" class="button-purple" rel="noreferrer noopener">hello</a>'];
return $tests;
}
+++ /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.");
- }
-
-}
if ($this->hookClass) {
$this->hookClass->reset();
}
- $session = CRM_Core_Session::singleton();
- $session->set('userID', NULL);
+ CRM_Core_Session::singleton()->reset(1);
if ($this->tx) {
$this->tx->rollback()->commit();
+++ /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
'check_permissions' => 0,
]);
$this->assertEquals(2, $dupes['count']);
- CRM_Core_Config::singleton()->userPermissionClass->permissions = ['administer CiviCRM'];
+ CRM_Core_Config::singleton()->userPermissionClass->permissions = ['access CiviCRM'];
$dupes = $this->callAPISuccess('Contact', 'duplicatecheck', [
'match' => [
$this->assertEquals('Individual', $result['contact_id.contact_type']);
}
+ /**
+ * Test Address create with a state name that at least two countries have, e.g. Maryland, United States vs. Maryland, Liberia
+ *
+ * @see https://lab.civicrm.org/dev/core/issues/725
+ */
+ public function testCreateAddressStateProvinceIDCorrectForCountry() {
+ $params = $this->_params;
+ $params['sequential'] = 1;
+ $params['country_id'] = '1228'; // United States country id
+ $params['state_province_id'] = 'Maryland';
+ $params['city'] = 'Baltimore';
+ $params['street_address'] = '600 N Charles St.';
+ $params['postal_code'] = '21201';
+ unset($params['street_name']);
+ unset($params['street_number']);
+ $address1 = $this->callAPISuccess('address', 'create', $params);
+ // should find state_province_id of 1019, Maryland, United States ... NOT 3497, Maryland, Liberia
+ $this->assertEquals('1019', $address1['values'][0]['state_province_id']);
+
+ // Now try it in Liberia
+ $params = $this->_params;
+ $params['sequential'] = 1;
+ $params['country_id'] = '1122'; // Liberia country id
+ $params['state_province_id'] = 'Maryland';
+ $address2 = $this->callAPISuccess('address', 'create', $params);
+ $this->assertEquals('3497', $address2['values'][0]['state_province_id']);
+ }
+
}
$this->assertEquals('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', $result['values'][$result['id']]['sort_name']);
}
+ /**
+ * Test that we can set the sort name via the api or alter it via a hook.
+ *
+ * As of writing this is being fixed for Organization & Household but it makes sense to do for individuals too.
+ */
+ public function testCreateAlterSortName() {
+ $organizationID = $this->organizationCreate(['organization_name' => 'The Justice League', 'sort_name' => 'Justice League, The']);
+ $organization = $this->callAPISuccessGetSingle('Contact', ['return' => ['sort_name', 'display_name'], 'id' => $organizationID]);
+ $this->assertEquals('Justice League, The', $organization['sort_name']);
+ $this->assertEquals('The Justice League', $organization['display_name']);
+ $this->hookClass->setHook('civicrm_pre', array($this, 'killTheJusticeLeague'));
+ $this->organizationCreate(['id' => $organizationID, 'sort_name' => 'Justice League, The']);
+ $organization = $this->callAPISuccessGetSingle('Contact', ['return' => ['sort_name', 'display_name', 'is_deceased'], 'id' => $organizationID]);
+ $this->assertEquals('Steppenwolf wuz here', $organization['display_name']);
+ $this->assertEquals('Steppenwolf wuz here', $organization['sort_name']);
+ $this->assertEquals(1, $organization['is_deceased']);
+
+ $householdID = $this->householdCreate();
+ $household = $this->callAPISuccessGetSingle('Contact', ['return' => ['sort_name', 'display_name'], 'id' => $householdID]);
+ $this->assertEquals('Steppenwolf wuz here', $household['display_name']);
+ $this->assertEquals('Steppenwolf wuz here', $household['sort_name']);
+ }
+
+ /**
+ * Implements hook_pre().
+ */
+ public function killTheJusticeLeague($op, $entity, $id, &$params) {
+ $params['sort_name'] = 'Steppenwolf wuz here';
+ $params['display_name'] = 'Steppenwolf wuz here';
+ $params['is_deceased'] = 1;
+ }
+
/**
* Test Single Entity format.
*/
$this->assertEmpty($errors);
}
+ /**
+ * Test validating a contribution page submit in POST context.
+ *
+ * A likely use case for the validation is when the is being submitted and some handling is
+ * to be done before processing but the validity of input needs to be checked first.
+ *
+ * For example Paypal Checkout will replace the confirm button with it's own but we are able to validate
+ * before paypal launches it's modal. In this case the $_REQUEST is post but we need validation to succeed.
+ */
+ public function testValidatePost() {
+ $_SERVER['REQUEST_METHOD'] = 'POST';
+ $this->setUpContributionPage();
+ $errors = $this->callAPISuccess('ContributionPage', 'validate', array_merge($this->getBasicSubmitParams(), ['action' => 'submit']))['values'];
+ $this->assertEmpty($errors);
+ unset($_SERVER['REQUEST_METHOD']);
+ }
+
+ /**
+ * Test that an error is generated if required fields are not submitted.
+ */
+ public function testValidateOutputOnMissingRecurFields() {
+ $this->params['is_recur_interval'] = 1;
+ $this->setUpContributionPage(TRUE);
+ $submitParams = array_merge($this->getBasicSubmitParams(), ['action' => 'submit']);
+ $submitParams['is_recur'] = 1;
+ $submitParams['frequency_interval'] = '';
+ $submitParams['frequency_unit'] = '';
+ $errors = $this->callAPISuccess('ContributionPage', 'validate', $submitParams)['values'];
+ $this->assertEquals('Please enter a number for how often you want to make this recurring contribution (EXAMPLE: Every 3 months).', $errors['frequency_interval']);
+ }
+
/**
* Implements hook_civicrm_alterPaymentProcessorParams().
*
$this->assertEquals(array('invoice_id'), $result['values']['UI_contrib_invoice_id']);
}
+ /**
+ * Test Repeat Transaction Contribution with Tax amount.
+ * https://lab.civicrm.org/dev/core/issues/806
+ */
+ public function testRepeatContributionWithTaxAmount() {
+ $this->enableTaxAndInvoicing();
+ $financialType = $this->callAPISuccess('financial_type', 'create', [
+ 'name' => 'Test taxable financial Type',
+ 'is_reserved' => 0,
+ 'is_active' => 1,
+ ]);
+ $this->relationForFinancialTypeWithFinancialAccount($financialType['id']);
+ $contribution = $this->setUpRepeatTransaction(
+ [],
+ 'single',
+ [
+ 'financial_type_id' => $financialType['id'],
+ ]
+ );
+ $this->callAPISuccess('contribution', 'repeattransaction', array(
+ 'original_contribution_id' => $contribution['id'],
+ 'contribution_status_id' => 'Completed',
+ 'trxn_id' => uniqid(),
+ ));
+ $this->callAPISuccessGetCount('Contribution', [], 2);
+ }
+
}
$this->assertEquals(2, $rows['count'], "Report failed - the sql used to generate the results was " . print_r($rows['metadata']['sql'], TRUE));
- $expected = preg_replace('/\s+/', ' ', 'DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci
+ $expected = preg_replace('/\s+/', ' ', 'DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci AS
SELECT SQL_CALC_FOUND_ROWS contact_civireport.id as cid FROM civicrm_contact contact_civireport INNER JOIN civicrm_contribution contribution_civireport USE index (received_date) ON contribution_civireport.contact_id = contact_civireport.id
AND contribution_civireport.is_test = 0
AND contribution_civireport.receive_date BETWEEN \'20140701000000\' AND \'20150630235959\'
));
}
+ /**
+ * Test contact subtype filter on grant report.
+ */
+ public function testGrantReportSeparatedFilter() {
+ $contactID = $this->individualCreate(['contact_sub_type' => ['Student', 'Parent']]);
+ $contactID2 = $this->individualCreate();
+ $this->callAPISuccess('Grant', 'create', ['contact_id' => $contactID, 'status_id' => 1, 'grant_type_id' => 1, 'amount_total' => 1]);
+ $this->callAPISuccess('Grant', 'create', ['contact_id' => $contactID2, 'status_id' => 1, 'grant_type_id' => 1, 'amount_total' => 1]);
+ $rows = $this->callAPISuccess('report_template', 'getrows', [
+ 'report_id' => 'grant/detail',
+ 'contact_sub_type_op' => 'in',
+ 'contact_sub_type_value' => ['Student'],
+ ]);
+ $this->assertEquals(1, $rows['count']);
+ }
+
/**
* Test PCP report to ensure total donors and total committed is accurate.
*/
INSERT INTO civicrm_country (id, name,iso_code,region_id,is_province_abbreviated) VALUES("1200", "Sudan", "SD", "3", "0");
INSERT INTO civicrm_country (id, name,iso_code,region_id,is_province_abbreviated) VALUES("1201", "Suriname", "SR", "2", "0");
INSERT INTO civicrm_country (id, name,iso_code,region_id,is_province_abbreviated) VALUES("1202", "Svalbard and Jan Mayen", "SJ", "1", "0");
-INSERT INTO civicrm_country (id, name,iso_code,region_id,is_province_abbreviated) VALUES("1203", "Swaziland", "SZ", "5", "0");
+INSERT INTO civicrm_country (id, name,iso_code,region_id,is_province_abbreviated) VALUES("1203", "Eswatini", "SZ", "5", "0");
INSERT INTO civicrm_country (id, name,iso_code,region_id,is_province_abbreviated) VALUES("1204", "Sweden", "SE", "1", "0");
INSERT INTO civicrm_country (id, name,iso_code,region_id,is_province_abbreviated) VALUES("1205", "Switzerland", "CH", "1", "0");
INSERT INTO civicrm_country (id, name,iso_code,region_id,is_province_abbreviated) VALUES("1206", "Syrian Arab Republic", "SY", "3", "0");
(145, "STD", NULL, "678", "São Tome and Principe Dobra"),
(146, "SVC", "$", "222", "El Salvador Colon"),
(147, "SYP", "£", "760", "Syrian Pound"),
-(148, "SZL", NULL, "748", "Swaziland Lilangeni"),
+(148, "SZL", NULL, "748", "Eswatini Lilangeni"),
(149, "TJS", NULL, "972", "Tajik Somoni"),
(150, "TMM", NULL, "795", "Turkmenistan Manat"),
(151, "TND", NULL, "788", "Tunisian Dinar"),