/** * Register the application services. * * @return void */ public function register() { $this->mergeConfigFrom(__DIR__ . '/../config/errors.php', 'errors'); $this->app->singleton(ViewErrorBag::class, function ($app) { $errorBag = new ViewErrorBag(); $errorBag->setClasses($app['config']->get('errors.classes', [])); $errorBag->setMessages($app['config']->get('errors.messages', [])); return $errorBag; }); }
/** * @test */ public function it_loads_an_existing_view_error_bag_from_a_request() { $request = Mockery::mock(Illuminate\Http\Request::class); $messageBags = $this->bag->getBags(); $request->shouldReceive('session')->once()->andReturn(Mockery::self())->shouldReceive('get')->once()->andReturn(Mockery::self())->shouldReceive('getBags')->once()->andReturn($messageBags); // MessageBags $bag = new ViewErrorBag(); $bag->make($request); $this->assertEquals(3, $bag->count()); }