create(['balance_rub' => '100000.00']); DB::statement("SET app.current_tenant_id = ".$tenant->id); $run = AutopodborRun::create([ 'tenant_id' => $tenant->id, 'kind' => 'resolve', 'status' => 'queued', 'region_code' => 16, 'params' => ['name' => 'Окна Комфорт'], ]); app()->call([new RunAutopodborResolveJob($run->id), 'handle']); expect($run->fresh()->status)->toBe('done') ->and($run->fresh()->price_rub_charged)->toBeNull() ->and(AutopodborCompetitor::where('search_run_id', $run->id)->where('origin', 'resolve')->count())->toBeGreaterThan(0) ->and((string) $tenant->fresh()->balance_rub)->toBe('100000.00'); }); it('пустой резолв: status=empty без списания', function () { app()->bind(\App\Services\Autopodbor\Agent\CompetitorAgent::class, \Tests\Doubles\EmptyCompetitorAgent::class); $tenant = Tenant::factory()->create(['balance_rub' => '100000.00']); DB::statement("SET app.current_tenant_id = ".$tenant->id); $run = AutopodborRun::create([ 'tenant_id' => $tenant->id, 'kind' => 'resolve', 'status' => 'queued', 'region_code' => 16, 'params' => ['name' => 'Несуществующая Фирма XYZ'], ]); app()->call([new RunAutopodborResolveJob($run->id), 'handle']); expect($run->fresh()->status)->toBe('empty') ->and($run->fresh()->price_rub_charged)->toBeNull(); });