add controllers, servoices
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit\Services\Users;
|
||||
|
||||
use App\Services\Users\LoginActivityService;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Tests\TestCase;
|
||||
|
||||
class LoginActivityServiceTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_list_returns_paginated_payload(): void
|
||||
{
|
||||
DB::table('login_activity')->insert([
|
||||
'user_id' => 1,
|
||||
'email' => 'user@example.com',
|
||||
'login_time' => '2025-01-02 09:00:00',
|
||||
'logout_time' => null,
|
||||
'ip_address' => '10.0.0.1',
|
||||
'user_agent' => 'TestAgent',
|
||||
'semester' => 'Fall',
|
||||
'school_year' => '2025-2026',
|
||||
]);
|
||||
|
||||
DB::table('login_activity')->insert([
|
||||
'user_id' => 1,
|
||||
'email' => 'user@example.com',
|
||||
'login_time' => '2025-01-01 09:00:00',
|
||||
'logout_time' => null,
|
||||
'ip_address' => '10.0.0.2',
|
||||
'user_agent' => 'TestAgent',
|
||||
'semester' => 'Fall',
|
||||
'school_year' => '2025-2026',
|
||||
]);
|
||||
|
||||
$service = app(LoginActivityService::class);
|
||||
$payload = $service->list(1, 2);
|
||||
|
||||
$this->assertSame(2, $payload['pagination']['total']);
|
||||
$this->assertSame(2, $payload['pagination']['currentPage']);
|
||||
$this->assertSame('10.0.0.2', $payload['activities'][0]['ip_address']);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user