Skip to content

Commit

Permalink
Allow testing of Blade components that return closures (#36919)
Browse files Browse the repository at this point in the history
  • Loading branch information
mpociot committed Apr 8, 2021
1 parent 5e0ef03 commit 94fd966
Showing 1 changed file with 5 additions and 0 deletions.
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

0 comments on commit 94fd966

Please sign in to comment.