Files
portal/app/tests/Feature/Billing/TenantPreflightTest.php
T
Дмитрий b1c3f39e38 feat(billing-v2-c): Tenant::requiredLeadsForTomorrow + cast флагов заморозки
Task 1.3 Спека C. Tenant: +frozen_by_balance_at (fillable+cast datetime) +
requiredLeadsForTomorrow() (sum daily_limit_target активных проектов). Project:
+preflight_blocked_at (fillable+cast). NB: фильтр по is_active (boolean) +
daily_limit_target — у projects нет колонок status/daily_limit (план поправлен
под факт схемы). 3 теста GREEN.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-26 20:39:14 +03:00

27 lines
1.1 KiB
PHP

<?php
declare(strict_types=1);
use App\Models\Project;
use App\Models\Tenant;
use Illuminate\Support\Carbon;
it('sums daily_limit_target of active projects for required leads', function () {
$tenant = Tenant::factory()->create(['balance_rub' => '1000.00']);
Project::factory()->for($tenant)->create(['is_active' => true, 'daily_limit_target' => 10]);
Project::factory()->for($tenant)->create(['is_active' => true, 'daily_limit_target' => 15]);
Project::factory()->for($tenant)->create(['is_active' => false, 'daily_limit_target' => 100]); // не считается
expect($tenant->requiredLeadsForTomorrow())->toBe(25);
});
it('casts frozen_by_balance_at to datetime', function () {
$tenant = Tenant::factory()->create(['frozen_by_balance_at' => now()]);
expect($tenant->frozen_by_balance_at)->toBeInstanceOf(Carbon::class);
});
it('casts project preflight_blocked_at to datetime', function () {
$project = Project::factory()->create(['preflight_blocked_at' => now()]);
expect($project->preflight_blocked_at)->toBeInstanceOf(Carbon::class);
});