Files
portal/app/tests/Unit/Autopodbor/Study/AnchorGateTest.php
T

34 lines
1.9 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
use App\Services\Autopodbor\Agent\Study\AnchorGate;
use App\Services\Autopodbor\Agent\Study\DomainKinship;
function gate(): AnchorGate { return new AnchorGate(new DomainKinship); }
it('сайт: seed — точно она', function () {
expect(gate()->siteVerified('kraslombard24.ru', 'kraslombard24.ru', '', [], ''))->toBeTrue();
});
it('сайт: близнец — точно она', function () {
// seedRaw = seed-домен (как в реальном вызове коллектора: siteVerified(..., $fp->seedDomain, ...));
// близнец красломбард.рф ↔ kraslombard24.ru распознаётся через DomainKinship.
expect(gate()->siteVerified('красломбард.рф', 'kraslombard24.ru', 'kraslombard24.ru', [], '<html></html>'))->toBeTrue();
});
it('сайт: чужой с якорным телефоном на странице — точно она', function () {
expect(gate()->siteVerified('other.ru', 'kraslombard24.ru', '', ['73912920000'], '...тел 8 (391) 292-00-00 = 73912920000...'))->toBeTrue();
});
it('сайт: чужой без якоря и без ссылки на seed — нет', function () {
expect(gate()->siteVerified('sberbank.ru', 'kraslombard24.ru', '', [], '<html>чужое</html>'))->toBeFalse();
});
it('карточка: сайт с seed — keep', function () {
expect(gate()->cardKept('http://kraslombard24.ru/?utm=2gis', '', 'kraslombard24.ru', []))->toBeTrue();
});
it('карточка: телефон-якорь — keep', function () {
expect(gate()->cardKept(null, '73912920000', 'kraslombard24.ru', ['73912920000' => true]))->toBeTrue();
});
it('карточка: чужая — drop', function () {
expect(gate()->cardKept('http://alien.ru', '79990000000', 'kraslombard24.ru', ['73912920000' => true]))->toBeFalse();
});
it('карточка: пустой seed — keep всё', function () {
expect(gate()->cardKept(null, '', '', []))->toBeTrue();
});