Skip to content

Commit 25dadba

Browse files
committed
Fix global filter segment in test utils
1 parent 925d03f commit 25dadba

File tree

3 files changed

+32
-2
lines changed

3 files changed

+32
-2
lines changed

src/Utils/Links/LinkToEntityList.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@ public function renderAsUrl(): string
5454
{
5555
return route('code16.sharp.list',
5656
array_merge(
57-
['entityKey' => $this->entityKey],
57+
[
58+
'filterKey' => sharp()->context()->globalFilterUrlSegmentValue(),
59+
'entityKey' => $this->entityKey,
60+
],
5861
$this->generateQuerystring(),
5962
),
6063
);

src/Utils/Links/LinkToSingleShowPage.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ public static function make(string $entityKey): self
1111

1212
public function renderAsUrl(): string
1313
{
14-
return route('code16.sharp.single-show', $this->entityKey);
14+
return route('code16.sharp.single-show', [
15+
'filterKey' => sharp()->context()->globalFilterUrlSegmentValue(),
16+
'entityKey' => $this->entityKey,
17+
]);
1518
}
1619
}

src/Utils/Testing/SharpAssertions.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
namespace Code16\Sharp\Utils\Testing;
44

55
use Closure;
6+
use Code16\Sharp\Filters\GlobalFilters\GlobalFilters;
67
use Code16\Sharp\Http\Context\SharpBreadcrumb;
78
use Code16\Sharp\Utils\Entities\SharpEntityManager;
89
use Code16\Sharp\Utils\Links\BreadcrumbBuilder;
10+
use Illuminate\Support\Facades\URL;
911

1012
trait SharpAssertions
1113
{
@@ -42,6 +44,8 @@ public function withSharpBreadcrumb(Closure $callback): self
4244

4345
public function deleteFromSharpShow(string $entityClassNameOrKey, $instanceId)
4446
{
47+
URL::defaults(['filterKey' => GlobalFilters::$defaultKey]);
48+
4549
$entityKey = $this->resolveEntityKey($entityClassNameOrKey);
4650

4751
return $this
@@ -59,6 +63,8 @@ public function deleteFromSharpShow(string $entityClassNameOrKey, $instanceId)
5963

6064
public function deleteFromSharpList(string $entityClassNameOrKey, $instanceId)
6165
{
66+
URL::defaults(['filterKey' => GlobalFilters::$defaultKey]);
67+
6268
$entityKey = $this->resolveEntityKey($entityClassNameOrKey);
6369

6470
return $this
@@ -73,6 +79,8 @@ public function deleteFromSharpList(string $entityClassNameOrKey, $instanceId)
7379

7480
public function getSharpForm(string $entityClassNameOrKey, $instanceId = null)
7581
{
82+
URL::defaults(['filterKey' => GlobalFilters::$defaultKey]);
83+
7684
$entityKey = $this->resolveEntityKey($entityClassNameOrKey);
7785

7886
return $this
@@ -100,6 +108,8 @@ public function getSharpForm(string $entityClassNameOrKey, $instanceId = null)
100108

101109
public function getSharpSingleForm(string $entityClassNameOrKey)
102110
{
111+
URL::defaults(['filterKey' => GlobalFilters::$defaultKey]);
112+
103113
$entityKey = $this->resolveEntityKey($entityClassNameOrKey);
104114

105115
return $this
@@ -117,6 +127,8 @@ public function getSharpSingleForm(string $entityClassNameOrKey)
117127

118128
public function updateSharpForm(string $entityClassNameOrKey, $instanceId, array $data)
119129
{
130+
URL::defaults(['filterKey' => GlobalFilters::$defaultKey]);
131+
120132
$entityKey = $this->resolveEntityKey($entityClassNameOrKey);
121133

122134
return $this
@@ -135,6 +147,8 @@ public function updateSharpForm(string $entityClassNameOrKey, $instanceId, array
135147

136148
public function updateSharpSingleForm(string $entityClassNameOrKey, array $data)
137149
{
150+
URL::defaults(['filterKey' => GlobalFilters::$defaultKey]);
151+
138152
$entityKey = $this->resolveEntityKey($entityClassNameOrKey);
139153

140154
return $this
@@ -152,6 +166,8 @@ public function updateSharpSingleForm(string $entityClassNameOrKey, array $data)
152166

153167
public function getSharpShow(string $entityClassNameOrKey, $instanceId)
154168
{
169+
URL::defaults(['filterKey' => GlobalFilters::$defaultKey]);
170+
155171
$entityKey = $this->resolveEntityKey($entityClassNameOrKey);
156172

157173
return $this
@@ -170,6 +186,8 @@ public function getSharpShow(string $entityClassNameOrKey, $instanceId)
170186

171187
public function storeSharpForm(string $entityClassNameOrKey, array $data)
172188
{
189+
URL::defaults(['filterKey' => GlobalFilters::$defaultKey]);
190+
173191
$entityKey = $this->resolveEntityKey($entityClassNameOrKey);
174192

175193
return $this
@@ -193,6 +211,8 @@ public function callSharpInstanceCommandFromList(
193211
array $data = [],
194212
?string $commandStep = null
195213
) {
214+
URL::defaults(['filterKey' => GlobalFilters::$defaultKey]);
215+
196216
$entityKey = $this->resolveEntityKey($entityClassNameOrKey);
197217

198218
$commandKey = class_exists($commandKeyOrClassName)
@@ -222,6 +242,8 @@ public function callSharpInstanceCommandFromShow(
222242
array $data = [],
223243
?string $commandStep = null
224244
) {
245+
URL::defaults(['filterKey' => GlobalFilters::$defaultKey]);
246+
225247
$entityKey = $this->resolveEntityKey($entityClassNameOrKey);
226248

227249
$commandKey = class_exists($commandKeyOrClassName)
@@ -250,6 +272,8 @@ public function callSharpEntityCommandFromList(
250272
array $data = [],
251273
?string $commandStep = null
252274
) {
275+
URL::defaults(['filterKey' => GlobalFilters::$defaultKey]);
276+
253277
$entityKey = $this->resolveEntityKey($entityClassNameOrKey);
254278

255279
$commandKey = class_exists($commandKeyOrClassName)

0 commit comments

Comments
 (0)