Did you find a solution? Seems to be a bit of a problem for me also. Id rather not have to mock the requirements for each ViewComposer with each Controller that will load a view of that ViewComposer inside.
Try this (tested in L5)
$factory = app('Illuminate\Contracts\View\Factory');
$mockView = $factory->make('modules/some-partial', ['inputData'=> 1]);
$mockComposer= new App\Http\ViewComposers\myComposer();
$mockComposer->compose($mockView);
//testing the data
$this->assertTrue($mockView->getData()['inputData']===2);
$html = $mockView->render();
//use your DOM parser of choice to test the $html from here
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community