feat: G1/SP2 реквизиты клиента + ИНН по DaData + гейт первого проекта

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Дмитрий
2026-06-18 22:25:23 +03:00
parent 53fb7b7760
commit 08d51eb6c8
33 changed files with 2456 additions and 23 deletions
@@ -0,0 +1,54 @@
<?php
declare(strict_types=1);
use App\Services\DaData\DaDataPartyClient;
use Illuminate\Http\Client\Factory as HttpFactory;
it('parses a party suggestion into a result', function () {
$http = new HttpFactory;
$http->fake([
'suggestions.dadata.ru/*' => $http->response([
'suggestions' => [[
'value' => 'ООО "РОМАШКА"',
'data' => [
'kpp' => '770101001',
'ogrn' => '1027700132195',
'type' => 'LEGAL',
'address' => ['value' => 'г Москва, ул Ленина, д 1'],
],
]],
]),
]);
config()->set('services.dadata.api_key', 'test-key');
$res = (new DaDataPartyClient($http))->findByInn('7707083893');
expect($res)->not->toBeNull();
expect($res->legalName)->toBe('ООО "РОМАШКА"');
expect($res->kpp)->toBe('770101001');
expect($res->type)->toBe('LEGAL');
});
it('returns null on empty suggestions', function () {
$http = new HttpFactory;
$http->fake(['suggestions.dadata.ru/*' => $http->response(['suggestions' => []])]);
config()->set('services.dadata.api_key', 'test-key');
expect((new DaDataPartyClient($http))->findByInn('0000000000'))->toBeNull();
});
it('returns null on HTTP error (soft)', function () {
$http = new HttpFactory;
$http->fake(['suggestions.dadata.ru/*' => $http->response('boom', 500)]);
config()->set('services.dadata.api_key', 'test-key');
expect((new DaDataPartyClient($http))->findByInn('7707083893'))->toBeNull();
});
it('returns null when api key is empty', function () {
$http = new HttpFactory;
config()->set('services.dadata.api_key', '');
expect((new DaDataPartyClient($http))->findByInn('7707083893'))->toBeNull();
});