Files
portal/app/tests/Feature/Billing/TenantPreflightTest.php
T

27 lines
1.1 KiB
PHP
Raw Normal View History

<?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);
});