【发布时间】:2015-11-04 21:44:30
【问题描述】:
我对 Laravel 5.1 中的单元测试有点困惑。
我想测试来自用户帐户的设置更新。我正在使用phpunit 进行测试。
这是我的测试用例。
/** @test */
public function it_updates_personal_details(){
$this->withoutMiddleware();
$this->visit('/account/settings')
->post('/account/settings', ["firstname"=>"RingoUpdated", 'lastname'=>"RingyUpdated", "username"=>"ringo", "bio"=>"My Personal Information", "facebook"=>"myFbUsername", "twitter"=>"myTwUsername", ])
->seeJson([
"signup"=>true
]);
}
但在我的控制器中,我使用Auth::id() 来获取当前登录用户的id。如何在 Laravel 5.1 中模拟这个?
【问题讨论】:
标签: php unit-testing laravel-5.1