d93404bc62
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
41 lines
2.6 KiB
PHP
41 lines
2.6 KiB
PHP
<?php
|
|
|
|
use App\Services\Autopodbor\Agent\Extract\SourceAggregator;
|
|
|
|
it('сливает один номер из разных мест в один источник с двумя где-нашли', function () {
|
|
$out = (new SourceAggregator)->aggregate([
|
|
['number' => '73912920000', 'kind' => 'code', 'label' => 'в коде сайта', 'url' => 'https://k.ru/', 'office' => null, 'tracker' => true],
|
|
['number' => '73912920000', 'kind' => 'contacts', 'label' => 'страница «Контакты»', 'url' => 'https://k.ru/c', 'office' => 'Единая справочная', 'tracker' => true],
|
|
]);
|
|
expect($out)->toHaveCount(1);
|
|
expect($out[0]->identifier)->toBe('73912920000');
|
|
expect($out[0]->confirmations())->toBe(2);
|
|
expect($out[0]->office)->toBe('Единая справочная');
|
|
expect($out[0]->phoneKind)->toBe('real');
|
|
expect($out[0]->phoneType)->toBe('city');
|
|
});
|
|
|
|
it('скрывает пул ротации и помечает видимый подменный', function () {
|
|
$out = (new SourceAggregator)->aggregate([
|
|
['number' => '79012414545', 'kind' => 'displayed', 'label' => 'Callibri (на сайте)', 'url' => 'https://k.ru/', 'office' => null, 'tracker' => true],
|
|
['number' => '70489624563', 'kind' => 'pool', 'label' => 'пул', 'url' => null, 'office' => null, 'tracker' => true],
|
|
]);
|
|
expect($out)->toHaveCount(1); // пул скрыт
|
|
expect($out[0]->identifier)->toBe('79012414545');
|
|
expect($out[0]->phoneKind)->toBe('substitute');
|
|
});
|
|
|
|
it('сортирует: больше подтверждений — выше, подменные — в самый низ', function () {
|
|
$out = (new SourceAggregator)->aggregate([
|
|
// 1 подтверждение
|
|
['number' => '73912500000', 'kind' => 'contacts', 'label' => 'контакты', 'url' => null, 'office' => null, 'tracker' => true],
|
|
// 2 подтверждения
|
|
['number' => '73912920000', 'kind' => 'code', 'label' => 'код', 'url' => null, 'office' => null, 'tracker' => true],
|
|
['number' => '73912920000', 'kind' => 'contacts', 'label' => 'контакты', 'url' => null, 'office' => null, 'tracker' => true],
|
|
// подменный
|
|
['number' => '79012414545', 'kind' => 'displayed', 'label' => 'Callibri', 'url' => null, 'office' => null, 'tracker' => true],
|
|
]);
|
|
expect(array_map(fn ($s) => $s->identifier, $out))
|
|
->toBe(['73912920000', '73912500000', '79012414545']);
|
|
});
|