How to assert if a middleware is applied on a specific route
I have a case where I need to set default locale on certain routes in my applications. So I created a middleware that does this job perfectly fine if it is applied on a route.
While creating tests I need to assert whether certain routes has applied this middleware or not. Is there a way in laravel where we can do this?
My middleware
class ForceBackOfficeLocale
{
public function handle($request, Closure $next)
{
if (! in_array(App::currentLocale(), Locales::enabledInBackOffice())) {
App::setLocale(Locales::default());
}
return $next($request);
}
}
I am already doing what you just mentioned, my question is how do I test if a route applies a specific middleware or not (not if middleware works or not).