-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathSessionStartMiddlewareTest.php
More file actions
51 lines (41 loc) · 1.27 KB
/
Copy pathSessionStartMiddlewareTest.php
File metadata and controls
51 lines (41 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
namespace Odan\Session\Test;
use Middlewares\Utils\Dispatcher;
use Odan\Session\Middleware\SessionStartMiddleware;
use Odan\Session\PhpSession;
use PHPUnit\Framework\TestCase;
/**
* Test.
*
* #[\PHPUnit\Framework\Attributes\CoversClass(\Odan\Session\Middleware\SessionStartMiddleware)]
*/
class SessionStartMiddlewareTest extends TestCase
{
private PhpSession $session;
private SessionStartMiddleware $middleware;
protected function setUp(): void
{
$_SESSION = [];
$this->session = new PhpSession([
'name' => 'app',
// turn off automatic sending of cache headers entirely
'cache_limiter' => '',
// garbage collection
'gc_probability' => 1,
'gc_divisor' => 1,
'gc_maxlifetime' => 30 * 24 * 60 * 60,
'save_path' => getenv('GITHUB_ACTIONS') ? '/tmp' : '',
]);
$this->middleware = new SessionStartMiddleware($this->session);
}
public function testInvoke(): void
{
// Session must not be started
$this->assertFalse($this->session->isStarted());
Dispatcher::run([
$this->middleware,
]);
// Session must be closed
$this->assertFalse($this->session->isStarted());
}
}