convert to trait
[civicrm-core.git] / tests / phpunit / CRM / Contribute / Form / UpdateSubscriptionTest.php
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 */
15 class CRM_Contribute_Form_UpdateSubscriptionTest extends CiviUnitTestCase {
16
17 use CRMTraits_Contribute_RecurFormsTrait;
18
19 /**
20 * Test the mail sent on update.
21 *
22 * @throws \CRM_Core_Exception|\API_Exception
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',
49 'From: "Bob" <bob@example.org>',
50 'To: Anthony Anderson <anthony_anderson@civicrm.org>',
51 'Subject: Recurring Contribution Update Notification - Mr. Anthony Anderson II',
52 'Return-Path: bob@example.org',
53 'Dear Anthony,',
54 'Your recurring contribution has been updated as requested:',
55 'Recurring contribution is for $10.00, every 1 month(s) for 12 installments.',
56 'If you have questions please contact us at "Bob" <bob@example.org>.',
57 ];
58 }
59
60 }