File tree 3 files changed +41
-45
lines changed
src/Symfony/Component/HttpFoundation/Session/Storage/Handler
tests/Symfony/Tests/Component/HttpFoundation/Session/Storage
3 files changed +41
-45
lines changed Original file line number Diff line number Diff line change 9
9
* file that was distributed with this source code.
10
10
*/
11
11
12
- namespace Symfony \Component \HttpFoundation \Session \Storage ;
12
+ namespace Symfony \Component \HttpFoundation \Session \Storage \ Handler ;
13
13
14
14
/**
15
15
* NativeRedisSessionStorage.
20
20
*
21
21
* @author Andrej Hudec <pulzarraider@gmail.com>
22
22
*/
23
- class NativeRedisSessionStorage extends AbstractSessionStorage
23
+ class NativeRedisSessionHandler extends NativeSessionHandler
24
24
{
25
- /**
26
- * @var string
27
- */
28
- private $ savePath ;
29
-
30
25
/**
31
26
* Constructor.
32
27
*
33
28
* @param string $savePath Path of redis server.
34
- * @param array $options Session configuration options.
35
- *
36
- * @see AbstractSessionStorage::__construct()
37
29
*/
38
- public function __construct ($ savePath = 'tcp://127.0.0.1:6379?persistent=0 ' , array $ options = array () )
30
+ public function __construct ($ savePath = 'tcp://127.0.0.1:6379?persistent=0 ' )
39
31
{
40
32
if (!extension_loaded ('redis ' )) {
41
33
throw new \RuntimeException ('PHP does not have "redis" session module registered ' );
42
34
}
43
35
44
- $ this -> savePath = $ savePath;
45
- parent :: __construct ( $ options );
46
- }
36
+ if ( null === $ savePath) {
37
+ $ savePath = ini_get ( ' session.save_path ' );
38
+ }
47
39
48
- /**
49
- * {@inheritdoc}
50
- */
51
- protected function registerSaveHandlers ()
52
- {
53
40
ini_set ('session.save_handler ' , 'redis ' );
54
- ini_set ('session.save_path ' , $ this -> savePath );
41
+ ini_set ('session.save_path ' , $ savePath );
55
42
}
56
43
}
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Symfony \Tests \Component \HttpFoundation \Session \Storage ;
4
+
5
+ use Symfony \Component \HttpFoundation \Session \Storage \Handler \NativeRedisSessionHandler ;
6
+ use Symfony \Component \HttpFoundation \Session \Storage \NativeSessionStorage ;
7
+
8
+ /**
9
+ * Test class for NativeRedisSessionHandlerTest.
10
+ *
11
+ * @runTestsInSeparateProcesses
12
+ */
13
+ class NativeRedisSessionHandlerTest extends \PHPUnit_Framework_TestCase
14
+ {
15
+ public function testSaveHandlers ()
16
+ {
17
+ if (!extension_loaded ('redis ' )) {
18
+ $ this ->markTestSkipped ('Skipped tests Redis extension is not present ' );
19
+ }
20
+
21
+ $ storage = new NativeSessionStorage (array ('name ' => 'TESTING ' ), new NativeRedisSessionHandler ('tcp://127.0.0.1:6379?persistent=0 ' ));
22
+
23
+ if (version_compare (phpversion (), '5.4.0 ' , '< ' )) {
24
+ $ this ->assertEquals ('redis ' , $ storage ->getSaveHandler ()->getSaveHandlerName ());
25
+ $ this ->assertEquals ('redis ' , ini_get ('session.save_handler ' ));
26
+ } else {
27
+ $ this ->assertEquals ('redis ' , $ storage ->getSaveHandler ()->getSaveHandlerName ());
28
+ $ this ->assertEquals ('user ' , ini_get ('session.save_handler ' ));
29
+ }
30
+
31
+ $ this ->assertEquals ('tcp://127.0.0.1:6379?persistent=0 ' , ini_get ('session.save_path ' ));
32
+ $ this ->assertEquals ('TESTING ' , ini_get ('session.name ' ));
33
+ }
34
+ }
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments