From: eileen Date: Sat, 10 Aug 2019 02:08:52 +0000 (+1200) Subject: Event confirm - minor cleanup + test X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=e579af797ad85e340a52552f6a7f43d8a710db8c;p=civicrm-core.git Event confirm - minor cleanup + test I've just started delving into this & have 1) added a test 2) removed an assign that is ALSO done in the sendMail function - ie participantID - this is tested 3) removed a pass-by-reference that I checked was not required --- diff --git a/CRM/Event/BAO/Event.php b/CRM/Event/BAO/Event.php index e77244bef1..df8ece444c 100644 --- a/CRM/Event/BAO/Event.php +++ b/CRM/Event/BAO/Event.php @@ -1054,7 +1054,7 @@ WHERE civicrm_event.is_active = 1 * @return array|null * @throws \CiviCRM_API3_Exception */ - public static function sendMail($contactID, &$values, $participantId, $isTest = FALSE, $returnMessageText = FALSE) { + public static function sendMail($contactID, $values, $participantId, $isTest = FALSE, $returnMessageText = FALSE) { $template = CRM_Core_Smarty::singleton(); $gIds = [ diff --git a/CRM/Event/Form/Registration/Confirm.php b/CRM/Event/Form/Registration/Confirm.php index db2829ef08..b5d6739186 100644 --- a/CRM/Event/Form/Registration/Confirm.php +++ b/CRM/Event/Form/Registration/Confirm.php @@ -928,7 +928,6 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration { //send mail to primary as well as additional participants. $this->assign('contactID', $contactId); - $this->assign('participantID', $participantID); CRM_Event_BAO_Event::sendMail($contactId, $this->_values, $participantID, $isTest); } } diff --git a/tests/phpunit/CRM/Event/Form/Registration/ConfirmTest.php b/tests/phpunit/CRM/Event/Form/Registration/ConfirmTest.php index 782874b2bf..683ed6035c 100644 --- a/tests/phpunit/CRM/Event/Form/Registration/ConfirmTest.php +++ b/tests/phpunit/CRM/Event/Form/Registration/ConfirmTest.php @@ -22,6 +22,7 @@ class CRM_Event_Form_Registration_ConfirmTest extends CiviUnitTestCase { */ public function testSubmit() { $event = $this->eventCreate(); + $mut = new CiviMailUtils($this, TRUE); CRM_Event_Form_Registration_Confirm::testSubmit([ 'id' => $event['id'], 'contributeMode' => 'direct', @@ -77,7 +78,15 @@ class CRM_Event_Form_Registration_ConfirmTest extends CiviUnitTestCase { ], ], ]); - $this->callAPISuccessGetSingle('Participant', []); + $participant = $this->callAPISuccessGetSingle('Participant', []); + $mut->checkMailLog([ + 'Dear Logged In, Thank you for your participation. This letter is a confirmation that your registration has been received and your status has been updated to Registered.', + ]); + $mut->stop(); + $mut->clearMessages(); + $tplVars = CRM_Core_Smarty::singleton()->get_template_vars(); + $this->assertEquals($participant['id'], $tplVars['participantID']); + } /** diff --git a/tests/phpunit/CiviTest/CiviUnitTestCase.php b/tests/phpunit/CiviTest/CiviUnitTestCase.php index 957a716325..1343cffa1b 100644 --- a/tests/phpunit/CiviTest/CiviUnitTestCase.php +++ b/tests/phpunit/CiviTest/CiviUnitTestCase.php @@ -1015,6 +1015,7 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { 'is_monetary' => 0, 'is_active' => 1, 'is_show_location' => 0, + 'is_email_confirm' => 1, ), $params); return $this->callAPISuccess('Event', 'create', $params);