add notifications logic and add support of both JWT and Sanctum
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit\Services\Staff;
|
||||
|
||||
use App\Services\Staff\StaffTimeOffLinkService;
|
||||
use Tests\TestCase;
|
||||
|
||||
class StaffTimeOffLinkServiceTest extends TestCase
|
||||
{
|
||||
public function test_token_round_trip(): void
|
||||
{
|
||||
$service = new StaffTimeOffLinkService('secret', 3600);
|
||||
|
||||
$token = $service->createToken(['uid' => 10, 'email' => 'staff@example.com']);
|
||||
$payload = $service->parseToken($token);
|
||||
|
||||
$this->assertNotNull($payload);
|
||||
$this->assertSame(10, $payload['uid']);
|
||||
$this->assertSame('staff@example.com', $payload['email']);
|
||||
}
|
||||
|
||||
public function test_token_invalid_on_expiry(): void
|
||||
{
|
||||
$service = new StaffTimeOffLinkService('secret', 1);
|
||||
|
||||
$token = $service->createToken(['uid' => 10]);
|
||||
sleep(2);
|
||||
$payload = $service->parseToken($token);
|
||||
|
||||
$this->assertNull($payload);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user