Skip to content
Snippets Groups Projects
Commit 3bca4150 authored by mattwire's avatar mattwire
Browse files

Fix IPN tests

parent bea412dd
No related branches found
No related tags found
No related merge requests found
...@@ -181,7 +181,7 @@ abstract class CRM_Stripe_BaseTest extends \PHPUnit\Framework\TestCase implement ...@@ -181,7 +181,7 @@ abstract class CRM_Stripe_BaseTest extends \PHPUnit\Framework\TestCase implement
if (array_key_exists('trxn_id', $ret)) { if (array_key_exists('trxn_id', $ret)) {
$this->trxn_id = $ret['trxn_id']; $this->trxn_id = $ret['trxn_id'];
$contribution = new CRM_Contribute_BAO_Contribution(); $contribution = new CRM_Contribute_BAO_Contribution();
$contribution->id = $params['contribution_id'] ?? $params['contributionID']; $contribution->id = $params['contributionID'];
$contribution->trxn_id = $ret['trxn_id']; $contribution->trxn_id = $ret['trxn_id'];
$contribution->save(); $contribution->save();
} }
......
...@@ -831,9 +831,24 @@ class CRM_Stripe_IpnTest extends CRM_Stripe_BaseTest { ...@@ -831,9 +831,24 @@ class CRM_Stripe_IpnTest extends CRM_Stripe_BaseTest {
['status', 'succeeded'], ['status', 'succeeded'],
['balance_transaction', 'txn_mock'], ['balance_transaction', 'txn_mock'],
])); ]));
$mockChargesCollection = new \Stripe\Collection(); $mockChargesCollection = new \Stripe\Collection();
$mockChargesCollection->data = [$mockCharge]; $mockChargesCollection->data = [$mockCharge];
$mockCharge = new PropertySpy('Charge', [
'id' => 'ch_mock',
'object' => 'charge',
'captured' => TRUE,
'status' => 'succeeded',
'balance_transaction' => 'txn_mock',
'invoice' => 'in_mock'
]);
$stripeClient->charges = $this->createMock('Stripe\\Service\\ChargeService');
$stripeClient->charges
->method('retrieve')
->with($this->equalTo('ch_mock'))
->willReturn($mockCharge);
$mockPaymentIntent = $this->createMock('Stripe\\PaymentIntent'); $mockPaymentIntent = $this->createMock('Stripe\\PaymentIntent');
$mockPaymentIntent $mockPaymentIntent
->method('__get') ->method('__get')
...@@ -907,12 +922,6 @@ class CRM_Stripe_IpnTest extends CRM_Stripe_BaseTest { ...@@ -907,12 +922,6 @@ class CRM_Stripe_IpnTest extends CRM_Stripe_BaseTest {
->willReturn(['data' => $mockInvoice]); ->willReturn(['data' => $mockInvoice]);
*/ */
$stripeClient->charges = $this->createMock('Stripe\\Service\\ChargeService');
$stripeClient->charges
->method('retrieve')
->with($this->equalTo('ch_mock'))
->willReturn($mockCharge);
// Setup a recurring contribution for $this->total per month. // Setup a recurring contribution for $this->total per month.
$this->setupRecurringTransaction(); $this->setupRecurringTransaction();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment