$this->withoutMiddleware();
Should do the trick, more here:
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi all. I'm starting a new project and I've just written my first test, but it's failing on CSRF validation. I was under the impression that CSRF validation was disabled for testing? Where does the logic live to disable this?
/** @test */
public function a_user_can_open_a_bank_account () {
// Given we have a user
$this->signIn();
// And a new bank account
$newBankAccount = make(BankAccount::class, [
'user_id' => auth()->id()
]);
// And they submit the form to open a new bank account
$this->post(auth()->id() . '/banking/account', $newBankAccount->toArray());
// Then they should have a bank account associated with them
$this->assertEquals(1, auth()->user()->bankAccounts()->count());
}
Illuminate\Session\TokenMismatchException
$this->withoutMiddleware();
Should do the trick, more here:
Please or to participate in this conversation.