forked from stefangabos/Zebra_Session
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSessionConfigTest.php
More file actions
63 lines (49 loc) · 2.23 KB
/
Copy pathSessionConfigTest.php
File metadata and controls
63 lines (49 loc) · 2.23 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
63
<?php
namespace steamegg\SessionDatabase\Test;
use steamegg\SessionDatabase\SessionConfig;
class SessionConfigTest extends TestCase {
function testSecurityCode(){
$config = new SessionConfig("code1", "fingerprint", 111, 222, 333);
$this->assertAttributeEquals("code1", "security_code", $config);
}
function testFingerprint(){
$config = new SessionConfig("code1", "fingerprint", 111, 222, 333);
$this->assertAttributeEquals("fingerprint", "fingerprint", $config);
$config = new SessionConfig("code1", "fingerprint+ip", 111, 222, 333);
$this->assertAttributeEquals("fingerprint+ip", "fingerprint", $config);
}
function testSessionLifetimeShouldNumeric(){
$this->setExpectedException("PHPUnit_Framework_Error", "session_lifetime is not numeric");
$config = new SessionConfig("code1", "fingerprint", "notNumeric", 222, 333);
}
function testSessionLifetime(){
$config = new SessionConfig("code1", "fingerprint", 111, 222, 333);
$this->assertEquals(111, $config->getSessionLifetime());
}
function testGcProbabilityShouldNumeric(){
$this->setExpectedException("PHPUnit_Framework_Error", "gc_probability is not numeric");
$config = new SessionConfig("code1", "fingerprint", 111, "notNumeric", 333);
}
function testGcDivisorShouldNumeric(){
$this->setExpectedException("PHPUnit_Framework_Error", "gc_divisor is not numeric");
$config = new SessionConfig("code1", "fingerprint", 111, 222, "notNumeric");
}
function testGc(){
$config = new SessionConfig("code1", "fingerprint", 111, 222, 333);
$this->assertEquals(222, $config->getGcProbability());
$this->assertEquals(333, $config->getGcDivisor());
}
function testTable(){
$config = new SessionConfig("code1", "fingerprint", 111, 222, 333);
$this->assertEquals("session_data", $config->getTable());
$config = new SessionConfig("code1", "fingerprint", 111, 222, 333, "table1");
$this->assertEquals("table1", $config->getTable());
}
function testHash(){
$config = new SessionConfig("code1", "fingerprint", 111, 222, 333);
$hash = md5(sprintf("%s%s", "code1", "fingerprint"));
$this->assertEquals($hash, $config->calculateHash());
$hash = md5(sprintf("%s%s", "code1", "fingerprint+ip"));
$this->assertNotEquals($hash, $config->calculateHash());
}
}