trypost/tests/Feature/Billing/TrialLengthTest.php
Paulo Castellano 4590fc5fd1
Make Stripe Checkout configurable via billing env knobs (#252)
* Make Stripe Checkout configurable via billing env knobs

Replace the hard-required $1 first-month coupon with env-driven trial days,
optional coupon, and allow_promotion_codes so SaaS can switch checkout modes
without a code change.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Fix no-effect ReflectionClass import in checkout test

CI treats bare global use statements as ErrorException and aborts
loading the suite before any assertions run.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Document checkout env knobs in AGENTS.md instead of .ai/

Remove the Boost record-rule .ai/rules folder and keep durable billing
checkout guidance in AGENTS.md / CLAUDE.md project-specific rules.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Harden checkout env knobs from review findings

Default allow_promotion_codes to false, grant Stripe trial only to
first-time subscribers, clarify the coupon/promo XOR error, and cover
negative XOR cases plus StartSubscriptionCheckout wiring.

Co-authored-by: Cursor <cursoragent@cursor.com>

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-07 21:25:32 -03:00

26 lines
769 B
PHP

<?php
declare(strict_types=1);
use App\Actions\User\CreateUser;
test('the default trial length is 8 days', function () {
expect(config('cashier.trial_days'))->toBe(8);
});
test('allow_promotion_codes defaults to false for saas recipe A', function () {
expect(config('cashier.allow_promotion_codes'))->toBeFalse();
});
test('signup grants a trial of cashier.trial_days in no-card mode', function () {
config(['trypost.billing.require_card_for_trial' => false]);
$user = CreateUser::execute([
'name' => 'Trial User',
'email' => 'trial@example.com',
'password' => 'secret123',
]);
expect($user->account->trial_ends_at->toDateString())
->toBe(now()->addDays(config('cashier.trial_days'))->toDateString());
});