mardi 25 octobre 2016

Laravel 5.3 TestCase upload file return null

I'm new to the phpunit and laravel testcase. I want to test upload file and add path to database. But when i run the code the file is null. Here are the code:

The testcase:

$file = new UploadedFile( 
        base_path(). "/public/upload/test.txt",
        'test.txt',
        'text/plain',
        502,
        null,
        true
    );
$posted = [];

The call:

$response = $this->call('POST', 'upload', $posted,[],['file' => $file]);

The Controller:

function upload(Request $request){
   dd($request->file());
}

The result:

[]



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire