Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MakesHttpRequests has wrong function > extractFilesFromDataArray #18671

Closed
alexchitoraga opened this issue Apr 5, 2017 · 1 comment
Closed

Comments

@alexchitoraga
Copy link

  • Laravel Version: 5.4.*
  • PHP Version: 7.1.1
  • Database Driver & Version: MySQL 10.2.4-MariaDB

Description:

Illuminate\Foundation\Testing\Concerns\MakesHttpRequests.php

protected function extractFilesFromDataArray(&$data) {...}

This function works wrong.
You need to update $data variable:

Before:

if (is_array($value)) {
   $files[$key] = $this->extractFilesFromDataArray($value);
}

After:

if (is_array($value)) {
   $files[$key] = $this->extractFilesFromDataArray($value);
   $data[$key] = $value;
}

Steps To Reproduce:

I used next array in my test class:

$response = $this->postJson(route('admin.postcards.store'), [
   'background' => [
      'image_file' => UploadedFile::fake()->image('image.png', 100)
   ],
   'image_file' => UploadedFile::fake()->image('image_file.png', 100),
   'title' => 'Postcard',
   'slug' => 'postcard',
   'music' => ['id' => 2]
])->getData();

Json function inside Illuminate\Foundation\Testing\Concerns\MakesHttpRequests.php make my data equal to false, because background.image_file is not deleted.

@alexchitoraga
Copy link
Author

Anyone can solve this on laravel core?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant