Turns out that Dusk can handle this :D
Dec 12, 2016
3
Level 29
Load view composer for a single test method
Hello everyone.
I'm trying to test a page with a form that's generated by a View composer instance inside the ViewComposerServiceProvider:
View::composer("components.user.settings", function ($view)
{
$settings = Setting::select(["key", "value"])->orderBy("key")->get();
$view->withSettings($settings);
});
The view is rendered properly when you use it but inside my test suite I cannot select any <select> generate by this view composer because the page rendered with PHPUnit doesn't have those selects at all.
I read about a bunch of solutions like forcing the rendering inside the test method by calling $this->app->make(... but I don't like very much and I wonder if Laravel has something already built in that I'm missing.
Does Laravel provide some sort of trait or whatever that I'm missing in order to render the view composer properly ?
Level 29
Please or to participate in this conversation.