jeudi 26 septembre 2019

Laravel 5.8 UploadedFile fake not working in test as expected

I have an api call where I upload some files, I am writing a test for this api call and I do this:

$response = $this->postJson(
    $url,
    [
        'uploadedFile' => UploadedFile::fake()->create('test.csv', 512),
    ]
);

When I do this in my code, not my test:

$request->uploadedFile->getClientOriginalName()

I get the following error when I run my test:

Call to a member function getClientOriginalName() on string

When I do my api call with postman everything works great.

Aucun commentaire:

Enregistrer un commentaire