Laravel 功能测试中设置请求 Cookie 的方法

TL;DR $this->withUnencryptedCookie('cookie_name', $cookieValue) ->withCredentials() 正文 在功能测试中,我们通常要使用 $this->postJson() 系列方法来测试接口,在此之前只要用 $this->actingAs() 即可解决登录态的问题 不过这次要测的接口比较特别,需要往 cookie 中塞 token 来维持登录态 我简单看了一下 postJson() 的源码,第三个参数名叫 $header。噢,我

文章来源:

Author:mokeyjay
link:https://mok.moe/p/ejqg