Summary
We are writing unit tests to test the creation and invalidation of JWT tokens and receiving a \"The token could not be parsed from the reque
There are two ways to send a token to our API, If header is not working simply append to your URL. Example:
http://api.mysite.com/me?token={yourtokenhere}
So you could do this:
In your TestCase
public function signIn($data=['email'=>'youremail@yahoo.com', 'password'=>'password'])
{
$this->post('/auth/signin', $data);
$content = json_decode($this->response->getContent());
$this->assertObjectHasAttribute('token', $content, 'Token does not exists');
$this->token = $content->token;
return $this;
}
This will grab and store a token in $this->token so you can use it to make a request
Then later in your tests
public function testResticted()
{
$this->signIn();
$this->call('GET', '/restricted/page', ['token'=>$this->token], $cookies = [], $files = [], $server = []);
dump($this->response);
}