Laravel integration test with several file inputs doesn't prepare input array properly
Hello, I have a form with following part of inputs:
{!! Form::file('documents[0][document]')) !!}
{!! Form::file('documents[1][document]')) !!}
{!! Form::file('documents[2][document]')) !!}
When I debug input array, I have a right structure of data, like this:
'documents' =>
array (
0 =>
array (
'document' =>
Illuminate\Http\UploadedFile::__set_state(array(
'test' => false,
'originalName' => 'tab1.png',
'mimeType' => 'image/png',
'size' => 82244,
'error' => 0,
)),
),
1 =>
array (
'document' => NULL,
),
2 =>
array (
'document' => NULL,
),
)
But when I debug the same request on integration test, I have a plain structure like this:
'documents[0][document]' =>
Illuminate\Http\UploadedFile::__set_state(array(
'test' => true,
'originalName' => 'dump1.jpg',
'mimeType' => 'application/octet-stream',
'size' => 90256,
'error' => 0,
)),
'documents[1][document]' =>
Illuminate\Http\UploadedFile::__set_state(array(
'test' => true,
'originalName' => 'dump2.jpg',
'mimeType' => 'application/octet-stream',
'size' => 90256,
'error' => 0,
))
I can manage it by manual transformation keys 'document[0], document[1], ... ' into correct structure 'documents => array(0 => array(), 1 => array, ...)' with checking if app is running in console (which means that tests are running instead of real web app). But what's the reason? I found that everything is fine with simple data. Let's say I have same nested structure for text values instead of files, and debugging of request during the test will show correct nested structure of input array. So, is it a bug of Laravel tests? Can I manage it in more clear way instead of manual transform of input array? The purpose is to keep separate input[type="file"] for each file, not single input with multiple=true attribute, and to cover it by tests, of course.
Please or to participate in this conversation.