在 Laravel 编写单元测试时经常会遇到需要模拟认证用户的时候,比如新建文章.创建订单等,那么在 Laravel unit test 中如何来实现呢? 官方解决方法 Laravel 的官方文档中的测试章节中有提到: Of course, one common use of the session is for maintaining state for the authenticated user. The actingAs helper method provides a simple w…