Fix StripeSyncCommandTest: use Stripe\PaymentIntent::constructFrom instead of stdClass
PHPUnit strict mock validation rejects stdClass as return value for retrievePaymentIntent which declares Stripe\PaymentIntent return type. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -215,10 +215,12 @@ class StripeSyncCommandTest extends TestCase
|
||||
$order = $this->createPendingOrder('pi_succeeded');
|
||||
$this->setBuyerRepo([$order]);
|
||||
|
||||
$paymentIntent = new \stdClass();
|
||||
$paymentIntent->status = 'succeeded';
|
||||
$paymentIntent->amount = 5000;
|
||||
$paymentIntent->metadata = (object) [];
|
||||
$paymentIntent = \Stripe\PaymentIntent::constructFrom([
|
||||
'id' => 'pi_succeeded',
|
||||
'status' => 'succeeded',
|
||||
'amount' => 5000,
|
||||
'metadata' => [],
|
||||
]);
|
||||
|
||||
$this->stripeService->method('retrievePaymentIntent')
|
||||
->with('pi_succeeded')
|
||||
@@ -243,10 +245,12 @@ class StripeSyncCommandTest extends TestCase
|
||||
$order = $this->createPendingOrder('pi_debt');
|
||||
$this->setBuyerRepo([$order]);
|
||||
|
||||
$paymentIntent = new \stdClass();
|
||||
$paymentIntent->status = 'succeeded';
|
||||
$paymentIntent->amount = 3000;
|
||||
$paymentIntent->metadata = (object) ['debt_organizer_id' => '42'];
|
||||
$paymentIntent = \Stripe\PaymentIntent::constructFrom([
|
||||
'id' => 'pi_debt',
|
||||
'status' => 'succeeded',
|
||||
'amount' => 3000,
|
||||
'metadata' => ['debt_organizer_id' => '42'],
|
||||
]);
|
||||
|
||||
$this->stripeService->method('retrievePaymentIntent')->willReturn($paymentIntent);
|
||||
|
||||
@@ -263,8 +267,10 @@ class StripeSyncCommandTest extends TestCase
|
||||
$order = $this->createPendingOrder('pi_canceled');
|
||||
$this->setBuyerRepo([$order]);
|
||||
|
||||
$paymentIntent = new \stdClass();
|
||||
$paymentIntent->status = 'canceled';
|
||||
$paymentIntent = \Stripe\PaymentIntent::constructFrom([
|
||||
'id' => 'pi_canceled',
|
||||
'status' => 'canceled',
|
||||
]);
|
||||
|
||||
$this->stripeService->method('retrievePaymentIntent')->willReturn($paymentIntent);
|
||||
|
||||
@@ -285,9 +291,11 @@ class StripeSyncCommandTest extends TestCase
|
||||
$order = $this->createPendingOrder('pi_failed');
|
||||
$this->setBuyerRepo([$order]);
|
||||
|
||||
$paymentIntent = new \stdClass();
|
||||
$paymentIntent->status = 'requires_payment_method';
|
||||
$paymentIntent->last_payment_error = (object) ['message' => 'Card declined'];
|
||||
$paymentIntent = \Stripe\PaymentIntent::constructFrom([
|
||||
'id' => 'pi_failed',
|
||||
'status' => 'requires_payment_method',
|
||||
'last_payment_error' => ['message' => 'Card declined'],
|
||||
]);
|
||||
|
||||
$this->stripeService->method('retrievePaymentIntent')->willReturn($paymentIntent);
|
||||
|
||||
@@ -324,8 +332,10 @@ class StripeSyncCommandTest extends TestCase
|
||||
$order = $this->createPendingOrder('pi_processing');
|
||||
$this->setBuyerRepo([$order]);
|
||||
|
||||
$paymentIntent = new \stdClass();
|
||||
$paymentIntent->status = 'processing';
|
||||
$paymentIntent = \Stripe\PaymentIntent::constructFrom([
|
||||
'id' => 'pi_processing',
|
||||
'status' => 'processing',
|
||||
]);
|
||||
|
||||
$this->stripeService->method('retrievePaymentIntent')->willReturn($paymentIntent);
|
||||
|
||||
@@ -367,9 +377,11 @@ class StripeSyncCommandTest extends TestCase
|
||||
|
||||
$this->setBuyerRepo([$order]);
|
||||
|
||||
$paymentIntent = new \stdClass();
|
||||
$paymentIntent->status = 'requires_payment_method';
|
||||
$paymentIntent->last_payment_error = null;
|
||||
$paymentIntent = \Stripe\PaymentIntent::constructFrom([
|
||||
'id' => 'pi_no_email',
|
||||
'status' => 'requires_payment_method',
|
||||
'last_payment_error' => null,
|
||||
]);
|
||||
|
||||
$this->stripeService->method('retrievePaymentIntent')->willReturn($paymentIntent);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user