Php 重定向后的Laravel断言状态
我正在尝试测试一个简单的控制器:Php 重定向后的Laravel断言状态,php,laravel,Php,Laravel,我正在尝试测试一个简单的控制器: public function testCreatePlace() { $response = $this->json('post','/create/place', [ 'name' => 'Testburg', 'description' => 'Hauptstadt Testlands' ]); $response->assertStatus(200); } 但问题是,我的
public function testCreatePlace()
{
$response = $this->json('post','/create/place', [
'name' => 'Testburg',
'description' => 'Hauptstadt Testlands'
]);
$response->assertStatus(200);
}
但问题是,我的中间件将用户重定向到具有特定语言版本的子域(例如,
de.mywebsite.vagrant
)。因此,当我运行测试时,它会获得第一个状态302,并立即中断。我如何在重定向后断言请求,resp。获取结束响应状态?您可以随时禁用中间件。Laravel为每个测试端提供了withoutMiddleware特性注意:我相信您的状态代码需要是201
,因为这是一个创建操作