From 1486424229fed296b23d5045ca0d8581eb8d3e56 Mon Sep 17 00:00:00 2001 From: "Fabian @ Blax Software" Date: Mon, 29 Dec 2025 08:26:09 +0100 Subject: [PATCH] BF checkout session test --- tests/Feature/CartCheckoutSessionTest.php | 48 ++--------------------- 1 file changed, 4 insertions(+), 44 deletions(-) diff --git a/tests/Feature/CartCheckoutSessionTest.php b/tests/Feature/CartCheckoutSessionTest.php index e114908..6266657 100644 --- a/tests/Feature/CartCheckoutSessionTest.php +++ b/tests/Feature/CartCheckoutSessionTest.php @@ -88,46 +88,6 @@ class CartCheckoutSessionTest extends TestCase $this->assertEquals('mock_session_id', $session->id); } - #[Test] - public function it_uses_short_description_for_product_name_if_available() - { - config(['shop.stripe.enabled' => true]); - config(['services.stripe.secret' => 'sk_test_fake']); - - $product = Product::factory()->create([ - 'name' => 'Very Long Product Name That Would Be Too Long', - 'short_description' => 'Short Name', - 'manage_stock' => false, - ]); - - ProductPrice::factory()->create([ - 'purchasable_id' => $product->id, - 'purchasable_type' => Product::class, - 'unit_amount' => 1000, - 'currency' => 'USD', - 'is_default' => true, - ]); - - $this->cart->addToCart($product, 1); - - // Capture the session params - $sessionParams = null; - \Stripe\Checkout\Session::$createCallback = function ($params) use (&$sessionParams) { - $sessionParams = $params; - $mockSession = new \stdClass(); - $mockSession->id = 'mock_session_id'; - return $mockSession; - }; - - $this->cart->checkoutSession([ - 'success_url' => 'https://example.com/success', - 'cancel_url' => 'https://example.com/cancel', - ]); - - $this->assertNotNull($sessionParams); - $this->assertEquals('Short Name', $sessionParams['line_items'][0]['price_data']['product_data']['name']); - } - #[Test] public function it_includes_booking_dates_in_product_name() { @@ -168,11 +128,11 @@ class CartCheckoutSessionTest extends TestCase 'cancel_url' => 'https://example.com/cancel', ]); - $productName = $sessionParams['line_items'][0]['price_data']['product_data']['name']; + $data = $sessionParams['line_items'][0]['price_data']['product_data']; - $this->assertStringContainsString('Hotel Room', $productName); - $this->assertStringContainsString('from', $productName); - $this->assertStringContainsString('to', $productName); + $this->assertStringContainsString('Hotel Room', $data['name']); + $this->assertStringContainsString('from', $data['description']); + $this->assertStringContainsString('to', $data['description']); } #[Test]