[英]Tenant Multi tenancy Laravel Unit Testing issue
這是我為類別測試創建的測試用例。 我在這條路線上得到 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 響應意味着重定向到登錄代碼。
我希望這段代碼可以幫助你
https://github.com/archtechx/tenancy/issues/635#issuecomment-939226522
tenancy()->initialize($tenant);
URL::forceRootUrl('http://' . $tenant->domains[0]['domain']);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.