testy's avatar
Level 1

Problem with unit test Input::file

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

0 likes
1 reply

Please or to participate in this conversation.