multi-tenant: routes/tenants.php is not loaded during tests, because there's no tenant, when app initializes

Don’t want this to get lost in discord.

Currently routes/tenants.php is being loaded during boot of service providers and it checks for a tenant. My tests and tenant is being set up after that and since json request in tests do not actually create a new app, tenant routes are never defined.

Would it be possible to have callable function to load routes during runtime?


Information

  • hyn/multi-tenant version: 5.2
  • laravel version: 5.6

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 1
  • Comments: 23 (22 by maintainers)

Most upvoted comments

@luceos just tested 5.3.0 and the above test is passing. Thank you!

Looks like refresh method takes 3 parameters. Couldn’t figure out what to pass there…

/**
 * Refresh an instance on the given target and method.
 *
 * @param  string  $abstract
 * @param  mixed   $target
 * @param  string  $method
 * @return mixed
 */
public function refresh($abstract, $target, $method)
{
	return $this->rebinding($abstract, function ($app, $instance) use ($target, $method) {
		$target->{$method}($instance);
	});
}

I took the logic from your RouteProvider.php and implemented it into my tests for now. Official solution is still welcome 😉

Nice find! But I feel like there should be a better solution to this. Forcing a tenant does not help while testing system stuff.