trypost/tests/Feature/PlanTest.php
Paulo Castellano 21e45b4847 chore: remove legacy plan tiers (starter/plus/pro/max)
All customers were migrated to the single Workspace plan and the old plan rows
were deleted in production, so drop the now-dead legacy tiers from the code:
reduce the Plan Slug enum to Workspace only and default the PlanFactory to it.
Rework StripeEventListenerTest around the single Workspace plan (its monthly and
yearly price ids still exercise plan-by-price mapping, trial clearing, deletion,
and previous-plan propagation), and point the remaining tests that referenced
the starter/pro slugs at the seeded Workspace plan.
2026-06-22 15:31:32 -03:00

44 lines
1.2 KiB
PHP

<?php
declare(strict_types=1);
use App\Enums\Plan\Slug;
use App\Models\Plan;
test('plan can be created with factory', function () {
Plan::where('slug', Slug::Workspace)->delete();
$plan = Plan::factory()->create([
'slug' => Slug::Workspace,
'name' => 'Workspace',
]);
expect($plan)->toBeInstanceOf(Plan::class)
->and($plan->slug)->toBe(Slug::Workspace)
->and($plan->name)->toBe('Workspace')
->and($plan->is_archived)->toBeFalse();
});
test('plan slug is cast to enum', function () {
$plan = Plan::where('slug', Slug::Workspace)->first();
expect($plan->slug)->toBeInstanceOf(Slug::class)
->and($plan->slug)->toBe(Slug::Workspace)
->and($plan->slug->label())->toBe('Workspace');
});
test('active scope excludes archived plans', function () {
$activeBefore = Plan::active()->count();
$plan = Plan::where('slug', Slug::Workspace)->first();
$plan->update(['is_archived' => true]);
expect(Plan::active()->count())->toBe($activeBefore - 1);
});
test('integer fields are cast correctly', function () {
$plan = Plan::where('slug', Slug::Workspace)->first();
expect($plan->monthly_credits_limit)->toBeInt()
->and($plan->sort)->toBeInt();
});