| Total Complexity | 4 |
| Total Lines | 30 |
| Duplicated Lines | 0 % |
| Changes | 7 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 14 | trait TestsBladeViews |
||
| 15 | { |
||
| 16 | /** |
||
| 17 | * Test a Blade view. |
||
| 18 | */ |
||
| 19 | protected function test(string|View $view, $data = []): TestView |
||
| 20 | { |
||
| 21 | $data = array_merge($this->testViewData(), $data); |
||
| 22 | |||
| 23 | if ($view instanceof View) { |
||
| 24 | return new TestView($view->with($data)); |
||
| 25 | } |
||
| 26 | |||
| 27 | return new TestView(view($view, $data)); |
||
| 28 | } |
||
| 29 | |||
| 30 | /** |
||
| 31 | * Create a testable HTML document instance. |
||
| 32 | */ |
||
| 33 | protected function html(string $html): TestableHtmlDocument |
||
| 34 | { |
||
| 35 | return new TestableHtmlDocument($html); |
||
| 36 | } |
||
| 37 | |||
| 38 | /** |
||
| 39 | * Define any view data to pass to all views in the test. |
||
| 40 | */ |
||
| 41 | protected function testViewData(): array |
||
| 42 | { |
||
| 43 | return []; |
||
| 44 | } |
||
| 46 |