summaryrefslogtreecommitdiff
path: root/tests/executor/user_session_handler.phpt
diff options
context:
space:
mode:
authorStefan Esser2014-02-11 12:27:53 +0100
committerStefan Esser2014-02-11 12:27:53 +0100
commite7dfd0bc820e59cd8abd2e36b0320cfceb9701a8 (patch)
treec0ff908a289c75869aa4f8c00774681550d78687 /tests/executor/user_session_handler.phpt
parent90fff832ca49aff1c7dd030a8c47acf2a38a22a0 (diff)
Fix problem with user space session handlers (including test case)
Diffstat (limited to 'tests/executor/user_session_handler.phpt')
-rw-r--r--tests/executor/user_session_handler.phpt87
1 files changed, 87 insertions, 0 deletions
diff --git a/tests/executor/user_session_handler.phpt b/tests/executor/user_session_handler.phpt
new file mode 100644
index 0000000..aa9d67c
--- /dev/null
+++ b/tests/executor/user_session_handler.phpt
@@ -0,0 +1,87 @@
1--TEST--
2Testing user session handler functions
3--SKIPIF--
4<?php include "../skipifnotcli.inc"; ?>
5--INI--
6suhosin.log.syslog=0
7suhosin.log.script=0
8suhosin.log.sapi=2
9suhosin.session.encrypt=On
10session.save_path=SUHOSIN_TEST_CASE
11--FILE--
12<?php
13
14$GLOBALS['test_array_session'] = array();
15$GLOBALS['msg'] = array();
16
17function sess_open($savePath, $sessionName)
18{
19 $GLOBALS['msg'][] = "open $savePath -> $sessionName";
20}
21function sess_close()
22{
23 $GLOBALS['msg'][] = "close";
24}
25function sess_read($id)
26{
27 $GLOBALS['msg'][] = "read $id";
28 return @$GLOBALS['test_array_session'][$id];
29}
30function sess_write($id, $data)
31{
32 $GLOBALS['msg'][] = "write $id - $data";
33 $GLOBALS['test_array_session'][$id] = $data;
34 return true;
35}
36function sess_destroy($id)
37{
38 $GLOBALS['msg'][] = "destroy $id";
39}
40function sess_gc($lifetime)
41{
42}
43
44session_set_save_handler ( "sess_open" , "sess_close" , "sess_read" , "sess_write" , "sess_destroy" , "sess_gc" );
45session_id(md5("testsession1"));
46session_start();
47
48$_SESSION['test1'] = "test";
49$_SESSION['test2'] = 12345;
50$_SESSION['test3'] = array();
51$_SESSION['test4'] = new StdClass();
52
53session_write_close();
54
55session_start();
56
57var_dump($_SESSION);
58var_dump($msg);
59
60?>
61--EXPECTF--
62array(4) {
63 ["test1"]=>
64 string(4) "test"
65 ["test2"]=>
66 int(12345)
67 ["test3"]=>
68 array(0) {
69 }
70 ["test4"]=>
71 object(stdClass)#1 (0) {
72 }
73}
74array(6) {
75 [0]=>
76 string(35) "open SUHOSIN_TEST_CASE -> PHPSESSID"
77 [1]=>
78 string(37) "read 4cdacd154c45b08c35d83f3b514eddab"
79 [2]=>
80 string(%d) "write 4cdacd154c45b08c35d83f3b514eddab - %s"
81 [3]=>
82 string(5) "close"
83 [4]=>
84 string(35) "open SUHOSIN_TEST_CASE -> PHPSESSID"
85 [5]=>
86 string(37) "read 4cdacd154c45b08c35d83f3b514eddab"
87}