From 71abc5a48aab786af7b1f6b6f927f95ad8f2eeb3 Mon Sep 17 00:00:00 2001 From: eileen Date: Sat, 6 Apr 2024 11:58:25 +1300 Subject: [PATCH] Fix test to use full form flow --- .../CRM/Contribute/Form/ContributionTest.php | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/tests/phpunit/CRM/Contribute/Form/ContributionTest.php b/tests/phpunit/CRM/Contribute/Form/ContributionTest.php index 432f92f69174..c355c101ad19 100644 --- a/tests/phpunit/CRM/Contribute/Form/ContributionTest.php +++ b/tests/phpunit/CRM/Contribute/Form/ContributionTest.php @@ -622,12 +622,9 @@ public function testEmailReceiptOnPayLater(bool $isTaxed): void { $params['price_' . $priceFieldID] = [$id => 1]; } } - $form = $this->getContributionForm($params); - $mailUtil = new CiviMailUtils($this, TRUE); - $form->_priceSet = current(CRM_Price_BAO_PriceSet::getSetDetail($priceSetID)); - $form->postProcess(); + $this->submitContributionForm($params); if ($isTaxed) { - $mailUtil->checkMailLog([ + $this->assertMailSentContainingString( 'Dear Anthony, =========================================================== @@ -648,10 +645,10 @@ public function testEmailReceiptOnPayLater(bool $isTaxed): void { Total Amount : $110.00 Contribution Date: ' . date('m/d/Y') . ' Receipt Date: ' . date('m/d/Y'), - ]); + ); } else { - $mailUtil->checkMailLog([ + $this->assertMailSentContainingString( 'Dear Anthony, =========================================================== @@ -669,8 +666,9 @@ public function testEmailReceiptOnPayLater(bool $isTaxed): void { Total Amount : $100.00 Contribution Date: ' . date('m/d/Y') . ' Receipt Date: ' . date('m/d/Y'), - ], - ['Amount before Tax', 'Tax Amount']); + ); + $this->assertMailSentNotContainingString('Amount before Tax'); + $this->assertMailSentNotContainingString('Tax Amount'); } } @@ -2108,6 +2106,7 @@ public function testContributionFormRuleDuplicateTrxn(): void { protected function getContributionForm(array $formValues): CRM_Contribute_Form_Contribution { /** @var CRM_Contribute_Form_Contribution $form */ $form = $this->getFormObject('CRM_Contribute_Form_Contribution', $formValues); + $form->preProcess(); $form->buildForm(); return $form; }