Skip to content

Commit

Permalink
Merge pull request #21855 from eileenmcnaughton/part
Browse files Browse the repository at this point in the history
Add test for selvsvctransfer, remove use of `$contact` from template
  • Loading branch information
monishdeb authored Oct 29, 2021
2 parents a51a14d + 6c43827 commit 88d97cc
Show file tree
Hide file tree
Showing 11 changed files with 3,883 additions and 3,792 deletions.
2 changes: 1 addition & 1 deletion CRM/Contact/DAO/RelationshipCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ public static function &fields() {
'title' => ts('Case ID'),
'description' => ts('FK to civicrm_case'),
'where' => 'civicrm_relationship_cache.case_id',
'default' => 'NULL',
'default' => NULL,
'table_name' => 'civicrm_relationship_cache',
'entity' => 'RelationshipCache',
'bao' => 'CRM_Contact_BAO_RelationshipCache',
Expand Down
8 changes: 7 additions & 1 deletion CRM/Event/BAO/Participant.php
Original file line number Diff line number Diff line change
Expand Up @@ -1406,12 +1406,18 @@ public static function sendTransitionParticipantMail(
$participantValues,
$eventDetails,
$contactDetails,
&$domainValues,
$domainValues,
$mailType
) {
//send emails.
$mailSent = FALSE;

if (!$contactDetails) {
$contactDetails = civicrm_api3('Contact', 'getsingle', [
'id' => $participantValues['contact_id'],
'return' => ['email', 'display_name'],
]);
}
//don't send confirmation mail to additional
//since only primary able to confirm registration.
if (!empty($participantValues['registered_by_id']) &&
Expand Down
16 changes: 3 additions & 13 deletions CRM/Event/Form/SelfSvcTransfer.php
Original file line number Diff line number Diff line change
Expand Up @@ -458,23 +458,13 @@ public function sendCancellation() {
//get the location info
$locParams = ['entity_id' => $this->_event_id, 'entity_table' => 'civicrm_event'];
$eventDetails[$this->_event_id]['location'] = CRM_Core_BAO_Location::getValues($locParams, TRUE);
//get contact details
$contactIds[$this->_from_contact_id] = $this->_from_contact_id;
list($currentContactDetails) = CRM_Utils_Token::getTokenDetails($contactIds, NULL,
FALSE, FALSE, NULL, [],
'CRM_Event_BAO_Participant'
);
foreach ($currentContactDetails as $contactId => $contactValues) {
$contactDetails[$this->_from_contact_id] = $contactValues;
}
//send a 'cancelled' email to user, and cc the event's cc_confirm email
$mail = CRM_Event_BAO_Participant::sendTransitionParticipantMail($this->_from_participant_id,
CRM_Event_BAO_Participant::sendTransitionParticipantMail($this->_from_participant_id,
$participantDetails[$this->_from_participant_id],
$eventDetails[$this->_event_id],
$contactDetails[$this->_from_contact_id],
NULL,
$domainValues,
"Transferred",
""
'Transferred'
);
$statusMsg = ts('Event registration information for %1 has been updated.', [1 => $this->_contact_name]);
$statusMsg .= ' ' . ts('A cancellation email has been sent to %1.', [1 => $this->_contact_email]);
Expand Down
25 changes: 25 additions & 0 deletions CRM/Event/WorkflowMessage/ParticipantTransferred.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php
/*
+--------------------------------------------------------------------+
| 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 |
+--------------------------------------------------------------------+
*/

use Civi\WorkflowMessage\GenericWorkflowMessage;

/**
* Notification that a registration has been transferred to a different person.
*
* @support template-only
*
* @see CRM_Event_BAO_Participant::sendTransitionParticipantMail
*/
class CRM_Event_WorkflowMessage_ParticipantTransferred extends GenericWorkflowMessage {

public const WORKFLOW = 'participant_transferred';

}
9 changes: 9 additions & 0 deletions CRM/Upgrade/Incremental/MessageTemplates.php
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,15 @@ protected function getTemplateUpdates() {
['name' => 'pledge_reminder', 'type' => 'html'],
],
],
[
'version' => '5.44.alpha1',
'upgrade_descriptor' => ts('Use domain and contact tokens instead of smarty values'),
'label' => ts('Pledge Transferred'),
'templates' => [
['name' => 'participant_transferred', 'type' => 'text'],
['name' => 'participant_transferred', 'type' => 'html'],
],
],
];
}

Expand Down
2 changes: 1 addition & 1 deletion install/langs.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@
'tr_TR' => 'Turkish',
'uk_UA' => 'Ukrainian',
'vi_VN' => 'Vietnamese',
);
);
7,562 changes: 3,793 additions & 3,769 deletions sql/civicrm_generated.mysql

