lundi 26 décembre 2016

PHPUnit / Laravel 5.3 - Header not reaching server while testing file upload

I am writing code to test the file upload using PHPUnit in Laravel 5.3. I am JWT and I am sending the token in the header (HTTP_Authorization), but the token is not reaching the server. The code is given below.

Please tell me what is wrong with my code?

public function testUpload()
{
     $content = $this->post('users/login', ['password' => 'mypass',
                'email' => 'scko@gmail.com'])->response->getContent();

    $data = json_decode($content);
    $token =  $data->token;


    $stub = 'D:/work/gw.png';
    $name = str_random(8).'.png';
    $path = 'D:/storage/userfiles/78/'.$name;

    copy($stub, $path);


    $file = new \Illuminate\Http\UploadedFile($path, $name, filesize($path), 'image/png', null, true);
    $response = $this->call('POST', 'files/uploadcardimage', ['HTTP_Authorization' => $token], [] ['file' => $file], ['Accept' => 'application/json']);

    $content = json_decode($response->getContent());

    echo json_encode($content);
    die;



}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire