ab784fb4ec
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
46 lines
1.8 KiB
PHP
46 lines
1.8 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Models\Project;
|
|
use App\Services\Supplier\SupplierOrderPlan;
|
|
use Carbon\Carbon;
|
|
|
|
it('строит intended по формуле: два клиента 3 и 2 на один call-источник → заказ 3, деление 1/1/1', function (): void {
|
|
$tomorrow = Carbon::parse('2026-07-13'); // понедельник
|
|
$mask = 1 << ($tomorrow->isoWeekday() - 1); // бит пн
|
|
|
|
$p1 = new Project(['signal_type' => 'call', 'signal_identifier' => '79135397707']);
|
|
$p1->daily_limit_target = 3;
|
|
$p1->delivery_days_mask = $mask;
|
|
$p1->regions = [];
|
|
|
|
$p2 = new Project(['signal_type' => 'call', 'signal_identifier' => '79135397707']);
|
|
$p2->daily_limit_target = 2;
|
|
$p2->delivery_days_mask = $mask;
|
|
$p2->regions = [];
|
|
|
|
$plan = SupplierOrderPlan::build(collect([$p1, $p2]), $tomorrow);
|
|
|
|
// order = max(3, ceil(5/3)=2) = 3; split B1/B2/B3 = 1/1/1
|
|
expect($plan['intended'])->toEqualCanonicalizing([
|
|
['signal_type' => 'call', 'identifier' => '79135397707', 'platform' => 'B1', 'limit' => 1],
|
|
['signal_type' => 'call', 'identifier' => '79135397707', 'platform' => 'B2', 'limit' => 1],
|
|
['signal_type' => 'call', 'identifier' => '79135397707', 'platform' => 'B3', 'limit' => 1],
|
|
]);
|
|
});
|
|
|
|
it('проект не eligible на завтра (нет бита дня) → не попадает в intended', function (): void {
|
|
$tomorrow = Carbon::parse('2026-07-13'); // пн
|
|
$notMondayMask = 1 << (Carbon::parse('2026-07-14')->isoWeekday() - 1); // вт
|
|
|
|
$p = new Project(['signal_type' => 'call', 'signal_identifier' => '7911']);
|
|
$p->daily_limit_target = 5;
|
|
$p->delivery_days_mask = $notMondayMask;
|
|
$p->regions = [];
|
|
|
|
$plan = SupplierOrderPlan::build(collect([$p]), $tomorrow);
|
|
|
|
expect($plan['intended'])->toBe([]);
|
|
});
|