From e579af797ad85e340a52552f6a7f43d8a710db8c Mon Sep 17 00:00:00 2001 From: eileen Date: Sat, 10 Aug 2019 14:08:52 +1200 Subject: [PATCH 1/2] 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 --- CRM/Event/BAO/Event.php | 2 +- CRM/Event/Form/Registration/Confirm.php | 1 - .../CRM/Event/Form/Registration/ConfirmTest.php | 11 ++++++++++- tests/phpunit/CiviTest/CiviUnitTestCase.php | 1 + 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/CRM/Event/BAO/Event.php b/CRM/Event/BAO/Event.php index e77244bef1f0..df8ece444cc8 100644 --- a/CRM/Event/BAO/Event.php +++ b/CRM/Event/BAO/Event.php @@ -1054,7 +1054,7 @@ public static function usesPriceSet($id) { * @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 db2829ef08e5..b5d6739186d7 100644 --- a/CRM/Event/Form/Registration/Confirm.php +++ b/CRM/Event/Form/Registration/Confirm.php @@ -928,7 +928,6 @@ public function postProcess() { //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 782874b2bf0b..683ed6035c36 100644 --- a/tests/phpunit/CRM/Event/Form/Registration/ConfirmTest.php +++ b/tests/phpunit/CRM/Event/Form/Registration/ConfirmTest.php @@ -22,6 +22,7 @@ public function setUp() { */ 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 @@ public function testSubmit() { ], ], ]); - $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 957a716325a7..1343cffa1b42 100644 --- a/tests/phpunit/CiviTest/CiviUnitTestCase.php +++ b/tests/phpunit/CiviTest/CiviUnitTestCase.php @@ -1015,6 +1015,7 @@ public function eventCreate($params = array()) { 'is_monetary' => 0, 'is_active' => 1, 'is_show_location' => 0, + 'is_email_confirm' => 1, ), $params); return $this->callAPISuccess('Event', 'create', $params); From 1604fa932478d507fa0e378a62b35dc992f28078 Mon Sep 17 00:00:00 2001 From: eileen Date: Sat, 10 Aug 2019 15:46:31 +1200 Subject: [PATCH 2/2] Update test to reflect test setup change --- tests/phpunit/api/v3/PaymentTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/phpunit/api/v3/PaymentTest.php b/tests/phpunit/api/v3/PaymentTest.php index 6395c462a984..8f0bf927e0f1 100644 --- a/tests/phpunit/api/v3/PaymentTest.php +++ b/tests/phpunit/api/v3/PaymentTest.php @@ -167,7 +167,7 @@ public function testPaymentEmailReceiptFullyPaid() { $payment = $this->callAPISuccess('payment', 'create', $params); $this->callAPISuccess('Payment', 'sendconfirmation', ['id' => $payment['id']]); - $mut->assertSubjects(['Payment Receipt - Annual CiviCRM meet']); + $mut->assertSubjects(['Payment Receipt - Annual CiviCRM meet', 'Registration Confirmation - Annual CiviCRM meet']); $mut->checkMailLog([ 'Dear Anthony,', 'A payment has been received.',