protected function mockController($controllerName = null)
{
$controllerName = $controllerName ?: $this->controllerName;
$this->router = $this->app['router'];
$events = $this->getProperty($this->router, 'events');
$this->setProperty($this->router, 'events', $events);
$this->app['router'] = $this->router;
$this->mock($controllerName);
$controllerInstance = $this->app->make($controllerName);
$controllerInstance->shouldReceive('paramsBeforeFilter')->with(m::type('string'))->once();
$controllerInstance->shouldReceive('callAction')->with(m::type('string'), m::type('array'))->andReturnUsing(function ($method, $parameters) use($controllerInstance) {
$this->app->make('Params')->fillController($controllerInstance);
$filterName = "router.filter: controller.parameters." . get_classname($controllerInstance);
$this->assertTrue(Event::hasListeners($filterName));
Event::fire($filterName);
return new \Symfony\Component\HttpFoundation\Response();
});
$this->mock('\\Efficiently\\AuthorityController\\ControllerResource');
$this->controllerResource = $this->app->make('\\Efficiently\\AuthorityController\\ControllerResource');
$this->controllerResource->shouldReceive('getNameByController')->with('ProjectsController')->andReturn('project');
return $controllerInstance;
}