Skip to content

Commit

Permalink
Merge pull request #10977 from jitendrapurohit/CRM-21160
Browse files Browse the repository at this point in the history
CRM-21160 - Make event_type_id available in event message templates
  • Loading branch information
eileenmcnaughton authored Sep 24, 2017
2 parents f70263e + 8742774 commit 4ac8861
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CRM/Event/Form/Participant.php
Original file line number Diff line number Diff line change
Expand Up @@ -1532,7 +1532,7 @@ public function submit($params) {
$this->assign('module', 'Event Registration');
//use of the message template below requires variables in different format
$event = $events = array();
$returnProperties = array('fee_label', 'start_date', 'end_date', 'is_show_location', 'title');
$returnProperties = array('event_type_id', 'fee_label', 'start_date', 'end_date', 'is_show_location', 'title');

//get all event details.
CRM_Core_DAO::commonRetrieveAll('CRM_Event_DAO_Event', 'id', $params['event_id'], $events, $returnProperties);
Expand Down
42 changes: 42 additions & 0 deletions tests/phpunit/CRM/Event/Form/ParticipantTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ public function testSubmitWithPayment() {
$form->_values['fee'] = array();
$form->_isPaidEvent = TRUE;
$form->_quickConfig = TRUE;
$form->_fromEmails = array(
'from_email_id' => array('abc@gmail.com' => 1),
);
$form->submit(array(
'register_date' => 'now',
'register_date_time' => '00:00:00',
Expand Down Expand Up @@ -84,6 +87,9 @@ public function testSubmitWithPayment() {
'amount_level' => 'Too much',
'fee_amount' => 55,
'total_amount' => 55,
'from_email_address' => 'abc@gmail.com',
'send_receipt' => 1,
'receipt_text' => '',
));
$participants = $this->callAPISuccess('Participant', 'get', array());
$this->assertEquals(1, $participants['count']);
Expand All @@ -92,4 +98,40 @@ public function testSubmitWithPayment() {
$this->assertEquals('Debit Card', $contribution['payment_instrument']);
}

/**
* Test offline participant mail.
*/
public function testParticipantOfflineReceipt() {
$mut = new CiviMailUtils($this, TRUE);

//Get workflow id of event_offline receipt.
$workflowId = $this->callAPISuccess('OptionValue', 'get', array(
'return' => array("id"),
'option_group_id' => "msg_tpl_workflow_event",
'name' => "event_offline_receipt",
));

//Modify html to contain event_type_id token.
$result = $this->callAPISuccess('MessageTemplate', 'get', array(
'sequential' => 1,
'return' => array("id", "msg_html"),
'workflow_id' => $workflowId['id'],
'is_default' => 1,
));
$oldMsg = $result['values'][0]['msg_html'];
$pos = strpos($oldMsg, 'Please print this confirmation');
$newMsg = substr_replace($oldMsg, '<p>Test event type - {$event.event_type_id}</p>', $pos, 0);
$this->callAPISuccess('MessageTemplate', 'create', array(
'id' => $result['id'],
'msg_html' => $newMsg,
));

$this->testSubmitWithPayment();
//Check if type is correctly populated in mails.
$mail = $mut->checkMailLog(array(
'<p>Test event type - 1</p>',
)
);
}

}

0 comments on commit 4ac8861

Please sign in to comment.