Files
fotospiel-app/tests/Feature/Api/Tenant/BillingTransactionsTest.php
Codex Agent 10c99de1e2
Some checks failed
linter / quality (push) Has been cancelled
tests / ci (push) Has been cancelled
tests / ui (push) Has been cancelled
Migrate billing from Paddle to Lemon Squeezy
2026-02-03 10:59:54 +01:00

51 lines
1.5 KiB
PHP

<?php
namespace Tests\Feature\Api\Tenant;
use Illuminate\Http\Client\Request;
use Illuminate\Support\Facades\Http;
use Tests\Feature\Tenant\TenantTestCase;
class BillingTransactionsTest extends TenantTestCase
{
public function test_transactions_endpoint_creates_missing_lemonsqueezy_customer_id(): void
{
Http::fake(function (Request $request) {
$path = parse_url($request->url(), PHP_URL_PATH);
if ($path === '/customers' && $request->method() === 'POST') {
return Http::response([
'data' => ['id' => 'cus_456'],
], 200);
}
if ($path === '/transactions' && $request->method() === 'GET') {
return Http::response([
'data' => [],
'meta' => [
'pagination' => [
'next' => null,
'previous' => null,
'has_more' => false,
],
],
], 200);
}
return Http::response([], 404);
});
$this->tenant->forceFill(['lemonsqueezy_customer_id' => null])->save();
$response = $this->authenticatedRequest('GET', '/api/v1/tenant/billing/transactions');
$response->assertOk();
$response->assertJsonPath('data', []);
$this->assertDatabaseHas('tenants', [
'id' => $this->tenant->id,
'lemonsqueezy_customer_id' => 'cus_456',
]);
}
}