How to create a unit test with Header Authentication?

0

I'm using the php framework Lumen and I need to do a unit test that passes through a midleware with authentication via token

Basically I get a token when I log in, and after that in this type of request I need to send an Authorization header

The value of it is my_hash MY_TOKEN.

Currently my unit test looks like this:

<?php

class EControllerTest extends TestCase
{

    public function testE(){

        //aqui é um exemplo de token valido que eu irei atomatizar futuramente.
        $token = "TOKENTOKNETOKNETOKENTOKENTOKNE";

        //ESTA REQUISIÇÃO PRECISA RECEBER NO HEADER O TOKEN QUE RECEBO AO LOGAR.
        $r = $this->json('GET', '/api/1/oda/1/evaluation', []);

        //Daqui pra baixo só funciona se eu passar o token 
        $json = (json_decode($r->response->getContent()))[0];
    }

}
    
asked by anonymous 18.06.2018 / 19:38

0 answers