Answer the question
In order to leave comments, you need to log in
Can't figure out test error in laravel?
I hand over the project, at the level of tests such an error takes off.
app_1 | ------ -----------------------------------------------------------------------
app_1 | Line code/tests/Feature/UrlControllerTest.php
app_1 | ------ -----------------------------------------------------------------------
app_1 | 68 Parameter #1 $body of static method
app_1 | Illuminate\Http\Client\Factory::response() expects array|string|null,
app_1 | string|false given.
app_1 | ------ -----------------------------------------------------------------------
public function testChecks(): void
{
$data = ['id' => 1, 'name' => 'https://test.ru'];
$url = $data['name'];
$expected = [
'url_id' => 1,
'status_code' => 200,
'keywords' => 'keywords test fixture',
'h1' => 'Header test fixtures',
'description' => 'description test fixture',
];
$html = file_get_contents(__DIR__ . '/../fixtures/test.html');
Http::fake([$url => Http::response($html)]);
$response = $this->post(route('urls.checks', $data['id']));
$response->assertSessionHasNoErrors();
$response->assertRedirect();
$this->assertDatabaseHas('url_checks', $expected);
}
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