Http::response([ 'status_code' => 200, 'response_body_base64' => base64_encode('привет'), ]), ]); $client = new XfetchClient('test-key'); expect($client->html('https://2gis.ru/x'))->toBe('привет'); }); it('без ключа не ходит в сеть и возвращает пусто', function () { Http::fake(); $client = new XfetchClient(null); expect($client->html('https://2gis.ru/x'))->toBe(''); Http::assertNothingSent(); }); it('шлёт url, api_key и render:true на endpoint xfetch', function () { Http::fake(['xf4.ru/*' => Http::response(['response_body_base64' => base64_encode('ok')])]); (new XfetchClient('k123'))->html('https://2gis.ru/y'); Http::assertSent(fn ($r) => $r->url() === 'https://xf4.ru/fetch' && $r['url'] === 'https://2gis.ru/y' && $r['api_key'] === 'k123' && $r['render'] === true); });