Skip to content

Commit 48a45ad

Browse files
authored
Merge pull request #1596 from hydephp/improved-view-testing
Improved view testing helper
2 parents 84f5a12 + 8de743a commit 48a45ad

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

packages/testing/src/TestsBladeViews.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,20 @@ trait TestsBladeViews
1717
*/
1818
protected function test(string|View $view, $data = []): TestView
1919
{
20+
$data = array_merge($this->testViewData(), $data);
21+
2022
if ($view instanceof View) {
21-
return new TestView($view);
23+
return new TestView($view->with($data));
2224
}
2325

2426
return new TestView(view($view, $data));
2527
}
28+
29+
/**
30+
* Define any view data to pass to all views in the test.
31+
*/
32+
protected function testViewData(): array
33+
{
34+
return [];
35+
}
2636
}

0 commit comments

Comments
 (0)