Files
portal/app/tests/Feature/Requisites/TenantRequisitesLookupTest.php
T
Дмитрий 2eaa78f95b
Accessibility (Pa11y live) / a11y (push) Has been cancelled
SAST — Semgrep / Semgrep SAST scan (push) Has been cancelled
fix(stan): Larastan-долг G1/G6 = 0 ошибок (реальные баги — починены, не спрятаны)
Продуктовый код (фиксы, не baseline): TenantRequisites+SupplierLead — явные @property (ide-helper:models пропускал модели); DealsController V1 — лишний ?-> на non-null received_at; ScrubPii — guard instanceof Monolog. Тест-код: ImitationTestCase @param int; findByInn return-type. Baseline перегенерён — в нём ТОЛЬКО ложноположительные (Pest TestCall + защитный ?-> на nullable first() в debug-строках ScenarioBC), 0 продуктовых подавлений (проверено диффом). composer stan: 0.

NB: столбцы lead-region (dadata_qc/phone_operator/region_source/resolved_subject_code) есть в БД, но отсутствуют в db/schema.sql — отдельный дрейф схемы.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-19 12:40:00 +03:00

39 lines
1.3 KiB
PHP

<?php
declare(strict_types=1);
use App\Models\Tenant;
use App\Models\User;
use App\Services\DaData\Dto\PartyLookupResult;
use App\Services\DaData\PartyLookup;
it('lookup-inn returns found:false when party lookup is null (default Null driver)', function () {
$tenant = Tenant::factory()->create();
$this->actingAs(User::factory()->create(['tenant_id' => $tenant->id]));
$this->postJson('/api/tenant/requisites/lookup-inn', ['inn' => '7707083893'])
->assertOk()
->assertJson(['found' => false]);
});
it('lookup-inn returns found:true with a fake lookup', function () {
$tenant = Tenant::factory()->create();
$this->actingAs(User::factory()->create(['tenant_id' => $tenant->id]));
$this->app->bind(PartyLookup::class, fn () => new class implements PartyLookup
{
public function findByInn(string $inn): PartyLookupResult
{
return new PartyLookupResult('ООО Тест', '770101001', '1027700132195', 'Москва', 'LEGAL', []);
}
});
$this->postJson('/api/tenant/requisites/lookup-inn', ['inn' => '7707083893'])
->assertOk()
->assertJson([
'found' => true,
'legal_name' => 'ООО Тест',
'subject_type_hint' => 'legal_entity',
]);
});