{"action":"created","issue":{"url":"https://api.github.com/repos/tymondesigns/jwt-auth/issues/161","labels_url":"https://api.github.com/repos/tymondesigns/jwt-auth/issues/161/labels{/name}","comments_url":"https://api.github.com/repos/tymondesigns/jwt-auth/issues/161/comments","events_url":"https://api.github.com/repos/tymondesigns/jwt-auth/issues/161/events","html_url":"https://github.com/tymondesigns/jwt-auth/issues/161","id":91333421,"number":161,"title":"$this->token being persisted on phpunit tests","user":{"login":"desertwinds","id":3259932,"avatar_url":"https://avatars.githubusercontent.com/u/3259932?v=3","gravatar_id":"","url":"https://api.github.com/users/desertwinds","html_url":"https://github.com/desertwinds","followers_url":"https://api.github.com/users/desertwinds/followers","following_url":"https://api.github.com/users/desertwinds/following{/other_user}","gists_url":"https://api.github.com/users/desertwinds/gists{/gist_id}","starred_url":"https://api.github.com/users/desertwinds/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/desertwinds/subscriptions","organizations_url":"https://api.github.com/users/desertwinds/orgs","repos_url":"https://api.github.com/users/desertwinds/repos","events_url":"https://api.github.com/users/desertwinds/events{/privacy}","received_events_url":"https://api.github.com/users/desertwinds/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2015-06-26T18:56:57Z","updated_at":"2015-07-16T17:02:54Z","closed_at":null,"body":"I'm testing my laravel 5.1 rest api with phpunit and somehow the token gets persisted. On one of my tests I have 2 different calls using 2 different tokens for users which I previously authenticate using the uri for doing so. However when I make the second call, the getToken() function retrieves the token set by the first call and so the \"authenticated\" user is the one from the first call. Is there a way to solve this? Or is this the intended flow and I'm missing something with phpunit?"},"comment":{"url":"https://api.github.com/repos/tymondesigns/jwt-auth/issues/comments/122022895","html_url":"https://github.com/tymondesigns/jwt-auth/issues/161#issuecomment-122022895","issue_url":"https://api.github.com/repos/tymondesigns/jwt-auth/issues/161","id":122022895,"user":{"login":"gvhuyssteen","id":1265536,"avatar_url":"https://avatars.githubusercontent.com/u/1265536?v=3","gravatar_id":"","url":"https://api.github.com/users/gvhuyssteen","html_url":"https://github.com/gvhuyssteen","followers_url":"https://api.github.com/users/gvhuyssteen/followers","following_url":"https://api.github.com/users/gvhuyssteen/following{/other_user}","gists_url":"https://api.github.com/users/gvhuyssteen/gists{/gist_id}","starred_url":"https://api.github.com/users/gvhuyssteen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gvhuyssteen/subscriptions","organizations_url":"https://api.github.com/users/gvhuyssteen/orgs","repos_url":"https://api.github.com/users/gvhuyssteen/repos","events_url":"https://api.github.com/users/gvhuyssteen/events{/privacy}","received_events_url":"https://api.github.com/users/gvhuyssteen/received_events","type":"User","site_admin":false},"created_at":"2015-07-16T17:02:54Z","updated_at":"2015-07-16T17:02:54Z","body":"In my Controller __construct method, I have these few lines of code that is running that sorts out this issue.\r\n\r\n```\r\nif ((\\App::environment() == 'testing') && array_key_exists(\"HTTP_Authorization\",  Request::server())) {\r\n    JWTAuth::setRequest(\\Route::getCurrentRequest());\r\n}\r\n````\r\n\r\nIs there a better solution?"}}