From 03342e8303891caf19db5bd3d41fe55d1db74b21 Mon Sep 17 00:00:00 2001 From: Serreau Jovann Date: Wed, 1 Apr 2026 19:16:32 +0200 Subject: [PATCH] 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) --- tests/Command/StripeSyncCommandTest.php | 48 +++++++++++++++---------- 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/tests/Command/StripeSyncCommandTest.php b/tests/Command/StripeSyncCommandTest.php index 7234026..4803627 100644 --- a/tests/Command/StripeSyncCommandTest.php +++ b/tests/Command/StripeSyncCommandTest.php @@ -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);