Passed
Push — master ( 5153a0...c7b3db )
by Josh
03:56
created

NovaResourceTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 17
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A novaResource() 0 7 2
1
<?php
2
3
namespace JoshGaber\NovaUnit\Resources;
4
5
use Illuminate\Database\Eloquent\Model;
6
use Laravel\Nova\Resource;
7
8
trait NovaResourceTest
9
{
10
    /**
11
     * Initialize the Nova Resource mock.
12
     *
13
     * @param string $class The class path of the Resource
14
     * @param Model $model The object to apply to this Resource
15
     * @return MockResource The Resource mock instance
16
     * @throws InvalidNovaResourceException If the supplied action class is not a Nova Resource
17
     */
18 2
    public static function novaResource(string $class, Model $model): MockResource
19
    {
20 2
        if (! \is_subclass_of($class, Resource::class)) {
21 1
            throw new InvalidNovaResourceException();
22
        }
23
24 1
        return new MockResource(new $class($model));
25
    }
26
}
27