Allowing local lemonsqueezy payment skip and emulate success response
Some checks failed
linter / quality (push) Has been cancelled
tests / ci (push) Has been cancelled
tests / ui (push) Has been cancelled

This commit is contained in:
Codex Agent
2026-02-04 10:39:53 +01:00
parent a07cc9610b
commit 049c4f82b9
7 changed files with 531 additions and 5 deletions

View File

@@ -94,4 +94,46 @@ class LemonSqueezyCheckoutControllerTest extends TestCase
'coupon_code' => 'SAVE15',
]);
}
public function test_local_environment_simulates_checkout_without_api_call(): void
{
$this->app->detectEnvironment(fn () => 'local');
$this->withoutMiddleware();
$tenant = Tenant::factory()->create([
'lemonsqueezy_customer_id' => 'cus_123',
]);
$user = User::factory()->for($tenant)->create();
$package = Package::factory()->create([
'lemonsqueezy_variant_id' => 'pri_123',
'lemonsqueezy_product_id' => 'pro_123',
'price' => 120,
]);
$checkoutServiceMock = Mockery::mock(LemonSqueezyCheckoutService::class);
$checkoutServiceMock->shouldNotReceive('createCheckout');
$this->instance(LemonSqueezyCheckoutService::class, $checkoutServiceMock);
$this->be($user);
$response = $this->postJson(route('lemonsqueezy.checkout.create'), [
'package_id' => $package->id,
'accepted_terms' => true,
]);
$response->assertOk()
->assertJsonPath('simulated', true)
->assertJsonStructure([
'checkout_session_id',
'order_id',
'id',
]);
$this->assertDatabaseHas('checkout_sessions', [
'package_id' => $package->id,
'lemonsqueezy_checkout_id' => $response->json('id'),
]);
}
}