Commit | Line | Data |
---|---|---|
ce262f18 EM |
1 | <?php |
2 | ||
3 | use Civi\Api4\Email; | |
4 | ||
5 | /** | |
6 | * Include dataProvider for tests | |
7 | * @group headless | |
8 | */ | |
9 | class CRM_Pledge_Form_PledgeTest extends CiviUnitTestCase { | |
10 | ||
11 | /** | |
12 | * Test the post process function. | |
13 | * | |
14 | * @throws \API_Exception | |
15 | * @throws \CRM_Core_Exception | |
16 | */ | |
17 | public function testPostProcess(): void { | |
18 | $mut = new CiviMailUtils($this); | |
19 | $loggedInUser = $this->createLoggedInUser(); | |
aa7dd30f | 20 | $this->addLocationBlockToDomain(); |
ce262f18 EM |
21 | $this->swapMessageTemplateForInput('pledge_acknowledge', '{domain.name} {contact.first_name}'); |
22 | ||
23 | $form = $this->getFormObject('CRM_Pledge_Form_Pledge', [ | |
24 | 'amount' => 10, | |
25 | 'installments' => 1, | |
26 | 'contact_id' => $this->individualCreate(), | |
27 | 'is_acknowledge' => 1, | |
aa7dd30f EM |
28 | 'start_date' => '2021-01-04', |
29 | 'create_date' => '2021-01-04', | |
ce262f18 EM |
30 | 'from_email_address' => Email::get() |
31 | ->addWhere('contact_id', '=', $loggedInUser) | |
32 | ->addSelect('id')->execute()->first()['id'], | |
33 | ]); | |
34 | $form->buildForm(); | |
35 | $form->postProcess(); | |
aa7dd30f EM |
36 | $mut->checkAllMailLog([ |
37 | 'Default Domain Name Anthony', | |
38 | 123, | |
39 | 'fixme.domainemail@example.org', | |
40 | '<p>Dear Anthony,</p>', | |
41 | ]); | |
ce262f18 EM |
42 | $mut->clearMessages(); |
43 | $this->revertTemplateToReservedTemplate('pledge_acknowledge'); | |
44 | } | |
45 | ||
46 | } |