-
-
Notifications
You must be signed in to change notification settings - Fork 824
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
dev/financial#6 Use template contribution for Contribution.repeattransaction #22487
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2523,6 +2523,47 @@ public function testRepeatTransactionTestRecurId() { | |
$this->assertEquals($contributionRecur['values'][1]['is_test'], $repeatedContribution['values'][2]['is_test']); | ||
} | ||
|
||
/** | ||
* Test repeat contribution accepts recur_id instead of | ||
* original_contribution_id. | ||
* | ||
* @throws \CRM_Core_Exception | ||
*/ | ||
public function testRepeatTransactionPreviousContributionRefunded(): void { | ||
$contributionRecur = $this->callAPISuccess('contribution_recur', 'create', [ | ||
'contact_id' => $this->_individualId, | ||
'installments' => '12', | ||
'frequency_interval' => '1', | ||
'amount' => '100', | ||
'contribution_status_id' => 1, | ||
'start_date' => '2012-01-01 00:00:00', | ||
'currency' => 'USD', | ||
'frequency_unit' => 'month', | ||
'payment_processor_id' => $this->paymentProcessorID, | ||
]); | ||
$this->callAPISuccess('contribution', 'create', array_merge( | ||
$this->_params, | ||
[ | ||
'contribution_recur_id' => $contributionRecur['id'], | ||
'contribution_status_id' => 'Refunded', | ||
] | ||
) | ||
); | ||
|
||
$this->callAPISuccess('contribution', 'repeattransaction', [ | ||
'contribution_recur_id' => $contributionRecur['id'], | ||
'trxn_id' => 1234, | ||
]); | ||
$contributions = $this->callAPISuccess('contribution', 'get', [ | ||
'contribution_recur_id' => $contributionRecur['id'], | ||
'sequential' => 1, | ||
]); | ||
// We should have contribution 0 in "Refunded" status and contribution 1 in "Pending" status | ||
$this->assertEquals(2, $contributions['count']); | ||
$this->assertEquals(7, $contributions['values'][0]['contribution_status_id']); | ||
$this->assertEquals(2, $contributions['values'][1]['contribution_status_id']); | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @eileenmcnaughton @mattwire I am happy with the logic, but I am not sure moving forward, are we relying on APIv4 to do CRUD operations on new unit tests? if it doesn't matter unless the UT captures the fix/change accurately then I am ok here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @monishdeb I think you are saying 'would this be better if we were using apiv4 instead of 3 in the tests. I guess we are moving that way - but we are not so far down the track I'm alarmed at adding new tests that use apiv3 - in this case, however, I think v4 would be better on the final get because it would make it easy to check contribution_status_id:name rather than the hard-coded '2' & '7' There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @eileenmcnaughton @monishdeb I agree with preferring to use API4 but I'm not sure I understand fully how we would implement it for the tests? We can set There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mattwire generally I just call the v4 api direct in the tests (unless specifically testing apiv3 or both 3 & 4) - the |
||
/** | ||
* CRM-19945 Tests that Contribute.repeattransaction renews a membership when contribution status=Completed | ||
* | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you change to
API_Exception
to make it APIv4 friendly tooThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I think within apiv3 this is correct.
API_Exception is a bit of a pain in a way - ideally we could catch 'all CiviCRM extensions' with one catch type but API_Exception doesn't extend any other CiviCRM exception types - I'm guessing that was before it was handed over to CT @colemanw ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@monishdeb This code is within an API3 function so it is unlikely to ever be called by API4? There is quite a bit within the function which would probably be cleaned up before creating a "repeattransaction" for API4 - see eg. #22488 for a start.