3
我需要基於cookie的存在來測試特定的行爲,在發送請求(或訪問頁面)之前如何設置cookie?目前下面的失敗,它的行爲喜歡沒有設置。如何在Laravel測試之前設置cookie?
$this->actingAs($user)
->withSession(['user' => $user, 'profile' => $profile]) ;
@setcookie('locale_lc', "fr", time() + 60 * 60 * 24 * 900, '/', "domain.com", true, true) ;
$this->visit('/profile') ;
或者
$cookie = ['locale_lc' => Crypt::encrypt('fr')] ;
$this->actingAs($user)
->withSession(['user' => $user, 'profile' => $profile])
->makeRequest('GET', '/profile', [], $cookie) ;
如果你還沒有禁用加密,這仍然有效嗎? – Flimm