add SessionTimeout logic
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit\Services\Auth;
|
||||
|
||||
use App\Services\Auth\SessionActivityService;
|
||||
use Illuminate\Session\ArraySessionHandler;
|
||||
use Illuminate\Session\Store;
|
||||
use Tests\TestCase;
|
||||
|
||||
class SessionActivityServiceTest extends TestCase
|
||||
{
|
||||
public function test_set_and_get_last_activity(): void
|
||||
{
|
||||
$store = $this->makeSessionStore();
|
||||
$service = new SessionActivityService($store);
|
||||
|
||||
$service->setLastActivity(12345);
|
||||
|
||||
$this->assertTrue($service->hasLastActivity());
|
||||
$this->assertSame(12345, $service->getLastActivity());
|
||||
}
|
||||
|
||||
public function test_clear_last_activity(): void
|
||||
{
|
||||
$store = $this->makeSessionStore();
|
||||
$service = new SessionActivityService($store);
|
||||
|
||||
$service->setLastActivity(12345);
|
||||
$service->clearLastActivity();
|
||||
|
||||
$this->assertFalse($service->hasLastActivity());
|
||||
}
|
||||
|
||||
private function makeSessionStore(): Store
|
||||
{
|
||||
$handler = new ArraySessionHandler(10);
|
||||
$store = new Store('test', $handler);
|
||||
$store->start();
|
||||
|
||||
return $store;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user