【发布时间】:2020-11-22 03:30:49
【问题描述】:
我正在使用Hyn/multi-tenant 5.6 包来支持多租户应用程序。
我的应用程序运行良好,我可以创建租户并且它们运行正常。
问题来自于测试。我想为我的测试目的设置一个现有租户。但不知何故,应用程序无法在测试期间创建正确的路由。
在 CreateApplication.php 中,我设置了用于测试的租户。其中有website_id = 1
trait CreatesApplication
{
/**
* Creates the application.
*
* @return \Illuminate\Foundation\Application
*/
public function createApplication()
{
$app = require __DIR__.'/../bootstrap/app.php';
$app->make(Kernel::class)->bootstrap();
return $app;
}
public function setUp() : void{
parent::setUp();
$hostname = Hostname::find(1);
$website = Website::findOrFail($hostname->website_id);
$tenancy = app(Environment::class);
$tenancy->hostname($hostname);
Artisan::call('optimize:clear');
Artisan::call('tenancy:migrate:fresh', ['--website_id' => 1]);
Artisan::call('tenancy:db:seed',['--class' => 'TenantSeeder','--website_id' => 1]);
}
}
我通过谷歌搜索发现了一些类似的问题,但他们的解决方案都不适合我: https://github.com/tenancy/multi-tenant/issues/584
我所有的路线都在我的tenants.php 文件中并且正在运行。
我正在使用最新版本的 PHPUNIT。
我得到的错误是:
Symfony\Component\Routing\Exception\RouteNotFoundException : Route [new_anmeldung_single] not defined.
【问题讨论】:
标签: laravel testing phpunit multi-tenant laravel-7