convert to trait
[civicrm-core.git] / tests / phpunit / CRM / Contribute / Form / UpdateSubscriptionTest.php
CommitLineData
91b773bf
EM
1<?php
2/*
3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
5 | |
6 | Use of this source code is governed by the AGPL license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
10 */
11
12/**
13 * Class CRM_Contribute_Form_UpdateSubscriptionTest
14 */
9bb5c4bd 15class CRM_Contribute_Form_UpdateSubscriptionTest extends CiviUnitTestCase {
16
17 use CRMTraits_Contribute_RecurFormsTrait;
91b773bf
EM
18
19 /**
20 * Test the mail sent on update.
21 *
8159df5f 22 * @throws \CRM_Core_Exception|\API_Exception
91b773bf
EM
23 */
24 public function testMail(): void {
25 $mut = new CiviMailUtils($this, TRUE);
26 $this->addContribution();
27 /* @var CRM_Contribute_Form_UpdateSubscription $form */
28 $form = $this->getFormObject('CRM_Contribute_Form_UpdateSubscription', ['is_notify' => TRUE]);
29 $form->set('crid', $this->getContributionRecurID());
30 $form->buildForm();
31 try {
32 $form->postProcess();
33 }
34 catch (CRM_Core_Exception_PrematureExitException $e) {
35 $mut->checkMailLog($this->getExpectedMailStrings());
36 return;
37 }
38 $this->fail('should not be reachable');
39 }
40
41 /**
42 * Get the strings to check for.
43 *
44 * @return string[]
45 */
46 public function getExpectedMailStrings(): array {
47 return [
48 'MIME-Version: 1.0',
8159df5f 49 'From: "Bob" <bob@example.org>',
91b773bf
EM
50 'To: Anthony Anderson <anthony_anderson@civicrm.org>',
51 'Subject: Recurring Contribution Update Notification - Mr. Anthony Anderson II',
8159df5f 52 'Return-Path: bob@example.org',
91b773bf
EM
53 'Dear Anthony,',
54 'Your recurring contribution has been updated as requested:',
f70a513f 55 'Recurring contribution is for $10.00, every 1 month(s) for 12 installments.',
8159df5f 56 'If you have questions please contact us at "Bob" <bob@example.org>.',
91b773bf
EM
57 ];
58 }
59
91b773bf 60}