From: Eileen McNaughton Date: Mon, 29 Nov 2021 04:03:41 +0000 (+1300) Subject: Fix tests to use form helper X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=6747724774a057368ae6ee6a1ac7308b3e88714f;p=civicrm-core.git Fix tests to use form helper --- diff --git a/tests/phpunit/CRM/Contribute/Form/ContributionTest.php b/tests/phpunit/CRM/Contribute/Form/ContributionTest.php index 9903ef744c..e2f396e31e 100644 --- a/tests/phpunit/CRM/Contribute/Form/ContributionTest.php +++ b/tests/phpunit/CRM/Contribute/Form/ContributionTest.php @@ -1157,29 +1157,28 @@ Price Field - Price Field 1 1 $ 100.00 $ 100.00 * * @throws \Exception */ - public function testReSubmitSaleTax($thousandSeparator): void { + public function testReSubmitSaleTax(string $thousandSeparator): void { $this->setCurrencySeparators($thousandSeparator); $this->enableTaxAndInvoicing(); $this->addTaxAccountToFinancialType($this->_financialTypeId); - [$form, $contribution] = $this->doInitialSubmit(); + $contribution = $this->doInitialSubmit(); $this->assertEquals(11000, $contribution['total_amount']); $this->assertEquals(1000, $contribution['tax_amount']); $this->assertEquals(11000, $contribution['net_amount']); $mut = new CiviMailUtils($this, TRUE); // Testing here if when we edit something trivial like adding a check_number tax, net, total amount stay the same: - $form->testSubmit([ + $this->submitContributionForm([ 'id' => $contribution['id'], 'tax_amount' => $contribution['tax_amount'], 'financial_type_id' => $contribution['financial_type_id'], 'receive_date' => $contribution['receive_date'], 'payment_instrument_id' => $contribution['payment_instrument_id'], - 'price_set_id' => 0, 'check_number' => 12345, 'contribution_status_id' => 1, 'is_email_receipt' => 1, 'from_email_address' => 'demo@example.com', - ], CRM_Core_Action::UPDATE); + ], $contribution['id']); $contribution = $this->callAPISuccessGetSingle('Contribution', [ 'contribution_id' => 1, @@ -1218,15 +1217,15 @@ Price Field - Price Field 1 1 $ 100.00 $ 100.00 * * @throws \Exception */ - public function testReSubmitSaleTaxAlteredAmount($thousandSeparator) { + public function testReSubmitSaleTaxAlteredAmount(string $thousandSeparator): void { $this->setCurrencySeparators($thousandSeparator); $this->enableTaxAndInvoicing(); $this->addTaxAccountToFinancialType($this->_financialTypeId); - [$form, $contribution] = $this->doInitialSubmit(); + $contribution = $this->doInitialSubmit(); $mut = new CiviMailUtils($this, TRUE); // Testing here if when we edit something trivial like adding a check_number tax, net, total amount stay the same: - $form->testSubmit([ + $this->submitContributionForm([ 'id' => $contribution['id'], 'total_amount' => $this->formatMoneyInput(20000), 'tax_amount' => $this->formatMoneyInput(2000), @@ -1238,7 +1237,7 @@ Price Field - Price Field 1 1 $ 100.00 $ 100.00 'contribution_status_id' => 1, 'is_email_receipt' => 1, 'from_email_address' => 'demo@example.com', - ], CRM_Core_Action::UPDATE); + ], $contribution['id']); $contribution = $this->callAPISuccessGetSingle('Contribution', [ 'contribution_id' => 1, @@ -1280,17 +1279,14 @@ Price Field - Price Field 1 1 $ 100.00 $ 100.00 * @throws \Exception */ protected function doInitialSubmit() { - $form = new CRM_Contribute_Form_Contribution(); - - $form->testSubmit([ + $this->submitContributionForm([ 'total_amount' => $this->formatMoneyInput(10000), 'financial_type_id' => $this->_financialTypeId, 'receive_date' => '2015-04-21 00:00:00', 'contact_id' => $this->_individualId, - 'payment_instrument_id' => array_search('Check', $this->paymentInstruments), + 'payment_instrument_id' => $this->getPaymentInstrumentID('Check'), 'contribution_status_id' => 1, - 'price_set_id' => 0, - ], CRM_Core_Action::ADD); + ]); $contribution = $this->callAPISuccessGetSingle('Contribution', [ 'contribution_id' => 1, @@ -1307,7 +1303,7 @@ Price Field - Price Field 1 1 $ 100.00 $ 100.00 $this->assertEquals(11000, $contribution['total_amount']); $this->assertEquals(1000, $contribution['tax_amount']); $this->assertEquals(11000, $contribution['net_amount']); - return [$form, $contribution]; + return $contribution; } /**