Skip to content

Commit 8766c00

Browse files
committed
add store action monitoring when a model created with login user with unknow guard
1 parent c0601bb commit 8766c00

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

tests/Feature/ActionMonitoringTest.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,29 @@
3434
assertDatabaseHas(config('user-monitoring.action_monitoring.table'), ['page' => url('/')]);
3535
});
3636

37+
test('store action monitoring when a model created with login user with unknow guard', function () {
38+
config(['user-monitoring.user.guards' => ['milwad']]);
39+
40+
$user = createUser();
41+
auth()->login($user);
42+
43+
Product::query()->create([
44+
'title' => 'milwad'
45+
]);
46+
47+
// Assertions
48+
expect(ActionMonitoring::query()->value('table_name'))
49+
->toBe('products')
50+
->and(ActionMonitoring::query()->value('action_type'))
51+
->toBe(ActionType::ACTION_STORE)
52+
->and(ActionMonitoring::first()->user)
53+
->toBeNull();
54+
55+
// DB Assertions
56+
assertDatabaseCount(config('user-monitoring.action_monitoring.table'), 1);
57+
assertDatabaseHas(config('user-monitoring.action_monitoring.table'), ['page' => url('/')]);
58+
});
59+
3760
test('store action monitoring when a model created without login user', function () {
3861
Product::query()->create([
3962
'title' => 'milwad'

0 commit comments

Comments
 (0)