Skip to content

Commit 8751a2e

Browse files
committed
add the getTypeColor method work as expected test
1 parent 0dc2637 commit 8751a2e

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

tests/Feature/ActionMonitoringTest.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
use Binafy\LaravelUserMonitoring\Models\ActionMonitoring;
44
use Binafy\LaravelUserMonitoring\Utills\ActionType;
5+
use Binafy\LaravelUserMonitoring\Utills\UserUtils;
56
use Illuminate\Foundation\Testing\RefreshDatabase;
7+
use Illuminate\Support\Facades\DB;
68
use Tests\SetUp\Models\Product;
79
use function Pest\Laravel\{assertDatabaseCount, assertDatabaseHas};
810

@@ -248,3 +250,32 @@
248250
assertDatabaseCount(config('user-monitoring.action_monitoring.table'), 3);
249251
assertDatabaseHas(config('user-monitoring.action_monitoring.table'), ['page' => url('/')]);
250252
});
253+
254+
test('the getTypeColor method work as expected', function () {
255+
$defaultData = [
256+
'user_id' => null,
257+
'table_name' => 'products',
258+
'browser_name' => 'Chrome',
259+
'platform' => 'Windows',
260+
'device' => 'Macbook M4',
261+
'ip' => '192.168.0.1',
262+
'user_guard' => 'web',
263+
'page' => 'https://github.com/milwad-dev',
264+
];
265+
$colors = [
266+
ActionType::ACTION_READ => 'blue',
267+
ActionType::ACTION_STORE => 'green',
268+
ActionType::ACTION_UPDATE => 'purple',
269+
ActionType::ACTION_DELETE => 'red',
270+
ActionType::ACTION_RESTORED => 'yellow',
271+
ActionType::ACTION_REPLICATE => 'pink',
272+
];
273+
274+
foreach (ActionType::$types as $type) {
275+
$actionMonitoring = ActionMonitoring::query()->create($defaultData + [
276+
'action_type' => $type
277+
]);
278+
279+
expect($actionMonitoring->getTypeColor())->toBe($colors[$type]);
280+
}
281+
});

0 commit comments

Comments
 (0)