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

MockAction::handle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace JoshGaber\NovaUnit\Actions;
4
5
use Illuminate\Database\Eloquent\Collection;
6
use Illuminate\Database\Eloquent\Model;
7
use JoshGaber\NovaUnit\MockComponent;
8
use JoshGaber\NovaUnit\Traits\FieldAssertions;
9
use Laravel\Nova\Fields\ActionFields;
10
11
class MockAction extends MockComponent
12
{
13
    use FieldAssertions;
14
15
    /**
16
     * Dispatches the Action, and returns a test handler for the Action response.
17
     *
18
     * @param array $fields A set of action fields send to the Action, as a key-value array
19
     * @param Model|Model[]|Collection $models A set of models sent to the Action
20
     * @return MockActionResponse A mock class for testing Nova Action responses
21
     */
22 1
    public function handle(array $fields, $models): MockActionResponse
23
    {
24 1
        return new MockActionResponse(
25 1
            $this->component->handle(new ActionFields(collect($fields), collect()), collect($models))
26
        );
27
    }
28
}
29