Level 1
Ok...this answer was the solution...lol
Make sure you are using Illuminate\Http\UploadedFile to mock your file and not Symfony\Component\HttpFoundation\File\UploadedFile.
This is my controller:
public function bla() {
$file = Input::file('bla') ?: 'NO FILE';
print_r($file);
// ... more
}
And this is my test:
$filename = 'bla-file.txt';
$path = __DIR__ . '/fixtures/' . $filename;
$file = new UploadedFile($path, $filename);
$this->actingAs($this->user)->json('POST', 'api/bla', ['bla' => $file]);
PHPUnit prints always NO FILE from my controller in my console. I checked the laravel framework for json method. There is an method extractFilesFromDataArray which returns the correct key, because the bla key is an instanceof SymfonyUploadedFile.
But the Input::file('bla') is not set :(
Ok...this answer was the solution...lol
Make sure you are using Illuminate\Http\UploadedFile to mock your file and not Symfony\Component\HttpFoundation\File\UploadedFile.
Please or to participate in this conversation.