Tests and template contributions
Many of the tests in this extension assume that a ContributionRecur
does not have a related Contribution
. But that's not how CiviCRM core works currently (see dev/financial#6 (closed)).
-
CRM_Contribute_BAO_ContributionRecur::ensureTemplateContributionExists()
will return NULL if there is no related contribution and will create a "template" contribution from an existing related contribution if found. -
CRM_Contribute_BAO_ContributionRecur::getTemplateContribution()
will return a template contribution if found, otherwise will fallback to returning the latest related contribution.
I replaced \Civi\UpdaterecurWorker\updateRecurAndTemplateContribution
with a call to my API4 action \Civi\Api4\ContributionRecur::updateAmountOnRecurMJW()
and most of the test failures are because of this difference (ie. the API call expects that there will always be an existing contribution like CiviCRM core does.
At one stage the goal was to allow core to create a ContributionRecur without a contribution but we're not there yet.