3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
15 * @package CiviCRM_APIv3
16 * @subpackage API_Contribution
19 class CRM_Contribute_Form_Task_EmailTest
extends CiviUnitTestCase
{
22 * Clean up after each test.
24 * @throws \CRM_Core_Exception
25 * @throws \API_Exception
27 public function tearDown(): void
{
28 $this->quickCleanUpFinancialEntities();
33 * Test that email tokens are rendered.
35 public function testEmailTokens(): void
{
36 Civi
::settings()->set('max_attachments', 0);
37 $contact1 = $this->individualCreate();
38 $contact2 = $this->individualCreate();
39 $userID = $this->createLoggedInUser();
40 Civi
::settings()->set('allow_mail_from_logged_in_contact', TRUE);
41 $this->callAPISuccess('Email', 'create', [
42 'contact_id' => $userID,
43 'email' => 'benny_jetts@example.com',
44 'signature_html' => 'Benny, Benny',
47 $contribution1 = $this->contributionCreate(['contact_id' => $contact2]);
48 $contribution2 = $this->contributionCreate(['total_amount' => 999, 'contact_id' => $contact1]);
49 $form = $this->getFormObject('CRM_Contribute_Form_Task_Email', [
52 'to' => implode(',', [
53 $contact1 . '::teresajensen-nielsen65@spamalot.co.in',
54 $contact2 . '::bob@example.com',
56 'subject' => '{contact.display_name}',
57 'text_message' => '{contribution.total_amount}',
58 'html_message' => '{domain.name}',
60 'radio_ts' => 'ts_sel',
61 'task' => CRM_Core_Task
::TASK_EMAIL
,
62 'mark_x_' . $contribution1 => 1,
63 'mark_x_' . $contribution2 => 1,
65 $form->set('cid', $contact1 . ',' . $contact2);
67 $this->assertEquals('<br/><br/>--Benny, Benny', $form->_defaultValues
['html_message']);