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

[REF] IPN - move unshared chunk of code out of shared function #18600

Merged
merged 1 commit into from
Sep 28, 2020

Conversation

eileenmcnaughton
Copy link
Contributor

Overview

[REF] IPN - move unshared chunk of code out of shared function

Before

We are passing variables into recur simply to do this processing - but it could be done in the calling function & we could stop constructing arrays just to call it

Also a couple of unused variables

Screen Shot 2020-09-26 at 9 43 59 AM

After

Closer to getting rid of $objects

Technical Details

We are passing a lot of variables into recur (& going to a lot of work to construct them) when they are not
actually processed in a common way - returning them to the calling functions makes it clear we are
a skip & a jump from not needing to instantiate objects at all

Comments

Good test cover in CRM_Core_Payment_AuthorizeNetIPNTest

This is part of the completeOrder cleanup - now that we are not passing paymentProcessor object through my definition of 'done' for this round of work is to clean up / remove how that object is loaded in the IPN functions that call completeOrder

@civibot
Copy link

civibot bot commented Sep 25, 2020

(Standard links)

@civibot civibot bot added the master label Sep 25, 2020
@eileenmcnaughton
Copy link
Contributor Author

Well that confirms the test cover - will check

Stacktrace
CRM_Core_Payment_AuthorizeNetIPNTest::testIPNPaymentMembershipRecurSuccess
Failed asserting that '4' matches expected 1.

/home/jenkins/bknix-dfl/build/core-18600-8sidk/web/sites/all/modules/civicrm/tests/phpunit/CRM/Core/Payment/AuthorizeNetIPNTest.php:240
/home/jenkins/bknix-dfl/build/core-18600-8sidk/web/sites/all/modules/civicrm/tests/phpunit/CiviTest/CiviUnitTestCase.php:226
/home/jenkins/bknix-dfl/extern/phpunit7/phpunit7.phar:615

We are passing a lot of variables into recur (& going to a lot of work to construct them) when they are not
actually processed in a common way - returning them to the calling functions makes it clear we are
a skip & a jump from not needing to instantiate objects at all
@eileenmcnaughton
Copy link
Contributor Author

@mattwire on working on this cleanup I hit a test fail where it turned out

  1. something I did wasn't quite grabbing payment_instrument_id and
  2. the code in completeOrder to calculate it wasn't kicking in due to it looking somewhere where it wasn't - probably for the same reason -

But - I think fixing the code in completeOrder to use our calculated variable makes more sense than doing it on the IPN class anyway - with this change 'relatedObjects' is no longer accessed!

$contribution->contribution_recur_id = $ids['contributionRecur'];
$contribution->receive_date = $input['receive_date'];
$contribution->currency = $objects['contribution']->currency;
$contribution->payment_instrument_id = $objects['contribution']->payment_instrument_id;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Due to the test fail I didn't copy this ^^ line over & instead fixed completeOrder to calculate it

@mattwire
Copy link
Contributor

@eileenmcnaughton Are the changes in BAO/Contribution independent to the authorizenetIPN changes or do they both need merging at the same time? I'm not so comfortable reviewing the authorizenetipn code as I don't use it and am not familiar with the level of test coverage on it.

@eileenmcnaughton
Copy link
Contributor Author

@mattwire so the test cover is in AuthorizeNetIPNTest & it's pretty thorough. The A.net part needs the other part but I think if you open up the file you can see it's just code being moved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants