Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.x] Allow testing of Blade components that return closures #36919

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -2,6 +2,7 @@

namespace Illuminate\Foundation\Testing\Concerns;

use Closure;
use Illuminate\Support\Facades\View as ViewFacade;
use Illuminate\Support\MessageBag;
use Illuminate\Support\Str;
Expand Down Expand Up @@ -58,6 +59,10 @@ protected function component(string $componentClass, array $data = [])

$view = $component->resolveView();

if ($view instanceof Closure) {
$view = $view($data);
}

return $view instanceof View
? new TestView($view->with($component->data()))
: new TestView(view($view, $component->data()));
Expand Down