[UniversalRoutes::class]]); Route::get('/foo', function () { return tenancy()->initialized ? 'Tenancy is initialized.' : 'Tenancy is not initialized.'; })->middleware(['universal', InitializeTenancyByDomain::class]); $this->get('http://localhost/foo') ->assertSuccessful() ->assertSee('Tenancy is not initialized.'); $tenant = Tenant::create([ 'id' => 'acme', ]); $tenant->domains()->create([ 'domain' => 'acme.localhost', ]); $this->get('http://acme.localhost/foo') ->assertSuccessful() ->assertSee('Tenancy is initialized.'); } /** @test */ public function making_one_route_universal_doesnt_make_all_routes_universal() { Route::get('/bar', function () { return tenant('id'); })->middleware(InitializeTenancyByDomain::class); $this->a_route_can_work_in_both_central_and_tenant_context(); tenancy()->end(); $this->get('http://localhost/bar') ->assertStatus(500); $this->get('http://acme.localhost/bar') ->assertSuccessful() ->assertSee('acme'); } }