File tree Expand file tree Collapse file tree 2 files changed +38
-1
lines changed
Expand file tree Collapse file tree 2 files changed +38
-1
lines changed Original file line number Diff line number Diff line change 1010use Illuminate \Foundation \Auth \User as Authenticatable ;
1111use Illuminate \Notifications \Notifiable ;
1212use Modules \AdminAuth \Notifications \ResetPassword ;
13- // use Modules\Traits\ActivityLog;
13+ // use Modules\Support\ Traits\ActivityLog;
1414use Modules \Support \Traits \Searchable ;
1515use Spatie \Permission \Traits \HasRoles ;
1616
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ use Illuminate \Database \Eloquent \Model ;
4+ use Illuminate \Database \Schema \Blueprint ;
5+ use Illuminate \Support \Facades \Schema ;
6+ use Modules \Support \Traits \ActivityLog ;
7+
8+ uses (ActivityLog::class);
9+
10+ beforeEach (function () {
11+ Schema::create ('items ' , function (Blueprint $ table ) {
12+ $ table ->id ();
13+ $ table ->string ('name ' )->nullable ();
14+ $ table ->timestamps ();
15+ });
16+ });
17+
18+ it ('logs the activity for the model ' , function () {
19+ $ model = new class extends Model
20+ {
21+ use ActivityLog;
22+
23+ protected $ table = 'items ' ;
24+
25+ protected $ guarded = [];
26+ };
27+
28+ $ item1 = $ model ->create (['name ' => 'Item 1 ' ]);
29+
30+ $ item1 ->delete ();
31+
32+ $ this ->assertDatabaseHas ('activity_log ' , [
33+ 'subject_id ' => $ item1 ->id ,
34+ 'subject_type ' => get_class ($ item1 ),
35+ 'description ' => 'deleted ' ,
36+ ]);
37+ });
You can’t perform that action at this time.
0 commit comments