withoutMiddleware(EnsurePlatformSession::class); config([ 'billing.api_url' => 'https://ladill.com/api/billing', 'billing.api_key' => 'events-billing-key', 'events.pro.enabled' => true, 'events.pro.price_minor' => 4900, 'events.plans.pro.price_minor' => 4900, 'events.plans.enterprise.price_minor' => 14900, 'events.pro.period_days' => 30, 'events.pro.grace_days' => 3, 'events.free.max_live_events' => 2, 'events.free.max_tickets_per_month' => 100, ]); } private function user(): User { return User::factory()->create(['public_id' => 'usr_'.uniqid()]); } public function test_subscribe_charges_wallet_and_activates(): void { Http::fake(['*/debit' => Http::response(['id' => 1], 201)]); $user = $this->user(); $svc = app(SubscriptionService::class); [$ok] = $svc->subscribe($user); $this->assertTrue($ok); $this->assertTrue($svc->isPro($user)); Http::assertSent(fn ($r) => str_ends_with(parse_url($r->url(), PHP_URL_PATH) ?: '', '/debit') && $r['amount_minor'] === 4900 && $r['service'] === 'events'); } public function test_subscribe_enterprise_charges_wallet_and_activates(): void { Http::fake(['*/debit' => Http::response(['id' => 1], 201)]); $user = $this->user(); $svc = app(SubscriptionService::class); [$ok] = $svc->subscribeEnterprise($user); $this->assertTrue($ok); $this->assertTrue($svc->isEnterprise($user)); $sub = ProSubscription::where('user_id', $user->id)->first(); $this->assertSame('enterprise', $sub->plan); $this->assertSame(14900, $sub->price_minor); } public function test_free_user_is_gated_to_event_limit(): void { $user = $this->user(); $svc = app(SubscriptionService::class); $this->assertTrue($svc->canCreateEvent($user)); $this->assertSame(0, $svc->liveEventCount($user)); } }