trypost/tests/Feature/PlanSeederTest.php
Paulo Castellano 2da15df96c feat: introduce Account entity as billing owner and refactor architecture
- Create Account model as Cashier Billable entity (stripe, plan, subscription)
- Account owns workspaces and has an owner_id (User)
- User belongs to one Account via account_id
- Workspace belongs to Account via account_id, no longer has billing fields
- Remove Brand model entirely (workspaces serve as grouping)
- Rename brand_limit to workspace_limit in plans
- Workspace roles simplified: admin/member/viewer (owner via Account)
- Invites now belong to Account with workspaces JSON array
- Pennant features scope changed from Workspace to Account
- EnsureSubscribed middleware checks Account subscription
- All controllers updated: BillingController, OnboardingController,
  WorkspaceInviteController, SocialController, StripeEventListener
- Frontend: extract GoogleAuthButton component, create WorkspaceRole
  enum for type-safe role checks, fix all views for new architecture
- All 1101 tests passing
2026-04-14 22:22:04 -03:00

53 lines
1.7 KiB
PHP

<?php
declare(strict_types=1);
use App\Enums\Plan\Slug;
use App\Models\Plan;
use Database\Seeders\PlanSeeder;
test('seeder creates 4 plans', function () {
expect(Plan::count())->toBe(4);
});
test('seeder creates plans with correct limits', function () {
$starter = Plan::where('slug', Slug::Starter)->first();
expect($starter->name)->toBe('Starter')
->and($starter->monthly_price)->toBe(1900)
->and($starter->yearly_price)->toBe(19000)
->and($starter->social_account_limit)->toBe(5)
->and($starter->member_limit)->toBe(1)
->and($starter->workspace_limit)->toBe(1)
->and($starter->ai_images_limit)->toBe(50)
->and($starter->ai_videos_limit)->toBe(10)
->and($starter->data_retention_days)->toBe(30)
->and($starter->sort)->toBe(1);
$max = Plan::where('slug', Slug::Max)->first();
expect($max->name)->toBe('Max')
->and($max->monthly_price)->toBe(9900)
->and($max->yearly_price)->toBe(99000)
->and($max->social_account_limit)->toBe(100)
->and($max->member_limit)->toBe(20)
->and($max->workspace_limit)->toBe(50)
->and($max->ai_images_limit)->toBe(2000)
->and($max->ai_videos_limit)->toBe(500)
->and($max->data_retention_days)->toBe(730)
->and($max->sort)->toBe(4);
});
test('seeder is idempotent', function () {
$this->seed(PlanSeeder::class);
expect(Plan::count())->toBe(4);
});
test('active scope excludes archived plans', function () {
$plan = Plan::where('slug', Slug::Starter)->first();
$plan->update(['is_archived' => true]);
expect(Plan::active()->count())->toBe(3)
->and(Plan::count())->toBe(4);
});