app(HttpStripeClient::class)->createPrice('prod_x', 100, 'EUR', 'month')) ->toThrow(StripeNotConfigured::class); }); it('does not create an order when the key is missing', function () { OperatingMode::set(OperatingMode::Test); $customer = Customer::factory()->create(); // A portal user is matched to its customer by email, not by a foreign // key — see the existing Billing feature tests (e.g. StorageAllowanceTest). $user = User::factory()->create(['email' => $customer->email]); // 'team' is a real, sellable plan (seeded by the plan-catalogue migration) // that ranks above the customer's implicit 'start' plan — a genuine // upgrade the purchase() guards would otherwise accept. A made-up key // would be refused by the existing plan-validity check regardless of // whether the Stripe guard works at all, and would prove nothing. // // assertHasErrors(), not assertHasNoErrors(): the guard reports through // addError('purchase', …) — the same page-blocking pattern order.blade.php // already uses for "cannot proceed" — and Livewire's test harness folds // any non-empty error bag into the call's result. Asserting no errors // here would contradict the very behaviour this test exists to prove. Livewire::actingAs($user) ->test(Billing::class) ->call('purchase', 'upgrade', 'team') ->assertHasErrors('purchase'); // Der Punkt: nach der Zahlung wäre es zu spät. Es darf gar nichts entstehen. expect(Order::count())->toBe(0); }); it('says why instead of failing silently', function () { OperatingMode::set(OperatingMode::Test); $customer = Customer::factory()->create(); $user = User::factory()->create(['email' => $customer->email]); Livewire::actingAs($user) ->test(Billing::class) ->call('purchase', 'upgrade', 'team') ->assertSee(__('billing.stripe_not_configured')); });