-
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathSessionTest.php
More file actions
62 lines (57 loc) · 1.67 KB
/
Copy pathSessionTest.php
File metadata and controls
62 lines (57 loc) · 1.67 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
52
53
54
55
56
57
58
59
60
61
62
<?php
/*
* This file is part of Aplus Framework Session Library.
*
* (c) Natan Felles <natanfelles@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Tests\Session;
use Framework\Session\Session;
/**
* Class SessionTest.
*
* @runTestsInSeparateProcesses
*/
final class SessionTest extends TestCase
{
public function setUp() : void
{
if (\is_dir($this->getSavePath())) {
\exec('chmod -R 777 ' . $this->getSavePath());
\exec('rm -rf ' . $this->getSavePath());
}
\exec('mkdir ' . $this->getSavePath());
$this->session = new Session([
'name' => 'SessionName',
'save_path' => $this->getSavePath(),
]);
$this->session->start();
}
protected function getSavePath() : string
{
return \sys_get_temp_dir() . '/sessions';
}
public function testStartFail() : void
{
$this->session->stop();
\exec('rm -rf ' . $this->getSavePath());
$this->expectException(\RuntimeException::class);
$this->expectExceptionMessage(
'Session could not be started:'
. ' session_start(): Failed to read session data:'
. ' files (path: ' . $this->getSavePath() . ')'
);
$this->session->start();
}
public function testGcFail() : void
{
$this->session->stop();
self::assertFalse($this->session->gc());
self::assertSame(
'session_gc(): Session cannot be garbage collected when there is no active session',
\error_get_last()['message']
);
}
}