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:
Serreau Jovann
2026-04-01 19:16:32 +02:00
parent 25354f9052
commit 03342e8303

View File

@@ -215,10 +215,12 @@ class StripeSyncCommandTest extends TestCase
$order = $this->createPendingOrder('pi_succeeded'); $order = $this->createPendingOrder('pi_succeeded');
$this->setBuyerRepo([$order]); $this->setBuyerRepo([$order]);
$paymentIntent = new \stdClass(); $paymentIntent = \Stripe\PaymentIntent::constructFrom([
$paymentIntent->status = 'succeeded'; 'id' => 'pi_succeeded',
$paymentIntent->amount = 5000; 'status' => 'succeeded',
$paymentIntent->metadata = (object) []; 'amount' => 5000,
'metadata' => [],
]);
$this->stripeService->method('retrievePaymentIntent') $this->stripeService->method('retrievePaymentIntent')
->with('pi_succeeded') ->with('pi_succeeded')
@@ -243,10 +245,12 @@ class StripeSyncCommandTest extends TestCase
$order = $this->createPendingOrder('pi_debt'); $order = $this->createPendingOrder('pi_debt');
$this->setBuyerRepo([$order]); $this->setBuyerRepo([$order]);
$paymentIntent = new \stdClass(); $paymentIntent = \Stripe\PaymentIntent::constructFrom([
$paymentIntent->status = 'succeeded'; 'id' => 'pi_debt',
$paymentIntent->amount = 3000; 'status' => 'succeeded',
$paymentIntent->metadata = (object) ['debt_organizer_id' => '42']; 'amount' => 3000,
'metadata' => ['debt_organizer_id' => '42'],
]);
$this->stripeService->method('retrievePaymentIntent')->willReturn($paymentIntent); $this->stripeService->method('retrievePaymentIntent')->willReturn($paymentIntent);
@@ -263,8 +267,10 @@ class StripeSyncCommandTest extends TestCase
$order = $this->createPendingOrder('pi_canceled'); $order = $this->createPendingOrder('pi_canceled');
$this->setBuyerRepo([$order]); $this->setBuyerRepo([$order]);
$paymentIntent = new \stdClass(); $paymentIntent = \Stripe\PaymentIntent::constructFrom([
$paymentIntent->status = 'canceled'; 'id' => 'pi_canceled',
'status' => 'canceled',
]);
$this->stripeService->method('retrievePaymentIntent')->willReturn($paymentIntent); $this->stripeService->method('retrievePaymentIntent')->willReturn($paymentIntent);
@@ -285,9 +291,11 @@ class StripeSyncCommandTest extends TestCase
$order = $this->createPendingOrder('pi_failed'); $order = $this->createPendingOrder('pi_failed');
$this->setBuyerRepo([$order]); $this->setBuyerRepo([$order]);
$paymentIntent = new \stdClass(); $paymentIntent = \Stripe\PaymentIntent::constructFrom([
$paymentIntent->status = 'requires_payment_method'; 'id' => 'pi_failed',
$paymentIntent->last_payment_error = (object) ['message' => 'Card declined']; 'status' => 'requires_payment_method',
'last_payment_error' => ['message' => 'Card declined'],
]);
$this->stripeService->method('retrievePaymentIntent')->willReturn($paymentIntent); $this->stripeService->method('retrievePaymentIntent')->willReturn($paymentIntent);
@@ -324,8 +332,10 @@ class StripeSyncCommandTest extends TestCase
$order = $this->createPendingOrder('pi_processing'); $order = $this->createPendingOrder('pi_processing');
$this->setBuyerRepo([$order]); $this->setBuyerRepo([$order]);
$paymentIntent = new \stdClass(); $paymentIntent = \Stripe\PaymentIntent::constructFrom([
$paymentIntent->status = 'processing'; 'id' => 'pi_processing',
'status' => 'processing',
]);
$this->stripeService->method('retrievePaymentIntent')->willReturn($paymentIntent); $this->stripeService->method('retrievePaymentIntent')->willReturn($paymentIntent);
@@ -367,9 +377,11 @@ class StripeSyncCommandTest extends TestCase
$this->setBuyerRepo([$order]); $this->setBuyerRepo([$order]);
$paymentIntent = new \stdClass(); $paymentIntent = \Stripe\PaymentIntent::constructFrom([
$paymentIntent->status = 'requires_payment_method'; 'id' => 'pi_no_email',
$paymentIntent->last_payment_error = null; 'status' => 'requires_payment_method',
'last_payment_error' => null,
]);
$this->stripeService->method('retrievePaymentIntent')->willReturn($paymentIntent); $this->stripeService->method('retrievePaymentIntent')->willReturn($paymentIntent);