0
背景: 我創建了一個測試類,它在laravel 5.1中正常工作;但不在laravel 5.2中。這是因爲文件的「測試」參數丟失。測試時使用文件上傳(UploadedFile)問題
我用以下代碼來創建文件請求:
$this->dataFile = new \Symfony\Component\HttpFoundation\File\UploadedFile(
base_path('tests/files/datafiles/A.csv'), 'A.csv', 'text/csv', 13071, null, true
);
,我可以用$ this->()調用
$this->call('POST', '/uploadFile?token=' . $this->token, $params, [], ['file' => [$this->dataFile]], []);
,我遇到的問題是,在接收發送結束「測試」參數來通過我們是假的:
[0] => Illuminate\Http\UploadedFile Object
(
[test:Symfony\Component\HttpFoundation\File\UploadedFile:private] =>
[originalName:Symfony\Component\HttpFoundation\File\UploadedFile:private] => A.csv
[mimeType:Symfony\Component\HttpFoundation\File\UploadedFile:private] => text/csv
[size:Symfony\Component\HttpFoundation\File\UploadedFile:private] => 13071
[error:Symfony\Component\HttpFoundation\File\UploadedFile:private] => 0
[pathName:SplFileInfo:private] => D:\tests/files/datafiles/A.csv
[fileName:SplFileInfo:private] => A.csv
)