This is a common when testing. I've never seen a proper solution for this.
Some people would disabling the csrd token middleware when testing.
To disable The CSFR Check you can add the following to your class:
class MyTest extends TestCase
{
use WithoutMiddleware;
...
or you can use a check in the middleware if env == testing just return/go to next request.. (cant remember the exact code)
If you look at the middleware you can see how it works, it retrieves the stored session value for _token from session. So you can avoid the exception by simple passing some session data with your request:
$this->withSession(['_token'=>'test']) //here
->makeRequest('POST', $deleteEntry, [
'id'=>1,
'_token'=>'test' //here
])->seePageIs($url);
mmakita liked this reply
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community