Answer the question
In order to leave comments, you need to log in
Testing with Http::fake(); in Laravel 8?
Trying to understand how HTTP::fake works in tests.
This is how I'm trying to simulate a response with a test html document in a test.
public function testChecks()
$html = file_get_contents(__DIR__ . '/../fixtures/test.html');
$fake = Http::fake(['test.ru' => Http::response($html)]);
$response = $this->post(route('route', $data['id']));
public function checks(Request $request, $id)
{
$url = DB::table('urls')->find($id);
try {
$check = Http::get($url->name);
} catch (\Exception $e) {
flash("Error: {$e->getMessage()}")->error();
return back();
}
$document = new DiDom\Document($url->name, true);
dd($document);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question