mercredi 2 mai 2018

Laravel file upload testing issue

I trying file upload testing. But I couldn't send a file. It always returns file name when I send file.

Laravel Version : 5.6

PHP Version : 7.2

Test Case :

 /** @test */
public function file_uploading_test()
{
    $this->signIn();

    $postData = [
        'file' => UploadedFile::fake()->image('test.png'),
    ];

    $this->post(route('frontend.ad.create.step2.uploadImage', $postData));
}

Request Class:

/**
 * Get the validation rules that apply to the request.
 *
 * @return array
 */
public function rules()
{
    return [
        'file' => 'image|dimensions:min_width=550,min_height=370',
    ];
}

I'm run dd method in the Request Class and then getting the following output :

array:1 [
 "file" => array:1 [
      "name" => "test.png"
  ]
]

I mean, I would like testing file upload. How can I resolve it?

Aucun commentaire:

Enregistrer un commentaire