D
D
Denis2021-02-14 19:07:40
PHPUnit
Denis, 2021-02-14 19:07:40

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  |  ------ -----------------------------------------------------------------------


here is the UrlControllerTest.php file with line 68 Http::fake([$url => Http::response($html)]);
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);
    }

If I understand correctly what the test swears at, then it turns out that Http::response comes false ?
If so, where from? The test is called 1 time with a fixture where the line (layout) lies .... maybe I don’t understand what exactly the error says? Or what is going on here?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question