4759b9b2ad68299d42d51b03faf81071527d99a9
[civicrm-core.git] / tests / phpunit / CRM / Pledge / Form / PledgeTest.php
1 <?php
2
3 use Civi\Api4\Email;
4
5 /**
6 * CRM_Pledge_Form_PledgeTest
7 *
8 * @group headless
9 */
10 class CRM_Pledge_Form_PledgeTest extends CiviUnitTestCase {
11
12 /**
13 * Test the post process function.
14 *
15 * @throws \API_Exception
16 * @throws \CRM_Core_Exception
17 */
18 public function testPostProcess(): void {
19 $mut = new CiviMailUtils($this);
20 $loggedInUser = $this->createLoggedInUser();
21 $this->addLocationBlockToDomain();
22 $this->swapMessageTemplateForInput('pledge_acknowledge', '{domain.name} {contact.first_name}');
23
24 $form = $this->getFormObject('CRM_Pledge_Form_Pledge', [
25 'amount' => 10,
26 'installments' => 1,
27 'contact_id' => $this->individualCreate(),
28 'is_acknowledge' => 1,
29 'start_date' => '2021-01-04',
30 'create_date' => '2021-01-04',
31 'from_email_address' => Email::get()
32 ->addWhere('contact_id', '=', $loggedInUser)
33 ->addSelect('id')->execute()->first()['id'],
34 ]);
35 $form->buildForm();
36 $form->postProcess();
37 $mut->checkAllMailLog([
38 'Default Domain Name Anthony',
39 // These strings that are in the text template, since we swapped out the html one.
40 123,
41 'fixme.domainemail@example.org',
42 'Dear Anthony,',
43 ]);
44 $mut->clearMessages();
45 $this->revertTemplateToReservedTemplate('pledge_acknowledge');
46 }
47
48 }