'site', 'identifier' => 'kraslombard24.ru', 'phone_kind' => null, 'phone_type' => null, 'provenance_url' => 'https://kraslombard24.ru/', 'provenance_label' => 'сайт конкурента', 'where_found' => [['label' => 'сайт конкурента', 'url' => 'https://kraslombard24.ru/']], 'office' => null, 'confirmations' => 1], ['signal_type' => 'site', 'identifier' => 'красломбард.рф', 'phone_kind' => null, 'phone_type' => null, 'provenance_url' => 'https://красломбард.рф/', 'provenance_label' => 'сайт конкурента', 'where_found' => [['label' => 'сайт конкурента', 'url' => 'https://красломбард.рф/']], 'office' => null, 'confirmations' => 1], ['signal_type' => 'call', 'identifier' => '73912920000', 'phone_kind' => 'real', 'phone_type' => 'city', 'provenance_url' => null, 'provenance_label' => 'в коде сайта', 'where_found' => [['label' => 'в коде сайта', 'url' => null]], 'office' => null, 'confirmations' => 1], ]); } }; app()->instance(CompetitorAgent::class, $stub); $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']); $searchRun = AutopodborRun::create(['tenant_id' => $tenant->id, 'kind' => 'search', 'status' => 'done', 'region_code' => 29, 'params' => []]); $comp = AutopodborCompetitor::create(['tenant_id' => $tenant->id, 'search_run_id' => $searchRun->id, 'name' => 'КрасЛомбард', 'dedup_key' => 'site:kraslombard24.ru', 'site_url' => 'kraslombard24.ru']); $run = AutopodborRun::create(['tenant_id' => $tenant->id, 'kind' => 'study', 'status' => 'queued', 'region_code' => 29, 'competitor_id' => $comp->id, 'params' => []]); app()->call([new RunAutopodborStudyJob($run->id), 'handle']); $sites = AutopodborSource::where('competitor_id', $comp->id)->where('signal_type', 'site')->pluck('identifier')->all(); expect($run->fresh()->status)->toBe('done') ->and(count($sites))->toBe(2) // близнецы — ДВЕ записи, не слиты ->and($sites)->toContain('kraslombard24.ru') ->and($sites)->toContain('красломбард.рф') ->and(AutopodborSource::where('competitor_id', $comp->id)->where('signal_type', 'call')->where('identifier', '73912920000')->exists())->toBeTrue(); });