这是我为类别测试创建的测试用例。我在这条路线上得到 404,而我已经正确配置了租户测试用例,并且这条路线存在于在 chrome 浏览器上创建的子域上。
public function test_example()
{
$response = $this->call('GET', '/categories/6/edit');
$this->assertEquals(200, $response->getStatusCode(),$response->exception->getMessage());
}
我的TestCase.php
protected $tenancy = false;
public function setUp(): void
{
parent::setUp();
if ($this->tenancy) {
$this->initializeTenancy();
}
}
public function initializeTenancy()
{
$tenant = Tenant::create();
tenancy()->initialize($tenant);
}
我正在关注的文档 https://tenancyforlaravel.com/docs/v3/testing
结果:我想要 302 响应意味着重定向到登录代码。