繁体   English   中英

租户多租户 Laravel 单元测试问题

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM