I am trying to write some unit tests to ensure that my routes were not accidentally rewritten. I already found the answer to check if the correct controller is assigned to a specific route here .
However, I would also like to check if the mediators are correctly assigned to the route. I tried a similar approach with
$tmp = new CorsService;
$corsMiddleware = Mockery::mock('Barryvdh\Cors\HandleCors[handle]', array($tmp))
->shouldReceive('handle')->once()
->andReturnUsing(function($request, Closure $next) {
return $next($request);
});
\App::instance('Barryvdh\Cors\HandleCors', $corsMiddleware);
For some reason, the test does not pick it up. I assume this is because middleware instances are not saved using App::instance.
What am I doing wrong?
source
share