Files
filegator/tests/backend/Unit/SessionStorageTest.php
Milos Stojanovic 261607e1d3 initial commit
2019-06-13 18:52:40 +02:00

63 lines
1.5 KiB
PHP

<?php
/*
* This file is part of the FileGator package.
*
* (c) Milos Stojanovic <alcalbg@gmail.com>
*
* For the full copyright and license information, please view the LICENSE file
*/
namespace Tests\Unit;
use Filegator\Kernel\Request;
use Filegator\Services\Session\Adapters\SessionStorage;
use Tests\TestCase;
/**
* @internal
*/
class SessionStorageTest extends TestCase
{
protected $session_service;
public function setUp(): void
{
$this->session_service = new SessionStorage(new Request());
$this->session_service->init([
'session_handler' => 'mockfilesession',
'available' => [
'mockfilesession' => function () {
return new \Symfony\Component\HttpFoundation\Session\Storage\MockFileSessionStorage();
},
],
]);
parent::setUp();
}
public function testInvalidateSession()
{
$this->session_service->set('test1', 444);
$this->session_service->invalidate();
$this->assertNull($this->session_service->get('test1'));
}
public function testInvalidateSessionWhichIsNotStartedYet()
{
$this->session_service->invalidate();
$this->assertNull($this->session_service->get('something'));
}
public function testUseSession()
{
$this->session_service->set('test2', 999);
$this->session_service->save();
$this->assertEquals($this->session_service->get('test2'), 999);
$this->assertNull($this->session_service->get('test1'));
}
}