protected function setUp() { parent::setUp(); $this->mock_view_finder = Mockery::mock('Illuminate\\View\\ViewFinderInterface')->shouldIgnoreMissing(); $this->mock_engine_resolver = Mockery::mock('Illuminate\\View\\Engines\\EngineResolver')->shouldIgnoreMissing(); $this->mock_translator = Mockery::mock('\\Illuminate\\Translation\\Translator')->shouldIgnoreMissing(); $this->mock_session = Mockery::mock('\\Illuminate\\Session\\Store')->shouldIgnoreMissing(); $this->mock_dispatcher = Mockery::mock('\\Illuminate\\Contracts\\Events\\Dispatcher')->shouldIgnoreMissing(); $this->mock_engine_resolver->shouldReceive('resolve')->andReturn(Mockery::mock('\\Illuminate\\View\\Engines\\EngineInterface')->shouldIgnoreMissing()); $this->factory = new Factory($this->mock_engine_resolver, $this->mock_view_finder, $this->mock_dispatcher, $this->mock_translator); $this->factory->setSession($this->mock_session); }
/** * Register the view environment. * * @return void */ public function registerFactory() { $this->app->bindShared('view', function ($app) { // Next we need to grab the engine resolver instance that will be used by the // environment. The resolver will be used by an environment to get each of // the various engine implementations such as plain PHP or Blade engine. $resolver = $app['view.engine.resolver']; $finder = $app['view.finder']; $env = new Factory($resolver, $finder, $app['events'], $app['translator']); // If the session is set on the application instance, we'll inject it into // the factory instance. This allows the view to use the flash session to // get messages from the redirector if (isset($app['session'])) { $env->setSession($app['session.store']); } // We will also set the container instance on this view environment since the // view composers may be classes registered in the container, which allows // for great testable, flexible composers for the application developer. $env->setContainer($app); $env->share('app', $app); return $env; }); }