【发布时间】:2016-09-23 07:54:21
【问题描述】:
我需要根据 cookie 的存在来测试特定行为,如何在发送请求(或访问页面)之前设置 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) ;
【问题讨论】:
标签: testing cookies laravel-5 phpunit