Hi
I am using Laravel 5.2 with Dingo to write APIs for my application. My application uses JWT to authenticate users.
I also wanted to write test cases for the API endpoints. When I hit my api endpoints using POSTMAN, they work like a charm, but the same endpoints when being hit through phpunit test cases, respond with [B]401 Unauthorized
Following is my test case code:
[code=php]
public function testSomeTest()
{
$token = ‘Bearer xxx’;
$response = $this->get(‘/users’, [‘Authorization’ => $token]);
print_r($response->dump());
}
I have also tried the following, but no dice
[code=php]
public function testSomeTest()
{
$token = ‘Bearer xxx’;
$response = $this->call(‘GET’, ‘/users’, [],[],[], [‘Authorization’ => $token]);
print_r($response->getContent());
}
Here is the error output: [url]http://pastebin.com/raw/Tjirez1V
Can someone please help me figure out what could be the problem?