Support the ongoing development of Laravel.io →
Views Architecture Testing
Last updated 2 years ago.
0

any idea ?

Last updated 2 years ago.
0

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.

Last updated 2 years ago.
0

Hi,

Did you found any solution?

Thanks

Last updated 2 years ago.
0

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
Last updated 8 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Elyahou elyahou Joined 7 Mar 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.