From 24cb6b018fbd0eaeb3f132167d4216f1afcc47e4 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Mon, 20 Dec 2021 10:56:31 +1300 Subject: [PATCH] dev/core#567 Add test shell --- tests/phpunit/api/v3/ContributionPageTest.php | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/tests/phpunit/api/v3/ContributionPageTest.php b/tests/phpunit/api/v3/ContributionPageTest.php index 596354fc4b66..eabfc954588f 100644 --- a/tests/phpunit/api/v3/ContributionPageTest.php +++ b/tests/phpunit/api/v3/ContributionPageTest.php @@ -1081,6 +1081,9 @@ public function testSubmitMembershipPriceSetPaymentPaymentProcessorSeparatePayme $this->setUpMembershipContributionPage(TRUE); $dummyPP = Civi\Payment\System::singleton()->getByProcessor($this->_paymentProcessor); $dummyPP->setDoDirectPaymentResult(['payment_status_id' => 1, 'trxn_id' => 'create_first_success']); + // Set Hook to check contributionRecurID is set + $this->hookClass->setHook('civicrm_alterPaymentProcessorParams', [$this, 'hookCheckRecurID']); + $submitParams = array_merge($this->getSubmitParamsContributionPlusMembership(TRUE), [ 'is_recur' => 1, 'auto_renew' => 1, @@ -1089,19 +1092,32 @@ public function testSubmitMembershipPriceSetPaymentPaymentProcessorSeparatePayme ]); $this->callAPIAndDocument('ContributionPage', 'submit', $submitParams, __FUNCTION__, __FILE__, 'submit contribution page'); - $contribution = $this->callAPISuccess('contribution', 'get', [ + $contributions = $this->callAPISuccess('contribution', 'get', [ 'contribution_page_id' => $this->_ids['contribution_page'], 'contribution_status_id' => 1, - ]); + ])['values']; - $this->assertEquals(2, $contribution['count']); + $this->assertCount(2, $contributions); + + // Check the recurring contribution is linked to the membership payment. $membershipPayment = $this->callAPISuccess('membership_payment', 'getsingle', []); $this->callAPISuccessGetSingle('membership', ['id' => $membershipPayment['membership_id']]); - $this->assertNotEmpty($contribution['values'][$membershipPayment['contribution_id']]['contribution_recur_id']); + $this->assertNotEmpty($contributions[$membershipPayment['contribution_id']]['contribution_recur_id']); $this->callAPISuccess('ContributionRecur', 'getsingle'); } /** + * Implements hook_civicrm_alterPaymentProcessorParams(). + * + * @throws CRM_Core_Exception + * @noinspection PhpUnusedParameterInspection + */ + public function hookCheckRecurID($paymentObj, $rawParams, $cookedParams): void { + // @todo - fix https://lab.civicrm.org/dev/core/-/issues/567 by testing for correct passing of + // contributionRecurID. + } + + /** * Test submit recurring membership with delayed confirmation (Authorize.net * style) * - we process 2 membership transactions against with a recurring