File tree Expand file tree Collapse file tree 3 files changed +34
-7
lines changed Expand file tree Collapse file tree 3 files changed +34
-7
lines changed Original file line number Diff line number Diff line change @@ -30,8 +30,6 @@ public static function table(Table $table): Table
30
30
->label ('Nom ' ),
31
31
TextColumn::make ('email ' )
32
32
->label ('Email ' ),
33
- TextColumn::make ('username ' )
34
- ->label ('Username ' ),
35
33
TextColumn::make (name: 'Points ' )
36
34
->getStateUsing (fn (User $ user ) => $ user ->getPoints ().' XP ' )
37
35
->sortable (),
Original file line number Diff line number Diff line change 8
8
use Livewire \Livewire ;
9
9
10
10
beforeEach (function (): void {
11
+
11
12
$ this ->user = $ this ->login ();
12
- $ this ->users = User::factory ()
13
- ->count (5 )
14
- ->create ();
15
13
});
16
14
17
15
describe (UserResource::class, function (): void {
18
16
19
- it ('page can display table with records ' , function (): void {
17
+ it ('page can display table with records without admin ' , function (): void {
18
+
19
+ $ users = User::factory ()
20
+ ->count (5 )
21
+ ->create ();
22
+
23
+ createAndAssignRole ('admin ' , User::first ());
24
+
25
+ Livewire::test (ListUsers::class)
26
+ ->assertCanSeeTableRecords ($ users )
27
+ ->assertCountTableRecords (5 );
28
+
29
+ });
30
+
31
+ it ('page can display table with records without moderator ' , function (): void {
32
+
33
+ $ users = User::factory ()
34
+ ->count (3 )
35
+ ->create ();
36
+
37
+ createAndAssignRole ('moderator ' , User::first ());
38
+
20
39
Livewire::test (ListUsers::class)
21
- ->assertCanSeeTableRecords ($ this ->users );
40
+ ->assertCanSeeTableRecords ($ users )
41
+ ->assertCountTableRecords (3 );
42
+
22
43
});
23
44
})->group ('users ' );
Original file line number Diff line number Diff line change 8
8
use Carbon \Carbon ;
9
9
use Illuminate \Foundation \Testing \RefreshDatabase ;
10
10
use Illuminate \Support \Collection ;
11
+ use Spatie \Permission \Models \Role ;
11
12
12
13
uses (Tests \TestCase::class, RefreshDatabase::class)
13
14
->in ('Feature ' );
@@ -59,3 +60,10 @@ function createActiveThread(): Thread
59
60
60
61
return $ thread ;
61
62
}
63
+
64
+ function createAndAssignRole (string $ role , User $ user ): User
65
+ {
66
+ Role::create (['name ' => $ role ]);
67
+
68
+ return $ user ->assignRole ($ role );
69
+ }
You can’t perform that action at this time.
0 commit comments