3
3
namespace Spatie \Permission \Tests ;
4
4
5
5
use Illuminate \Support \Facades \Artisan ;
6
+ use PHPUnit \Framework \Attributes \Test ;
6
7
use Spatie \Permission \Contracts \Role ;
7
8
8
9
class BladeTest extends TestCase
@@ -21,6 +22,7 @@ protected function setUp(): void
21
22
}
22
23
23
24
/** @test */
25
+ #[Test]
24
26
public function all_blade_directives_will_evaluate_false_when_there_is_nobody_logged_in ()
25
27
{
26
28
$ permission = 'edit-articles ' ;
@@ -40,6 +42,7 @@ public function all_blade_directives_will_evaluate_false_when_there_is_nobody_lo
40
42
}
41
43
42
44
/** @test */
45
+ #[Test]
43
46
public function all_blade_directives_will_evaluate_false_when_somebody_without_roles_or_permissions_is_logged_in ()
44
47
{
45
48
$ permission = 'edit-articles ' ;
@@ -59,6 +62,7 @@ public function all_blade_directives_will_evaluate_false_when_somebody_without_r
59
62
}
60
63
61
64
/** @test */
65
+ #[Test]
62
66
public function all_blade_directives_will_evaluate_false_when_somebody_with_another_guard_is_logged_in ()
63
67
{
64
68
$ permission = 'edit-articles ' ;
@@ -79,6 +83,7 @@ public function all_blade_directives_will_evaluate_false_when_somebody_with_anot
79
83
}
80
84
81
85
/** @test */
86
+ #[Test]
82
87
public function the_can_directive_can_accept_a_guard_name ()
83
88
{
84
89
$ user = $ this ->getWriter ();
@@ -109,6 +114,7 @@ public function the_can_directive_can_accept_a_guard_name()
109
114
}
110
115
111
116
/** @test */
117
+ #[Test]
112
118
public function the_can_directive_will_evaluate_true_when_the_logged_in_user_has_the_permission ()
113
119
{
114
120
$ user = $ this ->getWriter ();
@@ -121,6 +127,7 @@ public function the_can_directive_will_evaluate_true_when_the_logged_in_user_has
121
127
}
122
128
123
129
/** @test */
130
+ #[Test]
124
131
public function the_haspermission_directive_will_evaluate_true_when_the_logged_in_user_has_the_permission ()
125
132
{
126
133
$ user = $ this ->getWriter ();
@@ -145,6 +152,7 @@ public function the_haspermission_directive_will_evaluate_true_when_the_logged_i
145
152
}
146
153
147
154
/** @test */
155
+ #[Test]
148
156
public function the_role_directive_will_evaluate_true_when_the_logged_in_user_has_the_role ()
149
157
{
150
158
auth ()->setUser ($ this ->getWriter ());
@@ -153,6 +161,7 @@ public function the_role_directive_will_evaluate_true_when_the_logged_in_user_ha
153
161
}
154
162
155
163
/** @test */
164
+ #[Test]
156
165
public function the_elserole_directive_will_evaluate_true_when_the_logged_in_user_has_the_role ()
157
166
{
158
167
auth ()->setUser ($ this ->getMember ());
@@ -161,6 +170,7 @@ public function the_elserole_directive_will_evaluate_true_when_the_logged_in_use
161
170
}
162
171
163
172
/** @test */
173
+ #[Test]
164
174
public function the_role_directive_will_evaluate_true_when_the_logged_in_user_has_the_role_for_the_given_guard ()
165
175
{
166
176
auth ('admin ' )->setUser ($ this ->getSuperAdmin ());
@@ -169,6 +179,7 @@ public function the_role_directive_will_evaluate_true_when_the_logged_in_user_ha
169
179
}
170
180
171
181
/** @test */
182
+ #[Test]
172
183
public function the_hasrole_directive_will_evaluate_true_when_the_logged_in_user_has_the_role ()
173
184
{
174
185
auth ()->setUser ($ this ->getWriter ());
@@ -177,6 +188,7 @@ public function the_hasrole_directive_will_evaluate_true_when_the_logged_in_user
177
188
}
178
189
179
190
/** @test */
191
+ #[Test]
180
192
public function the_hasrole_directive_will_evaluate_true_when_the_logged_in_user_has_the_role_for_the_given_guard ()
181
193
{
182
194
auth ('admin ' )->setUser ($ this ->getSuperAdmin ());
@@ -185,6 +197,7 @@ public function the_hasrole_directive_will_evaluate_true_when_the_logged_in_user
185
197
}
186
198
187
199
/** @test */
200
+ #[Test]
188
201
public function the_unlessrole_directive_will_evaluate_true_when_the_logged_in_user_does_not_have_the_role ()
189
202
{
190
203
auth ()->setUser ($ this ->getWriter ());
@@ -193,6 +206,7 @@ public function the_unlessrole_directive_will_evaluate_true_when_the_logged_in_u
193
206
}
194
207
195
208
/** @test */
209
+ #[Test]
196
210
public function the_unlessrole_directive_will_evaluate_true_when_the_logged_in_user_does_not_have_the_role_for_the_given_guard ()
197
211
{
198
212
auth ('admin ' )->setUser ($ this ->getSuperAdmin ());
@@ -202,6 +216,7 @@ public function the_unlessrole_directive_will_evaluate_true_when_the_logged_in_u
202
216
}
203
217
204
218
/** @test */
219
+ #[Test]
205
220
public function the_hasanyrole_directive_will_evaluate_false_when_the_logged_in_user_does_not_have_any_of_the_required_roles ()
206
221
{
207
222
$ roles = ['writer ' , 'intern ' ];
@@ -213,6 +228,7 @@ public function the_hasanyrole_directive_will_evaluate_false_when_the_logged_in_
213
228
}
214
229
215
230
/** @test */
231
+ #[Test]
216
232
public function the_hasanyrole_directive_will_evaluate_true_when_the_logged_in_user_does_have_some_of_the_required_roles ()
217
233
{
218
234
$ roles = ['member ' , 'writer ' , 'intern ' ];
@@ -224,6 +240,7 @@ public function the_hasanyrole_directive_will_evaluate_true_when_the_logged_in_u
224
240
}
225
241
226
242
/** @test */
243
+ #[Test]
227
244
public function the_hasanyrole_directive_will_evaluate_true_when_the_logged_in_user_does_have_some_of_the_required_roles_for_the_given_guard ()
228
245
{
229
246
$ roles = ['super-admin ' , 'moderator ' ];
@@ -235,6 +252,7 @@ public function the_hasanyrole_directive_will_evaluate_true_when_the_logged_in_u
235
252
}
236
253
237
254
/** @test */
255
+ #[Test]
238
256
public function the_hasanyrole_directive_will_evaluate_true_when_the_logged_in_user_does_have_some_of_the_required_roles_in_pipe ()
239
257
{
240
258
$ guard = 'admin ' ;
@@ -245,6 +263,7 @@ public function the_hasanyrole_directive_will_evaluate_true_when_the_logged_in_u
245
263
}
246
264
247
265
/** @test */
266
+ #[Test]
248
267
public function the_hasanyrole_directive_will_evaluate_false_when_the_logged_in_user_doesnt_have_some_of_the_required_roles_in_pipe ()
249
268
{
250
269
$ guard = '' ;
@@ -255,6 +274,7 @@ public function the_hasanyrole_directive_will_evaluate_false_when_the_logged_in_
255
274
}
256
275
257
276
/** @test */
277
+ #[Test]
258
278
public function the_hasallroles_directive_will_evaluate_false_when_the_logged_in_user_does_not_have_all_required_roles ()
259
279
{
260
280
$ roles = ['member ' , 'writer ' ];
@@ -266,6 +286,7 @@ public function the_hasallroles_directive_will_evaluate_false_when_the_logged_in
266
286
}
267
287
268
288
/** @test */
289
+ #[Test]
269
290
public function the_hasallroles_directive_will_evaluate_true_when_the_logged_in_user_does_have_all_required_roles ()
270
291
{
271
292
$ roles = ['member ' , 'writer ' ];
@@ -281,6 +302,7 @@ public function the_hasallroles_directive_will_evaluate_true_when_the_logged_in_
281
302
}
282
303
283
304
/** @test */
305
+ #[Test]
284
306
public function the_hasallroles_directive_will_evaluate_true_when_the_logged_in_user_does_have_all_required_roles_for_the_given_guard ()
285
307
{
286
308
$ roles = ['super-admin ' , 'moderator ' ];
@@ -296,6 +318,7 @@ public function the_hasallroles_directive_will_evaluate_true_when_the_logged_in_
296
318
}
297
319
298
320
/** @test */
321
+ #[Test]
299
322
public function the_hasallroles_directive_will_evaluate_true_when_the_logged_in_user_does_have_all_required_roles_in_pipe ()
300
323
{
301
324
$ guard = 'admin ' ;
@@ -310,6 +333,7 @@ public function the_hasallroles_directive_will_evaluate_true_when_the_logged_in_
310
333
}
311
334
312
335
/** @test */
336
+ #[Test]
313
337
public function the_hasallroles_directive_will_evaluate_false_when_the_logged_in_user_doesnt_have_all_required_roles_in_pipe ()
314
338
{
315
339
$ guard = '' ;
@@ -323,6 +347,7 @@ public function the_hasallroles_directive_will_evaluate_false_when_the_logged_in
323
347
}
324
348
325
349
/** @test */
350
+ #[Test]
326
351
public function the_hasallroles_directive_will_evaluate_true_when_the_logged_in_user_does_have_all_required_roles_in_array ()
327
352
{
328
353
$ guard = 'admin ' ;
@@ -337,6 +362,7 @@ public function the_hasallroles_directive_will_evaluate_true_when_the_logged_in_
337
362
}
338
363
339
364
/** @test */
365
+ #[Test]
340
366
public function the_hasallroles_directive_will_evaluate_false_when_the_logged_in_user_doesnt_have_all_required_roles_in_array ()
341
367
{
342
368
$ guard = '' ;
0 commit comments