Skip to content

Commit 9e60e7a

Browse files
committed
add action not stored when the on_restore config is false test
1 parent 57a1b0f commit 9e60e7a

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

tests/Feature/ActionMonitoringTest.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,3 +222,29 @@
222222
assertDatabaseCount(config('user-monitoring.action_monitoring.table'), 4);
223223
assertDatabaseHas(config('user-monitoring.action_monitoring.table'), ['page' => url('/')]);
224224
});
225+
226+
test('action not stored when the on_restore config is false', function () {
227+
$user = createUser();
228+
auth()->login($user);
229+
230+
$product = \Tests\SetUp\Models\ProductSoftDelete::query()->create([
231+
'title' => 'milwad',
232+
'description' => 'WE ARE HELPING TO OPEN-SOURCE WORLD'
233+
]);
234+
235+
$product->delete();
236+
$product->restore();
237+
238+
// Assertions
239+
expect(ActionMonitoring::query()->value('table_name'))
240+
->toBe('products')
241+
->and(ActionMonitoring::query()->where('id', 4)->value('action_type'))
242+
->toBeNull()
243+
->and($user->name)
244+
->toBe(ActionMonitoring::first()->user->name);
245+
246+
// DB Assertions
247+
assertDatabaseCount('products', 1);
248+
assertDatabaseCount(config('user-monitoring.action_monitoring.table'), 3);
249+
assertDatabaseHas(config('user-monitoring.action_monitoring.table'), ['page' => url('/')]);
250+
});

0 commit comments

Comments
 (0)