Large diffs are not rendered by default.

37 changes: 37 additions & 0 deletions tests/phpunit/CRM/Event/Form/SelfSvcTransferTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

/**
* Test CRM_Event_Form_Registration functions.
*
* @package CiviCRM
* @group headless
*/
class CRM_Event_Form_SelfSvcTransferTest extends CiviUnitTestCase {

/**
* Test cancellation.
*
* @throws \CRM_Core_Exception
* @throws \CiviCRM_API3_Exception
*/
public function testCancel(): void {
$_REQUEST['pid'] = $this->participantCreate(['status_id' => 'Registered']);
$_REQUEST['is_backoffice'] = 1;
$this->addLocationBlockToDomain();
$this->individualCreate(['email' => '[email protected]']);
$mut = new CiviMailUtils($this);
/* @var CRM_Event_Form_SelfSvcTransfer $form*/
$form = $this->getFormObject('CRM_Event_Form_SelfSvcTransfer', [
'email' => '[email protected]',
]);
$form->buildForm();
$form->postProcess();
$emails = $mut->getAllMessages();
$this->assertStringContainsString('Registration Confirmation - Annual CiviCRM meet - Mr. Anthony', $emails[0]);
$this->assertStringContainsString('<p>Dear Anthony,</p> <p>Your Event Registration has been Transferred to Anthony Anderson.</p>', $emails[1]);
$this->assertStringContainsString('[email protected]', $emails[1]);
$this->assertStringContainsString('123', $emails[1]);
$this->assertStringContainsString('[email protected]', $emails[1]);
}

}
2 changes: 1 addition & 1 deletion tests/phpunit/CiviTest/CiviUnitTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -858,7 +858,7 @@ public function paymentProcessorAuthorizeNetCreate($params = []) {
*/
public function participantCreate(array $params = []) {
if (empty($params['contact_id'])) {
$params['contact_id'] = $this->individualCreate();
$this->ids['Contact']['participant'] = $params['contact_id'] = $this->individualCreate();
}
if (empty($params['event_id'])) {
$event = $this->eventCreate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,15 @@
{/foreach}
{/if}

{if $contact.email}
{if '{contact.email}'}
<tr>
<th {$headerStyle}>
{ts}Registered Email{/ts}
</th>
</tr>
<tr>
<td colspan="2" {$valueStyle}>
{$contact.email}
{contact.email}
</td>
</tr>
{/if}
Expand All @@ -117,7 +117,7 @@

<tr>
<td>
<p>{ts 1=$domain.phone 2=$domain.email}Please contact us at %1 or send email to %2 if you have questions.{/ts}</p>
<p>{ts 1='{domain.phone}' 2='{domain.email}'}Please contact us at %1 or send email to %2 if you have questions.{/ts}</p>
</td>
</tr>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,17 @@
{ts}Email{/ts}: {$eventEmail.email}{/if}{/foreach}
{/if}

{if $contact.email}
{if '{contact.email}'}

===========================================================
{ts}Registered Email{/ts}

===========================================================
{$contact.email}
{contact.email}
{/if}

{if $register_date}
{ts}Registration Date{/ts}: {$participant.register_date|crmDate}
{/if}

{ts 1=$domain.phone 2=$domain.email}Please contact us at %1 or send email to %2 if you have questions.{/ts}
{ts 1='{domain.phone}' 2='{domain.email}'}Please contact us at %1 or send email to %2 if you have questions.{/ts}

0 comments on commit 88d97cc

Please sign in to comment.