set('lemonsqueezy.base_url', 'https://lemonsqueezy.test'); $package = Package::factory()->reseller()->create(); TenantPackage::factory()->create([ 'tenant_id' => $this->tenant->id, 'package_id' => $package->id, 'lemonsqueezy_subscription_id' => 'sub_123', 'active' => true, ]); Http::fake([ 'https://lemonsqueezy.test/subscriptions/sub_123' => Http::response([ 'data' => [ 'id' => 'sub_123', 'attributes' => [ 'urls' => [ 'customer_portal' => 'https://portal.example/overview', ], ], ], ], 200), ]); $response = $this->authenticatedRequest('POST', '/api/v1/tenant/billing/portal'); $response->assertOk(); $response->assertJsonPath('url', 'https://portal.example/overview'); } public function test_portal_returns_404_when_no_active_subscription(): void { $response = $this->authenticatedRequest('POST', '/api/v1/tenant/billing/portal'); $response->assertNotFound(); } }