Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tax fixes in unit test #20390

Merged
merged 1 commit into from
May 24, 2021
Merged

Conversation

eileenmcnaughton
Copy link
Contributor

@eileenmcnaughton eileenmcnaughton commented May 24, 2021

Overview

Tax fixes in unit test

When this->isValidateFinancialsOnPostAssert is true the
test class checks that line items and payments are valid before tear down.

I'm trying to enable this for this class. However, there are some issues
that I have found fixes for (and at least 1 I'm still working on)

  • some tests try to set tax_amount when it is not enabled
    which is invalid - removed
  • one test tries to use chaining in a way that
    we know is not going to do a job of creating the entities
    as it adds the payment before the line items. I switched
    this to create a pending payment which doesn't alter the
    thing under test & brings it closer to the
    recommended flow
  • one test is deliberately invalid - I marked it as
    not eligible for the validation
  • the price set id was not being passed to the Confirm->submit
    function (accessed by tests, mostly via the ContributionPage.submit
    api) - I added functionality to retrieve it

Before

Taxes affected by the above fail when we increase financial validation

After

Those tests pass

Technical Details

Some or possibly all of the failures in #20357 relate to issues with the tests

Comments

@civibot
Copy link

civibot bot commented May 24, 2021

(Standard links)

@civibot civibot bot added the master label May 24, 2021
@@ -549,7 +558,7 @@ public function testCreateContributionChainedLineItems() {
'trxn_id' => 12345,
'invoice_id' => 67890,
'source' => 'SSF',
'contribution_status_id' => 1,
'contribution_status_id' => 'Pending',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switch to pending to create a valid payment flow - does not affect what is being tested (which should never be done in code - use the order api)

@eileenmcnaughton eileenmcnaughton force-pushed the tax2 branch 2 times, most recently from f3065d1 to 41723dd Compare May 24, 2021 03:48
@@ -2060,6 +2062,7 @@ public static function submit($params) {
$paramsProcessedForForm = $form->_params = self::getFormParams($params['id'], $params);
Copy link
Contributor Author

@eileenmcnaughton eileenmcnaughton May 24, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function (submit()) is used primary by unit tests via the ContributionPage.submit api. AFAIK that api is only used by a barage of tests but there might be some live usages in the ether - I would expect the test cover to be greater than any possible 'wild usage'

@monishdeb
Copy link
Member

Reviewed code, looks good. Tested on local.

@seamuslee001
Copy link
Contributor

Test fails relate @eileenmcnaughton

@eileenmcnaughton eileenmcnaughton force-pushed the tax2 branch 4 times, most recently from 265eaf8 to 8738175 Compare May 24, 2021 09:29
When this->isValidateFinancialsOnPostAssert is true the
test class checks that line items and payments are valid.

I'm trying to enable this for this class. However, there are some issues
that I have found fixes for (and at least 1 I'm still working on)
- some tests try to set tax_amount when it is not enabled
which is invalid - removed
- one test tries to use chaining in a way that
we know is not going to do a job of creating the entities
as it adds the payment before the line items. I switched
this to create a pending payment which doesn't alter the
thing under test & brings it closer to the
recommended flow
- one test is deliberately invalid - I marked it as
not eligible for the validation
- the price set id was not being passed to the Confirm->submit
function (accessed by tests, mostly via the ContributionPage.submit
api) - I added functionality to retrieve it
@eileenmcnaughton eileenmcnaughton merged commit fd917a9 into civicrm:master May 24, 2021
@eileenmcnaughton eileenmcnaughton deleted the tax2 branch May 24, 2021 21:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants