Passed
Push — master ( 48a45a...d91d3c )
by Caen
04:02
created

TestsBladeViews::testViewData()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Hyde\Testing;
6
7
use Illuminate\View\View;
8
use Hyde\Testing\Support\TestView;
9
10
/**
11
 * Provides a more fluent way to test Blade views.
12
 */
13
trait TestsBladeViews
14
{
15
    /**
16
     * Test a Blade view.
17
     */
18
    protected function test(string|View $view, $data = []): TestView
19
    {
20
        $data = array_merge($this->testViewData(), $data);
21
22
        if ($view instanceof View) {
23
            return new TestView($view->with($data));
24
        }
25
26
        return new TestView(view($view, $data));
27
    }
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
    }
36
}
37