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
|
|
|
|