Passed
Push — develop ( 63f05f...0005e4 )
by Mathieu
01:40
created

SessionTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 20
dl 0
loc 27
rs 10
c 1
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A testNative() 0 25 1
1
<?php
2
3
use \Suricate\Session;
4
use \Suricate\Suricate;
5
/**
6
 * @SuppressWarnings("StaticAccess")
7
 */
8
class SessionTest extends \PHPUnit\Framework\TestCase
9
{
10
    public function testNative()
11
    {
12
        new \Suricate\Suricate([], './tests/stubs/session.ini');
13
        $this->assertInstanceOf(Session\Native::class, Suricate::Session()->getInstance());
0 ignored issues
show
Bug introduced by
The method Session() does not exist on Suricate\Suricate. Since you implemented __callStatic, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

13
        $this->assertInstanceOf(Session\Native::class, Suricate::/** @scrutinizer ignore-call */ Session()->getInstance());
Loading history...
14
        $this->assertSame(session_id(), Suricate::Session()->getId());
15
        $oldSessionId = session_id();
16
        Suricate::Session()->regenerate();
17
        $newSessionId = session_id();
18
        $this->assertNotEquals($oldSessionId, $newSessionId);
19
20
        Suricate::Session()->write("key", "my value");
21
        $this->assertSame("my value", Suricate::Session()->read("key"));
22
23
        Suricate::Session()->write("key", 1);
24
        $this->assertSame(1, Suricate::Session()->read("key"));
25
26
        Suricate::Session()->destroy("key");
27
        $this->assertNull(Suricate::Session()->read("key"));
28
29
        $oldSessionId = session_id();
30
        Suricate::Session()->write("key", 1);
31
        Suricate::Session()->close();
32
        $newSessionId = session_id();
33
        $this->assertNull(Suricate::Session()->read("key"));
34
        $this->assertNotEquals($oldSessionId, $newSessionId);
35
    }
36
    
37
    
38
}
39