@@ -113,7 +113,7 @@ public function test_gate_watcher_registers_allowed_policy_entries()
113
113
114
114
$ this ->assertSame (EntryType::GATE , $ entry ->type );
115
115
$ this ->assertSame (__FILE__ , $ entry ->content ['file ' ]);
116
- $ this ->assertSame (271 , $ entry ->content ['line ' ]);
116
+ $ this ->assertSame (303 , $ entry ->content ['line ' ]);
117
117
$ this ->assertSame ('create ' , $ entry ->content ['ability ' ]);
118
118
$ this ->assertSame ('allowed ' , $ entry ->content ['result ' ]);
119
119
$ this ->assertSame ([[]], $ entry ->content ['arguments ' ]);
@@ -156,12 +156,34 @@ public function test_gate_watcher_registers_denied_policy_entries()
156
156
157
157
$ this ->assertSame (EntryType::GATE , $ entry ->type );
158
158
$ this ->assertSame (__FILE__ , $ entry ->content ['file ' ]);
159
- $ this ->assertSame (276 , $ entry ->content ['line ' ]);
159
+ $ this ->assertSame (308 , $ entry ->content ['line ' ]);
160
160
$ this ->assertSame ('update ' , $ entry ->content ['ability ' ]);
161
161
$ this ->assertSame ('denied ' , $ entry ->content ['result ' ]);
162
162
$ this ->assertSame ([[]], $ entry ->content ['arguments ' ]);
163
163
}
164
164
165
+ public function test_gate_watcher_calls_format_for_telescope_method_if_it_exists ()
166
+ {
167
+ $ this ->app ->setBasePath (dirname (__FILE__ , 3 ));
168
+
169
+ Gate::policy (TestResourceWithFormatForTelescope::class, TestPolicy::class);
170
+
171
+ try {
172
+ (new TestController ())->update (new TestResourceWithFormatForTelescope ());
173
+ } catch (\Exception $ ex ) {
174
+ // ignore
175
+ }
176
+
177
+ $ entry = $ this ->loadTelescopeEntries ()->first ();
178
+
179
+ $ this ->assertSame (EntryType::GATE , $ entry ->type );
180
+ $ this ->assertSame (__FILE__ , $ entry ->content ['file ' ]);
181
+ $ this ->assertSame (308 , $ entry ->content ['line ' ]);
182
+ $ this ->assertSame ('update ' , $ entry ->content ['ability ' ]);
183
+ $ this ->assertSame ('denied ' , $ entry ->content ['result ' ]);
184
+ $ this ->assertSame ([['Telescope ' , 'Laravel ' , 'PHP ' ]], $ entry ->content ['arguments ' ]);
185
+ }
186
+
165
187
public function test_gate_watcher_registers_allowed_response_policy_entries ()
166
188
{
167
189
$ this ->app ->setBasePath (dirname (__FILE__ , 3 ));
@@ -178,7 +200,7 @@ public function test_gate_watcher_registers_allowed_response_policy_entries()
178
200
179
201
$ this ->assertSame (EntryType::GATE , $ entry ->type );
180
202
$ this ->assertSame (__FILE__ , $ entry ->content ['file ' ]);
181
- $ this ->assertSame (266 , $ entry ->content ['line ' ]);
203
+ $ this ->assertSame (298 , $ entry ->content ['line ' ]);
182
204
$ this ->assertSame ('view ' , $ entry ->content ['ability ' ]);
183
205
$ this ->assertSame ('allowed ' , $ entry ->content ['result ' ]);
184
206
$ this ->assertSame ([[]], $ entry ->content ['arguments ' ]);
@@ -200,7 +222,7 @@ public function test_gate_watcher_registers_denied_response_policy_entries()
200
222
201
223
$ this ->assertSame (EntryType::GATE , $ entry ->type );
202
224
$ this ->assertSame (__FILE__ , $ entry ->content ['file ' ]);
203
- $ this ->assertSame (281 , $ entry ->content ['line ' ]);
225
+ $ this ->assertSame (313 , $ entry ->content ['line ' ]);
204
226
$ this ->assertSame ('delete ' , $ entry ->content ['ability ' ]);
205
227
$ this ->assertSame ('denied ' , $ entry ->content ['result ' ]);
206
228
$ this ->assertSame ([[]], $ entry ->content ['arguments ' ]);
@@ -257,6 +279,16 @@ class TestResource
257
279
//
258
280
}
259
281
282
+ class TestResourceWithFormatForTelescope
283
+ {
284
+ public function formatForTelescope (): array
285
+ {
286
+ return [
287
+ 'Telescope ' , 'Laravel ' , 'PHP ' ,
288
+ ];
289
+ }
290
+ }
291
+
260
292
class TestController
261
293
{
262
294
use AuthorizesRequests;
0 commit comments