Align most of the tokens in the token processor handling with the legacy handling
* Access Control List
*/
class CRM_ACL_BAO_ACL extends CRM_ACL_DAO_ACL {
- /**
- * @var string
- */
- public static $_entityTable = NULL;
- public static $_objectTable = NULL;
- public static $_operation = NULL;
-
- public static $_fieldKeys = NULL;
/**
* Available operations for pseudoconstant.
*
* @return array
*/
- public static function operation() {
- if (!self::$_operation) {
- self::$_operation = [
- 'View' => ts('View'),
- 'Edit' => ts('Edit'),
- 'Create' => ts('Create'),
- 'Delete' => ts('Delete'),
- 'Search' => ts('Search'),
- 'All' => ts('All'),
- ];
- }
- return self::$_operation;
- }
-
- /**
- * Construct an associative array of an ACL rule's properties
- *
- * @param string $format
- * Sprintf format for array.
- * @param bool $hideEmpty
- * Only return elements that have a value set.
- *
- * @return array
- * Assoc. array of the ACL rule's properties
- */
- public function toArray($format = '%s', $hideEmpty = FALSE) {
- $result = [];
-
- if (!self::$_fieldKeys) {
- $fields = CRM_ACL_DAO_ACL::fields();
- self::$_fieldKeys = array_keys($fields);
- }
-
- foreach (self::$_fieldKeys as $field) {
- $result[$field] = $this->$field;
- }
- return $result;
- }
-
- /**
- * Get all of the ACLs through ACL groups.
- *
- * @param int $contact_id
- * ID of a contact to search for.
- *
- * @return array
- * Array of assoc. arrays of ACL rules
- *
- * @throws \CRM_Core_Exception
- */
- protected static function getACLRoles($contact_id = NULL) {
- $contact_id = CRM_Utils_Type::escape($contact_id, 'Integer');
-
- $query = 'SELECT acl.* FROM civicrm_acl acl';
- $where = ['acl.entity_table = "civicrm_acl_role" AND acl.entity_id IN (' . implode(',', array_keys(CRM_Core_OptionGroup::values('acl_role'))) . ')'];
-
- if (!empty($contact_id)) {
- return [];
- }
-
- $results = [];
-
- $rule = CRM_Core_DAO::executeQuery($query . ' WHERE ' . implode(' AND ', $where));
-
- while ($rule->fetch()) {
- $results[$rule->id] = $rule->toArray();
- }
-
- return $results;
- }
-
- /**
- * Get all ACLs granted to a contact through all group memberships.
- *
- * @param int $contact_id
- * The contact's ID.
- * @param bool $aclRoles
- * Include ACL Roles?.
- *
- * @return array
- * Assoc array of ACL rules
- * @throws \CRM_Core_Exception
- */
- protected static function getGroupACLs($contact_id, $aclRoles = FALSE) {
- $contact_id = CRM_Utils_Type::escape($contact_id, 'Integer');
-
- $results = [];
-
- if ($contact_id) {
- $query = "
-SELECT acl.*
- FROM civicrm_acl acl
- INNER JOIN civicrm_group_contact group_contact
- ON acl.entity_id = group_contact.group_id
- WHERE acl.entity_table = 'civicrm_group'
- AND group_contact.contact_id = $contact_id
- AND group_contact.status = 'Added'";
-
- $rule = CRM_Core_DAO::executeQuery($query);
-
- while ($rule->fetch()) {
- $results[$rule->id] = $rule->toArray();
- }
- }
-
- if ($aclRoles) {
- $results += self::getGroupACLRoles($contact_id);
- }
-
- return $results;
+ public static function operation(): array {
+ return [
+ 'View' => ts('View'),
+ 'Edit' => ts('Edit'),
+ 'Create' => ts('Create'),
+ 'Delete' => ts('Delete'),
+ 'Search' => ts('Search'),
+ 'All' => ts('All'),
+ ];
}
/**
/**
* Get all ACLs owned by a given contact, including domain and group-level.
*
- * @param int $contact_id
+ * @param int|null $contact_id
* The contact ID.
*
* @return array
*
* @throws \CRM_Core_Exception
*/
- public static function getAllByContact($contact_id) {
+ public static function getAllByContact(?int $contact_id): array {
$result = [];
/* First, the contact-specific ACLs, including ACL Roles */
while ($rule->fetch()) {
$result[$rule->id] = $rule->toArray();
}
+ $query = "
+SELECT acl.*
+ FROM civicrm_acl acl
+ INNER JOIN civicrm_group_contact group_contact
+ ON acl.entity_id = group_contact.group_id
+ WHERE acl.entity_table = 'civicrm_group'
+ AND group_contact.contact_id = $contact_id
+ AND group_contact.status = 'Added'";
- $result += self::getACLRoles($contact_id);
- }
-
- /* Then, all ACLs granted through group membership */
- $result += self::getGroupACLs($contact_id, TRUE);
+ $rule = CRM_Core_DAO::executeQuery($query);
+ while ($rule->fetch()) {
+ $result[$rule->id] = $rule->toArray();
+ }
+ }
+ $result += self::getGroupACLRoles($contact_id);
return $result;
}
'start_date' => $value['membership_start_date'] ?? NULL,
];
$membershipSource = $value['source'] ?? NULL;
- list($membership) = CRM_Member_BAO_Membership::processMembership(
+ [$membership] = CRM_Member_BAO_Membership::processMembership(
$value['contact_id'], $value['membership_type_id'], FALSE,
//$numTerms should be default to 1.
NULL, NULL, $value['custom'], 1, NULL, FALSE,
//process premiums
if (!empty($value['product_name'])) {
if ($value['product_name'][0] > 0) {
- list($products, $options) = CRM_Contribute_BAO_Premium::getPremiumProductInfo();
+ [$products, $options] = CRM_Contribute_BAO_Premium::getPremiumProductInfo();
$value['hidden_Premium'] = 1;
$value['product_option'] = CRM_Utils_Array::value(
$value['from_email_address'] = $domainEmail;
$value['membership_id'] = $membership->id;
$value['contribution_id'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipPayment', $membership->id, 'contribution_id', 'membership_id');
- CRM_Member_Form_Membership::emailReceipt($this, $value, $membership);
+ $this->emailReceipt($this, $value, $membership);
}
}
}
return $batchTotal;
}
+ /**
+ * Send email receipt.
+ *
+ * @param CRM_Core_Form $form
+ * Form object.
+ * @param array $formValues
+ * @param object $membership
+ * Object.
+ *
+ * @return bool
+ * true if mail was sent successfully
+ * @throws \CRM_Core_Exception
+ *
+ * @deprecated
+ * This function is shared with Batch_Entry which has limited overlap
+ * & needs rationalising.
+ *
+ */
+ public function emailReceipt($form, &$formValues, $membership) {
+ // retrieve 'from email id' for acknowledgement
+ $receiptFrom = $formValues['from_email_address'] ?? NULL;
+
+ // @todo figure out how much of the stuff below is genuinely shared with the batch form & a logical shared place.
+ if (!empty($formValues['payment_instrument_id'])) {
+ $paymentInstrument = CRM_Contribute_PseudoConstant::paymentInstrument();
+ $formValues['paidBy'] = $paymentInstrument[$formValues['payment_instrument_id']];
+ }
+
+ $form->assign('module', 'Membership');
+ $form->assign('contactID', $formValues['contact_id']);
+
+ $form->assign('membershipID', CRM_Utils_Array::value('membership_id', $form->_params, CRM_Utils_Array::value('membership_id', $form->_defaultValues)));
+
+ if (!empty($formValues['contribution_id'])) {
+ $form->assign('contributionID', $formValues['contribution_id']);
+ }
+
+ if (!empty($formValues['contribution_status_id'])) {
+ $form->assign('contributionStatusID', $formValues['contribution_status_id']);
+ $form->assign('contributionStatus', CRM_Contribute_PseudoConstant::contributionStatus($formValues['contribution_status_id'], 'name'));
+ }
+
+ if (!empty($formValues['is_renew'])) {
+ $form->assign('receiptType', 'membership renewal');
+ }
+ else {
+ $form->assign('receiptType', 'membership signup');
+ }
+ $form->assign('receive_date', CRM_Utils_Array::value('receive_date', $formValues));
+ $form->assign('formValues', $formValues);
+
+ $form->assign('mem_start_date', CRM_Utils_Date::formatDateOnlyLong($membership->start_date));
+ if (!CRM_Utils_System::isNull($membership->end_date)) {
+ $form->assign('mem_end_date', CRM_Utils_Date::formatDateOnlyLong($membership->end_date));
+ }
+ $form->assign('membership_name', CRM_Member_PseudoConstant::membershipType($membership->membership_type_id));
+
+ [$form->_contributorDisplayName, $form->_contributorEmail]
+ = CRM_Contact_BAO_Contact_Location::getEmailDetails($formValues['contact_id']);
+ $form->_receiptContactId = $formValues['contact_id'];
+
+ CRM_Core_BAO_MessageTemplate::sendTemplate(
+ [
+ 'groupName' => 'msg_tpl_workflow_membership',
+ 'valueName' => 'membership_offline_receipt',
+ 'contactId' => $form->_receiptContactId,
+ 'from' => $receiptFrom,
+ 'toName' => $form->_contributorDisplayName,
+ 'toEmail' => $form->_contributorEmail,
+ 'PDFFilename' => ts('receipt') . '.pdf',
+ 'isEmailPdf' => Civi::settings()->get('invoicing') && Civi::settings()->get('invoice_is_email_pdf'),
+ 'contributionId' => $formValues['contribution_id'],
+ 'isTest' => (bool) ($form->_action & CRM_Core_Action::PREVIEW),
+ ]
+ );
+
+ return TRUE;
+ }
+
/**
* Update contact information.
*
* @param array $value
* Associated array of submitted values.
*/
- private function updateContactInfo(&$value) {
+ private function updateContactInfo(array &$value) {
$value['preserveDBName'] = $this->_preserveDefault;
//parse street address, CRM-7768
+--------------------------------------------------------------------+
*/
+use Civi\Api4\Group;
+
/**
*
* @package CRM
$query = "DELETE FROM civicrm_acl_entity_role where entity_table = 'civicrm_group' AND entity_id = %1";
CRM_Core_DAO::executeQuery($query, $params);
+ //check whether this group contains any saved searches and check if that saved search is appropriate to delete.
+ $groupDetails = Group::get(FALSE)->addWhere('id', '=', $id)->execute();
+ if (!empty($groupDetails[0]['saved_search_id'])) {
+ $savedSearch = new CRM_Contact_DAO_SavedSearch();
+ $savedSearch->id = $groupDetails[0]['saved_search_id'];
+ $savedSearch->find(TRUE);
+ // If it is a traditional saved search i.e has form values and there is no linked api_entity then delete the saved search as well.
+ if (!empty($savedSearch->form_values) && empty($savedSearch->api_entity) && empty($savedSearch->api_params)) {
+ $savedSearch->delete();
+ }
+ }
+
// delete from group table
$group = new CRM_Contact_DAO_Group();
$group->id = $id;
CRM_Core_DAO::executeQuery("INSERT IGNORE INTO $tempTable (group_id, contact_id) {$contactQuery}");
}
+ CRM_Core_DAO::reenableFullGroupByMode();
+
if ($group->children) {
// Store a list of contacts who are removed from the parent group
*
* Generated from xml/schema/CRM/Contact/Group.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
- * (GenCodeChecksum:31478cb7fd1eee1299fb22225020be77)
+ * (GenCodeChecksum:8f7306d4427fc261d17944ad601bb422)
*/
/**
*
* Generated from xml/schema/CRM/Contact/RelationshipCache.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
- * (GenCodeChecksum:11ec799a538838c310dc75be4427c9f0)
+ * (GenCodeChecksum:6092bd6a166a4209f57a62d71076b0dc)
*/
/**
'html' => [
'label' => ts("Relationship"),
],
+ 'readonly' => TRUE,
'add' => '5.29',
],
'relationship_type_id' => [
'html' => [
'label' => ts("Relationship Type"),
],
+ 'readonly' => TRUE,
'add' => '5.29',
],
'orientation' => [
'pseudoconstant' => [
'callback' => 'CRM_Core_SelectValues::relationshipOrientation',
],
+ 'readonly' => TRUE,
'add' => '5.29',
],
'near_contact_id' => [
'type' => 'EntityRef',
'label' => ts("Contact (Near side)"),
],
+ 'readonly' => TRUE,
'add' => '5.29',
],
'near_relation' => [
'pseudoconstant' => [
'callback' => 'CRM_Core_PseudoConstant::relationshipTypeOptions',
],
+ 'readonly' => TRUE,
'add' => '5.29',
],
'far_contact_id' => [
'type' => 'EntityRef',
'label' => ts("Contact (Far side)"),
],
+ 'readonly' => TRUE,
'add' => '5.29',
],
'far_relation' => [
'pseudoconstant' => [
'callback' => 'CRM_Core_PseudoConstant::relationshipTypeOptions',
],
+ 'readonly' => TRUE,
'add' => '5.29',
],
'is_active' => [
'html' => [
'type' => 'CheckBox',
],
+ 'readonly' => TRUE,
'add' => '5.29',
],
'relationship_start_date' => [
'type' => 'Select Date',
'formatType' => 'activityDate',
],
+ 'readonly' => TRUE,
'add' => '5.29',
],
'relationship_end_date' => [
'type' => 'Select Date',
'formatType' => 'activityDate',
],
+ 'readonly' => TRUE,
'add' => '5.29',
],
];
return [
[
'id' => 'summary',
- 'url' => '#contact-summary',
+ 'template' => 'CRM/Contact/Page/View/Summary-tab.tpl',
'title' => ts('Summary'),
'weight' => 0,
'icon' => 'crm-i fa-address-card-o',
* @copyright CiviCRM LLC https://civicrm.org/licensing
*/
+use Civi\Api4\Contribution;
+
/**
* This class contains Contribution Page related functions.
*/
$userID = $values['related_contact'] ?? NULL;
}
}
- list($values['customPre_grouptitle'], $values['customPre']) = self::getProfileNameAndFields($preID, $userID, $params['custom_pre_id']);
+ [$values['customPre_grouptitle'], $values['customPre']] = self::getProfileNameAndFields($preID, $userID, $params['custom_pre_id']);
}
$userID = $contactID;
if ($postID = CRM_Utils_Array::value('custom_post_id', $values)) {
/**
* Send the emails for Recurring Contribution Notification.
*
+ * @param int $contributionID
* @param string $type
* TxnType.
- * @param int $contactID
- * Contact id for contributor.
- * @param int $pageID
* Contribution page id.
* @param object $recur
* Object of recurring contribution table.
* @param bool|object $autoRenewMembership is it a auto renew membership.
+ *
+ * @throws \API_Exception
*/
- public static function recurringNotify($type, $contactID, $pageID, $recur, $autoRenewMembership = FALSE) {
- $value = [];
- $isEmailReceipt = FALSE;
- if ($pageID) {
- CRM_Core_DAO::commonRetrieveAll('CRM_Contribute_DAO_ContributionPage', 'id', $pageID, $value, [
- 'title',
- 'is_email_receipt',
- 'receipt_from_name',
- 'receipt_from_email',
- 'cc_receipt',
- 'bcc_receipt',
- ]);
- $isEmailReceipt = $value[$pageID]['is_email_receipt'] ?? NULL;
- }
- elseif ($recur->id) {
- // This means we are coming from back-office - ie. no page ID, but recurring.
- // Ideally this information would be passed into the function clearly rather than guessing by convention.
- $isEmailReceipt = TRUE;
- }
-
- if ($isEmailReceipt) {
- if ($pageID) {
- $receiptFrom = '"' . CRM_Utils_Array::value('receipt_from_name', $value[$pageID]) . '" <' . $value[$pageID]['receipt_from_email'] . '>';
-
- $receiptFromName = $value[$pageID]['receipt_from_name'];
- $receiptFromEmail = $value[$pageID]['receipt_from_email'];
+ public static function recurringNotify($contributionID, $type, $recur, $autoRenewMembership = FALSE): void {
+ $contribution = Contribution::get(FALSE)
+ ->addWhere('id', '=', $contributionID)
+ ->setSelect([
+ 'contribution_page_id',
+ 'contact_id',
+ 'contribution_recur_id',
+ 'contribution_recur.is_email_receipt',
+ 'contribution_page.title',
+ 'contribution_page.is_email_receipt',
+ 'contribution_page.receipt_from_name',
+ 'contribution_page.receipt_from_email',
+ 'contribution_page.cc_receipt',
+ 'contribution_page.bcc_receipt',
+ ])
+ ->execute()->first();
+
+ if ($contribution['contribution_recur.is_email_receipt'] || $contribution['contribution_page.is_email_receipt']) {
+ if ($contribution['contribution_page.receipt_from_email']) {
+ $receiptFromName = $contribution['contribution_page.receipt_from_name'];
+ $receiptFromEmail = $contribution['contribution_page.receipt_from_email'];
}
else {
- $domainValues = CRM_Core_BAO_Domain::getNameAndEmail();
- $receiptFrom = "$domainValues[0] <$domainValues[1]>";
- $receiptFromName = $domainValues[0];
- $receiptFromEmail = $domainValues[1];
+ [$receiptFromName, $receiptFromEmail] = CRM_Core_BAO_Domain::getNameAndEmail();
}
- list($displayName, $email) = CRM_Contact_BAO_Contact_Location::getEmailDetails($contactID, FALSE);
+ $receiptFrom = "$receiptFromName <$receiptFromEmail>";
+ [$displayName, $email] = CRM_Contact_BAO_Contact_Location::getEmailDetails($contribution['contact_id'], FALSE);
$templatesParams = [
'groupName' => 'msg_tpl_workflow_contribution',
'valueName' => 'contribution_recurring_notify',
- 'contactId' => $contactID,
+ 'contactId' => $contribution['contact_id'],
'tplParams' => [
'recur_frequency_interval' => $recur->frequency_interval,
'recur_frequency_unit' => $recur->frequency_unit,
'toEmail' => $email,
];
//CRM-13811
- if ($pageID) {
- $templatesParams['cc'] = $value[$pageID]['cc_receipt'] ?? NULL;
- $templatesParams['bcc'] = $value[$pageID]['bcc_receipt'] ?? NULL;
- }
+ $templatesParams['cc'] = $contribution['contribution_page.cc_receipt'];
+ $templatesParams['bcc'] = $contribution['contribution_page.cc_receipt'];
if ($recur->id) {
// in some cases its just recurringNotify() thats called for the first time and these urls don't get set.
// like in PaypalPro, & therefore we set it here additionally.
}
//send recurring Notification email for user
- CRM_Contribute_BAO_ContributionPage::recurringNotify($isFirstOrLastRecurringPayment,
- $ids['contact'],
- $ids['contributionPage'],
+ CRM_Contribute_BAO_ContributionPage::recurringNotify(
+ $ids['contribution'],
+ $isFirstOrLastRecurringPayment,
$recur,
$autoRenewMembership
);
*/
protected $_contributionContactIds = [];
- /**
- * The flag to tell if there are soft credits included.
- *
- * @var bool
- */
- public $_includesSoftCredits = FALSE;
-
/**
* Build all the data structures needed to build the form.
*/
$ids = $form->getSelectedIDs($values);
if (!$ids) {
$result = $form->getSearchQueryResults();
- $contributionContactIds = $contactIds = [];
while ($result->fetch()) {
$ids[] = $result->contribution_id;
- if ($form->_includesSoftCredits) {
- $contactIds[$result->contact_id] = $result->contact_id;
- $contributionContactIds["{$result->contact_id}-{$result->contribution_id}"] = $result->contribution_id;
+ if ($form->isQueryIncludesSoftCredits()) {
+ $form->_contactIds[$result->contact_id] = $result->contact_id;
+ $form->_contributionContactIds["{$result->contact_id}-{$result->contribution_id}"] = $result->contribution_id;
}
}
$form->assign('totalSelectedContributions', $form->get('rowCount'));
$form->assign('totalSelectedContributions', count($ids));
}
- if (!empty($form->_includesSoftCredits) && !empty($contactIds)) {
- $form->_contactIds = $contactIds;
- $form->_contributionContactIds = $contributionContactIds;
- }
$form->_contributionIds = $form->_componentIds = $ids;
$form->set('contributionIds', $form->_contributionIds);
* Given the contribution id, compute the contact id
* since its used for things like send email
*/
- public function setContactIDs() {
- if (!$this->_includesSoftCredits) {
+ public function setContactIDs(): void {
+ if (!$this->isQueryIncludesSoftCredits()) {
$this->_contactIds = CRM_Core_DAO::getContactIDsFromComponent(
$this->_contributionIds,
'civicrm_contribution'
/**
* Process the form after the input has been submitted and validated.
*
- * @param CRM_Contribute_Form_Task $form
+ * @param \CRM_Contribute_Form_Task_PDFLetter $form
* @param array $formValues
*/
public static function postProcess(&$form, $formValues = NULL) {
$skipOnHold = $form->skipOnHold ?? FALSE;
$skipDeceased = $form->skipDeceased ?? TRUE;
$contributionIDs = $form->getVar('_contributionIds');
- if ($form->_includesSoftCredits) {
+ if ($form->isQueryIncludesSoftCredits()) {
//@todo - comment on what is stored there
$contributionIDs = $form->getVar('_contributionContactIds');
}
- [$contributions, $contacts] = self::buildContributionArray($groupBy, $contributionIDs, $returnProperties, $skipOnHold, $skipDeceased, $messageToken, $task, $separator, $form->_includesSoftCredits);
+ [$contributions, $contacts] = self::buildContributionArray($groupBy, $contributionIDs, $returnProperties, $skipOnHold, $skipDeceased, $messageToken, $task, $separator, $form->isQueryIncludesSoftCredits());
$html = [];
$contactHtml = $emailedHtml = [];
foreach ($contributions as $contributionId => $contribution) {
*/
trait CRM_Contribute_Form_Task_TaskTrait {
+ /**
+ * Query result object.
+ *
+ * @var \CRM_Core_DAO
+ */
+ protected $queryBAO;
+
/**
* Get the results from the BAO_Query object based search.
*
* @throws \CRM_Core_Exception
*/
public function getSearchQueryResults(): CRM_Core_DAO {
- $form = $this;
- $queryParams = $this->getQueryParams();
- $returnProperties = ['contribution_id' => 1];
- $sortOrder = $sortCol = NULL;
- if ($form->get(CRM_Utils_Sort::SORT_ORDER)) {
- $sortOrder = $form->get(CRM_Utils_Sort::SORT_ORDER);
- //Include sort column in select clause.
- $sortCol = trim(str_replace(['`', 'asc', 'desc'], '', $sortOrder));
- $returnProperties[$sortCol] = 1;
- }
+ if (!$this->queryBAO) {
+ $form = $this;
+ $queryParams = $this->getQueryParams();
+ $returnProperties = ['contribution_id' => 1];
+ $sortOrder = $sortCol = NULL;
+ if ($form->get(CRM_Utils_Sort::SORT_ORDER)) {
+ $sortOrder = $form->get(CRM_Utils_Sort::SORT_ORDER);
+ //Include sort column in select clause.
+ $sortCol = trim(str_replace(['`', 'asc', 'desc'], '', $sortOrder));
+ $returnProperties[$sortCol] = 1;
+ }
- $form->_includesSoftCredits = CRM_Contribute_BAO_Query::isSoftCreditOptionEnabled($queryParams);
- $query = new CRM_Contact_BAO_Query($queryParams, $returnProperties, NULL, FALSE, FALSE,
- CRM_Contact_BAO_Query::MODE_CONTRIBUTE
- );
- // @todo the function CRM_Contribute_BAO_Query::isSoftCreditOptionEnabled should handle this
- // can we remove? if not why not?
- if ($form->_includesSoftCredits) {
- $query->_rowCountClause = " count(civicrm_contribution.id)";
- $query->_groupByComponentClause = " GROUP BY contribution_search_scredit_combined.id, contribution_search_scredit_combined.contact_id, contribution_search_scredit_combined.scredit_id ";
- }
- else {
- $query->_distinctComponentClause = ' civicrm_contribution.id';
- $query->_groupByComponentClause = ' GROUP BY civicrm_contribution.id ';
+ $query = new CRM_Contact_BAO_Query($queryParams, $returnProperties, NULL, FALSE, FALSE,
+ CRM_Contact_BAO_Query::MODE_CONTRIBUTE
+ );
+ // @todo the function CRM_Contribute_BAO_Query::isSoftCreditOptionEnabled should handle this
+ // can we remove? if not why not?
+ if ($this->isQueryIncludesSoftCredits()) {
+ $query->_rowCountClause = ' count(civicrm_contribution.id)';
+ $query->_groupByComponentClause = ' GROUP BY contribution_search_scredit_combined.id, contribution_search_scredit_combined.contact_id, contribution_search_scredit_combined.scredit_id ';
+ }
+ else {
+ $query->_distinctComponentClause = ' civicrm_contribution.id';
+ $query->_groupByComponentClause = ' GROUP BY civicrm_contribution.id ';
+ }
+ $this->queryBAO = $query->searchQuery(0, 0, $sortOrder);
}
- return $query->searchQuery(0, 0, $sortOrder);
+ return $this->queryBAO;
}
/**
return $queryParams;
}
+ /**
+ * Has soft credit information been requested in the query filters.
+ *
+ * @return bool
+ */
+ public function isQueryIncludesSoftCredits(): bool {
+ return (bool) CRM_Contribute_BAO_Query::isSoftCreditOptionEnabled($this->getQueryParams());
+ }
+
}
/**
* @return int
*/
- public function getPaymentProcessorID() {
- return $this->_paymentProcessorID;
+ public function getPaymentProcessorID(): int {
+ return (int) $this->_paymentProcessorID;
}
/**
CRM_Utils_Request::retrieve('triggerRebuild', 'Boolean', CRM_Core_DAO::$_nullObject, FALSE, 0, 'GET')
) {
CRM_Core_DAO::triggerRebuild();
+ $config->userSystem->invalidateRouteCache();
}
CRM_Core_DAO_AllCoreTables::reinitializeCache(TRUE);
CRM_Core_ManagedEntities::singleton(TRUE)->reconcile();
if ($isFirstOrLastRecurringPayment) {
//send recurring Notification email for user
- CRM_Contribute_BAO_ContributionPage::recurringNotify(TRUE,
- $contributionRecur->contact_id,
- $ids['contributionPage'],
+ CRM_Contribute_BAO_ContributionPage::recurringNotify($contributionID, TRUE,
$contributionRecur,
(bool) $this->getMembershipID($contributionID, $contributionRecur->id)
);
$this->recur($input, $ids, $contributionRecur, $contribution, $first);
if ($this->getFirstOrLastInSeriesStatus()) {
//send recurring Notification email for user
- CRM_Contribute_BAO_ContributionPage::recurringNotify($this->getFirstOrLastInSeriesStatus(),
- $ids['contact'],
- $ids['contributionPage'],
+ CRM_Contribute_BAO_ContributionPage::recurringNotify(
+ $ids['contribution'],
+ $this->getFirstOrLastInSeriesStatus(),
$contributionRecur,
!empty($ids['membership'])
);
if ($sendNotification) {
//send recurring Notification email for user
- CRM_Contribute_BAO_ContributionPage::recurringNotify($subscriptionPaymentStatus,
- $ids['contact'],
- $ids['contributionPage'],
+ CRM_Contribute_BAO_ContributionPage::recurringNotify(
+ $ids['contribution'],
+ $subscriptionPaymentStatus,
$recur,
!empty($ids['membership'])
);
"t2.{$this->rule_field} IS NOT NULL",
"t1.{$this->rule_field} = t2.{$this->rule_field}",
];
- if ($this->getFieldType($this->rule_field) === CRM_Utils_Type::T_DATE) {
- $innerJoinClauses[] = "t1.{$this->rule_field} > '1000-01-01'";
- $innerJoinClauses[] = "t2.{$this->rule_field} > '1000-01-01'";
- }
- else {
+
+ if (in_array($this->getFieldType($this->rule_field), CRM_Utils_Type::getTextTypes(), TRUE)) {
$innerJoinClauses[] = "t1.{$this->rule_field} <> ''";
$innerJoinClauses[] = "t2.{$this->rule_field} <> ''";
}
*/
class CRM_Extension_ClassLoader {
+ /**
+ * List of class-loader features that are valid in this version of Civi.
+ *
+ * This may be useful for some extensions which enable/disable polyfills based on environment.
+ */
+ const FEATURES = ',psr0,psr4,';
+
/**
* @var CRM_Extension_Mapper
*/
if (!empty($info->classloader)) {
foreach ($info->classloader as $mapping) {
switch ($mapping['type']) {
+ case 'psr0':
+ $loader->add($mapping['prefix'], CRM_Utils_File::addTrailingSlash($path . '/' . $mapping['path']));
+ break;
+
case 'psr4':
$loader->addPsr4($mapping['prefix'], $path . '/' . $mapping['path']);
break;
'path' => (string) $psr4->attributes()->path,
];
}
+ foreach ($val->psr0 as $psr0) {
+ $this->classloader[] = [
+ 'type' => 'psr0',
+ 'prefix' => (string) $psr0->attributes()->prefix,
+ 'path' => (string) $psr0->attributes()->path,
+ ];
+ }
}
elseif ($attr === 'tags') {
$this->tags = [];
return $this->lineItems;
}
+ /**
+ * Get line items that specifically relate to memberships.
+ *
+ * return array
+ *
+ * @throws \CiviCRM_API3_Exception
+ */
+ public function getMembershipLineItems():array {
+ $lines = $this->getLineItems();
+ foreach ($lines as $index => $line) {
+ if (empty($line['membership_type_id'])) {
+ unset($lines[$index]);
+ continue;
+ }
+ if (empty($line['membership_num_terms'])) {
+ $lines[$index]['membership_num_terms'] = 1;
+ }
+ }
+ return $lines;
+ }
+
/**
* @return array
* @throws \CiviCRM_API3_Exception
* & needs rationalising.
*
*/
- public static function emailReceipt($form, &$formValues, $membership) {
+ protected function emailReceipt($form, &$formValues, $membership) {
// retrieve 'from email id' for acknowledgement
$receiptFrom = $formValues['from_email_address'] ?? NULL;
$params['tax_amount'] = $this->order->getTotalTaxAmount();
$params['total_amount'] = $this->order->getTotalAmount();
- if (!empty($lineItem[$this->_priceSetId])) {
- foreach ($lineItem[$this->_priceSetId] as &$li) {
- if (!empty($li['membership_type_id'])) {
- if (!empty($li['membership_num_terms'])) {
- $termsByType[$li['membership_type_id']] = $li['membership_num_terms'];
- }
- }
- }
- }
-
$params['contact_id'] = $this->_contactID;
$params = array_merge($params, $this->getFormMembershipParams());
$startDate = $formValues['start_date'];
$endDate = $formValues['end_date'];
- $memTypeNumTerms = empty($termsByType) ? CRM_Utils_Array::value('num_terms', $formValues) : NULL;
-
$calcDates = [];
- foreach ($this->_memTypeSelected as $memType) {
- if (empty($memTypeNumTerms)) {
- $memTypeNumTerms = CRM_Utils_Array::value($memType, $termsByType, 1);
- }
- $calcDates[$memType] = CRM_Member_BAO_MembershipType::getDatesForMembershipType($memType,
+ foreach ($this->order->getMembershipLineItems() as $membershipLineItem) {
+ $memTypeNumTerms = $this->getSubmittedValue('num_terms') ?: $membershipLineItem['membership_num_terms'];
+ $calcDates[$membershipLineItem['membership_type_id']] = CRM_Member_BAO_MembershipType::getDatesForMembershipType($membershipLineItem['membership_type_id'],
$joinDate, $startDate, $endDate, $memTypeNumTerms
);
}
$params['lineItems'] = $lineItem;
$params['processPriceSet'] = TRUE;
}
- $createdMemberships = [];
+
if ($this->_mode) {
$params['total_amount'] = CRM_Utils_Array::value('total_amount', $formValues, 0);
$params['financial_type_id'] = $this->getFinancialTypeID();
//get the payment processor id as per mode. Try removing in favour of beginPostProcess.
- $params['payment_processor_id'] = $formValues['payment_processor_id'] = $this->_paymentProcessor['id'];
+ $params['payment_processor_id'] = $formValues['payment_processor_id'] = $this->getPaymentProcessorID();
$params['register_date'] = CRM_Utils_Time::date('YmdHis');
// add all the additional payment params we need
$membershipTypeValues[$memType]['startDate'] = NULL;
$membershipTypeValues[$memType]['endDate'] = NULL;
}
- $endDate = $startDate = NULL;
+ $startDate = NULL;
}
$now = CRM_Utils_Time::date('YmdHis');
$params['receive_date'] = CRM_Utils_Time::date('Y-m-d H:i:s');
$params['contribution'] = $membershipParams['contribution'] ?? NULL;
unset($params['lineItems']);
$this->_membershipIDs[] = $membership->id;
- $createdMemberships[$memType] = $membership;
$count++;
}
$lineItem[$this->_priceSetId][$id]['entity_table'] = 'civicrm_membership';
$this->_membershipIDs[] = $membership->id;
- $createdMemberships[$membership->membership_type_id] = $membership;
}
$params['lineItems'] = $lineItem;
if (!empty($formValues['record_contribution'])) {
}
}
if (($this->_action & CRM_Core_Action::UPDATE)) {
- $this->addStatusMessage($this->getStatusMessageForUpdate($membership, $endDate));
+ $this->addStatusMessage($this->getStatusMessageForUpdate());
}
elseif (($this->_action & CRM_Core_Action::ADD)) {
- $this->addStatusMessage($this->getStatusMessageForCreate($endDate, $createdMemberships,
- $this->isCreateRecurringContribution(), $calcDates));
+ $this->addStatusMessage($this->getStatusMessageForCreate());
}
// This would always be true as we always add price set id into both
/**
* Get status message for updating membership.
*
- * @param CRM_Member_BAO_Membership $membership
- * @param string $endDate
- *
* @return string
+ * @throws \CiviCRM_API3_Exception
*/
- protected function getStatusMessageForUpdate($membership, $endDate) {
- // End date can be modified by hooks, so if end date is set then use it.
- $endDate = ($membership->end_date) ? $membership->end_date : $endDate;
-
+ protected function getStatusMessageForUpdate(): string {
+ foreach ($this->getCreatedMemberships() as $membership) {
+ $endDate = $membership['end_date'] ?? NULL;
+ }
$statusMsg = ts('Membership for %1 has been updated.', [1 => $this->_memberDisplayName]);
- if ($endDate && $endDate !== 'null') {
+ if ($endDate) {
$endDate = CRM_Utils_Date::customFormat($endDate);
$statusMsg .= ' ' . ts('The membership End Date is %1.', [1 => $endDate]);
}
/**
* Get status message for create action.
*
- * @param string $endDate
- * @param array $createdMemberships
- * @param bool $isRecur
- * @param array $calcDates
- *
* @return array|string
+ * @throws \CiviCRM_API3_Exception
*/
- protected function getStatusMessageForCreate($endDate, $createdMemberships,
- $isRecur, $calcDates) {
- // FIX ME: fix status messages
-
- $statusMsg = [];
- foreach ($this->_memTypeSelected as $membershipTypeID) {
- $statusMsg[$membershipTypeID] = ts('%1 membership for %2 has been added.', [
- 1 => $this->allMembershipTypeDetails[$membershipTypeID]['name'],
+ protected function getStatusMessageForCreate(): string {
+ foreach ($this->getCreatedMemberships() as $membership) {
+ $statusMsg[$membership['membership_type_id']] = ts('%1 membership for %2 has been added.', [
+ 1 => $this->allMembershipTypeDetails[$membership['membership_type_id']]['name'],
2 => $this->_memberDisplayName,
]);
- $membership = $createdMemberships[$membershipTypeID];
- $memEndDate = $membership->end_date ?: $endDate;
-
- //get the end date from calculated dates.
- if (!$memEndDate && !$isRecur) {
- $memEndDate = $calcDates[$membershipTypeID]['end_date'] ?? NULL;
- }
+ $memEndDate = $membership['end_date'] ?? NULL;
- if ($memEndDate && $memEndDate !== 'null') {
+ if ($memEndDate) {
$memEndDate = CRM_Utils_Date::formatDateOnlyLong($memEndDate);
- $statusMsg[$membershipTypeID] .= ' ' . ts('The new membership End Date is %1.', [1 => $memEndDate]);
+ $statusMsg[$membership['membership_type_id']] .= ' ' . ts('The new membership End Date is %1.', [1 => $memEndDate]);
}
}
$statusMsg = implode('<br/>', $statusMsg);
- return $statusMsg;
+ return $statusMsg ?? '';
}
/**
$this->assign('is_pay_later', 0);
$this->assign('isPrimary', 1);
}
- return self::emailReceipt($this, $formValues, $membership);
+ return $this->emailReceipt($this, $formValues, $membership);
}
/**
}
$recurParams['invoice_id'] = $this->getInvoiceID();
$recurParams['contribution_status_id'] = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Pending');
- $recurParams['payment_processor_id'] = $params['payment_processor_id'] ?? NULL;
+ $recurParams['payment_processor_id'] = $this->getPaymentProcessorID();
$recurParams['is_email_receipt'] = (bool) $this->getSubmittedValue('send_receipt');
// we need to add a unique trxn_id to avoid a unique key error
// in paypal IPN we reset this when paypal sends us the real trxn id, CRM-2991
return $this->_mode && $this->getSubmittedValue('auto_renew');
}
+ /**
+ * Get the payment processor ID.
+ *
+ * @return int
+ */
+ public function getPaymentProcessorID(): int {
+ return (int) ($this->getSubmittedValue('payment_processor_id') ?: $this->_paymentProcessor['id']);
+ }
+
+ /**
+ * Get memberships submitted through the form submission.
+ * @return array
+ *
+ * @throws \CiviCRM_API3_Exception
+ */
+ protected function getCreatedMemberships(): array {
+ return civicrm_api3('Membership', 'get', ['id' => ['IN' => $this->_membershipIDs]])['values'];
+ }
+
}
* (change the x in the function name):
*/
+ /**
+ * Upgrade function.
+ *
+ * @param string $rev
+ */
+ public function upgrade_5_37_alpha1($rev) {
+ $this->addTask(ts('Upgrade DB to %1: SQL', [1 => $rev]), 'runSql', $rev);
+ $this->addTask('core-issue#1845 - Alter Foreign key on civicrm_group to delete when the associated group when the saved search is deleted', 'alterSavedSearchFK');
+ }
+
// /**
// * Upgrade function.
// *
// return TRUE;
// }
+ /**
+ * @param \CRM_Queue_TaskContext $ctx
+ *
+ * @return bool
+ */
+ public static function alterSavedSearchFK(CRM_Queue_TaskContext $ctx) {
+ CRM_Core_BAO_SchemaHandler::safeRemoveFK('civicrm_group', 'FK_civicrm_group_saved_search_id');
+ CRM_Core_DAO::executeQuery('DELETE civicrm_saved_search FROM civicrm_saved_search LEFT JOIN civicrm_group ON civicrm_saved_search.id = civicrm_group.saved_search_id WHERE civicrm_group.id IS NULL AND form_values IS NOT NULL and api_params IS NULL');
+ CRM_Core_DAO::executeQuery('ALTER TABLE civicrm_group ADD CONSTRAINT `FK_civicrm_group_saved_search_id` FOREIGN KEY (`saved_search_id`) REFERENCES `civicrm_saved_search`(`id`) ON DELETE CASCADE', [], TRUE, NULL, FALSE, FALSE);
+ return TRUE;
+ }
+
}
'civicrm_saved_search', 'description', "text DEFAULT NULL");
$this->addTask('core-issue#2422 - Add constraints to civicrm_saved_search', 'taskAddConstraints');
-
}
/**
return [];
}
+ /**
+ * Invalidates the cache of dynamic routes and forces a rebuild.
+ */
+ public function invalidateRouteCache() {
+ }
+
}
return \Drupal::entityTypeManager()->getStorage('user')->load($userID);
}
+ /**
+ * Helper function to rebuild the Drupal 8 or 9 dynamic routing cache.
+ * We need to do this after enabling extensions that add routes and it's worth doing when we reset Civi paths.
+ */
+ public function invalidateRouteCache() {
+ if (class_exists('\Drupal') && \Drupal::hasContainer()) {
+ \Drupal::service('router.builder')->rebuild();
+ }
+ }
+
}
return array_combine($types, $types);
}
+ /**
+ * Get all the types that are text-like.
+ *
+ * The returned types would all legitimately be compared to '' by mysql
+ * in a query.
+ *
+ * e.g
+ * WHERE display_name = '' is valid
+ * WHERE id = '' is not and in some mysql configurations and queries
+ * could cause an error.
+ *
+ * @return array
+ */
+ public static function getTextTypes(): array {
+ return [
+ self::T_STRING,
+ self::T_ENUM,
+ self::T_TEXT,
+ self::T_LONGTEXT,
+ self::T_BLOB,
+ self::T_EMAIL,
+ self::T_URL,
+ self::T_MEDIUMBLOB,
+ ];
+ }
+
}
use Civi\API\Exception\NotImplementedException;
use Civi\Api4\Generic\BasicGetAction;
+use Civi\Api4\Utils\CoreUtil;
use Civi\Api4\Utils\ReflectionUtils;
/**
protected function getRecords() {
$this->_actionsToGet = $this->_itemsToGet('name');
- $entityReflection = new \ReflectionClass('\Civi\Api4\\' . $this->_entityName);
+ $className = CoreUtil::getApiClass($this->_entityName);
+ $entityReflection = new \ReflectionClass($className);
foreach ($entityReflection->getMethods(\ReflectionMethod::IS_STATIC | \ReflectionMethod::IS_PUBLIC) as $method) {
$actionName = $method->getName();
if ($actionName != 'permissions' && $actionName != 'getInfo' && $actionName[0] != '_') {
}
if (!$this->_actionsToGet || count($this->_actionsToGet) > count($this->_actions)) {
// Search for entity-specific actions in extensions
+ $nameSpace = str_replace('Civi\Api4\\', 'Civi\Api4\Action\\', $className);
foreach (\CRM_Extension_System::singleton()->getMapper()->getActiveModuleFiles() as $ext) {
$dir = \CRM_Utils_File::addTrailingSlash(dirname($ext['filePath']));
- $this->scanDir($dir . 'Civi/Api4/Action/' . $this->_entityName);
+ $this->scanDir($dir, $nameSpace);
}
// Search for entity-specific actions in core
- $this->scanDir(\CRM_Utils_File::addTrailingSlash(__DIR__) . $this->_entityName);
+ global $civicrm_root;
+ $this->scanDir(\CRM_Utils_File::addTrailingSlash($civicrm_root), $nameSpace);
}
ksort($this->_actions);
return $this->_actions;
}
/**
- * @param $dir
+ * @param string $dir
+ * @param string $nameSpace
*/
- private function scanDir($dir) {
+ private function scanDir($dir, $nameSpace) {
+ $dir .= str_replace('\\', '/', $nameSpace);
if (is_dir($dir)) {
foreach (glob("$dir/*.php") as $file) {
- $matches = [];
- preg_match('/(\w*)\.php$/', $file, $matches);
- $actionName = array_pop($matches);
- $actionClass = new \ReflectionClass('\\Civi\\Api4\\Action\\' . $this->_entityName . '\\' . $actionName);
- if ($actionClass->isInstantiable() && $actionClass->isSubclassOf('\\Civi\\Api4\\Generic\\AbstractAction')) {
+ $actionName = basename($file, '.php');
+ $actionClass = new \ReflectionClass($nameSpace . '\\' . $actionName);
+ if ($actionClass->isInstantiable() && $actionClass->isSubclassOf('\Civi\\Api4\Generic\AbstractAction')) {
$this->loadAction(lcfirst($actionName));
}
}
* @return \Civi\Api4\Action\GetActions
*/
public static function getActions($checkPermissions = TRUE) {
- return (new \Civi\Api4\Action\GetActions(self::getEntityName(), __FUNCTION__))
+ return (new \Civi\Api4\Action\GetActions(static::getEntityName(), __FUNCTION__))
->setCheckPermissions($checkPermissions);
}
* @throws NotImplementedException
*/
public static function __callStatic($action, $args) {
- $entity = self::getEntityName();
+ $entity = static::getEntityName();
$nameSpace = str_replace('Civi\Api4\\', 'Civi\Api4\Action\\', static::class);
// Find class for this action
$entityAction = "$nameSpace\\" . ucfirst($action);
* @return BasicGetAction
*/
public static function get($checkPermissions = TRUE) {
- return (new BasicGetAction(static::class, __FUNCTION__, static::$getter))
+ return (new BasicGetAction(static::getEntityName(), __FUNCTION__, static::$getter))
->setCheckPermissions($checkPermissions);
}
* @return BasicCreateAction
*/
public static function create($checkPermissions = TRUE) {
- return (new BasicCreateAction(static::class, __FUNCTION__, static::$setter))
+ return (new BasicCreateAction(static::getEntityName(), __FUNCTION__, static::$setter))
->setCheckPermissions($checkPermissions);
}
* @return BasicSaveAction
*/
public static function save($checkPermissions = TRUE) {
- return (new BasicSaveAction(static::class, __FUNCTION__, static::$idField, static::$setter))
+ return (new BasicSaveAction(static::getEntityName(), __FUNCTION__, static::$idField, static::$setter))
->setCheckPermissions($checkPermissions);
}
* @return BasicUpdateAction
*/
public static function update($checkPermissions = TRUE) {
- return (new BasicUpdateAction(static::class, __FUNCTION__, static::$idField, static::$setter))
+ return (new BasicUpdateAction(static::getEntityName(), __FUNCTION__, static::$idField, static::$setter))
->setCheckPermissions($checkPermissions);
}
* @return BasicBatchAction
*/
public static function delete($checkPermissions = TRUE) {
- return (new BasicBatchAction(static::class, __FUNCTION__, static::$idField, static::$deleter))
+ return (new BasicBatchAction(static::getEntityName(), __FUNCTION__, static::$idField, static::$deleter))
->setCheckPermissions($checkPermissions);
}
* @return BasicReplaceAction
*/
public static function replace($checkPermissions = TRUE) {
- return (new BasicReplaceAction(static::class, __FUNCTION__))
+ return (new BasicReplaceAction(static::getEntityName(), __FUNCTION__))
->setCheckPermissions($checkPermissions);
}
* @return DAOGetAction
*/
public static function get($checkPermissions = TRUE) {
- return (new DAOGetAction(static::class, __FUNCTION__))
+ return (new DAOGetAction(static::getEntityName(), __FUNCTION__))
->setCheckPermissions($checkPermissions);
}
* @return DAOSaveAction
*/
public static function save($checkPermissions = TRUE) {
- return (new DAOSaveAction(static::class, __FUNCTION__))
+ return (new DAOSaveAction(static::getEntityName(), __FUNCTION__))
->setCheckPermissions($checkPermissions);
}
* @return DAOGetFieldsAction
*/
public static function getFields($checkPermissions = TRUE) {
- return (new DAOGetFieldsAction(static::class, __FUNCTION__))
+ return (new DAOGetFieldsAction(static::getEntityName(), __FUNCTION__))
->setCheckPermissions($checkPermissions);
}
* @return DAOCreateAction
*/
public static function create($checkPermissions = TRUE) {
- return (new DAOCreateAction(static::class, __FUNCTION__))
+ return (new DAOCreateAction(static::getEntityName(), __FUNCTION__))
->setCheckPermissions($checkPermissions);
}
* @return DAOUpdateAction
*/
public static function update($checkPermissions = TRUE) {
- return (new DAOUpdateAction(static::class, __FUNCTION__))
+ return (new DAOUpdateAction(static::getEntityName(), __FUNCTION__))
->setCheckPermissions($checkPermissions);
}
* @return DAODeleteAction
*/
public static function delete($checkPermissions = TRUE) {
- return (new DAODeleteAction(static::class, __FUNCTION__))
+ return (new DAODeleteAction(static::getEntityName(), __FUNCTION__))
->setCheckPermissions($checkPermissions);
}
* @return BasicReplaceAction
*/
public static function replace($checkPermissions = TRUE) {
- return (new BasicReplaceAction(static::class, __FUNCTION__))
+ return (new BasicReplaceAction(static::getEntityName(), __FUNCTION__))
->setCheckPermissions($checkPermissions);
}
* @return \Civi\Api4\Action\MailSettings\TestConnection
*/
public static function testConnection($checkPermissions = TRUE) {
- $action = new \Civi\Api4\Action\MailSettings\TestConnection(static::class, __FUNCTION__);
+ $action = new \Civi\Api4\Action\MailSettings\TestConnection(__CLASS__, __FUNCTION__);
return $action->setCheckPermissions($checkPermissions);
}
* @return Generic\DAOGetAction
*/
public static function get($checkPermissions = TRUE) {
- return (new Generic\DAOGetAction(static::class, __FUNCTION__))
+ return (new Generic\DAOGetAction(__CLASS__, __FUNCTION__))
->setCheckPermissions($checkPermissions);
}
* @return Generic\DAOGetFieldsAction
*/
public static function getFields($checkPermissions = TRUE) {
- return (new Generic\DAOGetFieldsAction(static::class, __FUNCTION__))
+ return (new Generic\DAOGetFieldsAction(__CLASS__, __FUNCTION__))
->setCheckPermissions($checkPermissions);
}
// Format oop params
function formatOOP(entity, action, params, indent) {
- var code = '',
+ var info = getEntity(entity),
newLine = "\n" + _.repeat(' ', indent),
+ code = '\\' + info.class + '::' + action + '(',
perm = params.checkPermissions === false ? 'FALSE' : '';
if (entity.substr(0, 7) !== 'Custom_') {
- code = "\\Civi\\Api4\\" + entity + '::' + action + '(' + perm + ')';
+ code += perm + ')';
} else {
- code = "\\Civi\\Api4\\CustomValue::" + action + "('" + entity.substr(7) + "'" + (perm ? ', ' : '') + perm + ")";
+ code += "'" + entity.substr(7) + "'" + (perm ? ', ' : '') + perm + ")";
}
_.each(params, function(param, key) {
var val = '';
/**
* The setup() method is executed before the test is executed (optional).
*/
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
CRM_Core_Config::singleton()->userPermissionTemp = new CRM_Core_Permission_Temp();
CRM_Core_Config::singleton()->userPermissionTemp->grant('administer CiviCRM');
}
- /**
- * The tearDown() method is executed after the test was executed (optional)
- * This can be used for cleanup.
- */
- public function tearDown() {
- parent::tearDown();
- }
-
}
// Add in FK fields for implicit joins
// For example, add a `campaign.title` field to the Contribution entity
foreach ($schema as &$entity) {
- foreach (array_reverse($entity['fields'], TRUE) as $index => $field) {
- if (!empty($field['fk_entity']) && !$field['options'] && !empty($schema[$field['fk_entity']]['label_field'])) {
- // The original field will get title instead of label since it represents the id (title usually ends in ID but label does not)
- $entity['fields'][$index]['label'] = $field['title'];
- // Add the label field from the other entity to this entity's list of fields
- $newField = \CRM_Utils_Array::findAll($schema[$field['fk_entity']]['fields'], ['name' => $schema[$field['fk_entity']]['label_field']])[0];
- $newField['name'] = str_replace('_id', '', $field['name']) . '.' . $schema[$field['fk_entity']]['label_field'];
- $newField['label'] = $field['label'] . ' ' . $newField['label'];
- array_splice($entity['fields'], $index, 0, [$newField]);
+ if (in_array('DAOEntity', $entity['type'], TRUE) && !in_array('EntityBridge', $entity['type'], TRUE)) {
+ foreach (array_reverse($entity['fields'], TRUE) as $index => $field) {
+ if (!empty($field['fk_entity']) && !$field['options'] && !empty($schema[$field['fk_entity']]['label_field'])) {
+ // The original field will get title instead of label since it represents the id (title usually ends in ID but label does not)
+ $entity['fields'][$index]['label'] = $field['title'];
+ // Add the label field from the other entity to this entity's list of fields
+ $newField = \CRM_Utils_Array::findAll($schema[$field['fk_entity']]['fields'], ['name' => $schema[$field['fk_entity']]['label_field']])[0];
+ $newField['name'] = str_replace('_id', '', $field['name']) . '.' . $schema[$field['fk_entity']]['label_field'];
+ $newField['label'] = $field['label'] . ' ' . $newField['label'];
+ array_splice($entity['fields'], $index, 0, [$newField]);
+ }
}
}
}
'label',
'api_entity',
'api_params',
+ 'created.display_name',
+ 'modified.display_name',
+ 'created_date',
+ 'modified_date',
'GROUP_CONCAT(display.name ORDER BY display.id) AS display_name',
'GROUP_CONCAT(display.label ORDER BY display.id) AS display_label',
'GROUP_CONCAT(display.type:icon ORDER BY display.id) AS display_icon',
angular.module('crmSearchAdmin').controller('searchList', function($scope, savedSearches, crmApi4) {
var ts = $scope.ts = CRM.ts('org.civicrm.search'),
ctrl = $scope.$ctrl = this;
+ $scope.formatDate = CRM.utils.formatDate;
this.savedSearches = savedSearches;
this.afformEnabled = CRM.crmSearchAdmin.afformEnabled;
this.afformAdminEnabled = CRM.crmSearchAdmin.afformAdminEnabled;
<th>{{:: ts('Displays') }}</th>
<th>{{:: ts('Smart Group') }}</th>
<th ng-if="$ctrl.afformEnabled">{{:: ts('Forms') }}</th>
+ <th>{{:: ts('Created') }}</th>
+ <th>{{:: ts('Last Modified') }}</th>
<th></th>
</tr>
</thead>
<tbody>
<tr ng-repeat="search in $ctrl.savedSearches | filter:$ctrl.searchFilter">
- <td>{{ search.id }}</td>
- <td>{{ search.label }}</td>
- <td>{{ $ctrl.entityTitles[search.api_entity] }}</td>
+ <td>{{:: search.id }}</td>
+ <td>{{:: search.label }}</td>
+ <td>{{:: $ctrl.entityTitles[search.api_entity] }}</td>
<td>
<div class="btn-group">
<button type="button" disabled ng-if="!search.display_name" class="btn btn-xs dropdown-toggle btn-primary-outline">
</ul>
</div>
</td>
- <td>{{ search.groups.join(', ') }}</td>
+ <td>{{:: search.groups.join(', ') }}</td>
<td ng-if="::$ctrl.afformEnabled">
<div class="btn-group">
<button type="button" ng-click="$ctrl.loadAfforms()" ng-if="search.display_name" class="btn btn-xs dropdown-toggle btn-primary-outline" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
</ul>
</div>
</td>
+ <td>{{:: ts('%1 by %2', {1: formatDate(search.created_date), 2: search['created.display_name']}) }}</td>
+ <td>{{:: ts('%1 by %2', {1: formatDate(search.created_date), 2: search['modified.display_name']}) }}</td>
<td class="text-right">
<a class="btn btn-xs btn-default" href="#/edit/{{:: search.id }}">{{:: ts('Edit') }}</a>
<a class="btn btn-xs btn-default" href="#/create/{{:: search.api_entity + '?params=' + $ctrl.encode(search.api_params) }}">{{:: ts('Clone') }}</a>
<div class="crm-content crm-custom-data crm-contact-reference">
{', '|implode:$element.contact_ref_links}
</div>
- {elseif $element.field_data_type EQ 'Money'}
- <div class="crm-content crm-custom-data">{$element.field_value|crmMoney}</div>
{else}
<div class="crm-content crm-custom-data">{$element.field_value}</div>
{/if}
--- /dev/null
+{*
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC. All rights reserved. |
+ | |
+ | This work is published under the GNU AGPLv3 license with some |
+ | permitted exceptions and without any warranty. For full license |
+ | and copyright information, see https://civicrm.org/licensing |
+ +--------------------------------------------------------------------+
+*}
+{* Summary tab from Contact Summary screen *}
+
+{if (isset($hookContentPlacement) and ($hookContentPlacement neq 3)) or empty($hookContentPlacement)}
+
+ {if !empty($hookContent) and isset($hookContentPlacement) and $hookContentPlacement eq 2}
+ {include file="CRM/Contact/Page/View/SummaryHook.tpl"}
+ {/if}
+
+ <div class="contactTopBar contact_panel">
+ <div class="contactCardLeft">
+ {crmRegion name="contact-basic-info-left"}
+ <div class="crm-summary-contactinfo-block">
+ <div class="crm-summary-block" id="contactinfo-block">
+ {include file="CRM/Contact/Page/Inline/ContactInfo.tpl"}
+ </div>
+ </div>
+ {/crmRegion}
+ </div>
+ <div class="contactCardRight">
+ {crmRegion name="contact-basic-info-right"}
+ {if !empty($imageURL)}
+ <div id="crm-contact-thumbnail">
+ {include file="CRM/Contact/Page/ContactImage.tpl"}
+ </div>
+ {/if}
+ <div class="{if !empty($imageURL)} float-left{/if}">
+ <div class="crm-summary-basic-block crm-summary-block">
+ {include file="CRM/Contact/Page/Inline/Basic.tpl"}
+ </div>
+ </div>
+ {/crmRegion}
+ </div>
+ </div>
+ <div class="contact_details">
+ <div class="contact_panel">
+ <div class="contactCardLeft">
+ {crmRegion name="contact-details-left"}
+ <div >
+ {if $showEmail}
+ <div class="crm-summary-email-block crm-summary-block" id="email-block">
+ {include file="CRM/Contact/Page/Inline/Email.tpl"}
+ </div>
+ {/if}
+ {if $showWebsite}
+ <div class="crm-summary-website-block crm-summary-block" id="website-block">
+ {include file="CRM/Contact/Page/Inline/Website.tpl"}
+ </div>
+ {/if}
+ </div>
+ {/crmRegion}
+ </div><!-- #contactCardLeft -->
+
+ <div class="contactCardRight">
+ {crmRegion name="contact-details-right"}
+ <div>
+ {if $showPhone}
+ <div class="crm-summary-phone-block crm-summary-block" id="phone-block">
+ {include file="CRM/Contact/Page/Inline/Phone.tpl"}
+ </div>
+ {/if}
+ {if $showIM}
+ <div class="crm-summary-im-block crm-summary-block" id="im-block">
+ {include file="CRM/Contact/Page/Inline/IM.tpl"}
+ </div>
+ {/if}
+ {if $showOpenID}
+ <div class="crm-summary-openid-block crm-summary-block" id="openid-block">
+ {include file="CRM/Contact/Page/Inline/OpenID.tpl"}
+ </div>
+ {/if}
+ </div>
+ {/crmRegion}
+ </div><!-- #contactCardRight -->
+
+ <div class="clear"></div>
+ </div><!-- #contact_panel -->
+ {if $showAddress}
+ <div class="contact_panel">
+ {crmRegion name="contact-addresses"}
+ {assign var='locationIndex' value=1}
+ {if $address}
+ {foreach from=$address item=add key=locationIndex}
+ <div class="{if $locationIndex is odd}contactCardLeft{else}contactCardRight{/if} crm-address_{$locationIndex} crm-address-block crm-summary-block">
+ {include file="CRM/Contact/Page/Inline/Address.tpl"}
+ </div>
+ {/foreach}
+ {assign var='locationIndex' value=$locationIndex+1}
+ {/if}
+ {* add new link *}
+ {if $permission EQ 'edit'}
+ {assign var='add' value=0}
+ <div class="{if $locationIndex is odd}contactCardLeft{else}contactCardRight{/if} crm-address-block crm-summary-block">
+ {include file="CRM/Contact/Page/Inline/Address.tpl"}
+ </div>
+ {/if}
+ {/crmRegion}
+ </div> <!-- end of contact panel -->
+ {/if}
+ <div class="contact_panel">
+ {if $showCommunicationPreferences}
+ <div class="contactCardLeft">
+ {crmRegion name="contact-comm-pref"}
+ <div class="crm-summary-comm-pref-block">
+ <div class="crm-summary-block" id="communication-pref-block" >
+ {include file="CRM/Contact/Page/Inline/CommunicationPreferences.tpl"}
+ </div>
+ </div>
+ {/crmRegion}
+ </div> <!-- contactCardLeft -->
+ {/if}
+ {if $contact_type eq 'Individual' AND $showDemographics}
+ <div class="contactCardRight">
+ {crmRegion name="contact-demographic"}
+ <div class="crm-summary-demographic-block">
+ <div class="crm-summary-block" id="demographic-block">
+ {include file="CRM/Contact/Page/Inline/Demographics.tpl"}
+ </div>
+ </div>
+ {/crmRegion}
+ </div> <!-- contactCardRight -->
+ {/if}
+ <div class="clear"></div>
+ <div class="separator"></div>
+ </div> <!-- contact panel -->
+ </div><!--contact_details-->
+
+ {if $showCustomData}
+ <div id="customFields">
+ <div class="contact_panel">
+ <div class="contactCardLeft">
+ {include file="CRM/Contact/Page/View/CustomDataView.tpl" side='1'}
+ </div><!--contactCardLeft-->
+ <div class="contactCardRight">
+ {include file="CRM/Contact/Page/View/CustomDataView.tpl" side='0'}
+ </div>
+
+ <div class="clear"></div>
+ </div>
+ </div>
+ {/if}
+
+ {if !empty($hookContent) and isset($hookContentPlacement) and $hookContentPlacement eq 1}
+ {include file="CRM/Contact/Page/View/SummaryHook.tpl"}
+ {/if}
+{else}
+ {include file="CRM/Contact/Page/View/SummaryHook.tpl"}
+{/if}
<div class="crm-block crm-content-block crm-contact-page crm-inline-edit-container">
<div id="mainTabContainer">
<ul class="crm-contact-tabs-list">
- {foreach from=$allTabs key=tabName item=tabValue}
+ {foreach from=$allTabs item=tabValue}
<li id="tab_{$tabValue.id}" class="crm-tab-button ui-corner-all crm-count-{$tabValue.count}{if isset($tabValue.class)} {$tabValue.class}{/if}">
- <a href="{$tabValue.url}" title="{$tabValue.title|escape}">
+ <a href="{if !empty($tabValue.template)}#contact-{$tabValue.id}{else}{$tabValue.url}{/if}" title="{$tabValue.title|escape}">
<i class="{if $tabValue.icon}{$tabValue.icon}{else}crm-i fa-puzzle-piece{/if}" aria-hidden="true"></i>
<span>{$tabValue.title}</span>
{if empty($tabValue.hideCount)}<em>{$tabValue.count}</em>{/if}
{/foreach}
</ul>
- <div id="contact-summary" class="ui-tabs-panel ui-widget-content ui-corner-bottom">
- {if (isset($hookContentPlacement) and ($hookContentPlacement neq 3)) or empty($hookContentPlacement)}
-
- {if !empty($hookContent) and isset($hookContentPlacement) and $hookContentPlacement eq 2}
- {include file="CRM/Contact/Page/View/SummaryHook.tpl"}
- {/if}
-
- <div class="contactTopBar contact_panel">
- <div class="contactCardLeft">
- {crmRegion name="contact-basic-info-left"}
- <div class="crm-summary-contactinfo-block">
- <div class="crm-summary-block" id="contactinfo-block">
- {include file="CRM/Contact/Page/Inline/ContactInfo.tpl"}
- </div>
- </div>
- {/crmRegion}
- </div> <!-- end of left side -->
- <div class="contactCardRight">
- {crmRegion name="contact-basic-info-right"}
- {if !empty($imageURL)}
- <div id="crm-contact-thumbnail">
- {include file="CRM/Contact/Page/ContactImage.tpl"}
- </div>
- {/if}
- <div class="{if !empty($imageURL)} float-left{/if}">
- <div class="crm-summary-basic-block crm-summary-block">
- {include file="CRM/Contact/Page/Inline/Basic.tpl"}
- </div>
- </div>
- {/crmRegion}
- </div>
- <!-- end of right side -->
- </div>
- <div class="contact_details">
- <div class="contact_panel">
- <div class="contactCardLeft">
- {crmRegion name="contact-details-left"}
- <div >
- {if $showEmail}
- <div class="crm-summary-email-block crm-summary-block" id="email-block">
- {include file="CRM/Contact/Page/Inline/Email.tpl"}
- </div>
- {/if}
- {if $showWebsite}
- <div class="crm-summary-website-block crm-summary-block" id="website-block">
- {include file="CRM/Contact/Page/Inline/Website.tpl"}
- </div>
- {/if}
- </div>
- {/crmRegion}
- </div><!-- #contactCardLeft -->
-
- <div class="contactCardRight">
- {crmRegion name="contact-details-right"}
- <div>
- {if $showPhone}
- <div class="crm-summary-phone-block crm-summary-block" id="phone-block">
- {include file="CRM/Contact/Page/Inline/Phone.tpl"}
- </div>
- {/if}
- {if $showIM}
- <div class="crm-summary-im-block crm-summary-block" id="im-block">
- {include file="CRM/Contact/Page/Inline/IM.tpl"}
- </div>
- {/if}
- {if $showOpenID}
- <div class="crm-summary-openid-block crm-summary-block" id="openid-block">
- {include file="CRM/Contact/Page/Inline/OpenID.tpl"}
- </div>
- {/if}
- </div>
- {/crmRegion}
- </div><!-- #contactCardRight -->
-
- <div class="clear"></div>
- </div><!-- #contact_panel -->
- {if $showAddress}
- <div class="contact_panel">
- {crmRegion name="contact-addresses"}
- {assign var='locationIndex' value=1}
- {if $address}
- {foreach from=$address item=add key=locationIndex}
- <div class="{if $locationIndex is odd}contactCardLeft{else}contactCardRight{/if} crm-address_{$locationIndex} crm-address-block crm-summary-block">
- {include file="CRM/Contact/Page/Inline/Address.tpl"}
- </div>
- {/foreach}
- {assign var='locationIndex' value=$locationIndex+1}
- {/if}
- {* add new link *}
- {if $permission EQ 'edit'}
- {assign var='add' value=0}
- <div class="{if $locationIndex is odd}contactCardLeft{else}contactCardRight{/if} crm-address-block crm-summary-block">
- {include file="CRM/Contact/Page/Inline/Address.tpl"}
- </div>
- {/if}
- {/crmRegion}
- </div> <!-- end of contact panel -->
- {/if}
- <div class="contact_panel">
- {if $showCommunicationPreferences}
- <div class="contactCardLeft">
- {crmRegion name="contact-comm-pref"}
- <div class="crm-summary-comm-pref-block">
- <div class="crm-summary-block" id="communication-pref-block" >
- {include file="CRM/Contact/Page/Inline/CommunicationPreferences.tpl"}
- </div>
- </div>
- {/crmRegion}
- </div> <!-- contactCardLeft -->
- {/if}
- {if $contact_type eq 'Individual' AND $showDemographics}
- <div class="contactCardRight">
- {crmRegion name="contact-demographic"}
- <div class="crm-summary-demographic-block">
- <div class="crm-summary-block" id="demographic-block">
- {include file="CRM/Contact/Page/Inline/Demographics.tpl"}
- </div>
- </div>
- {/crmRegion}
- </div> <!-- contactCardRight -->
- {/if}
- <div class="clear"></div>
- <div class="separator"></div>
- </div> <!-- contact panel -->
- </div><!--contact_details-->
-
- {if $showCustomData}
- <div id="customFields">
- <div class="contact_panel">
- <div class="contactCardLeft">
- {include file="CRM/Contact/Page/View/CustomDataView.tpl" side='1'}
- </div><!--contactCardLeft-->
- <div class="contactCardRight">
- {include file="CRM/Contact/Page/View/CustomDataView.tpl" side='0'}
- </div>
-
- <div class="clear"></div>
- </div>
- </div>
- {/if}
-
- {if !empty($hookContent) and isset($hookContentPlacement) and $hookContentPlacement eq 1}
- {include file="CRM/Contact/Page/View/SummaryHook.tpl"}
- {/if}
- {else}
- {include file="CRM/Contact/Page/View/SummaryHook.tpl"}
- {/if}
- </div>
- <div class="clear"></div>
+ {foreach from=$allTabs item=tabValue}
+ {if !empty($tabValue.template)}
+ <div id="contact-{$tabValue.id}">
+ {include file=$tabValue.template}
+ </div>
+ {/if}
+ {/foreach}
</div>
<div class="clear"></div>
- </div><!-- /.crm-content-block -->
+ </div>
{/if}
{* CRM-10560 *}
</ul>
{foreach from=$tabHeader key=tabName item=tabValue}
{if !empty($tabValue.template)}
- <div id="#panel_{$tabName}">
+ <div id="panel_{$tabName}">
{include file=$tabValue.template}
</div>
{/if}
/**
* Set up function.
*/
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
// $this->quickCleanup(array('civicrm_acl_contact_cache'), TRUE);
$this->useTransaction(TRUE);
*/
class CRM_Activity_BAO_ActivityAssignmentTest extends CiviUnitTestCase {
- /**
- * Sets up the fixture, for example, opens a network connection.
- * This method is called before a test is executed.
- */
- protected function setUp() {
- parent::setUp();
- }
-
- /**
- * Tears down the fixture, for example, closes a network connection.
- * This method is called after a test is executed.
- */
- protected function tearDown() {
- }
-
/**
* Pass zero as an id and make sure no Assignees are retrieved.
*/
*/
class CRM_Activity_BAO_ActivityTargetTest extends CiviUnitTestCase {
- /**
- * Sets up the fixture, for example, opens a network connection.
- * This method is called before a test is executed.
- */
- protected function setUp() {
- parent::setUp();
- }
-
- /**
- * Tears down the fixture, for example, closes a network connection.
- *
- * This method is called after a test is executed.
- */
- protected function tearDown() {
- }
-
public function testRetrieveTargetIdsByActivityIdZeroID() {
$this->activityCreate();
$target = CRM_Activity_BAO_ActivityTarget::retrieveTargetIdsByActivityId(0);
*
* @throws \CiviCRM_API3_Exception
*/
- public function setUp() {
+ public function setUp():void {
parent::setUp();
$this->prepareForACLs();
CRM_Core_Config::singleton()->userPermissionClass->permissions = ['view all contacts', 'access CiviCRM'];
* @throws \CRM_Core_Exception
* @throws \CiviCRM_API3_Exception
*/
- public function tearDown() {
+ public function tearDown(): void {
$tablesToTruncate = [
'civicrm_activity',
'civicrm_activity_contact',
*/
class CRM_Activity_Form_ActivityTest extends CiviUnitTestCase {
- public function setUp() {
+ public function setUp():void {
parent::setUp();
$this->assignee1 = $this->individualCreate([
'first_name' => 'testassignee1',
*/
class CRM_Activity_Form_SearchTest extends CiviUnitTestCase {
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
$this->individualID = $this->individualCreate();
$this->contributionCreate([
]);
}
- public function tearDown() {
+ public function tearDown(): void {
$tablesToTruncate = [
'civicrm_activity',
'civicrm_activity_contact',
*/
class CRM_Activity_Page_AJAXTest extends CiviUnitTestCase {
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
$this->loadAllFixtures();
*
* @throws \CRM_Core_Exception
*/
- public function tearDown() {
+ public function tearDown(): void {
parent::tearDown();
$this->quickCleanup(['civicrm_batch']);
}
*/
protected $_contactID4 = NULL;
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
$params = [
* Tears down the fixture, for example, closes a network connection.
* This method is called after a test is executed.
*/
- public function tearDown() {
+ public function tearDown(): void {
$this->quickCleanUpFinancialEntities();
$this->relationshipTypeDelete($this->_relationshipTypeId);
if ($this->callAPISuccessGetCount('membership', ['id' => $this->_membershipTypeID])) {
*/
class CRM_Case_BAO_CaseTest extends CiviUnitTestCase {
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
$this->tablesToTruncate = [
}
}
- protected function tearDown() {
+ protected function tearDown(): void {
parent::tearDown();
$this->quickCleanup($this->tablesToTruncate, TRUE);
}
*/
class CRM_Case_BAO_CaseTypeForkTest extends CiviCaseTestCase {
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
CRM_Core_ManagedEntities::singleton(TRUE)->reconcile();
}
- public function tearDown() {
+ public function tearDown(): void {
parent::tearDown();
CRM_Core_ManagedEntities::singleton(TRUE)->reconcile();
}
protected $custom_group;
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
$this->custom_group = $this->customGroupCreate(['extends' => 'Case']);
$this->custom_group = $this->custom_group['values'][$this->custom_group['id']];
*/
class CRM_Case_Form_SearchTest extends CiviCaseTestCase {
- public function setUp() {
+ public function setUp():void {
parent::setUp();
$this->quickCleanup(['civicrm_case_contact', 'civicrm_case', 'civicrm_contact']);
}
*/
class CRM_Case_XMLProcessor_ProcessTest extends CiviCaseTestCase {
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
$this->defaultAssigneeOptionsValues = [];
$this->process = new CRM_Case_XMLProcessor_Process();
}
- public function tearDown() {
+ public function tearDown(): void {
$this->deleteMoreRelationshipTypes();
parent::tearDown();
*/
class CRM_Case_XMLProcessor_ReportTest extends CiviCaseTestCase {
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
$this->simplifyCaseTypeDefinition();
$this->report = new CRM_Case_XMLProcessor_Report();
}
- public function tearDown() {
+ public function tearDown(): void {
parent::tearDown();
}
*/
class CRM_Case_XMLProcessorTest extends CiviCaseTestCase {
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
$this->processor = new CRM_Case_XMLProcessor();
class CRM_Case_XMLRepositoryTest extends CiviUnitTestCase {
protected $fixtures = [];
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->fixtures['CaseTypeWithSingleActivityType'] = '
<CaseType>
* Connect to the database, truncate the tables that will be used
* and redirect stdin to a temporary file
*/
- public function setUp() {
+ public function setUp(): void {
// Connect to the database
parent::setUp();
*
* This method is called after a test is executed.
*/
- public function tearDown() {
+ public function tearDown(): void {
$tablesToTruncate = [
'civicrm_contact',
'civicrm_activity',
*/
class CRM_Contact_BAO_ContactTest extends CiviUnitTestCase {
- /**
- * Set up function.
- */
- public function setUp() {
- parent::setUp();
- }
-
/**
* Test case for add( ).
*
*/
class CRM_Contact_BAO_ContactType_ContactSearchTest extends CiviUnitTestCase {
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
$students = 'indivi_student' . substr(sha1(rand()), 0, 7);
$params = [
*/
class CRM_Contact_BAO_ContactType_ContactTest extends CiviUnitTestCase {
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
$params = [
$this->team = $params['name'];
}
- public function tearDown() {
+ public function tearDown(): void {
$this->quickCleanup(['civicrm_contact']);
$query = "
DELETE FROM civicrm_contact_type
*/
class CRM_Contact_BAO_ContactType_ContactTypeTest extends CiviUnitTestCase {
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
$params = [
'label' => 'sub1_individual',
* @throws \API_Exception
* @throws \Civi\API\Exception\UnauthorizedException
*/
- public function tearDown() {
+ public function tearDown(): void {
parent::tearDown();
ContactType::delete()->addWhere('id', 'IN', $this->ids['ContactType'])->execute();
}
*/
class CRM_Contact_BAO_ContactType_RelationshipTest extends CiviUnitTestCase {
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
//create contact subtypes
$this->organization_sponsor = $this->organizationCreate($params);
}
- public function tearDown() {
+ public function tearDown(): void {
$this->quickCleanup(['civicrm_contact']);
$query = "
*/
private $_testObjects;
- /**
- * Sets up the fixture, for example, opens a network connection.
- *
- * This method is called before a test is executed.
- */
- protected function setUp() {
- $this->_testObjects = [];
- parent::setUp();
- }
-
/**
* Tears down the fixture, for example, closes a network connection.
*
* This method is called after a test is executed.
*/
- protected function tearDown() {
+ protected function tearDown(): void {
parent::tearDown();
$this->deleteTestObjects();
}
*/
class CRM_Contact_BAO_GroupContactTest extends CiviUnitTestCase {
- /**
- * Sets up the fixture, for example, opens a network connection.
- * This method is called before a test is executed.
- */
- protected function setUp() {
- parent::setUp();
- }
-
- /**
- * Tears down the fixture, for example, closes a network connection.
- *
- * This method is called after a test is executed.
- */
- protected function tearDown() {
- }
-
/**
* Test case for add( ).
*/
*/
class CRM_Contact_BAO_GroupTest extends CiviUnitTestCase {
- /**
- * Sets up the fixture, for example, opens a network connection.
- *
- * This method is called before a test is executed.
- */
- protected function setUp() {
- parent::setUp();
- }
-
/**
* Tears down the fixture, for example, closes a network connection.
*
* This method is called after a test is executed.
*/
- protected function tearDown() {
+ protected function tearDown(): void {
$this->quickCleanup(['civicrm_mapping_field', 'civicrm_mapping', 'civicrm_group', 'civicrm_saved_search']);
}
return new CRM_Contact_BAO_QueryTestDataProvider();
}
- public function setUp() {
- parent::setUp();
- }
-
/**
* Clean up after test.
*
* @throws \Exception
*/
- public function tearDown() {
+ public function tearDown(): void {
$this->quickCleanUpFinancialEntities();
$tablesToTruncate = [
'civicrm_group_contact',
*/
class CRM_Contact_BAO_RelationshipCacheTest extends CiviUnitTestCase {
- protected function setUp() {
+ protected function setUp(): void {
$this->useTransaction(TRUE);
parent::setUp();
}
*/
class CRM_Contact_BAO_RelationshipTest extends CiviUnitTestCase {
- /**
- * Sets up the fixture, for example, opens a network connection.
- *
- * This method is called before a test is executed.
- */
- protected function setUp() {
- parent::setUp();
- }
-
/**
* Tears down the fixture, for example, closes a network connection.
*
*
* @throws \CRM_Core_Exception
*/
- protected function tearDown() {
+ protected function tearDown(): void {
$this->quickCleanup([
'civicrm_relationship_type',
'civicrm_relationship',
*
* This method is called after a test is executed.
*/
- protected function tearDown() {
+ protected function tearDown(): void {
if (!empty($this->ids['CustomField'])) {
foreach ($this->ids['CustomField'] as $type => $id) {
$field = civicrm_api3('CustomField', 'getsingle', ['id' => $id]);
return new CRM_Contact_Form_Search_Custom_GroupTestDataProvider();
}
- public function setUp() {
- parent::setUp();
- }
-
- public function tearDown() {
- }
-
/**
* Test CRM_Contact_Form_Search_Custom_Group::count()
* @dataProvider dataProvider
*/
class CRM_Contact_Form_Search_Custom_PriceSetTest extends CiviUnitTestCase {
- public function setUp() {
- parent::setUp();
- }
-
- public function tearDown() {
- }
-
public function testRunSearch() {
$order = $this->callAPISuccess('Order', 'create', $this->getParticipantOrderParams());
$this->callAPISuccess('Payment', 'create', [
return new CRM_Contact_Form_Search_Custom_SampleTestDataProvider();
}
- public function setUp() {
- parent::setUp();
- }
-
- public function tearDown() {
- }
-
/**
* Test CRM_Contact_Form_Search_Custom_Sample::count()
* @dataProvider dataProvider
]);
}
- protected function tearDown() {
+ protected function tearDown(): void {
$this->quickCleanup([
'civicrm_contact',
]);
*
* Make sure the setting is returned to 'stock'.
*/
- public function tearDown() {
+ public function tearDown(): void {
Civi::settings()->set('allow_mail_from_logged_in_contact', 0);
parent::tearDown();
}
/**
* Clean up after test.
*/
- protected function tearDown() {
+ protected function tearDown(): void {
unset($this->_contactIds);
parent::tearDown();
}
*
* @throws \CRM_Core_Exception
*/
- public function tearDown() {
+ public function tearDown(): void {
$this->quickCleanup(['civicrm_address', 'civicrm_phone', 'civicrm_email'], TRUE);
parent::tearDown();
}
$this->originalRequest = $_REQUEST;
}
- public function tearDown() {
+ public function tearDown(): void {
$_REQUEST = $this->originalRequest;
parent::tearDown();
}
*
* This method is called after a test is executed.
*/
- protected function tearDown() {
+ protected function tearDown(): void {
parent::tearDown();
}
*
* This method is called after a test is executed.
*/
- protected function tearDown() {
+ protected function tearDown(): void {
parent::tearDown();
}
/**
* Clean up after each test.
*/
- public function tearDown() {
+ public function tearDown(): void {
$this->quickCleanUpFinancialEntities();
$this->quickCleanup(['civicrm_uf_match']);
CRM_Utils_Hook::singleton()->reset();
*
* This method is called after a test is executed.
*/
- protected function tearDown() {
+ protected function tearDown(): void {
parent::tearDown();
}
*/
class CRM_Contribute_BAO_ContributionPageTest extends CiviUnitTestCase {
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
$this->_financialTypeID = 1;
}
- public function tearDown() {
- }
-
/**
* Create() method (create Contribution Page)
*/
/**
* Clean up after tests.
*/
- public function tearDown() {
+ public function tearDown(): void {
$this->quickCleanUpFinancialEntities();
parent::tearDown();
}
*/
class CRM_Contribute_BAO_ContributionTypeTest extends CiviUnitTestCase {
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
$this->organizationCreate();
}
- public function teardown() {
+ public function tearDown(): void {
$this->financialAccountDelete('Donations');
}
*/
class CRM_Contribute_BAO_ProductTest extends CiviUnitTestCase {
- public function setUp() {
- parent::setUp();
- }
-
/**
* Check method add()
*/
*/
class CRM_Contribute_BAO_QueryTest extends CiviUnitTestCase {
- public function tearDown() {
+ public function tearDown(): void {
$this->quickCleanUpFinancialEntities();
parent::tearDown();
}
*
* @throws \CRM_Core_Exception
*/
- public function tearDown() {
+ public function tearDown(): void {
$this->quickCleanUpFinancialEntities();
$this->quickCleanup(['civicrm_mailing_spool']);
parent::tearDown();
/**
* Clean up DB.
*/
- public function tearDown() {
+ public function tearDown(): void {
$this->quickCleanUpFinancialEntities();
}
/**
* Clean up DB.
*/
- public function tearDown() {
+ public function tearDown(): void {
$this->quickCleanUpFinancialEntities();
}
/**
* Clean up DB.
*/
- public function tearDown() {
+ public function tearDown(): void {
$this->quickCleanUpFinancialEntities();
}
CRM_Core_I18n_Schema::addLocale('fr_FR', 'en_US');
}
- public function tearDown() {
+ public function tearDown(): void {
global $dbLocale;
if ($dbLocale) {
CRM_Core_I18n_Schema::makeSinglelingual('en_US');
*
* @throws \CRM_Core_Exception
*/
- public function tearDown() {
+ public function tearDown(): void {
$this->quickCleanUpFinancialEntities();
$this->quickCleanup(['civicrm_note', 'civicrm_uf_match', 'civicrm_address']);
}
$this->ids['Contact']['contactID2'] = $this->individualCreate([], 2);
}
- public function tearDown() {
+ public function tearDown(): void {
$this->quickCleanUpFinancialEntities();
parent::tearDown();
}
/**
* Clean up after each test.
*/
- public function tearDown() {
+ public function tearDown(): void {
$this->quickCleanUpFinancialEntities();
CRM_Utils_Hook::singleton()->reset();
}
protected $_individualId;
- protected $_docTypes = NULL;
+ protected $_docTypes;
protected $_contactIds;
*/
protected $hookTokensCalled = 0;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->_individualId = $this->individualCreate(['first_name' => 'Anthony', 'last_name' => 'Collins']);
$this->_docTypes = CRM_Core_SelectValues::documentApplicationType();
*
* @throws \CRM_Core_Exception
*/
- public function tearDown() {
+ public function tearDown(): void {
$this->quickCleanUpFinancialEntities();
$this->quickCleanup(['civicrm_uf_match']);
CRM_Utils_Hook::singleton()->reset();
/**
* Test the buildContributionArray function.
*
- * @throws \CRM_Core_Exception
+ * @throws \CRM_Core_Exception|\CiviCRM_API3_Exception
*/
public function testBuildContributionArray(): void {
$this->_individualId = $this->individualCreate();
* @param array $tokens
* @param string $className
*/
- public function hookTokenValues(&$details, $contactIDs, $jobID, $tokens, $className) {
+ public function hookTokenValues(&$details, $contactIDs, $jobID, $tokens, $className): void {
foreach ($details as $index => $detail) {
$details[$index]['favourite_emoticon'] = 'emo';
}
];
$contribution = $this->callAPISuccess('Contribution', 'create', $contributionParams);
$contributionId = $contribution['id'];
- $form = new CRM_Contribute_Form_Task_PDFLetter();
+ /* @var $form CRM_Contribute_Form_Task_PDFLetter */
+ $form = $this->getFormObject('CRM_Contribute_Form_Task_PDFLetter');
$form->setContributionIds([$contributionId]);
$format = Civi::settings()->get('dateformatFull');
$date = CRM_Utils_Date::getToday();
]);
$contributionIDs[] = $contribution['id'];
- $form = new CRM_Contribute_Form_Task_PDFLetter();
+ /* @var \CRM_Contribute_Form_Task_PDFLetter $form */
+ $form = $this->getFormObject('CRM_Contribute_Form_Task_PDFLetter');
$form->setContributionIds($contributionIDs);
$html = CRM_Contribute_Form_Task_PDFLetterCommon::postProcess($form, $formValues);
/**
* Clean up after each test.
*/
- public function tearDown() {
+ public function tearDown(): void {
$this->quickCleanUpFinancialEntities();
CRM_Utils_Hook::singleton()->reset();
}
*/
/**
- * Class CRM_Contribute_Form_Tasktest
+ * Class CRM_Contribute_Form_TaskTest
*/
class CRM_Contribute_Form_TaskTest extends CiviUnitTestCase {
/**
* Clean up after each test.
+ *
+ * @throws \CRM_Core_Exception
*/
- public function tearDown() {
+ public function tearDown(): void {
$this->quickCleanUpFinancialEntities();
- CRM_Utils_Hook::singleton()->reset();
+ parent::tearDown();
}
/**
* executes without any error after sorting the search result.
*
* @throws \CRM_Core_Exception
+ * @throws \CiviCRM_API3_Exception
*/
- public function testPreProcessCommonAfterSorting() {
+ public function testPreProcessCommonAfterSorting(): void {
$fields = [
'source' => 'contribution_source',
'status' => 'contribution_status',
'financialTypes' => 'financial_type',
];
+ $contributionIds = [];
$financialTypes = ['Member Dues', 'Event Fee', 'Donation'];
$status = ['Completed', 'Partially paid', 'Pending'];
$source = ['test source text', 'check source text', 'source text'];
$expectedValues[$fld] = $sortedFields;
}
- // Assert contribIds are returned in a sorted order.
- $form = $this->getFormObject('CRM_Contribute_Form_Task', ['radio_ts' => 'ts_all'], 'Search');
foreach ($fields as $val) {
+ // Assert contribIds are returned in a sorted order.
+ /* @var CRM_Contribute_Form_Task $form */
+ $form = $this->getFormObject('CRM_Contribute_Form_Task', ['radio_ts' => 'ts_all'], 'Search');
$form->set(CRM_Utils_Sort::SORT_ORDER, "`{$val}` asc");
CRM_Contribute_Form_Task::preProcessCommon($form);
/**
* Setup function.
*/
- public function tearDown() {
+ public function tearDown(): void {
$this->quickCleanUpFinancialEntities();
parent::tearDown();
}
/**
* Clean up after tests.
*/
- public function tearDown() {
+ public function tearDown(): void {
$this->quickCleanUpFinancialEntities();
parent::tearDown();
}
*
* @throws \Exception
*/
- public function tearDown() {
+ public function tearDown(): void {
$this->quickCleanup([], TRUE);
parent::tearDown();
}
*
* @throws \Exception
*/
- public function tearDown() {
+ public function tearDown(): void {
$tablesToTruncate = [
'civicrm_contact',
];
* Tears down the fixture, for example, closes a network connection.
* This method is called after a test is executed.
*/
- public function tearDown() {
+ public function tearDown(): void {
$tablesToTruncate = [
'civicrm_contact',
'civicrm_openid',
*
* @throws \CRM_Core_Exception
*/
- public function tearDown() {
+ public function tearDown(): void {
$this->quickCleanup(['civicrm_mapping_field', 'civicrm_mapping']);
parent::tearDown();
}
*/
class CRM_Core_BAO_OpenIDTest extends CiviUnitTestCase {
- public function tearDown() {
+ public function tearDown(): void {
$this->quickCleanup(['civicrm_contact', 'civicrm_openid', 'civicrm_email']);
parent::tearDown();
}
*/
class CRM_Core_BAO_RecurringEntityTest extends CiviUnitTestCase {
- /**
- * Sets up the fixture, for example, opens a network connection.
- * This method is called before a test is executed.
- */
- protected function setUp() {
- parent::setUp();
- }
-
- /**
- * Tears down the fixture, for example, closes a network connection.
- * This method is called after a test is executed.
- */
- protected function tearDown() {
- }
-
/**
* Testing Activity Generation through Entity Recursion.
*/
*
* @throws \CRM_Core_Exception
*/
- public function tearDown() {
+ public function tearDown(): void {
parent::tearDown();
$this->callAPISuccess('System', 'updateindexes', []);
}
*
* @throws \CRM_Core_Exception
*/
- public function tearDown() {
+ public function tearDown(): void {
global $civicrm_setting;
$civicrm_setting = $this->origSetting;
$this->quickCleanup(['civicrm_contribution']);
self::initWebResponses();
}
- public function tearDown() {
+ public function tearDown(): void {
parent::tearDown();
CRM_Utils_Time::resetTime();
}
};
}
- protected function tearDown() {
+ protected function tearDown(): void {
CRM_Utils_Hook::singleton()->reset();
CRM_Core_DAO_AllCoreTables::init(1);
parent::tearDown();
$config->configAndLogDir = $this->createTempDir('test-log-');
}
- public function tearDown() {
+ public function tearDown(): void {
$config = CRM_Core_Config::singleton();
$config->configAndLogDir = $this->oldConfigAndLogDir;
parent::tearDown();
CRM_Utils_Hook::singleton()->setHook('civicrm_fieldOptions', [$this, 'hook_civicrm_fieldOptions']);
}
- public function tearDown() {
+ public function tearDown(): void {
parent::tearDown();
$this->quickCleanup(['civicrm_custom_field', 'civicrm_custom_group']);
}
*/
class CRM_Core_I18n_LocaleTest extends CiviUnitTestCase {
- public function setUp() {
- parent::setUp();
- }
-
- public function tearDown() {
- parent::tearDown();
- }
-
/**
*
*/
parent::setUp();
}
- public function tearDown() {
+ public function tearDown(): void {
CRM_Core_I18n_Schema::makeSinglelingual('en_US');
parent::tearDown();
}
*/
class CRM_Core_InnoDBIndexerTest extends CiviUnitTestCase {
- public function tearDown() {
+ public function tearDown(): void {
// May or may not cleanup well if there's a bug in the indexer.
// This is better than nothing -- and better than duplicating the
// cleanup logic.
$this->apiKernel->registerApiProvider($this->adhocProvider);
}
- public function tearDown() {
+ public function tearDown(): void {
parent::tearDown();
\Civi::reset();
}
$this->_contributionPageID = $contributionPage['id'];
}
- public function tearDown() {
+ public function tearDown(): void {
$this->quickCleanUpFinancialEntities();
}
$GLOBALS['_PEAR_ERRORSTACK_OVERRIDE_CALLBACK'] = [];
}
- public function tearDown() {
+ public function tearDown(): void {
$this->quickCleanUpFinancialEntities();
}
/**
* Tear down after class.
*/
- public function tearDown() {
+ public function tearDown(): void {
$this->quickCleanUpFinancialEntities();
CRM_Member_PseudoConstant::membershipStatus(NULL, NULL, 'name', TRUE);
}
/**
* Set up function.
*/
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
$this->_paymentProcessorID = $this->paymentProcessorCreate(['is_test' => 0, 'payment_processor_type_id' => 'PayPal_Standard']);
$this->_contactID = $this->individualCreate();
/**
* Tear down function.
*/
- public function tearDown() {
+ public function tearDown(): void {
$this->quickCleanUpFinancialEntities();
parent::tearDown();
}
/**
* Tear down function.
*/
- public function tearDown() {
+ public function tearDown(): void {
$this->quickCleanUpFinancialEntities();
}
$this->processor = Civi\Payment\System::singleton()->getById($this->ids['PaymentProcessor']['paypal_pro']);
}
- public function tearDown() {
+ public function tearDown(): void {
$this->quickCleanUpFinancialEntities();
parent::tearDown();
}
/**
* @throws \CRM_Core_Exception
*/
- public function tearDown() {
+ public function tearDown(): void {
$this->quickCleanUpFinancialEntities();
parent::tearDown();
}
*
* @throws \CRM_Core_Exception
*/
- public function tearDown() {
+ public function tearDown(): void {
foreach ($this->contactIDs as $contactId) {
$this->contactDelete($contactId);
*
* @throws \CRM_Core_Exception
*/
- public function tearDown() {
+ public function tearDown(): void {
$this->eventDelete($this->_eventId);
$this->quickCleanUpFinancialEntities();
}
/**
* Clean up after test.
*/
- public function tearDown() {
+ public function tearDown(): void {
$this->eventDelete($this->_eventId);
$this->quickCleanUpFinancialEntities();
}
*/
class CRM_Event_BAO_ParticipantStatusTest extends CiviUnitTestCase {
- /**
- * Sets up the fixture, for example, opens a network connection.
- * This method is called before a test is executed.
- */
- protected function setUp() {
- parent::setUp();
- }
-
- /**
- * Tears down the fixture, for example, closes a network connection.
- * This method is called after a test is executed.
- */
- protected function tearDown() {
- }
-
/**
* create() and deleteParticipantStatusType() method
*/
]);
}
- public function tearDown() {
+ public function tearDown(): void {
$this->quickCleanUpFinancialEntities();
parent::tearDown();
}
*
* @throws \Exception
*/
- public function tearDown() {
+ public function tearDown(): void {
$this->quickCleanUpFinancialEntities();
$this->quickCleanup([
'civicrm_contact',
* @throws \CRM_Core_Exception
* @throws \League\Csv\Exception
*/
- public function testExportComponentsNull() {
+ public function testExportComponentsNull(): void {
$this->doExportTest([]);
}
* @throws \CRM_Core_Exception
* @throws \League\Csv\Exception
*/
- public function testExportComponentsContribution() {
+ public function testExportComponentsContribution(): void {
$this->setUpContributionExportData();
$selectedFields = [
['contact_type' => 'Individual', 'name' => 'first_name'],
'componentClause' => 'civicrm_contribution.id IN ( ' . implode(',', $this->contributionIDs) . ')',
]);
$this->assertContains('display', array_values($this->csv->getHeader()));
- $row = $this->csv->fetchOne(0);
+ $row = $this->csv->fetchOne();
$this->assertEquals('This is a test', $row['display']);
}
/**
* Implements hook_civicrm_export().
- *
*/
- public function confirmHookWasCalled(&$exportTempTable, &$headerRows, &$sqlColumns, $exportMode, $componentTable, $ids) {
+ public function confirmHookWasCalled($exportTempTable, &$headerRows, &$sqlColumns, $exportMode, $componentTable, $ids): void {
$sqlColumns['display'] = 'display varchar(255)';
$headerRows[] = 'display';
CRM_Core_DAO::executeQuery("ALTER TABLE $exportTempTable ADD COLUMN display varchar(255)");
* @throws \CRM_Core_Exception
* @throws \League\Csv\Exception
*/
- public function testExportComponentsContributionSoftCredits() {
+ public function testExportComponentsContributionSoftCredits(): void {
$this->setUpContributionExportData();
$this->callAPISuccess('ContributionSoft', 'create', ['contact_id' => $this->contactIDs[1], 'contribution_id' => $this->contributionIDs[0], 'amount' => 5]);
$params = [
$this->assertEquals(array_merge($this->getBasicHeaderDefinition(FALSE), $this->getContributeHeaderDefinition()), $this->csv->getHeader());
$this->assertCount(3, $this->csv);
- $row = $this->csv->fetchOne(0);
+ $row = $this->csv->fetchOne();
$this->assertEquals(95, $row['Net Amount']);
$this->assertEquals('', $row['Soft Credit Amount']);
$row = $this->csv->fetchOne(1);
* @throws \CRM_Core_Exception
* @throws \League\Csv\Exception
*/
- public function testExportComponentsMembership() {
+ public function testExportComponentsMembership(): void {
$this->setUpMembershipExportData();
$this->doExportTest([
'selectAll' => TRUE,
* Basic test to ensure the exportComponents function can export selected fields for activity
*
* @throws \CRM_Core_Exception
+ * @throws \CiviCRM_API3_Exception
* @throws \League\Csv\Exception
*/
- public function testExportComponentsActivity() {
+ public function testExportComponentsActivity(): void {
$this->setUpActivityExportData();
$selectedFields = [
['contact_type' => 'Individual', 'name' => 'display_name'],
* repeated 100,000 times and in general we should simply be able to match the query fields to
* our expected rows & do a little pseudoconstant mapping.
*/
- public function testGetExportStructureArrays() {
+ public function testGetExportStructureArrays(): void {
// This is how return properties are formatted internally within the function for passing to the BAO query.
$returnProperties = [
'first_name' => 1,
FALSE, TRUE, TRUE, NULL, 'AND'
);
- list($select) = $query->query();
+ [$select] = $query->query();
$pattern = '/as `?([^`,]*)/';
$queryFieldAliases = [];
- preg_match_all($pattern, $select, $queryFieldAliases, PREG_PATTERN_ORDER);
+ preg_match_all($pattern, $select, $queryFieldAliases);
$processor = new CRM_Export_BAO_ExportProcessor(CRM_Contact_BAO_Query::MODE_CONTRIBUTE, NULL, 'AND');
$processor->setQueryFields($query->_fields);
$processor->setReturnProperties($returnProperties);
- list($outputFields) = $processor->getExportStructureArrays();
+ [$outputFields] = $processor->getExportStructureArrays();
foreach (array_keys($outputFields) as $fieldAlias) {
if ($fieldAlias === 'Home-country') {
- $this->assertTrue(in_array($fieldAlias . '_id', $queryFieldAliases[1]), 'Country is subject to some funky translate so we make sure country id is present');
+ $this->assertContains($fieldAlias . '_id', $queryFieldAliases[1], 'Country is subject to some funky translate so we make sure country id is present');
}
else {
- $this->assertTrue(in_array($fieldAlias, $queryFieldAliases[1]), 'looking for field ' . $fieldAlias . ' in generaly the alias fields need to match the outputfields');
+ $this->assertContains($fieldAlias, $queryFieldAliases[1], 'looking for field ' . $fieldAlias . ' in generaly the alias fields need to match the outputfields');
}
}
* Set up some data for us to do testing on.
*
* @throws \CRM_Core_Exception
+ * @throws \CiviCRM_API3_Exception
*/
- public function setUpContributionExportData() {
+ public function setUpContributionExportData(): void {
$this->setUpContactExportData();
$this->contributionIDs[] = $this->contributionCreate(['contact_id' => $this->contactIDs[0], 'trxn_id' => 'null', 'invoice_id' => 'null', 'receive_date' => '2019-07-25 07:34:23']);
$this->contributionIDs[] = $this->contributionCreate(['contact_id' => $this->contactIDs[1], 'trxn_id' => 'null', 'invoice_id' => 'null', 'receive_date' => '2018-12-01 00:00:00']);
* Set up some data for us to do testing on.
*
* @throws \CRM_Core_Exception
+ * @throws \CiviCRM_API3_Exception
*/
- public function setUpMembershipExportData() {
+ public function setUpMembershipExportData(): void {
$this->setUpContactExportData();
// Create an extra so we don't get false passes due to 1
$this->contactMembershipCreate(['contact_id' => $this->contactIDs[0]]);
* Set up data to test case export.
*
* @throws \CRM_Core_Exception
+ * @throws \CiviCRM_API3_Exception
*/
- public function setupCaseExportData() {
+ public function setupCaseExportData(): void {
$contactID1 = $this->individualCreate();
$contactID2 = $this->individualCreate([], 1);
* Set up some data for us to do testing on.
*
* @throws \CRM_Core_Exception
+ * @throws \CiviCRM_API3_Exception
*/
- public function setUpActivityExportData() {
+ public function setUpActivityExportData(): void {
$this->setUpContactExportData();
$this->activityIDs[] = $this->activityCreate(['contact_id' => $this->contactIDs[0]])['id'];
}
* Set up some data for us to do testing on.
*
* @throws \CRM_Core_Exception
+ * @throws \CiviCRM_API3_Exception
*/
- public function setUpContactExportData() {
+ public function setUpContactExportData(): void {
$this->contactIDs[] = $contactA = $this->individualCreate(['gender_id' => 'Female']);
// Create address for contact A.
$params = [
*
* @param int $isPrimaryOnly
*
- * @dataProvider getBooleanDataProvider
* @throws \CRM_Core_Exception
+ * @throws \CiviCRM_API3_Exception
* @throws \League\Csv\Exception
+ * @dataProvider getBooleanDataProvider
*/
- public function testExportPrimaryAddress($isPrimaryOnly) {
- \Civi::settings()->set('searchPrimaryDetailsOnly', $isPrimaryOnly);
+ public function testExportPrimaryAddress($isPrimaryOnly): void {
+ Civi::settings()->set('searchPrimaryDetailsOnly', $isPrimaryOnly);
$this->setUpContactExportData();
$selectedFields = [
'Home-Email' => 'home@example.com',
'Work-Email' => 'work@example.com',
], $row);
- $this->assertEquals(2, count($this->csv));
- \Civi::settings()->set('searchPrimaryDetailsOnly', FALSE);
+ $this->assertCount(2, $this->csv);
+ Civi::settings()->set('searchPrimaryDetailsOnly', FALSE);
}
/**
* does NOT retain the gender of the former.
*
* @throws \CRM_Core_Exception
+ * @throws \CiviCRM_API3_Exception
* @throws \League\Csv\Exception
*/
- public function testExportPseudoField() {
+ public function testExportPseudoField(): void {
$this->setUpContactExportData();
$this->callAPISuccess('OptionValue', 'create', ['option_group_id' => 'gender', 'name' => 'Really long string', 'value' => 678, 'label' => 'Really long string']);
$selectedFields = [['contact_type' => 'Individual', 'name' => 'gender_id']];
* @throws \CRM_Core_Exception
* @throws \League\Csv\Exception
*/
- public function testExportPseudoFieldCampaign() {
+ public function testExportPseudoFieldCampaign(): void {
$this->setUpContributionExportData();
$campaign = $this->callAPISuccess('Campaign', 'create', ['title' => 'Big campaign and kinda long too']);
$this->callAPISuccess('Contribution', 'create', ['campaign_id' => $campaign['id'], 'id' => $this->contributionIDs[0]]);
* Test exporting relationships.
*
* @throws \CRM_Core_Exception
+ * @throws \CiviCRM_API3_Exception
* @throws \League\Csv\Exception
*/
- public function testExportRelationships() {
+ public function testExportRelationships(): void {
$organization1 = $this->organizationCreate(['organization_name' => 'Org 1', 'legal_name' => 'pretty legal', 'contact_source' => 'friend who took a law paper once']);
$organization2 = $this->organizationCreate(['organization_name' => 'Org 2', 'legal_name' => 'well dodgey']);
$contact1 = $this->individualCreate(['employer_id' => $organization1, 'first_name' => 'one']);
* @throws CRM_Core_Exception
* @throws \League\Csv\Exception
*/
- public function testExportRelationshipsMergeToHousehold($includeHouseHold) {
- list($householdID, $houseHoldTypeID) = $this->setUpHousehold();
+ public function testExportRelationshipsMergeToHousehold($includeHouseHold): void {
+ [$householdID, $houseHoldTypeID] = $this->setUpHousehold();
if ($includeHouseHold) {
$this->contactIDs[] = $householdID;
* @throws CRM_Core_Exception
* @throws \League\Csv\Exception
*/
- public function testExportMergeToHousehold($includeHouseHold) {
- list($householdID, $houseHoldTypeID) = $this->setUpHousehold();
+ public function testExportMergeToHousehold($includeHouseHold): void {
+ [$householdID, $houseHoldTypeID] = $this->setUpHousehold();
if ($includeHouseHold) {
$this->contactIDs[] = $householdID;
* @throws \CRM_Core_Exception
* @throws \League\Csv\Exception
*/
- public function testExportRelationshipsMergeToHouseholdAllFields() {
- list($householdID) = $this->setUpHousehold();
+ public function testExportRelationshipsMergeToHouseholdAllFields(): void {
+ [$householdID] = $this->setUpHousehold();
$this->doExportTest(['ids' => $this->contactIDs, 'mergeSameHousehold' => TRUE]);
$row = $this->csv->fetchOne();
$this->assertCount(1, $this->csv);
*
* @throws \API_Exception
* @throws \CRM_Core_Exception
+ * @throws \CiviCRM_API3_Exception
* @throws \Civi\API\Exception\UnauthorizedException
* @throws \League\Csv\Exception
*/
- public function testExportCustomData() {
+ public function testExportCustomData(): void {
$this->setUpContactExportData();
$this->entity = 'Contact';
$this->createCustomGroupWithFieldsOfAllTypes();
* Attempt to do a fairly full export of location data.
*
* @throws \CRM_Core_Exception
+ * @throws \CiviCRM_API3_Exception
* @throws \League\Csv\Exception
*/
- public function testExportIMData() {
+ public function testExportIMData(): void {
// Use default providers.
- $providers = ['Aim', 'Gtalk', 'Jabber', 'Msn', 'Skype', 'Yahoo'];
+ $providers = ['AIM' => 'Aim', 'GTalk' => 'Gtalk', 'Jabber' => 'Jabber', 'MSN' => 'Msn', 'Skype' => 'Skype', 'Yahoo' => 'Yahoo'];
// Main sure labels are not all anglo chars.
$this->diversifyLocationTypes();
foreach ($this->csv->getRecords() as $row) {
$id = $row['Contact ID'];
- $this->assertEquals('AIM', $row['Billing-IM Provider']);
- $this->assertEquals('AIM', $row['Whare Kai-IM Provider']);
+ // The provider could be any of them as we created multiple ims for each location
+ // type. In earlier mysql versions it gets a somewhat consistent result but there
+ // is no 'right' provider so we just check it is a resolved pseudoconstant.
+ $this->assertContains($row['Billing-IM Provider'], array_keys($providers));
+ $this->assertContains($row['Whare Kai-IM Provider'], array_keys($providers));
$this->assertEquals('BillingJabber' . $id, $row['Billing-IM Screen Name-Jabber']);
$this->assertEquals('Whare KaiJabber' . $id, $row['Whare Kai-IM Screen Name-Jabber']);
$this->assertEquals('BillingSkype' . $id, $row['Billing-IM Screen Name-Skype']);
*
* @throws \API_Exception
* @throws \CRM_Core_Exception
+ * @throws \CiviCRM_API3_Exception
* @throws \Civi\API\Exception\UnauthorizedException
* @throws \League\Csv\Exception
*/
- public function testExportPhoneData() {
+ public function testExportPhoneData(): void {
$this->contactIDs[] = $this->individualCreate();
$this->contactIDs[] = $this->individualCreate();
* Export City against multiple location types.
*
* @throws \CRM_Core_Exception
+ * @throws \CiviCRM_API3_Exception
* @throws \League\Csv\Exception
*/
- public function testExportAddressData() {
+ public function testExportAddressData(): void {
$this->diversifyLocationTypes();
$locationTypes = ['Billing' => 'Billing', 'Home' => 'Home', 'Main' => 'Méin', 'Other' => 'Other', 'Whare Kai' => 'Whare Kai'];
* Test master_address_id field when no merge is in play.
*
* @throws \CRM_Core_Exception
+ * @throws \CiviCRM_API3_Exception
* @throws \League\Csv\Exception
*/
- public function testExportMasterAddress() {
+ public function testExportMasterAddress(): void {
$this->setUpContactExportData();
//export the master address for contact B
* Test merging same address when specifying fields.
*
* @throws \CRM_Core_Exception
+ * @throws \CiviCRM_API3_Exception
* @throws \League\Csv\Exception
*/
- public function testMergeSameAddressSpecifyFields() {
+ public function testMergeSameAddressSpecifyFields(): void {
$this->setUpContactSameAddressExportData();
$this->doExportTest(['mergeSameAddress' => TRUE, 'fields' => [['contact_type' => 'Individual', 'name' => 'master_id', 'location_type_id' => 1]]]);
}
* Test the merge same address option.
*
* @throws \CRM_Core_Exception
+ * @throws \CiviCRM_API3_Exception
* @throws \League\Csv\Exception
*/
- public function testMergeSameAddress() {
+ public function testMergeSameAddress(): void {
$this->setUpContactSameAddressExportData();
$this->doExportTest(['mergeSameAddress' => TRUE]);
// ie 2 merged, one extra.
* Tests the options for greeting templates when choosing to merge same address.
*
* @throws \CRM_Core_Exception
+ * @throws \CiviCRM_API3_Exception
* @throws \League\Csv\Exception
*/
- public function testMergeSameAddressGreetingOptions() {
+ public function testMergeSameAddressGreetingOptions(): void {
$this->setUpContactSameAddressExportData();
$this->callAPISuccess('OptionValue', 'create', [
'option_group_id' => 'postal_greeting',
* @throws \CRM_Core_Exception
* @throws \League\Csv\Exception
*/
- public function testExportNoRows() {
+ public function testExportNoRows(): void {
$contactA = $this->callAPISuccess('contact', 'create', [
'first_name' => 'John',
'last_name' => 'Doe',
* So C take preference over A and thus C is exported as result.
*
* @throws \CRM_Core_Exception
+ * @throws \CiviCRM_API3_Exception
* @throws \League\Csv\Exception
*/
- public function testMergeSameAddressOnExport() {
+ public function testMergeSameAddressOnExport(): void {
$this->individualCreate();
$householdID = $this->setUpHousehold()[0];
$contactIDs = array_merge($this->contactIDs, [$householdID]);
* @throws \CRM_Core_Exception
* @throws \League\Csv\Exception
*/
- public function testExportDeceasedDoNotMail($reason, $addressReason) {
+ public function testExportDeceasedDoNotMail($reason, $addressReason): void {
$contactA = $this->callAPISuccess('contact', 'create', [
'first_name' => 'John',
'last_name' => 'Doe',
'mergeSameAddress' => TRUE,
],
]);
- $row = $this->csv->fetchOne(0);
+ $row = $this->csv->fetchOne();
- $this->assertTrue(!in_array('Stage', $this->processor->getHeaderRows()));
+ $this->assertNotTrue(in_array('Stage', $this->processor->getHeaderRows()));
$this->assertEquals('Dear John', $row['Email Greeting']);
$this->assertCount(1, $this->csv);
}
*
* @return array
*/
- public function getReasonsNotToMail() {
+ public function getReasonsNotToMail(): array {
return [
[['is_deceased' => 1], []],
[['do_not_mail' => 1], []],
*
* @return array
*
- * @throws CRM_Core_Exception
+ * @throws \CRM_Core_Exception
+ * @throws \CiviCRM_API3_Exception
*/
- protected function setUpHousehold() {
+ protected function setUpHousehold(): array {
$this->setUpContactExportData();
$householdID = $this->householdCreate([
'source' => 'household sauce',
*
* @param int $exportMode
*/
- public function ensureComponentIsEnabled($exportMode) {
+ public function ensureComponentIsEnabled($exportMode): void {
if ($exportMode === CRM_Export_Form_Select::CASE_EXPORT) {
CRM_Core_BAO_ConfigSetting::enableComponent('CiviCase');
}
* @param int $exportMode
* @param $expected
*/
- public function testAdditionalReturnProperties($exportMode, $expected) {
+ public function testAdditionalReturnProperties($exportMode, $expected): void {
$this->ensureComponentIsEnabled($exportMode);
$processor = new CRM_Export_BAO_ExportProcessor($exportMode, NULL, 'AND');
$metadata = $processor->getAdditionalReturnProperties();
* @param int $exportMode
* @param $expected
*/
- public function testDefaultReturnProperties($exportMode, $expected) {
+ public function testDefaultReturnProperties($exportMode, $expected): void {
$this->ensureComponentIsEnabled($exportMode);
$processor = new CRM_Export_BAO_ExportProcessor($exportMode, NULL, 'AND');
$metadata = $processor->getDefaultReturnProperties();
*
* @return array
*/
- public function additionalFieldsDataProvider() {
+ public function additionalFieldsDataProvider(): array {
return [
[
'anything that will then be defaulting ton contact',
/**
* get data for testing field metadata by query mode.
*/
- public function allFieldsDataProvider() {
+ public function allFieldsDataProvider(): array {
return [
[
'anything that will then be defaulting ton contact',
/**
* Get return properties manually added in.
*/
- public function getExtraReturnProperties() {
+ public function getExtraReturnProperties(): array {
return [];
}
*
* @return array
*/
- protected function getBasicReturnProperties($isContactMode) {
+ protected function getBasicReturnProperties($isContactMode): array {
$returnProperties = [
'id' => 1,
'contact_type' => 1,
*
* @return array
*/
- public function getPledgeReturnProperties() {
+ public function getPledgeReturnProperties(): array {
return [
'contact_type' => 1,
'contact_sub_type' => 1,
*
* @return array
*/
- public function getMembershipReturnProperties() {
+ public function getMembershipReturnProperties(): array {
return [
'contact_type' => 1,
'contact_sub_type' => 1,
*
* @return array
*/
- public function getEventReturnProperties() {
+ public function getEventReturnProperties(): array {
return [
'contact_type' => 1,
'contact_sub_type' => 1,
*
* @return array
*/
- public function getActivityReturnProperties() {
+ public function getActivityReturnProperties(): array {
return [
'activity_id' => 1,
'contact_type' => 1,
*
* @return array
*/
- public function getCaseReturnProperties() {
+ public function getCaseReturnProperties(): array {
return [
'contact_type' => 1,
'contact_sub_type' => 1,
*
* @return array
*/
- public function getContributionReturnProperties() {
+ public function getContributionReturnProperties(): array {
return [
'contact_type' => 1,
'contact_sub_type' => 1,
*
* @dataProvider getSqlColumnsOutput
*/
- public function testGetSQLColumnsAndHeaders($exportMode, $expected, $expectedHeaders) {
+ public function testGetSQLColumnsAndHeaders($exportMode, $expected, $expectedHeaders): void {
$this->ensureComponentIsEnabled($exportMode);
// We need some data so that we can get to the end of the export
// function. Hopefully one day that won't be required to get metadata info out.
* https://lab.civicrm.org/dev/core/issues/819
*
* @throws \CRM_Core_Exception
+ * @throws \CiviCRM_API3_Exception
* @throws \League\Csv\Exception
*/
- public function testExportIncompleteSubmission() {
+ public function testExportIncompleteSubmission(): void {
$this->setUpContactExportData();
$this->doExportTest(['fields' => [['contact_type' => 'Individual', 'name' => '']], 'ids' => [$this->contactIDs[1]]]);
}
* @throws \CRM_Core_Exception
* @throws \League\Csv\Exception
*/
- public function testExportSpecifyFields($exportMode, $selectedFields, $expected) {
+ public function testExportSpecifyFields($exportMode, $selectedFields, $expected): void {
$this->ensureComponentIsEnabled($exportMode);
$this->setUpContributionExportData();
$this->doExportTest(['fields' => $selectedFields, 'ids' => [$this->contactIDs[1]], 'exportMode' => $exportMode]);
* @throws \CRM_Core_Exception
* @throws \League\Csv\Exception
*/
- public function textExportParticipantSpecifyFieldsNoPayment() {
+ public function textExportParticipantSpecifyFieldsNoPayment(): void {
$selectedFields = $this->getAllSpecifiableParticipantReturnFields();
foreach ($selectedFields as $index => $field) {
if (substr($field[1], 0, 22) === 'componentPaymentField_') {
* @todo - still being built up.
*
*/
- public function getAllSpecifiableReturnFields() {
+ public function getAllSpecifiableReturnFields(): array {
return [
[
CRM_Export_Form_Select::EVENT_EXPORT,
*
* @return array
*/
- public function getAllSpecifiableParticipantReturnColumns() {
+ public function getAllSpecifiableParticipantReturnColumns(): array {
return [
'participant_campaign_id' => '`participant_campaign_id` varchar(16)',
'participant_contact_id' => '`participant_contact_id` varchar(16)',
/**
* @return array
*/
- public function getAllSpecifiableParticipantReturnFields() {
+ public function getAllSpecifiableParticipantReturnFields(): array {
return [
0 =>
[
/**
* @param string $exportMode
+ *
+ * @throws \CRM_Core_Exception
+ * @throws \CiviCRM_API3_Exception
*/
- public function setupBaseExportData($exportMode) {
+ public function setupBaseExportData($exportMode): void {
$this->createLoggedInUser();
if ($exportMode === CRM_Export_Form_Select::CASE_EXPORT) {
$this->setupCaseExportData();
*
* @return array
*/
- public function getSqlColumnsOutput() {
+ public function getSqlColumnsOutput(): array {
return [
[
'anything that will then be defaulting ton contact',
*
* @return array
*/
- protected function getBasicHeaderDefinition($isContactExport) {
+ protected function getBasicHeaderDefinition($isContactExport): array {
$headers = [
0 => 'Contact ID',
1 => 'Contact Type',
*
* @return array
*/
- protected function getActivityHeaderDefinition() {
+ protected function getActivityHeaderDefinition(): array {
return [
82 => 'Activity ID',
83 => 'Activity Type',
*
* @return array
*/
- protected function getCaseHeaderDefinition() {
+ protected function getCaseHeaderDefinition(): array {
return [
82 => 'Contact ID',
83 => 'Case ID',
*
* @return array
*/
- protected function getContributeHeaderDefinition() {
+ protected function getContributeHeaderDefinition(): array {
return [
82 => 'Financial Type',
83 => 'Contribution Source',
*
* @return array
*/
- protected function getParticipantHeaderDefinition() {
+ protected function getParticipantHeaderDefinition(): array {
return [
82 => 'Event ID',
83 => 'Event Title',
*
* @return array
*/
- protected function getMemberHeaderDefinition() {
+ protected function getMemberHeaderDefinition(): array {
return [
82 => 'Membership Type',
83 => 'Test',
*
* @return array
*/
- protected function getPledgeHeaderDefinition() {
+ protected function getPledgeHeaderDefinition(): array {
return [
82 => 'Pledge ID',
83 => 'Total Pledged',
*
* @return array
*/
- protected function getBasicSqlColumnDefinition($isContactExport) {
+ protected function getBasicSqlColumnDefinition($isContactExport): array {
$columns = [
'civicrm_primary_id' => '`civicrm_primary_id` varchar(16)',
'contact_type' => '`contact_type` varchar(64)',
*
* @return array
*/
- protected function getCaseSqlColumns() {
+ protected function getCaseSqlColumns(): array {
return [
'case_start_date' => '`case_start_date` varchar(32)',
'case_end_date' => '`case_end_date` varchar(32)',
*
* @return array
*/
- protected function getActivitySqlColumns() {
+ protected function getActivitySqlColumns(): array {
return [
'activity_id' => '`activity_id` varchar(16)',
'activity_type' => '`activity_type` varchar(255)',
*
* @return array
*/
- protected function getParticipantSqlColumns() {
+ protected function getParticipantSqlColumns(): array {
return [
'event_id' => '`event_id` varchar(16)',
'event_title' => '`event_title` varchar(255)',
*
* @return array
*/
- public function getContributionSqlColumns() {
+ public function getContributionSqlColumns(): array {
return [
'civicrm_primary_id' => '`civicrm_primary_id` varchar(16)',
'contact_type' => '`contact_type` varchar(64)',
*
* @return array
*/
- public function getPledgeSqlColumns() {
+ public function getPledgeSqlColumns(): array {
return [
'pledge_id' => '`pledge_id` varchar(16)',
'pledge_amount' => '`pledge_amount` varchar(32)',
*
* @return array
*/
- public function getMembershipSqlColumns() {
+ public function getMembershipSqlColumns(): array {
return [
'membership_type' => '`membership_type` varchar(128)',
'member_is_test' => '`member_is_test` varchar(16)',
* - name differs from label
* - non-anglo char in the label (not valid in the name).
*/
- protected function diversifyLocationTypes() {
+ protected function diversifyLocationTypes(): void {
$this->locationTypes['Main'] = $this->callAPISuccess('Location_type', 'get', [
'name' => 'Main',
'return' => 'id',
* @throws \CRM_Core_Exception
* @throws \League\Csv\Exception
*/
- protected function doExportTest($params) {
+ protected function doExportTest($params): void {
$fields = $params['fields'] ?? [];
$fieldDefaults = ['contact_type' => 'Individual', 'phone_type_id' => NULL, 'location_type_id' => NULL];
foreach ($fields as $key => $field) {
* @param array $row
* @param array $alternatives
*/
- protected function assertExpectedOutput(array $expected, array $row, array $alternatives = []) {
+ protected function assertExpectedOutput(array $expected, array $row, array $alternatives = []): void {
$variableFields = ['Created Date', 'Modified Date', 'Contact Hash'];
foreach ($expected as $key => $value) {
if (in_array($key, $variableFields)) {
- $this->assertTrue(!empty($row[$key]));
+ $this->assertNotTrue(empty($row[$key]));
}
elseif (array_key_exists($key, $alternatives)) {
$this->assertContains($row[$key], $alternatives[$key]);
* Test get preview function on export processor.
*
* @throws \CRM_Core_Exception
+ * @throws \CiviCRM_API3_Exception
*/
- public function testExportGetPreview() {
+ public function testExportGetPreview(): void {
$this->setUpContactExportData();
$fields = [
['contact_type' => 'Individual', 'name' => 'first_name'],
* Set up contacts which will be merged with the same address option.
*
* @throws \CRM_Core_Exception
+ * @throws \CiviCRM_API3_Exception
*/
- protected function setUpContactSameAddressExportData() {
+ protected function setUpContactSameAddressExportData(): void {
$this->setUpContactExportData();
$this->contactIDs[] = $contact3 = $this->individualCreate(['first_name' => 'Sarah', 'last_name' => 'Smith', 'prefix_id' => 'Dr.']);
// Create address for contact A.
* Test for single select Autocomplete custom field.
*
*/
- public function testSingleAndMultiSelectAutoComplete() {
+ public function testSingleAndMultiSelectAutoComplete(): void {
$customGroupId = $this->customGroupCreate([
'extends' => 'Individual',
])['id'];
parent::setUp();
}
- public function tearDown() {
+ public function tearDown(): void {
parent::tearDown();
}
parent::setUp();
}
- public function tearDown() {
+ public function tearDown(): void {
parent::tearDown();
}
parent::setUp();
}
- public function tearDown() {
+ public function tearDown(): void {
parent::tearDown();
}
parent::setUp();
}
- public function tearDown() {
+ public function tearDown(): void {
parent::tearDown();
}
$this->file = NULL;
}
- public function tearDown() {
+ public function tearDown(): void {
if ($this->file) {
unlink($this->file);
}
public function testGood_string_extras() {
$data = "<extension key='test.bar' type='module'><file>testbar</file>
- <classloader><psr4 prefix=\"Civi\\\" path=\"Civi\"/></classloader>
+ <classloader>
+ <psr4 prefix=\"Civi\\\" path=\"Civi\"/>
+ <psr0 prefix=\"CRM_\" path=\"\"/>
+ </classloader>
<requires><ext>org.civicrm.a</ext><ext>org.civicrm.b</ext></requires>
</extension>
";
$this->assertEquals('testbar', $info->file);
$this->assertEquals('Civi\\', $info->classloader[0]['prefix']);
$this->assertEquals('Civi', $info->classloader[0]['path']);
+ $this->assertEquals('psr4', $info->classloader[0]['type']);
+ $this->assertEquals('CRM_', $info->classloader[1]['prefix']);
+ $this->assertEquals('', $info->classloader[1]['path']);
+ $this->assertEquals('psr0', $info->classloader[1]['type']);
$this->assertEquals(['org.civicrm.a', 'org.civicrm.b'], $info->requires);
}
*/
class CRM_Extension_Manager_ModuleTest extends CiviUnitTestCase {
- public function setUp() {
+ public function setUp():void {
parent::setUp();
// $query = "INSERT INTO civicrm_domain ( name, version ) VALUES ( 'domain', 3 )";
// $result = CRM_Core_DAO::executeQuery($query);
$this->setExtensionSystem($this->system);
}
- public function tearDown() {
+ public function tearDown(): void {
parent::tearDown();
$this->system = NULL;
}
$this->quickCleanup(['civicrm_payment_processor']);
}
- public function tearDown() {
+ public function tearDown(): void {
parent::tearDown();
$this->system = NULL;
$this->quickCleanup(['civicrm_payment_processor']);
*/
class CRM_Extension_Manager_ReportTest extends CiviUnitTestCase {
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
//if (class_exists('test_extension_manager_reporttest')) {
// test_extension_manager_reporttest::$counts = array();
]);
}
- public function tearDown() {
- parent::tearDown();
- }
-
/**
* Install an extension with a valid type name.
*/
]);
}
- public function tearDown() {
+ public function tearDown(): void {
parent::tearDown();
$this->system = NULL;
}
const TESTING_TYPE = 'report';
const OTHER_TESTING_TYPE = 'module';
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
list ($this->basedir, $this->container) = $this->_createContainer();
$this->mapper = new CRM_Extension_Mapper($this->container);
}
- public function tearDown() {
- parent::tearDown();
- }
-
/**
* Install an extension with an invalid type name.
*
*/
protected $mapperWithSlash;
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
list ($this->basedir, $this->container) = $this->_createContainer();
$this->mapper = new CRM_Extension_Mapper($this->container);
$this->mapperWithSlash = new CRM_Extension_Mapper($this->containerWithSlash);
}
- public function tearDown() {
- parent::tearDown();
- }
-
public function testClassToKey() {
$this->assertEquals("test.foo.bar", $this->mapper->classToKey('test_foo_bar'));
}
/**
* Clean up after each test.
*/
- public function tearDown() {
+ public function tearDown(): void {
$this->quickCleanUpFinancialEntities();
parent::tearDown();
}
$this->_orgContactID = $this->organizationCreate();
}
- public function teardown() {
+ public function tearDown(): void {
global $dbLocale;
if ($dbLocale) {
CRM_Core_I18n_Schema::makeSinglelingual('en_US');
/**
* Setup function.
*/
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
$this->createLoggedInUser();
*
* @throws \CRM_Core_Exception
*/
- public function tearDown() {
+ public function tearDown(): void {
$this->quickCleanUpFinancialEntities();
$this->quickCleanup(['civicrm_note', 'civicrm_uf_match', 'civicrm_address']);
}
$this->groupCreate(['title' => 'not-me-active', 'is_active' => 1, 'name' => 'not-me-active']);
}
- public function tearDown() {
+ public function tearDown(): void {
CRM_Utils_Hook::singleton()->reset();
$this->quickCleanup(['civicrm_group']);
$config = CRM_Core_Config::singleton();
parent::setUp();
}
- public function tearDown() {
+ public function tearDown(): void {
CRM_Core_I18n_Schema::makeSinglelingual('en_US');
$logging = new CRM_Logging_Schema();
$logging->dropAllLogTables();
*
* @throws \CRM_Core_Exception
*/
- public function tearDown() {
+ public function tearDown(): void {
$schema = new CRM_Logging_Schema();
$schema->disableLogging();
$this->databaseVersion = NULL;
parent::setUp();
}
- public function tearDown() {
+ public function tearDown(): void {
global $dbLocale;
if ($dbLocale) {
CRM_Core_I18n_Schema::makeSinglelingual('en_US');
parent::setUp();
}
- public function tearDown() {
+ public function tearDown(): void {
$tablesToTruncate = [
'civicrm_mailing_event_bounce',
'civicrm_mailing_event_delivered',
$this->_mut = new CiviMailUtils($this, TRUE);
}
- public function tearDown() {
+ public function tearDown(): void {
$this->_mut->stop();
parent::tearDown();
}
/**
*/
- public function tearDown() {
+ public function tearDown(): void {
$this->_mut->stop();
CRM_Utils_Hook::singleton()->reset();
// DGW
@unlink($this->workDir);
}
- public function tearDown() {
+ public function tearDown(): void {
parent::tearDown();
if (is_dir($this->workDir)) {
CRM_Utils_File::cleanDir($this->workDir);
$this->assertEquals('civimail', $context);
}
- public function tearDown() {
+ public function tearDown(): void {
global $dbLocale;
if ($dbLocale) {
CRM_Core_I18n_Schema::makeSinglelingual('en_US');
*
* @throws \CRM_Core_Exception
*/
- public function tearDown() {
+ public function tearDown(): void {
$this->relationshipTypeDelete($this->relationshipTypeID);
$this->quickCleanUpFinancialEntities();
$this->restoreMembershipTypes();
*/
class CRM_Member_BAO_MembershipStatusTest extends CiviUnitTestCase {
- protected function tearDown() {
+ protected function tearDown(): void {
foreach ($this->ids as $entity => $ids) {
foreach ($ids as $id) {
$this->callAPISuccess($entity, 'Delete', ['id' => $id]);
*
* @throws \CRM_Core_Exception
*/
- public function tearDown() {
+ public function tearDown(): void {
$this->membershipTypeDelete(['id' => $this->_membershipTypeID]);
$this->membershipStatusDelete($this->_membershipStatusID);
$this->contactDelete($this->_contactID);
* Tears down the fixture, for example, closes a network connection.
* This method is called after a test is executed.
*/
- public function tearDown() {
+ public function tearDown(): void {
$this->relationshipTypeDelete($this->_relationshipTypeId);
$this->membershipStatusDelete($this->_membershipStatusID);
$this->contactDelete($this->_orgContactID);
*
* @throws \CRM_Core_Exception
*/
- public function tearDown() {
+ public function tearDown(): void {
$this->quickCleanUpFinancialEntities();
$this->quickCleanup(
[
CRM_Core_Session::singleton()->getStatus(TRUE);
$this->setCurrencySeparators($thousandSeparator);
$form = $this->getForm();
- $form->preProcess();
$this->mut = new CiviMailUtils($this, TRUE);
$form->_mode = 'test';
$this->createLoggedInUser();
public function testContributionUpdateOnMembershipTypeChange(): void {
// Step 1: Create a Membership via backoffice whose with 50.00 payment
$form = $this->getForm();
- $form->preProcess();
$this->mut = new CiviMailUtils($this, TRUE);
$this->createLoggedInUser();
$priceSet = $this->callAPISuccess('PriceSet', 'Get', ["extends" => "CiviMember"]);
*
* @throws \CRM_Core_Exception
*/
- public function tearDown() {
+ public function tearDown(): void {
$this->validateAllContributions();
$this->validateAllPayments();
$this->quickCleanUpFinancialEntities();
/**
* Clean up after each test.
*/
- public function tearDown() {
+ public function tearDown(): void {
$this->quickCleanUpFinancialEntities();
CRM_Utils_Hook::singleton()->reset();
}
*
* @throws \CRM_Core_Exception
*/
- public function tearDown() {
+ public function tearDown(): void {
$tablesToTruncate = [
'civicrm_membership',
'civicrm_membership_log',
*
* @throws \CRM_Core_Exception
*/
- public function tearDown() {
+ public function tearDown(): void {
$this->quickCleanUpFinancialEntities();
parent::tearDown();
}
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$contributionPage = $this->contributionPageCreate();
$this->_contributionPageId = $contributionPage['id'];
}
- /**
- * Tears down the fixture, for example, closes a network connection.
- * This method is called after a test is executed.
- */
- protected function tearDown() {
- }
-
/**
* create() and deletepledgeblock() method
*/
*/
class CRM_Pledge_BAO_PledgePaymentTest extends CiviUnitTestCase {
- /**
- * Sets up the fixture, for example, opens a network connection.
- * This method is called before a test is executed.
- */
- protected function setUp() {
- parent::setUp();
- }
-
- /**
- * Tears down the fixture, for example, closes a network connection.
- * This method is called after a test is executed.
- */
- protected function tearDown() {
- }
-
/**
* Test for Add/Update Pledge Payment.
*/
*
* @throws \CiviCRM_API3_Exception
*/
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->ids['Contact'][0] = $this->individualCreate();
$this->_params = [
];
}
- /**
- * Tears down the fixture, for example, closes a network connection.
- * This method is called after a test is executed.
- */
- protected function tearDown() {
- }
-
/**
* Test for Add/Update Pledge.
*
$this->pledgeCreate(['contact_id' => $this->individualID]);
}
- public function tearDown() {
+ public function tearDown(): void {
parent::tearDown();
$tablesToTruncate = [
'civicrm_activity',
*/
class CRM_Price_BAO_PriceFieldValueTest extends CiviUnitTestCase {
- /**
- * Sets up the fixtures.
- */
- protected function setUp() {
- parent::setUp();
- }
-
- /**
- * Tears down the fixture.
- */
- protected function tearDown() {
- }
-
/**
* Verifies visibility field exists and is configured as a pseudoconstant
* referencing the 'visibility' option group.
*/
class CRM_Price_BAO_PriceSetTest extends CiviUnitTestCase {
- /**
- * Sets up the fixtures.
- */
- protected function setUp() {
- parent::setUp();
- }
-
- /**
- * Tears down the fixture.
- */
- protected function tearDown() {
- }
-
/**
* Test the correct amount level is returned for an event which is not presented as a price set event.
*
$this->queueService = CRM_Queue_Service::singleton(TRUE);
}
- public function tearDown() {
+ public function tearDown(): void {
CRM_Utils_Time::resetTime();
$tablesToTruncate = ['civicrm_queue_item'];
$this->queueService = CRM_Queue_Service::singleton(TRUE);
}
- public function tearDown() {
+ public function tearDown(): void {
CRM_Utils_Time::resetTime();
$tablesToTruncate = ['civicrm_queue_item'];
self::$_recordedValues = [];
}
- public function tearDown() {
+ public function tearDown(): void {
unset($this->queue);
unset($this->queueService);
$this->quickCleanup($this->_tablesToTruncate);
}
- public function tearDown() {
+ public function tearDown(): void {
parent::tearDown();
CRM_Core_DAO::executeQuery('DROP TEMPORARY TABLE IF EXISTS civireport_activity_temp_target');
}
'civicrm_address',
];
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
$this->quickCleanup($this->_tablesToTruncate);
}
- public function tearDown() {
- parent::tearDown();
- }
-
/**
* Ensure the new Odd/Event street number sort column works correctly
*/
*/
class CRM_Report_FormTest extends CiviUnitTestCase {
- public function setUp() {
- // There are only unit tests here at present, we can skip database loading.
- return TRUE;
- }
-
- public function tearDown() {
- // There are only unit tests here at present, we can skip database loading.
- return TRUE;
- }
-
/**
* Used by testGetFromTo
*/
/**
* Clean up after each test.
*/
- public function tearDown() {
+ public function tearDown(): void {
parent::tearDown();
$this->callAPISuccess('option_value', 'delete', ['id' => $this->option_value]);
}
/**
* Clean up after each test.
*/
- public function tearDown() {
+ public function tearDown(): void {
parent::tearDown();
$this->callAPISuccess('option_value', 'delete', ['id' => $this->option_value]);
}
/**
* Clean up after each test.
*/
- public function tearDown() {
+ public function tearDown(): void {
parent::tearDown();
$this->quickCleanup(['civicrm_email', 'civicrm_phone', 'civicrm_activity', 'civicrm_activity_contact']);
$this->callAPISuccess('option_value', 'delete', ['id' => $this->option_value]);
class CRM_Upgrade_Incremental_BaseTest extends CiviUnitTestCase {
use CRMTraits_Custom_CustomDataTrait;
- public function tearDown() {
+ public function tearDown(): void {
$this->quickCleanup(['civicrm_saved_search']);
}
*/
class CRM_Upgrade_Incremental_php_FiveTwentyTest extends CiviCaseTestCase {
- public function setUp() {
- parent::setUp();
- }
-
/**
* Test that the upgrade task changes the direction but only
* for bidirectional relationship types that are b_a.
]);
}
- public function tearDown() {
+ public function tearDown(): void {
$noise = $this->callAPISuccess('Contact', 'get', [
'id' => $this->noise['individual'],
'return' => ['email'],
*/
class CRM_Utils_Cache_SqlGroupTest extends CiviUnitTestCase {
- public function setUp() {
- parent::setUp();
- }
-
- public function tearDown() {
- parent::tearDown();
- }
-
/**
* Add and remove two items from the same cache instance.
*/
*/
class CRM_Utils_DateTest extends CiviUnitTestCase {
- public function setUp() {
- // There are only unit tests here at present, we can skip database loading.
- return TRUE;
- }
-
- public function tearDown() {
- // There are only unit tests here at present, we can skip database loading.
- return TRUE;
- }
-
/**
* Used by testGetFromTo
*/
self::$activeTest = $this;
}
- public function tearDown() {
+ public function tearDown(): void {
self::$activeTest = $this;
parent::tearDown();
}
$this->client = new CRM_Utils_HttpClient();
}
- public function tearDown() {
+ public function tearDown(): void {
CRM_Core_DAO::executeQuery("DELETE FROM civicrm_setting WHERE name = 'verifySSL'");
CRM_Core_Config::singleton(TRUE);
parent::tearDown();
])['id'];
}
- public function tearDown() {
+ public function tearDown(): void {
CRM_Utils_File::cleanDir(__DIR__ . '/data/mail');
$this->callAPISuccess('MailSettings', 'delete', [
'id' => $this->mailSettingsId,
]);
}
- public function tearDown() {
+ public function tearDown(): void {
CRM_Utils_File::cleanDir(__DIR__ . '/data/mail');
parent::tearDown();
$this->quickCleanup([
* @group headless
*/
class CRM_Utils_Migrate_ImportExportTest extends CiviUnitTestCase {
- protected $_apiversion;
- public function setUp() {
- $this->_apiversion = 3;
- parent::setUp();
- }
-
- public function tearDown() {
+ public function tearDown(): void {
$tablesToTruncate = [
'civicrm_custom_group',
'civicrm_custom_field',
$this->file = FALSE;
}
- public function tearDown() {
+ public function tearDown(): void {
parent::tearDown();
if ($this->file) {
unlink($this->file);
*/
class CRM_Utils_versionCheckTest extends CiviUnitTestCase {
- public function setUp() {
- parent::setUp();
- }
-
/**
* @var array
*/
],
];
- public function tearDown() {
+ public function tearDown(): void {
parent::tearDown();
$vc = new CRM_Utils_VersionCheck();
if (file_exists($vc->cacheFile)) {
*/
class SequenceListenerTest extends \CiviCaseTestCase {
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
$this->_params = [
'case_type' => $this->caseType,
$this->mandates = [];
}
- public function tearDown() {
+ public function tearDown(): void {
$GLOBALS['civicrm_setting'] = $this->origSetting;
parent::tearDown();
}
class GenericHookEventTest extends \CiviUnitTestCase {
- public function tearDown() {
+ public function tearDown(): void {
\CRM_Utils_Hook::singleton()->reset();
parent::tearDown();
}
$this->mandates = [];
}
- public function tearDown() {
+ public function tearDown(): void {
$GLOBALS['civicrm_setting'] = $this->origSetting;
parent::tearDown();
}
];
}
- public function tearDown() {
+ public function tearDown(): void {
$GLOBALS['civicrm_setting'] = $this->origSetting;
parent::tearDown();
}
class SettingsStackTest extends \CiviUnitTestCase {
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->useTransaction(TRUE);
}
- public function tearDown() {
- parent::tearDown();
- }
-
/**
* Temporarily modify -- then restore -- settings.
*/
return \Civi\Test::headless()->apply();
}
- protected function setUp() {
+ protected function setUp(): void {
$this->contact = \CRM_Core_DAO::createTestObject('CRM_Contact_DAO_Contact', [
'contact_type' => 'Individual',
]);
$session->set('userID', $this->contact->id);
}
- protected function tearDown() {
+ protected function tearDown(): void {
$this->contact->delete();
}
return \Civi\Test::headless()->apply();
}
- protected function setUp() {
+ protected function setUp(): void {
/** @var \CRM_Contact_DAO_Contact $contact */
$contact = \CRM_Core_DAO::createTestObject('CRM_Contact_DAO_Contact', [
'contact_type' => 'Individual',
$this->assertTrue((bool) $dao->find());
}
- public function tearDown() {
- }
-
/**
* Both testDummy1 and testDummy2 have been created at some point (as part of the test runs),
* but all the data was rolled-back
protected $_loggedInUser;
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
// CRM-9404 - set-up is a bit cumbersome but had to put something in place to set up activity types & case types
* Tears down the fixture, for example, closes a network connection.
* This method is called after a test is executed.
*/
- public function tearDown() {
+ public function tearDown(): void {
$this->quickCleanup($this->tablesToTruncate, TRUE);
$this->customDirectories(array('template_path' => FALSE));
CRM_Case_XMLRepository::singleton(TRUE);
*/
class CiviReportTestCase extends CiviUnitTestCase {
- public function setUp() {
- parent::setUp();
- $this->_sethtmlGlobals();
- }
-
- public function tearDown() {
+ public function tearDown(): void {
// TODO Figure out how to automatically drop all temporary tables.
// Note that MySQL doesn't provide a way to list them, so we would need
// to keep track ourselves (eg CRM_Core_TemporaryTableManager) or reset
$this->renameLabels();
$this->_sethtmlGlobals();
+ $this->ensureMySQLMode(['IGNORE_SPACE', 'ERROR_FOR_DIVISION_BY_ZERO', 'STRICT_TRANS_TABLES']);
}
/**
* Read everything from the datasets directory and insert into the db.
*/
- public function loadAllFixtures() {
+ public function loadAllFixtures(): void {
$fixturesDir = __DIR__ . '/../../fixtures';
CRM_Core_DAO::executeQuery("SET FOREIGN_KEY_CHECKS = 0;");
/**
* Common teardown functions for all unit tests.
*/
- protected function tearDown() {
+ protected function tearDown(): void {
$this->_apiversion = 3;
$this->resetLabels();
'));
}
+ /**
+ * Ensure the specified mysql mode/s are activated.
+ *
+ * @param array $modes
+ */
+ protected function ensureMySQLMode(array $modes): void {
+ $currentModes = array_fill_keys(CRM_Utils_SQL::getSqlModes(), 1);
+ $currentModes = array_merge($currentModes, array_fill_keys($modes, 1));
+ CRM_Core_DAO::executeQuery("SET GLOBAL sql_mode = '" . implode(',', array_keys($currentModes)) . "'");
+ CRM_Core_DAO::executeQuery("SET sql_mode = '" . implode(',', array_keys($currentModes)) . "'");
+ }
+
}
*/
protected $b;
- protected function tearDown() {
+ protected function tearDown(): void {
if (function_exists('timecop_return')) {
timecop_return();
}
$this->a = $this->b = NULL;
}
- protected function tearDown() {
+ protected function tearDown(): void {
parent::tearDown();
if ($this->a) {
$this->a->clear();
);
}
- protected function tearDown() {
+ protected function tearDown(): void {
\Civi::service('prevnext')->deleteItem(NULL, $this->cacheKey);
\Civi::service('prevnext')->deleteItem(NULL, $this->cacheKeyB);
}
*/
class E2E_Extern_CliRunnerTest extends CiviEndToEndTestCase {
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
foreach (['CIVI_CORE', 'CMS_ROOT', 'CMS_URL'] as $var) {
}
}
- protected function tearDown() {
- parent::tearDown();
- }
-
/**
* @return array
* Each case gives a name (eg "cv") and template for executing the command
//$this->assertEquals($cmpvar, $apiResult['is_error'], $prefix . print_r($apiResult, TRUE));
}
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
if (empty($GLOBALS['_CV']['CIVI_SITE_KEY'])) {
->getUrl('civicrm', 'extern/rest.php');
}
- protected function tearDown() {
+ protected function tearDown(): void {
if (!empty($this->old_api_keys)) {
foreach ($this->old_api_keys as $cid => $apiKey) {
civicrm_api3('Contact', 'create', array(
public $DBResetRequired = FALSE;
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
}
* (non-PHPdoc)
* @see CiviUnitTestCase::tearDown()
*/
- public function tearDown() {
+ public function tearDown(): void {
$tablesToTruncate = [
'civicrm_activity',
];
public $DBResetRequired = FALSE;
protected $_entity;
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
CRM_Core_DAO::createTestObject('CRM_Pledge_BAO_Pledge', [], 1, 0);
$this->callAPISuccess('Phone', 'create', ['id' => $this->individualCreate(['email' => '']), 'phone' => '911', 'location_type_id' => 'Home']);
* (non-PHPdoc)
* @see CiviUnitTestCase::tearDown()
*/
- public function tearDown() {
+ public function tearDown(): void {
$this->cleanUpAfterACLs();
$tablesToTruncate = [
'civicrm_contact',
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->useTransaction(TRUE);
CRM_Utils_Hook_UnitTests::singleton()->setHook('civicrm_apiWrappers', [$this, 'onApiWrappers']);
}
- /**
- * Tears down the fixture, for example, closes a network connection.
- * This method is called after a test is executed.
- */
- protected function tearDown() {
- parent::tearDown();
- }
-
/**
* @param $apiWrappers
* @param $apiRequest
/**
* Test setup for every test.
*/
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
$this->useTransaction(TRUE);
}
* Connect to the database, truncate the tables that will be used
* and redirect stdin to a temporary file.
*/
- public function setUp() {
+ public function setUp(): void {
$this->_entity = 'case';
parent::setUp();
protected $_activityID;
protected $_params;
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
$this->useTransaction(TRUE);
* Connect to the database, truncate the tables that will be used
* and redirect stdin to a temporary file
*/
- public function setUp() {
+ public function setUp(): void {
// Connect to the database
parent::setUp();
*
* This method is called after a test is executed.
*/
- public function tearDown() {
+ public function tearDown(): void {
$tablesToTruncate = [
'civicrm_contact',
'civicrm_activity',
class api_v3_ActivityTypeTest extends CiviUnitTestCase {
protected $_apiversion;
- public function setUp() {
+ public function setUp(): void {
$this->_apiversion = 3;
CRM_Core_PseudoConstant::activityType(TRUE, TRUE, TRUE, 'name');
parent::setUp();
protected $_entity;
- public function setUp() {
+ public function setUp(): void {
$this->_entity = 'Address';
parent::setUp();
];
}
- public function tearDown() {
+ public function tearDown(): void {
$this->locationTypeDelete($this->_locationTypeID);
$this->contactDelete($this->_contactID);
$this->quickCleanup(['civicrm_address', 'civicrm_relationship']);
return self::$filePrefix;
}
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->useTransaction(TRUE);
file_put_contents($this->tmpFile('mytest.txt'), 'This comes from a file');
}
- protected function tearDown() {
+ protected function tearDown(): void {
parent::tearDown();
$this->cleanupFiles();
\Civi::reset();
*
* This method is called before a test is executed.
*/
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->useTransaction(TRUE);
}
* Connect to the database, truncate the tables that will be used
* and redirect stdin to a temporary file
*/
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
$this->individualCreate();
$this->organizationCreate();
}
- public function tearDown() {
+ public function tearDown(): void {
parent::tearDown();
}
public $DBResetRequired = FALSE;
- public function setUp() {
+ public function setUp(): void {
$this->params = [
'title' => "campaign title",
'description' => "Call people, ask for money",
* Connect to the database, truncate the tables that will be used
* and redirect stdin to a temporary file.
*/
- public function setUp() {
+ public function setUp(): void {
$this->_entity = 'case';
parent::setUp();
* Connect to the database, truncate the tables that will be used
* and redirect stdin to a temporary file.
*/
- public function setUp() {
+ public function setUp(): void {
$this->_entity = 'case';
parent::setUp();
$this->settingsStack = new \Civi\Core\SettingsStack();
}
- public function tearDown() {
+ public function tearDown(): void {
$this->settingsStack->popAll();
parent::tearDown();
}
*/
class api_v3_CaseTypeTest extends CiviCaseTestCase {
- public function setUp() {
+ public function setUp(): void {
$this->quickCleanup(['civicrm_case_type']);
parent::setUp();
*
* This method is called after a test is executed.
*/
- public function tearDown() {
+ public function tearDown(): void {
parent::tearDown();
$this->quickCleanup(['civicrm_case_type', 'civicrm_uf_match']);
}
* Connect to the database, truncate the tables that will be used
* and redirect stdin to a temporary file
*/
- public function setUp() {
+ public function setUp(): void {
// Connect to the database
parent::setUp();
}
class api_v3_ContactTypeTest extends CiviUnitTestCase {
protected $_apiversion;
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
$this->useTransaction(TRUE);
$params = [
*
* @throws \CRM_Core_Exception
*/
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
$this->contactIds[] = $this->individualCreate();
$this->params = [
*
* @throws \CRM_Core_Exception
*/
- public function tearDown() {
+ public function tearDown(): void {
foreach ($this->contactIds as $id) {
$this->callAPISuccess('contact', 'delete', ['id' => $id]);
}
/**
* @throws \CRM_Core_Exception
*/
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
$this->useTransaction();
$this->ids['contact'][0] = $this->individualCreate();
public $debug = 0;
protected $_params;
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
$this->useTransaction(TRUE);
*
* @throws \CRM_Core_Exception
*/
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
$this->_apiversion = 3;
*
* @throws \CRM_Core_Exception
*/
- public function tearDown() {
+ public function tearDown(): void {
$this->quickCleanUpFinancialEntities();
$this->quickCleanup(['civicrm_uf_match'], TRUE);
$financialAccounts = $this->callAPISuccess('FinancialAccount', 'get', []);
class api_v3_CountryTest extends CiviUnitTestCase {
protected $_params;
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
$this->useTransaction(TRUE);
$this->_params = [
protected $_apiversion = 3;
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
$this->installApi();
}
- public function tearDown() {
+ public function tearDown(): void {
parent::tearDown();
CRM_Core_DAO::executeQuery('DROP TABLE civicrm_mailing_provider_data');
}
*
* @throws \CRM_Core_Exception
*/
- public function tearDown() {
+ public function tearDown(): void {
$this->quickCleanup([
'civicrm_contact',
'civicrm_file',
public $DBResetRequired = TRUE;
- public function setUp() {
+ public function setUp(): void {
$this->_entity = 'CustomGroup';
$this->_params = [
'title' => 'Test_Group_1',
parent::setUp();
}
- public function tearDown() {
+ public function tearDown(): void {
$tablesToTruncate = ['civicrm_custom_group', 'civicrm_custom_field'];
// true tells quickCleanup to drop any tables that might have been created in the test
$this->quickCleanup($tablesToTruncate, TRUE);
class api_v3_CustomSearchTest extends CiviUnitTestCase {
protected $_apiversion;
- public function setUp() {
+ public function setUp(): void {
$this->_apiversion = 3;
parent::setUp();
$this->useTransaction(TRUE);
protected $CustomGroupIndividual;
protected $individualStudent;
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
// Create Group For Individual Contact Type
$groupIndividual = [
CRM_Core_BAO_CustomField::getTableColumnGroup($this->IndiStudentField['id'], TRUE);
}
- public function tearDown() {
+ public function tearDown(): void {
$tablesToTruncate = ['civicrm_contact', 'civicrm_cache'];
$this->quickCleanup($tablesToTruncate, TRUE);
}
public $DBResetRequired = FALSE;
- public function setUp() {
- parent::setUp();
- }
-
public function _populateOptionAndCustomGroup($type = NULL) {
$dataValues = [
'integer' => [1, 2, 3],
}
- public function tearDown() {
+ public function tearDown(): void {
$tablesToTruncate = [
'civicrm_email',
'civicrm_custom_field',
* Connect to the database, truncate the tables that will be used
* and redirect stdin to a temporary file
*/
- public function setUp() {
+ public function setUp(): void {
// Connect to the database
parent::setUp();
$this->useTransaction(TRUE);
* Connect to the database, truncate the tables that will be used
* and redirect stdin to a temporary file
*/
- public function setUp() {
+ public function setUp(): void {
// Connect to the database
parent::setUp();
$this->useTransaction(TRUE);
*
* This method is called before a test is executed.
*/
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->useTransaction(TRUE);
protected $_entity;
protected $_params;
- public function setUp() {
+ public function setUp(): void {
$this->_entity = 'Email';
parent::setUp();
$this->useTransaction(TRUE);
public $DBResetRequired = FALSE;
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
$this->useTransaction(TRUE);
*/
class api_v3_EntityJoinTest extends CiviUnitTestCase {
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
$this->useTransaction(TRUE);
}
/**
* Set up permissions for test.
*/
- public function setUp() {
+ public function setUp(): void {
$this->useTransaction(TRUE);
parent::setUp();
$individualID = $this->individualCreate();
*
* @throws \CRM_Core_Exception
*/
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
$this->useTransaction(TRUE);
protected $_apiversion;
protected $_entity;
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
$this->_apiversion = 3;
$this->_entity = 'event';
}
}
- public function tearDown() {
+ public function tearDown(): void {
foreach ($this->eventIds as $eventId) {
$this->eventDelete($eventId);
}
*
* This method is called before a test is executed.
*/
- protected function setUp() {
+ protected function setUp(): void {
$this->useTransaction(TRUE);
parent::setUp();
}
*/
class api_v3_ExtensionTest extends CiviUnitTestCase {
- public function setUp() {
+ public function setUp(): void {
$url = 'file://' . dirname(dirname(dirname(dirname(__FILE__)))) . '/mock/extension_browser_results';
Civi::settings()->set('ext_repo_url', $url);
}
- public function tearDown() {
+ public function tearDown(): void {
Civi::settings()->revert('ext_repo_url');
}
/**
* Setup function.
*/
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
$this->_apiversion = 3;
*
* @throws \Exception
*/
- public function tearDown() {
+ public function tearDown(): void {
$this->quickCleanUpFinancialEntities();
$this->quickCleanup(['civicrm_uf_match']);
$this->disableFinancialACLs();
public $DBResetRequired = FALSE;
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
$this->ids['contact'][0] = $this->individualCreate();
$this->params = [
*
* @throws \Exception
*/
- public function tearDown() {
+ public function tearDown(): void {
foreach ($this->ids as $entity => $entities) {
foreach ($entities as $id) {
$this->callAPISuccess($entity, 'delete', ['id' => $id]);
*
* @todo set up calls function that doesn't work @ the moment
*/
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
$this->useTransaction(TRUE);
*
* This method is called before a test is executed.
*/
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->ids['Group'] = [];
*
* @throws \Exception
*/
- protected function tearDown() {
+ protected function tearDown(): void {
$this->quickCleanup(
[
'civicrm_group',
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
- protected function setUp() {
+ protected function setUp(): void {
$this->_apiversion = 3;
parent::setUp();
$this->useTransaction(TRUE);
/**
* Set up for tests.
*/
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
$this->_groupID = $this->groupCreate();
$config = CRM_Core_Config::singleton();
*
* @throws \Exception
*/
- public function tearDown() {
+ public function tearDown(): void {
CRM_Utils_Hook::singleton()->reset();
$config = CRM_Core_Config::singleton();
unset($config->userPermissionClass->permissions);
public $DBResetRequired = FALSE;
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
$this->useTransaction(TRUE);
*/
private $_mut;
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
// DGW
CRM_Mailing_BAO_MailingJob::$mailsProcessed = 0;
/**
*/
- public function tearDown() {
+ public function tearDown(): void {
$this->_mut->stop();
CRM_Utils_Hook::singleton()->reset();
$this->cleanupMailingTest();
*/
public $_tomorrow;
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
$this->loadReferenceDates();
$this->loadMembershipStatuses();
$this->_tomorrow = date('Y-m-d', time() + 60 * 60 * 24);
}
- public function tearDown() {
+ public function tearDown(): void {
parent::tearDown();
// For each case, the `old` membershipt type must start as
*/
public $customGroupID = NULL;
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
$customGroup = $this->customGroupCreate();
$this->customGroupID = $customGroup['id'];
*
* @throws \CRM_Core_Exception
*/
- public function tearDown() {
+ public function tearDown(): void {
$this->quickCleanup(['civicrm_contact'], TRUE);
parent::tearDown();
}
*
* @throws \CRM_Core_Exception
*/
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
$this->useTransaction();
$contributionParams = [
/**
* Set up.
*/
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
$this->useTransaction(TRUE);
}
*
* This method is called before a test is executed.
*/
- protected function setUp() {
+ protected function setUp(): void {
$this->ensureTempColIsCleanedUp();
parent::setUp();
}
/**
* Clean up log tables.
*/
- protected function tearDown() {
+ protected function tearDown(): void {
$this->quickCleanup(['civicrm_email', 'civicrm_address']);
parent::tearDown();
$this->callAPISuccess('Setting', 'create', ['logging' => FALSE]);
public $DBResetRequired = FALSE;
- public function setUp() {
+ public function setUp(): void {
$this->params = [
'domain_id' => 1,
'name' => "my mail setting",
protected $_entity = 'MailingAB';
protected $_groupID;
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
$this->useTransaction(TRUE);
$this->createLoggedInUser();
class api_v3_MailingContactTest extends CiviUnitTestCase {
protected $_entity = 'mailing';
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
$params = [
'first_name' => 'abc1',
$this->_contact = $this->callAPISuccess("contact", "create", $params);
}
- public function tearDown() {
+ public function tearDown(): void {
$this->callAPISuccess("contact", "delete", ['id' => $this->_contact['id']]);
parent::tearDown();
}
protected $_email;
protected $_apiversion;
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
$this->useTransaction(TRUE);
$this->_apiversion = 3;
*/
protected $footer;
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
$this->useTransaction();
// DGW
]);
}
- public function tearDown() {
+ public function tearDown(): void {
// DGW
CRM_Mailing_BAO_MailingJob::$mailsProcessed = 0;
parent::tearDown();
public $DBResetRequired = FALSE;
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
$this->useTransaction(TRUE);
public $DBResetRequired = FALSE;
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
$this->useTransaction(TRUE);
protected $_membershipStatusID;
protected $_contribution = [];
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
$this->useTransaction(TRUE);
protected $_apiversion = 3;
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
$this->_contactID = $this->individualCreate();
$this->_membershipTypeID = $this->membershipTypeCreate(['member_of_contact_id' => $this->_contactID]);
*
* @throws \CRM_Core_Exception
*/
- public function tearDown() {
+ public function tearDown(): void {
$this->membershipStatusDelete($this->_membershipStatusID);
$this->membershipTypeDelete(['id' => $this->_membershipTypeID]);
$this->contactDelete($this->_contactID);
/**
* Set up for tests.
*/
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
$this->_contactID = $this->individualCreate();
$this->_membershipTypeID = $this->membershipTypeCreate(['member_of_contact_id' => $this->_contactID]);
*
* @throws \Exception
*/
- public function tearDown() {
+ public function tearDown(): void {
$this->quickCleanUpFinancialEntities();
$this->quickCleanup(['civicrm_uf_match'], TRUE);
$this->contactDelete($this->_contactID);
/**
* Set up for tests.
*/
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
$this->useTransaction(TRUE);
$this->_contactID = $this->organizationCreate();
protected $entity = 'MessageTemplate';
protected $params;
- public function setUp() {
+ public function setUp(): void {
$this->_apiversion = 3;
parent::setUp();
$this->useTransaction(TRUE);
];
}
- public function tearDown() {
+ public function tearDown(): void {
parent::tearDown();
unset(CRM_Core_Config::singleton()->userPermissionClass->permissions);
}
*
* This method is called before a test is executed.
*/
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->useTransaction(TRUE);
}
- public function tearDown() {
+ public function tearDown(): void {
CRM_Core_I18n_Schema::makeSinglelingual('en_US');
parent::tearDown();
}
protected $_noteID;
protected $_note;
- public function setUp() {
+ public function setUp(): void {
// Connect to the database.
parent::setUp();
public $DBResetRequired = FALSE;
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
$this->useTransaction();
protected $_entity = 'OptionGroup';
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
$this->useTransaction(TRUE);
$this->_params = [
class api_v3_OptionValueTest extends CiviUnitTestCase {
protected $_apiversion = 3;
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
$this->useTransaction(TRUE);
}
*
* @throws \CRM_Core_Exception
*/
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
$this->_apiversion = 3;
*
* @throws \CRM_Core_Exception
*/
- public function tearDown() {
+ public function tearDown(): void {
$this->quickCleanUpFinancialEntities();
$this->quickCleanup(['civicrm_uf_match']);
}
/**
* Set up for tests.
*/
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
$this->useTransaction(TRUE);
$event = $this->eventCreate(NULL);
public $DBResetRequired = FALSE;
- public function setUp() {
+ public function setUp(): void {
$this->_apiversion = 3;
$this->params = [
'name' => 'test status',
protected $_individualId;
protected $_params;
- public function setUp() {
+ public function setUp(): void {
$this->_apiversion = 3;
parent::setUp();
$this->_entity = 'participant';
];
}
- public function tearDown() {
+ public function tearDown(): void {
$this->eventDelete($this->_eventID);
$tablesToTruncate = [
'civicrm_custom_group',
*
* @throws \CRM_Core_Exception
*/
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
$this->useTransaction(TRUE);
// Create dummy processor
class api_v3_PaymentProcessorTypeTest extends CiviUnitTestCase {
protected $_ppTypeID;
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
$this->useTransaction(TRUE);
}
- // function tearDown() {
+ // function tearDown(): void {
//
// $tablesToTruncate = array(
// 'civicrm_payment_processor_type',
*
* @throws \CRM_Core_Exception
*/
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
$this->_apiversion = 3;
*
* @throws \Exception
*/
- public function tearDown() {
+ public function tearDown(): void {
$this->quickCleanUpFinancialEntities();
$this->quickCleanup(['civicrm_uf_match']);
unset(CRM_Core_Config::singleton()->userPermissionClass->permissions);
public $DBResetRequired = FALSE;
- public function setUp() {
+ public function setUp(): void {
$this->_apiversion = 3;
$this->useTransaction(TRUE);
parent::setUp();
protected $entity = 'Pcp';
public $DBResetRequired = TRUE;
- public function setUp() {
+ public function setUp(): void {
$this->params = [
'title' => "Pcp title",
'contact_id' => 1,
*/
protected $isLocationTypesOnPostAssert = TRUE;
- public function setUp() {
+ public function setUp(): void {
$this->_entity = 'Phone';
parent::setUp();
$this->useTransaction();
*
* @throws \CRM_Core_Exception
*/
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
$this->_individualId = $this->individualCreate();
$this->_pledgeID = $this->pledgeCreate(['contact_id' => $this->_individualId]);
* Clean up after function.
* @throws \CRM_Core_Exception
*/
- public function tearDown() {
+ public function tearDown(): void {
$tablesToTruncate = [
'civicrm_contribution',
'civicrm_contact',
/**
* @throws \CRM_Core_Exception
*/
- public function setUp() {
+ public function setUp(): void {
$this->_apiversion = 3;
parent::setUp();
$this->quickCleanup(['civicrm_pledge', 'civicrm_pledge_payment']);
];
}
- public function tearDown() {
+ public function tearDown(): void {
$this->contactDelete($this->_individualId);
}
*
* @throws \CRM_Core_Exception
*/
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
$priceSetparams = [
'name' => 'default_goat_priceset',
*
* @throws \CRM_Core_Exception
*/
- public function tearDown() {
+ public function tearDown(): void {
$tablesToTruncate = [
'civicrm_contact',
'civicrm_contribution',
/**
* Setup function.
*/
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
// Put stuff here that should happen before all tests in this unit.
$priceSetParams = [
*
* @throws \Exception
*/
- public function tearDown() {
+ public function tearDown(): void {
$tablesToTruncate = [
'civicrm_contact',
'civicrm_contribution',
/**
* Set up for class.
*/
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
$this->_params = [
'name' => 'default_goat_priceset',
protected $_entity = 'Product';
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
$this->useTransaction();
$this->_params = [
/**
* Set up for test.
*/
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
$config = CRM_Core_Config::singleton();
$countryLimit = $config->countryLimit;
*
* @throws \Exception
*/
- public function tearDown() {
+ public function tearDown(): void {
$this->quickCleanup([
'civicrm_contact',
/**
* Set up function.
*/
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
$this->_cId_a = $this->individualCreate();
$this->_cId_a_2 = $this->individualCreate([
*
* @throws \Exception
*/
- public function tearDown() {
+ public function tearDown(): void {
$this->contactDelete($this->_cId_a);
$this->contactDelete($this->_cId_a_2);
$this->contactDelete($this->_cId_b);
protected $_relTypeID;
protected $_apiversion = 3;
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
$this->_cId_a = $this->individualCreate();
$this->_cId_b = $this->organizationCreate();
}
- public function tearDown() {
+ public function tearDown(): void {
$tablesToTruncate = [
'civicrm_contact',
*
* @throws \Exception
*/
- public function tearDown() {
+ public function tearDown(): void {
$this->quickCleanUpFinancialEntities();
$this->quickCleanup(['civicrm_group', 'civicrm_saved_search', 'civicrm_group_contact', 'civicrm_group_contact_cache', 'civicrm_group'], TRUE);
parent::tearDown();
protected $_entity;
public $DBResetRequired = FALSE;
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
// The line below makes it unneccessary to do cleanup after a test,
/**
* Create a saved search, and see whether the returned values make sense.
*/
- public function testCreateSavedSearch() {
+ public function testCreateSavedSearch(): void {
$contactID = $this->createLoggedInUser();
$result = $this->callAPIAndDocument(
$this->_entity, 'create', $this->params, __FUNCTION__, __FILE__)['values'];
* Create a saved search, retrieve it again, and check for ID and one of
* the field values.
*/
- public function testCreateAndGetSavedSearch() {
+ public function testCreateAndGetSavedSearch(): void {
// Arrange:
// (create a saved search)
$create_result = $this->callAPISuccess(
* Create a saved search, and test whether it can be used for a smart
* group.
*/
- public function testCreateSavedSearchWithSmartGroup() {
+ public function testCreateSavedSearchWithSmartGroup(): void {
// First create a volunteer for the default organization
$result = $this->callAPISuccess('Contact', 'create', [
$this->assertEquals($contact_id, $get_result['values'][$contact_id]['id']);
}
- public function testDeleteSavedSearch() {
+ /**
+ * Create a saved search, and test whether it can be used for a smart
+ * group. Also check that when the Group is deleted the associated saved search gets deleted.
+ * @dataProvider versionThreeAndFour
+ */
+ public function testSavedSearchIsDeletedWhenSmartGroupIs($apiVersion): void {
+ $this->_apiVersion = $apiVersion;
+ // First create a volunteer for the default organization
+
+ $result = $this->callAPISuccess('Contact', 'create', [
+ 'first_name' => 'Joe',
+ 'last_name' => 'Schmoe',
+ 'contact_type' => 'Individual',
+ 'api.Relationship.create' => [
+ 'contact_id_a' => '$value.id',
+ // default organization:
+ 'contact_id_b' => 1,
+ // volunteer relationship:
+ 'relationship_type_id' => 6,
+ 'is_active' => 1,
+ ],
+ ]);
+ $contact_id = $result['id'];
+
+ // Now create our saved search, and chain the creation of a smart group.
+ $params = $this->params;
+ $params['api.Group.create'] = [
+ 'name' => 'my_smartgroup',
+ 'title' => 'my smartgroup',
+ 'description' => 'Volunteers for the default organization',
+ 'saved_search_id' => '$value.id',
+ 'is_active' => 1,
+ 'visibility' => 'User and User Admin Only',
+ 'is_hidden' => 0,
+ 'is_reserved' => 0,
+ ];
+
+ $create_result = $this->callAPISuccess($this->_entity, 'create', $params);
+
+ $created_search = CRM_Utils_Array::first($create_result['values']);
+ $group_id = $created_search['api.Group.create']['id'];
+
+ // Search for contacts in our new smart group
+ $get_result = $this->callAPISuccess('Contact', 'get', ['group' => $group_id]);
+
+ // Expect our contact to be there.
+ $this->assertEquals(1, $get_result['count']);
+ $this->assertEquals($contact_id, $get_result['values'][$contact_id]['id']);
+
+ $this->callAPISuccess('Group', 'delete', ['id' => $group_id]);
+ $savedSearch = $this->callAPISuccess('SavedSearch', 'get', ['id' => $created_search['id']]);
+ $this->assertCount(0, $savedSearch['values']);
+ }
+
+ public function testDeleteSavedSearch(): void {
// Create saved search, delete it again, and try to get it
$create_result = $this->callAPISuccess($this->_entity, 'create', $this->params);
$delete_params = ['id' => $create_result['id']];
private $hookEntity;
private $hookCondition = [];
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
$this->useTransaction(TRUE);
CRM_Utils_Hook::singleton()->setHook('civicrm_selectWhereClause', [$this, 'hook_civicrm_selectWhereClause']);
protected $_domainID2;
protected $_domainID3;
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
$params = [
'name' => __CLASS__ . 'Second Domain',
$this->hookClass = CRM_Utils_Hook::singleton();
}
- public function tearDown() {
+ public function tearDown(): void {
CRM_Utils_Hook::singleton()->reset();
parent::tearDown();
$this->callAPISuccess('system', 'flush', []);
class api_v3_StateProvinceTest extends CiviUnitTestCase {
protected $_params;
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
$this->useTransaction(TRUE);
$this->_params = [
protected $_locationType;
protected $_params;
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
$this->useTransaction(TRUE);
$this->_params = [
protected $_apiversion = 3;
protected $params;
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
$this->useTransaction(TRUE);
$phoneBankActivity = $this->callAPISuccess('Option_value', 'Get', ['label' => 'PhoneBank', 'sequential' => 1]);
protected $entity = 'survey';
public $DBResetRequired = FALSE;
- public function setUp() {
+ public function setUp(): void {
$phoneBankActivityTypeID = $this->callAPISuccessGetValue('Option_value', [
'label' => 'PhoneBank',
'return' => 'value',
* and that will never exist (eg an obsoleted Entity
* they need to be returned by the function toBeSkipped_{$action} (because it has to be a static method and therefore couldn't access a this->toBeSkipped)
*/
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
$this->enableCiviCampaign();
$this->toBeImplemented['get'] = [
$this->deletableTestObjects = [];
}
- public function tearDown() {
+ public function tearDown(): void {
foreach ($this->deletableTestObjects as $entityName => $entities) {
foreach ($entities as $entityID) {
CRM_Core_DAO::deleteTestObjects($entityName, ['id' => $entityID]);
'website_type_id',
// Not a real field
'option.autoweight',
+ 'field_name',
],
'break_return' => [
// These fields get auto-adjusted by the BAO prior to saving
*/
class api_v3_SystemCheckTest extends CiviUnitTestCase {
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
$this->useTransaction(TRUE);
}
*
* This method is called before a test is executed.
*/
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->useTransaction(TRUE);
}
protected $tagID;
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
$this->useTransaction(TRUE);
$this->tag = $this->tagCreate();
protected $halfFinancialAccId;
protected $halfFinancialTypeId;
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
$this->_individualId = $this->individualCreate();
$this->_orgId = $this->organizationCreate(NULL);
/**
* Cleanup after function.
*/
- public function tearDown() {
+ public function tearDown(): void {
$this->quickCleanUpFinancialEntities();
parent::tearDown();
}
*
* @throws \Exception
*/
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->quickCleanup(
[
*
* @throws \Exception
*/
- public function tearDown() {
+ public function tearDown(): void {
$this->quickCleanup(
[
'civicrm_group',
protected $_groupId;
protected $params;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->_groupId = $this->groupCreate();
$this->_contactId = $this->individualCreate();
];
}
- public function tearDown() {
+ public function tearDown(): void {
// Truncate the tables
$this->quickCleanup(
[
protected $_ufFieldId;
protected $_contactId = 69;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
// Truncate the tables
$this->quickCleanup(
$this->loadXMLDataSet(dirname(__FILE__) . '/dataset/uf_group_test.xml');
}
- public function tearDown() {
+ public function tearDown(): void {
// Truncate the tables
$this->quickCleanup(
[
protected $_contactId;
protected $_params = [];
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->quickCleanup(
[
];
}
- public function tearDown() {
+ public function tearDown(): void {
// Truncate the tables
$this->quickCleanup(
[
public $DBResetRequired = FALSE;
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
$this->contactID = $this->createLoggedInUser();
$this->params = [
*
* This method is called before a test is executed.
*/
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->useTransaction(TRUE);
}
/**
* This method is called before a test is executed.
*/
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
}
public $DBResetRequired = FALSE;
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
$this->useTransaction();
*/
class ChainTest extends UnitTestCase {
- public function tearDown() {
- $result = CustomField::delete()
+ public function tearDown(): void {
+ CustomField::delete()
->setCheckPermissions(FALSE)
->addWhere('name', '=', 'FavPerson')
->addChain('group', CustomGroup::delete()->addWhere('name', '=', 'TestActCus'))
return parent::setUpHeadless();
}
- public function tearDown() {
+ public function tearDown(): void {
$relatedTables = [
'civicrm_activity',
'civicrm_phone',
$this->optionValueMaxId = \CRM_Core_DAO::singleValueQuery('SELECT MAX(id) FROM civicrm_option_value');
}
- public function tearDown() {
+ public function tearDown(): void {
if ($this->optionValueMaxId) {
\CRM_Core_DAO::executeQuery('DELETE FROM civicrm_option_value WHERE id > ' . $this->optionValueMaxId);
}
return \Civi\Test::headless()->apply();
}
- /**
- * Tears down the fixture, for example, closes a network connection.
- *
- * This method is called after a test is executed.
- */
- public function tearDown() {
- parent::tearDown();
- }
-
/**
* Quick clean by emptying tables created for the test.
*
<table>civicrm_saved_search</table>
<key>id</key>
<add>1.1</add>
- <onDelete>SET NULL</onDelete>
+ <onDelete>CASCADE</onDelete>
</foreignKey>
<field>
<name>is_active</name>
<label>Relationship</label>
</html>
<add>5.29</add>
+ <readonly>true</readonly>
</field>
<foreignKey>
<name>relationship_id</name>
<label>Relationship Type</label>
</html>
<add>5.29</add>
+ <readonly>true</readonly>
</field>
<foreignKey>
<name>relationship_type_id</name>
</pseudoconstant>
<comment>The cache record is a permutation of the original relationship record. The orientation indicates whether it is forward (a_b) or reverse (b_a) relationship.</comment>
<add>5.29</add>
+ <readonly>true</readonly>
</field>
<field>
<type>EntityRef</type>
<label>Contact (Near side)</label>
</html>
+ <readonly>true</readonly>
</field>
<foreignKey>
<name>near_contact_id</name>
<pseudoconstant>
<callback>CRM_Core_PseudoConstant::relationshipTypeOptions</callback>
</pseudoconstant>
+ <readonly>true</readonly>
</field>
<field>
<type>EntityRef</type>
<label>Contact (Far side)</label>
</html>
+ <readonly>true</readonly>
</field>
<foreignKey>
<name>far_contact_id</name>
<pseudoconstant>
<callback>CRM_Core_PseudoConstant::relationshipTypeOptions</callback>
</pseudoconstant>
+ <readonly>true</readonly>
</field>
<index>
<html>
<type>CheckBox</type>
</html>
+ <readonly>true</readonly>
</field>
<field>
<name>start_date</name>
<type>Select Date</type>
<formatType>activityDate</formatType>
</html>
+ <readonly>true</readonly>
</field>
<field>
<name>end_date</name>
<type>Select Date</type>
<formatType>activityDate</formatType>
</html>
+ <readonly>true</readonly>
</field>
</table>