1<?php
2
3// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the GNU Affero General Public License v3.0.
4// See the LICENCE file in the repository root for full licence text.
5
6declare(strict_types=1);
7
8namespace Tests\Libraries\Session;
9
10use App\Libraries\Session\Store;
11use App\Models\User;
12use Tests\TestCase;
13
14class StoreTest extends TestCase
15{
16 public function testBatchDeleteRemovesCurrentSessionUserId(): void
17 {
18 $user = User::factory()->create();
19 \Auth::login($user);
20 $session = \Session::instance();
21
22 $this->assertSame($user->getKey(), $session->userId());
23
24 Store::batchDelete($user->getKey(), [$session->getId()]);
25
26 $this->assertNull($session->userId());
27 }
28
29 public function testUserId(): void
30 {
31 $this->assertNull(\Session::userId());
32
33 $user = User::factory()->create();
34 \Auth::login($user);
35
36 $this->assertSame(\Session::userId(), $user->getKey());
37 }
38}