測試環境不會驗證 CSRF token,總是會通過 可以在 VerifyCsrfToken Middleware 中看到 $this->runningUnitTests() @Illuminate\Foundation\Http\Middleware\VerifyCsrfToken /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed * * @throws \Illuminate\Session\TokenMismatchException */ public function handle ($request, Closure $next) { if ( $this ->isReading($request) || $this ->runningUnitTests() || $this ->inExceptArray($request) || $this ->tokensMatch($request) ) { return tap($next($request), function ($response) use ($request) { if ( $this ->shouldAddXsrfTokenCookie()) { $this ->addCookieToResponse($request, $response); } }); } throw new TokenMismatchException( 'CSRF token mi...