Passed
Push — master ( 5fa21f...f08728 )
by Caen
03:34 queued 15s
created

InteractsWithPages   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 9
c 3
b 0
f 0
dl 0
loc 23
rs 10
wmc 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Hyde\Testing;
6
7
use Hyde\Pages\InMemoryPage;
8
use Hyde\Pages\Concerns\HydePage;
9
use Hyde\Support\Facades\Render;
10
use Hyde\Support\Models\Route;
11
12
trait InteractsWithPages
13
{
14
    protected function mockRoute(?Route $route = null): static
15
    {
16
        Render::share('route', $route ?? (new Route(new InMemoryPage())));
17
18
        return $this;
19
    }
20
21
    protected function mockPage(?HydePage $page = null, ?string $currentPage = null): static
22
    {
23
        Render::share('page', $page ?? new InMemoryPage());
24
        Render::share('routeKey', $currentPage ?? 'foo');
25
26
        return $this;
27
    }
28
29
    protected function mockCurrentPage(string $currentPage): static
30
    {
31
        Render::share('routeKey', $currentPage);
32
        Render::share('route', new Route(new InMemoryPage($currentPage)));
33
34
        return $this;
35
    }
36
}
37