888f737c88
Правило «последние 2 сегмента через точку»: subdomain → root, root → null, не-домен (телефон, sms-ключ) → null. Покрытие unit-тестами на 10 кейсов. Spec: docs/superpowers/specs/2026-05-22-root-domain-auto-link-design.md §4.1 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
28 lines
1.1 KiB
PHP
28 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Support\SupplierIdentifier;
|
|
use Tests\TestCase;
|
|
|
|
uses(TestCase::class);
|
|
|
|
it('extracts root domain from subdomain', function (): void {
|
|
expect(SupplierIdentifier::extractRootDomain('krasnoyarsk.carmoney.ru'))->toBe('carmoney.ru');
|
|
expect(SupplierIdentifier::extractRootDomain('client.carmoney.ru'))->toBe('carmoney.ru');
|
|
expect(SupplierIdentifier::extractRootDomain('next.vashinvestor.ru'))->toBe('vashinvestor.ru');
|
|
expect(SupplierIdentifier::extractRootDomain('cabinet.caranga.ru'))->toBe('caranga.ru');
|
|
});
|
|
|
|
it('returns null for already-root domain', function (): void {
|
|
expect(SupplierIdentifier::extractRootDomain('carmoney.ru'))->toBeNull();
|
|
expect(SupplierIdentifier::extractRootDomain('заложитьптс.рф'))->toBeNull();
|
|
});
|
|
|
|
it('returns null for non-domain identifiers', function (): void {
|
|
expect(SupplierIdentifier::extractRootDomain('7800XXXXXXX'))->toBeNull();
|
|
expect(SupplierIdentifier::extractRootDomain(''))->toBeNull();
|
|
expect(SupplierIdentifier::extractRootDomain(' '))->toBeNull();
|
|
expect(SupplierIdentifier::extractRootDomain('TINKOFF'))->toBeNull();
|
|
});
|