/
mikopbx
/
ModuleAutoDialer
Обзор
Документация
Войти
/
mikopbx
/
ModuleAutoDialer
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
master
tests/unit/test-dialing-candidate-selector.php
55 строк
2 KB
boffart
feat: apply dialing windows per recipient timezone
06 авг 2026, 14:06
06 авг 2026, 14:06
f500fde
Код
Авторство
О чём код?
<?php require_once __DIR__ . '/../lib/TestRunner.php'; require_once __DIR__ . '/../../Lib/DialingWindow.php'; require_once __DIR__ . '/../../Lib/DialingCandidateSelector.php'; use Modules\ModuleAutoDialer\Lib\DialingCandidateSelector; $runner = new TestRunner('Dialing Candidate Selector'); $now = gmmktime(3, 0, 0, 8, 6, 2026); $runner->run('Skip first number outside its recipient-local window', function () use ($now): void { $selected = DialingCandidateSelector::select([ ['id' => 1, 'clientId' => 'a', 'timeCallAllow' => 0, 'timeOffsetMinutes' => 0], ['id' => 2, 'clientId' => 'b', 'timeCallAllow' => 0, 'timeOffsetMinutes' => 300], ], [], $now, 480, 1320); assertEq(2, $selected['id'], 'UTC+5 candidate at 08:00 is selected'); }); $runner->run('Respect absolute timeCallAllow', function () use ($now): void { $selected = DialingCandidateSelector::select([ ['id' => 1, 'clientId' => 'a', 'timeCallAllow' => $now + 60, 'timeOffsetMinutes' => 300], ['id' => 2, 'clientId' => 'b', 'timeCallAllow' => $now, 'timeOffsetMinutes' => 300], ], [], $now, 480, 1320); assertEq(2, $selected['id'], 'future candidate is skipped'); }); $runner->run('Skip candidates belonging to busy clients', function () use ($now): void { $selected = DialingCandidateSelector::select([ ['id' => 1, 'clientId' => 'busy', 'timeCallAllow' => 0, 'timeOffsetMinutes' => 300], ['id' => 2, 'clientId' => 'free', 'timeCallAllow' => 0, 'timeOffsetMinutes' => 300], ], ['busy' => true], $now, 480, 1320); assertEq(2, $selected['id'], 'free client is selected'); }); $runner->run('Empty client IDs do not participate in client locking', function () use ($now): void { $selected = DialingCandidateSelector::select([ ['id' => 1, 'clientId' => '', 'timeCallAllow' => 0, 'timeOffsetMinutes' => 300], ], ['' => true], $now, 480, 1320); assertEq(1, $selected['id'], 'empty client remains eligible'); }); $runner->run('Return null when no candidate is eligible', function () use ($now): void { $selected = DialingCandidateSelector::select([ ['id' => 1, 'clientId' => 'a', 'timeCallAllow' => 0, 'timeOffsetMinutes' => -240], ], [], $now, 480, 1320); assertEq(null, $selected, 'no candidate selected'); }); exit($runner->exitCode());