33namespace Code16 \Sharp \Utils \Testing ;
44
55use Closure ;
6- use Code16 \Sharp \Filters \GlobalFilters \GlobalFilters ;
76use Code16 \Sharp \Http \Context \SharpBreadcrumb ;
87use Code16 \Sharp \Utils \Entities \SharpEntityManager ;
98use Code16 \Sharp \Utils \Links \BreadcrumbBuilder ;
109use Code16 \Sharp \Utils \Testing \Dashboard \PendingDashboard ;
1110use Code16 \Sharp \Utils \Testing \EntityList \PendingEntityList ;
1211use Code16 \Sharp \Utils \Testing \Form \PendingForm ;
1312use Code16 \Sharp \Utils \Testing \Show \PendingShow ;
14- use Illuminate \Support \Facades \URL ;
1513
1614trait SharpAssertions
1715{
1816 use GeneratesCurrentPageUrl;
17+ use HasGlobalFilters;
1918
2019 private BreadcrumbBuilder $ breadcrumbBuilder ;
21- private ?string $ globalFilter = null ;
2220
2321 public function setUpSharpAssertions (): void
2422 {
25- URL :: defaults ([ ' globalFilter ' => $ this ->globalFilter ?: GlobalFilters:: $ defaultKey ] );
23+ $ this ->setGlobalFilterUrlDefault ( );
2624 }
2725
2826 public function sharpList (string $ entityClassNameOrKey ): PendingEntityList
2927 {
28+ $ this ->setGlobalFilterUrlDefault ();
29+
3030 return new PendingEntityList ($ this , $ entityClassNameOrKey );
3131 }
3232
3333 public function sharpShow (string $ entityClassNameOrKey , int |string |null $ instanceId = null ): PendingShow
3434 {
35+ $ this ->setGlobalFilterUrlDefault ();
36+
3537 return new PendingShow ($ this , $ entityClassNameOrKey , $ instanceId );
3638 }
3739
3840 public function sharpForm (string $ entityClassNameOrKey , int |string |null $ instanceId = null ): PendingForm
3941 {
42+ $ this ->setGlobalFilterUrlDefault ();
43+
4044 return new PendingForm ($ this , $ entityClassNameOrKey , $ instanceId );
4145 }
4246
4347 public function sharpDashboard (string $ entityClassNameOrKey ): PendingDashboard
4448 {
45- return new PendingDashboard ($ this , $ entityClassNameOrKey );
46- }
47-
48- public function withSharpGlobalFilterValues (array |string $ globalFilterValues ): self
49- {
50- $ this ->globalFilter = collect ((array ) $ globalFilterValues )
51- ->implode (GlobalFilters::$ valuesUrlSeparator );
52-
53- URL ::defaults (['globalFilter ' => $ this ->globalFilter ?: GlobalFilters::$ defaultKey ]);
49+ $ this ->setGlobalFilterUrlDefault ();
5450
55- return $ this ;
51+ return new PendingDashboard ( $ this , $ entityClassNameOrKey ) ;
5652 }
5753
5854 /**
5955 * @deprecated use withSharpBreadcrumb() instead
6056 */
61- public function withSharpCurrentBreadcrumb (...$ breadcrumb ): self
57+ public function withSharpCurrentBreadcrumb (...$ breadcrumb ): static
6258 {
6359 $ this ->breadcrumbBuilder = new BreadcrumbBuilder ();
6460
@@ -77,7 +73,7 @@ public function withSharpCurrentBreadcrumb(...$breadcrumb): self
7773 * @param (\Closure(BreadcrumbBuilder): BreadcrumbBuilder) $callback
7874 * @return $this
7975 */
80- public function withSharpBreadcrumb (Closure $ callback ): self
76+ public function withSharpBreadcrumb (Closure $ callback ): static
8177 {
8278 $ this ->breadcrumbBuilder = $ callback (new BreadcrumbBuilder ());
8379
@@ -92,7 +88,6 @@ public function deleteFromSharpShow(string $entityClassNameOrKey, mixed $instanc
9288 ->delete (
9389 route (
9490 'code16.sharp.show.delete ' , [
95- 'globalFilter ' => $ this ->globalFilter ,
9691 'parentUri ' => $ this ->breadcrumbBuilder ($ entityKey )->generateUri (),
9792 'entityKey ' => $ entityKey ,
9893 'instanceId ' => $ instanceId ,
@@ -114,7 +109,6 @@ public function deleteFromSharpList(string $entityClassNameOrKey, mixed $instanc
114109 )
115110 ->delete (
116111 route ('code16.sharp.api.list.delete ' , [
117- 'globalFilter ' => $ this ->globalFilter ,
118112 'entityKey ' => $ entityKey ,
119113 'instanceId ' => $ instanceId ,
120114 ])
@@ -131,7 +125,6 @@ public function getSharpForm(string $entityClassNameOrKey, mixed $instanceId = n
131125 ? route (
132126 'code16.sharp.form.edit ' ,
133127 [
134- 'globalFilter ' => $ this ->globalFilter ,
135128 'parentUri ' => $ this ->breadcrumbBuilder ($ entityKey )->generateUri (),
136129 'entityKey ' => $ entityKey ,
137130 'instanceId ' => $ instanceId ,
@@ -140,7 +133,6 @@ public function getSharpForm(string $entityClassNameOrKey, mixed $instanceId = n
140133 : route (
141134 'code16.sharp.form.create ' ,
142135 [
143- 'globalFilter ' => $ this ->globalFilter ,
144136 'parentUri ' => $ this ->breadcrumbBuilder ($ entityKey )->generateUri (),
145137 'entityKey ' => $ entityKey ,
146138 ]
@@ -157,7 +149,6 @@ public function getSharpSingleForm(string $entityClassNameOrKey)
157149 route (
158150 'code16.sharp.form.edit ' ,
159151 [
160- 'globalFilter ' => $ this ->globalFilter ,
161152 'parentUri ' => $ this ->breadcrumbBuilder ($ entityKey )->generateUri (),
162153 'entityKey ' => $ entityKey ,
163154 ]
@@ -173,7 +164,6 @@ public function updateSharpForm(string $entityClassNameOrKey, $instanceId, array
173164 ->post (
174165 route (
175166 'code16.sharp.form.update ' , [
176- 'globalFilter ' => $ this ->globalFilter ,
177167 'parentUri ' => $ this ->breadcrumbBuilder ($ entityKey )->generateUri (),
178168 'entityKey ' => $ entityKey ,
179169 'instanceId ' => $ instanceId ,
@@ -191,7 +181,6 @@ public function updateSharpSingleForm(string $entityClassNameOrKey, array $data)
191181 ->post (
192182 route (
193183 'code16.sharp.form.update ' , [
194- 'globalFilter ' => $ this ->globalFilter ,
195184 'parentUri ' => $ this ->breadcrumbBuilder ($ entityKey )->generateUri (),
196185 'entityKey ' => $ entityKey ,
197186 ]
@@ -209,7 +198,6 @@ public function getSharpShow(string $entityClassNameOrKey, $instanceId)
209198 route (
210199 'code16.sharp.show.show ' ,
211200 [
212- 'globalFilter ' => $ this ->globalFilter ,
213201 'parentUri ' => $ this ->breadcrumbBuilder ($ entityKey )->generateUri (),
214202 'entityKey ' => $ entityKey ,
215203 'instanceId ' => $ instanceId ,
@@ -227,7 +215,6 @@ public function storeSharpForm(string $entityClassNameOrKey, array $data)
227215 route (
228216 'code16.sharp.form.store ' ,
229217 [
230- 'globalFilter ' => $ this ->globalFilter ,
231218 'parentUri ' => $ this ->breadcrumbBuilder ($ entityKey )->generateUri (),
232219 'entityKey ' => $ entityKey ,
233220 ]
@@ -317,7 +304,7 @@ public function callSharpEntityCommandFromList(
317304 );
318305 }
319306
320- public function loginAsSharpUser ($ user ): self
307+ public function loginAsSharpUser ($ user ): static
321308 {
322309 return $ this ->actingAs ($ user , sharp ()->config ()->get ('auth.guard ' ) ?: config ('auth.defaults.guard ' ));
323310 }
0 commit comments