diff options
Diffstat (limited to 'tests/SessionManagerTest.php')
-rw-r--r-- | tests/SessionManagerTest.php | 31 |
1 files changed, 10 insertions, 21 deletions
diff --git a/tests/SessionManagerTest.php b/tests/SessionManagerTest.php index a92c3ccc..aa75962a 100644 --- a/tests/SessionManagerTest.php +++ b/tests/SessionManagerTest.php | |||
@@ -1,4 +1,6 @@ | |||
1 | <?php | 1 | <?php |
2 | require_once 'tests/utils/FakeConfigManager.php'; | ||
3 | |||
2 | // Initialize reference data _before_ PHPUnit starts a session | 4 | // Initialize reference data _before_ PHPUnit starts a session |
3 | require_once 'tests/utils/ReferenceSessionIdHashes.php'; | 5 | require_once 'tests/utils/ReferenceSessionIdHashes.php'; |
4 | ReferenceSessionIdHashes::genAllHashes(); | 6 | ReferenceSessionIdHashes::genAllHashes(); |
@@ -8,18 +10,6 @@ use \PHPUnit\Framework\TestCase; | |||
8 | 10 | ||
9 | 11 | ||
10 | /** | 12 | /** |
11 | * Fake ConfigManager | ||
12 | */ | ||
13 | class FakeConfigManager | ||
14 | { | ||
15 | public static function get($key) | ||
16 | { | ||
17 | return $key; | ||
18 | } | ||
19 | } | ||
20 | |||
21 | |||
22 | /** | ||
23 | * Test coverage for SessionManager | 13 | * Test coverage for SessionManager |
24 | */ | 14 | */ |
25 | class SessionManagerTest extends TestCase | 15 | class SessionManagerTest extends TestCase |
@@ -27,12 +17,16 @@ class SessionManagerTest extends TestCase | |||
27 | // Session ID hashes | 17 | // Session ID hashes |
28 | protected static $sidHashes = null; | 18 | protected static $sidHashes = null; |
29 | 19 | ||
20 | // Fake ConfigManager | ||
21 | protected static $conf = null; | ||
22 | |||
30 | /** | 23 | /** |
31 | * Assign reference data | 24 | * Assign reference data |
32 | */ | 25 | */ |
33 | public static function setUpBeforeClass() | 26 | public static function setUpBeforeClass() |
34 | { | 27 | { |
35 | self::$sidHashes = ReferenceSessionIdHashes::getHashes(); | 28 | self::$sidHashes = ReferenceSessionIdHashes::getHashes(); |
29 | self::$conf = new FakeConfigManager(); | ||
36 | } | 30 | } |
37 | 31 | ||
38 | /** | 32 | /** |
@@ -41,8 +35,7 @@ class SessionManagerTest extends TestCase | |||
41 | public function testGenerateToken() | 35 | public function testGenerateToken() |
42 | { | 36 | { |
43 | $session = []; | 37 | $session = []; |
44 | $conf = new FakeConfigManager(); | 38 | $sessionManager = new SessionManager($session, self::$conf); |
45 | $sessionManager = new SessionManager($session, $conf); | ||
46 | 39 | ||
47 | $token = $sessionManager->generateToken(); | 40 | $token = $sessionManager->generateToken(); |
48 | 41 | ||
@@ -61,9 +54,7 @@ class SessionManagerTest extends TestCase | |||
61 | $token => 1, | 54 | $token => 1, |
62 | ], | 55 | ], |
63 | ]; | 56 | ]; |
64 | $conf = new FakeConfigManager(); | 57 | $sessionManager = new SessionManager($session, self::$conf); |
65 | $sessionManager = new SessionManager($session, $conf); | ||
66 | |||
67 | 58 | ||
68 | // check and destroy the token | 59 | // check and destroy the token |
69 | $this->assertTrue($sessionManager->checkToken($token)); | 60 | $this->assertTrue($sessionManager->checkToken($token)); |
@@ -79,8 +70,7 @@ class SessionManagerTest extends TestCase | |||
79 | public function testGenerateAndCheckToken() | 70 | public function testGenerateAndCheckToken() |
80 | { | 71 | { |
81 | $session = []; | 72 | $session = []; |
82 | $conf = new FakeConfigManager(); | 73 | $sessionManager = new SessionManager($session, self::$conf); |
83 | $sessionManager = new SessionManager($session, $conf); | ||
84 | 74 | ||
85 | $token = $sessionManager->generateToken(); | 75 | $token = $sessionManager->generateToken(); |
86 | 76 | ||
@@ -102,8 +92,7 @@ class SessionManagerTest extends TestCase | |||
102 | public function testCheckInvalidToken() | 92 | public function testCheckInvalidToken() |
103 | { | 93 | { |
104 | $session = []; | 94 | $session = []; |
105 | $conf = new FakeConfigManager(); | 95 | $sessionManager = new SessionManager($session, self::$conf); |
106 | $sessionManager = new SessionManager($session, $conf); | ||
107 | 96 | ||
108 | $this->assertFalse($sessionManager->checkToken('4dccc3a45ad9d03e5542b90c37d8db6d10f2b38b')); | 97 | $this->assertFalse($sessionManager->checkToken('4dccc3a45ad9d03e5542b90c37d8db6d10f2b38b')); |
109 | } | 98 | } |