From 4fb1502850122289fb75761e3e151bebfcdfaae2 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Sun, 26 Sep 2021 08:10:14 +1300 Subject: [PATCH] [Ref] Function signature cleanup --- CRM/Contact/Form/Task/EmailTrait.php | 25 +++++++------------ .../phpunit/CRM/Activity/BAO/ActivityTest.php | 24 +++--------------- 2 files changed, 13 insertions(+), 36 deletions(-) diff --git a/CRM/Contact/Form/Task/EmailTrait.php b/CRM/Contact/Form/Task/EmailTrait.php index d9530c0c5c..058eef3bf7 100644 --- a/CRM/Contact/Form/Task/EmailTrait.php +++ b/CRM/Contact/Form/Task/EmailTrait.php @@ -443,13 +443,10 @@ trait CRM_Contact_Form_Task_EmailTrait { $this->getSubject($formValues['subject']), $formValues['text_message'], $formValues['html_message'], - NULL, - NULL, $from, $this->getAttachments($formValues), $cc, $bcc, - array_keys($this->_toContactDetails), $additionalDetails, $this->getContributionIDs(), CRM_Utils_Array::value('campaign_id', $formValues), @@ -781,6 +778,8 @@ trait CRM_Contact_Form_Task_EmailTrait { * * Do not use this function outside of core tested code. It will change. * + * It will also become protected once tests no longer call it. + * * @internal * * Also insert a contact activity in each contacts record. @@ -791,10 +790,6 @@ trait CRM_Contact_Form_Task_EmailTrait { * The subject of the message. * @param $text * @param $html - * @param string $emailAddress - * Use this 'to' email address instead of the default Primary address. - * @param int|null $userID - * Use this userID if set. * @param string|null $from * @param array|null $attachments * The array of attachments if any. @@ -802,8 +797,6 @@ trait CRM_Contact_Form_Task_EmailTrait { * Cc recipient. * @param string|null $bcc * Bcc recipient. - * @param array|null $contactIds - * unused. * @param string|null $additionalDetails * The additional information of CC and BCC appended to the activity Details. * @param array|null $contributionIds @@ -816,28 +809,28 @@ trait CRM_Contact_Form_Task_EmailTrait { * * @throws \API_Exception * @throws \CRM_Core_Exception + * @throws \Civi\API\Exception\UnauthorizedException + * @internal + * + * Also insert a contact activity in each contacts record. + * */ public function sendEmail( $contactDetails, $subject, $text, $html, - $emailAddress, - $userID = NULL, $from = NULL, $attachments = NULL, $cc = NULL, $bcc = NULL, - $contactIds = NULL, $additionalDetails = NULL, $contributionIds = NULL, $campaignId = NULL, $caseId = NULL ) { - // get the contact details of logged in contact, which we set as from email - if ($userID == NULL) { - $userID = CRM_Core_Session::getLoggedInContactID(); - } + + $userID = CRM_Core_Session::getLoggedInContactID(); [$fromDisplayName, $fromEmail, $fromDoNotEmail] = CRM_Contact_BAO_Contact::getContactDetails($userID); if (!$fromEmail) { diff --git a/tests/phpunit/CRM/Activity/BAO/ActivityTest.php b/tests/phpunit/CRM/Activity/BAO/ActivityTest.php index b6619b9eb9..017c3a8e5f 100644 --- a/tests/phpunit/CRM/Activity/BAO/ActivityTest.php +++ b/tests/phpunit/CRM/Activity/BAO/ActivityTest.php @@ -1228,7 +1228,7 @@ class CRM_Activity_BAO_ActivityTest extends CiviUnitTestCase { $contactId = $this->getContactID(); // create a logged in USER since the code references it for sendEmail user. - $loggedInUser = $this->createLoggedInUser(); + $this->createLoggedInUser(); $contactDetailsIntersectKeys = [ 'contact_id' => '', @@ -1259,7 +1259,6 @@ class CRM_Activity_BAO_ActivityTest extends CiviUnitTestCase { $subject = __FUNCTION__ . ' subject'; $html = __FUNCTION__ . ' html {contact.display_name} {case.case_type_id:label}'; $text = __FUNCTION__ . ' text {contact.display_name} {case.case_type_id:label}'; - $userID = $loggedInUser; /* @var CRM_Contact_Form_Task_Email $form */ $form = $this->getFormObject('CRM_Contact_Form_Task_Email'); @@ -1269,13 +1268,10 @@ class CRM_Activity_BAO_ActivityTest extends CiviUnitTestCase { $subject, $text, $html, - $contact['email'], - $userID, - $from = __FUNCTION__ . '@example.com', + __FUNCTION__ . '@example.com', NULL, NULL, NULL, - [$contactId], NULL, NULL, NULL, @@ -1385,8 +1381,6 @@ class CRM_Activity_BAO_ActivityTest extends CiviUnitTestCase { $subject, $text, $html, - $contact['email'], - $loggedInUser, $from = __FUNCTION__ . '@example.com' ); @@ -1452,14 +1446,11 @@ $text $subject, $text, $html, - $contact['email'], - $userID, - $from = __FUNCTION__ . '@example.com', + __FUNCTION__ . '@example.com', $attachments = NULL, $cc = NULL, $bcc = NULL, $contactIds = NULL, - $additionalDetails = NULL, NULL, $campaign_id ); @@ -1713,13 +1704,10 @@ $text $subject, $text, $html, - $contact['values'][$contactId]['email'], - $loggedInUser, $from = __FUNCTION__ . '@example.com', NULL, NULL, NULL, - [$contactId], NULL, NULL, NULL, @@ -1755,7 +1743,6 @@ $text $subject = __FUNCTION__ . ' subject' . '{contact.display_name}'; $html = __FUNCTION__ . ' html' . '{contact.display_name}'; $text = __FUNCTION__ . ' text' . '{contact.display_name}'; - $userID = $loggedInUser; /* @var CRM_Contact_Form_Task_Email $form */ $form = $this->getFormObject('CRM_Contact_Form_Task_Email'); @@ -1764,13 +1751,10 @@ $text $subject, $text, $html, - $contact['values'][0]['email'], - $userID, - $from = __FUNCTION__ . '@example.com', + __FUNCTION__ . '@example.com', $attachments = NULL, $cc = NULL, $bcc = NULL, - $contactIds = array_column($contact['values'], 'id'), $additionalDetails = NULL, NULL, $campaign_id -- 2.25.1