R1.1: Buchungs-Gate geprueft + safe-by-default; Legacy-Buchungspfade festgeschrieben
Default von billing.enforce_booking auf true gedreht: ein in Produktion vergessener Env-Key haette das Gate sonst still geoeffnet (jeder haette ohne Zahlung veroeffentlichen koennen). Tests ergaenzt: Grandfathered gueltig/abgelaufen/NULL (= abgelaufen, Entscheidung 19.06.), Active ausserhalb der Periode, Service-Level-Submit mit Legacy-Buchung und BookingRequiredException ohne Buchung. Scope-Logik selbst war korrekt. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
8653abdeec
commit
c9641e9184
4 changed files with 109 additions and 9 deletions
|
|
@ -73,3 +73,62 @@ test('a cancelled legacy agreement does not count as booking', function () {
|
|||
|
||||
expect($user->hasActiveBooking())->toBeFalse();
|
||||
});
|
||||
|
||||
test('an active legacy agreement outside its current period does not count as booking', function () {
|
||||
$user = User::factory()->create();
|
||||
|
||||
UserPaymentOption::factory()->create([
|
||||
'user_id' => $user->id,
|
||||
'payment_option_id' => PaymentOption::factory()->create()->id,
|
||||
'status' => UserPaymentOptionStatus::Active->value,
|
||||
'current_period_start' => now()->subMonths(2)->startOfMonth(),
|
||||
'current_period_end' => now()->subMonths(2)->endOfMonth(),
|
||||
'grandfathered_until' => null,
|
||||
'stripe_subscription_id' => null,
|
||||
]);
|
||||
|
||||
expect($user->hasActiveBooking())->toBeFalse();
|
||||
});
|
||||
|
||||
test('a grandfathered agreement with valid protection counts as booking', function () {
|
||||
$user = User::factory()->create();
|
||||
|
||||
UserPaymentOption::factory()->create([
|
||||
'user_id' => $user->id,
|
||||
'payment_option_id' => PaymentOption::factory()->create()->id,
|
||||
'status' => UserPaymentOptionStatus::Grandfathered->value,
|
||||
'grandfathered_until' => now()->addYear(),
|
||||
'stripe_subscription_id' => null,
|
||||
]);
|
||||
|
||||
expect($user->hasActiveBooking())->toBeTrue();
|
||||
});
|
||||
|
||||
test('a grandfathered agreement with expired protection does not count as booking', function () {
|
||||
$user = User::factory()->create();
|
||||
|
||||
UserPaymentOption::factory()->create([
|
||||
'user_id' => $user->id,
|
||||
'payment_option_id' => PaymentOption::factory()->create()->id,
|
||||
'status' => UserPaymentOptionStatus::Grandfathered->value,
|
||||
'grandfathered_until' => now()->subDay(),
|
||||
'stripe_subscription_id' => null,
|
||||
]);
|
||||
|
||||
expect($user->hasActiveBooking())->toBeFalse();
|
||||
});
|
||||
|
||||
test('a grandfathered agreement without an end date does not count as booking', function () {
|
||||
// NULL = abgelaufen/ungültig (User-Entscheidung 19.06.2026).
|
||||
$user = User::factory()->create();
|
||||
|
||||
UserPaymentOption::factory()->create([
|
||||
'user_id' => $user->id,
|
||||
'payment_option_id' => PaymentOption::factory()->create()->id,
|
||||
'status' => UserPaymentOptionStatus::Grandfathered->value,
|
||||
'grandfathered_until' => null,
|
||||
'stripe_subscription_id' => null,
|
||||
]);
|
||||
|
||||
expect($user->hasActiveBooking())->toBeFalse();
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue