Completed
Push — master ( 3f89d7...f790e9 )
by Mike
30:28 queued 29:00
created

NovaTestCase   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 48
c 0
b 0
f 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 19 1
A authenticate() 0 9 1
A getPackageProviders() 0 11 1
1
<?php
2
3
namespace GeneaLabs\LaravelModelCaching\Tests;
4
5
use GeneaLabs\LaravelModelCaching\Tests\Fixtures\Nova\AuthorResource;
6
use GeneaLabs\LaravelModelCaching\Tests\Fixtures\Nova\BookResource;
7
use GeneaLabs\LaravelModelCaching\Tests\Fixtures\Nova\StoreResource;
8
use GeneaLabs\LaravelModelCaching\Tests\Fixtures\Providers\NovaServiceProvider;
9
use Illuminate\Contracts\Auth\Authenticatable;
10
use Laravel\Nova\Nova;
11
use Laravel\Nova\NovaCoreServiceProvider;
12
13
abstract class NovaTestCase extends FeatureTestCase
14
{
15
    protected $response;
16
17
    protected $authenticatedAs;
18
19
    public function setUp(): void
20
    {
21
        parent::setUp();
22
23
        Nova::$tools = [];
24
        Nova::$resources = [];
25
26
        Nova::resources([
27
            AuthorResource::class,
28
            BookResource::class,
29
            StoreResource::class,
30
        ]);
31
32
        Nova::auth(function () {
33
            return true;
34
        });
35
36
        $this->authenticate();
37
    }
38
39
    protected function authenticate()
40
    {
41
        $this->actingAs($this->authenticatedAs = \Mockery::mock(Authenticatable::class));
42
43
        $this->authenticatedAs->shouldReceive('getAuthIdentifier')->andReturn(1);
44
        $this->authenticatedAs->shouldReceive('getKey')->andReturn(1);
45
46
        return $this;
47
    }
48
49
    protected function getPackageProviders($app)
50
    {
51
        return array_merge(
52
            parent::getPackageProviders($app),
53
            [
54
                NovaCoreServiceProvider::class,
55
                \Laravel\Nova\NovaServiceProvider::class,
56
                NovaServiceProvider::class,
57
            ]
58
        );
59
    }
60
}
61