Passed
Push — release/3.1 ( 0467d5 )
by Josh
04:46
created

MockActionElement   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 115
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 21
dl 0
loc 115
ccs 30
cts 30
cp 1
rs 10
c 1
b 0
f 0
wmc 11

11 Methods

Rating   Name   Duplication   Size   Complexity  
A assertShownOnIndex() 0 5 1
A assertShownOnDetail() 0 5 1
A assertHiddenFromIndex() 0 5 1
A __construct() 0 3 1
A assertHiddenFromDetail() 0 5 1
A assertNotShownInline() 0 5 1
A assertHiddenFromTableRow() 0 3 1
A assertShownInline() 0 5 1
A assertShownOnTableRow() 0 3 1
A assertNotStandalone() 0 5 1
A assertStandalone() 0 5 1
1
<?php
2
3
namespace JoshGaber\NovaUnit\Actions;
4
5
use Laravel\Nova\Actions\Action;
6
use PHPUnit\Framework\Assert as PHPUnit;
7
8
class MockActionElement
9
{
10
    private $action;
11
12 17
    public function __construct(Action $action)
13
    {
14 17
        $this->action = $action;
15
    }
16
17
    /**
18
     * Assert that the action can be shown on the index view.
19
     *
20
     * @param  string  $message
21
     * @return $this
22
     */
23 2
    public function assertShownOnIndex(string $message = ''): self
24
    {
25 2
        PHPUnit::assertTrue($this->action->showOnIndex, $message);
26
27 1
        return $this;
28
    }
29
30
    /**
31
     * Assert that the action is hidden from the index view.
32
     *
33
     * @param  string  $message
34
     * @return $this
35
     */
36 2
    public function assertHiddenFromIndex(string $message = ''): self
37
    {
38 2
        PHPUnit::assertFalse($this->action->showOnIndex, $message);
39
40 1
        return $this;
41
    }
42
43
    /**
44
     * Assert that the action can be shown on the detail view.
45
     *
46
     * @param  string  $message
47
     * @return $this
48
     */
49 2
    public function assertShownOnDetail(string $message = ''): self
50
    {
51 2
        PHPUnit::assertTrue($this->action->showOnDetail, $message);
52
53 1
        return $this;
54
    }
55
56
    /**
57
     * Assert that the action is hidden from the detail view.
58
     *
59
     * @param  string  $message
60
     * @return $this
61
     */
62 2
    public function assertHiddenFromDetail(string $message = ''): self
63
    {
64 2
        PHPUnit::assertFalse($this->action->showOnDetail, $message);
65
66 1
        return $this;
67
    }
68
69
    /**
70
     * Assert that the action can be shown on table rows.
71
     *
72
     * @param  string  $message
73
     * @return $this
74
     */
75 2
    public function assertShownInline(string $message = ''): self
76
    {
77 2
        PHPUnit::assertTrue($this->action->showInline, $message);
78
79 1
        return $this;
80
    }
81
82
    /**
83
     * @deprecated
84
     */
85 2
    public function assertShownOnTableRow(string $message = ''): self
86
    {
87 2
        return $this->assertShownInline($message);
88
    }
89
90
    /**
91
     * Assert that the action is hidden from table rows.
92
     *
93
     * @param  string  $message
94
     * @return $this
95
     */
96 2
    public function assertNotShownInline(string $message = ''): self
97
    {
98 2
        PHPUnit::assertFalse($this->action->showInline, $message);
99
100 1
        return $this;
101
    }
102
103
    /**
104
     * @deprecated
105
     */
106 2
    public function assertHiddenFromTableRow(string $message = ''): self
107
    {
108 2
        return $this->assertNotShownInline($message);
109
    }
110
111 2
    public function assertStandalone(string $message = ''): self
112
    {
113 2
        PHPUnit::assertTrue($this->action->standalone, $message);
114
115 1
        return $this;
116
    }
117
118 2
    public function assertNotStandalone(string $message = ''): self
119
    {
120 2
        PHPUnit::assertFalse($this->action->standalone, $message);
121
122 1
        return $this;
123
    }
124
}
125