bind(CompetitorAgent::class, RichCompetitorAgent::class); $tenant = Tenant::factory()->create(['balance_rub' => '100000.00']); DB::statement('SET app.current_tenant_id = '.$tenant->id); SystemSetting::updateOrCreate(['key' => 'autopodbor_price_study_rub'], ['value' => '900', 'type' => 'decimal']); $comp = AutopodborCompetitor::create(['tenant_id' => $tenant->id, 'name' => 'КрасЛомбард', 'dedup_key' => 'site:k.ru', 'site_url' => 'k.ru']); $run = AutopodborRun::create(['tenant_id' => $tenant->id, 'kind' => 'study', 'status' => 'queued', 'region_code' => 24, 'competitor_id' => $comp->id, 'params' => []]); app()->call([new RunAutopodborStudyJob($run->id), 'handle']); $src = AutopodborSource::where('competitor_id', $comp->id)->where('signal_type', 'call')->firstOrFail(); expect($src->where_found)->toBeArray()->toHaveCount(2); expect(collect($src->where_found)->pluck('url'))->toContain('https://2gis.ru/firm/1'); expect($src->office)->toBe('Единая справочная'); expect($src->confirmations)->toBe(2); }); it('API-ресурс источника отдаёт where_found, office и confirmations', function () { $tenant = Tenant::factory()->create(); DB::statement('SET app.current_tenant_id = '.$tenant->id); $comp = AutopodborCompetitor::create(['tenant_id' => $tenant->id, 'name' => 'К', 'dedup_key' => 'site:k.ru', 'site_url' => 'k.ru']); $run = AutopodborRun::create(['tenant_id' => $tenant->id, 'kind' => 'study', 'status' => 'done', 'region_code' => 24, 'competitor_id' => $comp->id, 'params' => []]); $src = AutopodborSource::create([ 'tenant_id' => $tenant->id, 'competitor_id' => $comp->id, 'study_run_id' => $run->id, 'signal_type' => 'call', 'identifier' => '73912920000', 'phone_kind' => 'real', 'phone_type' => 'city', 'provenance_url' => 'https://k.ru', 'provenance_label' => 'в коде сайта', 'dedup_key' => 'call:73912920000', 'where_found' => [['label' => 'в коде сайта', 'url' => 'https://k.ru'], ['label' => '2ГИС', 'url' => 'https://2gis.ru/firm/1']], 'office' => 'Единая справочная', 'confirmations' => 2, ]); $arr = (new SourceResource($src))->toArray(request()); expect($arr['where_found'])->toHaveCount(2); expect($arr['office'])->toBe('Единая справочная'); expect($arr['confirmations'])->toBe(2); });