diff options
| author | Stefan Esser | 2014-02-11 12:27:53 +0100 |
|---|---|---|
| committer | Stefan Esser | 2014-02-11 12:27:53 +0100 |
| commit | e7dfd0bc820e59cd8abd2e36b0320cfceb9701a8 (patch) | |
| tree | c0ff908a289c75869aa4f8c00774681550d78687 /tests/executor | |
| parent | 90fff832ca49aff1c7dd030a8c47acf2a38a22a0 (diff) | |
Fix problem with user space session handlers (including test case)
Diffstat (limited to '')
| -rw-r--r-- | tests/executor/user_session_handler.phpt | 87 |
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-- | ||
| 2 | Testing user session handler functions | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php include "../skipifnotcli.inc"; ?> | ||
| 5 | --INI-- | ||
| 6 | suhosin.log.syslog=0 | ||
| 7 | suhosin.log.script=0 | ||
| 8 | suhosin.log.sapi=2 | ||
| 9 | suhosin.session.encrypt=On | ||
| 10 | session.save_path=SUHOSIN_TEST_CASE | ||
| 11 | --FILE-- | ||
| 12 | <?php | ||
| 13 | |||
| 14 | $GLOBALS['test_array_session'] = array(); | ||
| 15 | $GLOBALS['msg'] = array(); | ||
| 16 | |||
| 17 | function sess_open($savePath, $sessionName) | ||
| 18 | { | ||
| 19 | $GLOBALS['msg'][] = "open $savePath -> $sessionName"; | ||
| 20 | } | ||
| 21 | function sess_close() | ||
| 22 | { | ||
| 23 | $GLOBALS['msg'][] = "close"; | ||
| 24 | } | ||
| 25 | function sess_read($id) | ||
| 26 | { | ||
| 27 | $GLOBALS['msg'][] = "read $id"; | ||
| 28 | return @$GLOBALS['test_array_session'][$id]; | ||
| 29 | } | ||
| 30 | function sess_write($id, $data) | ||
| 31 | { | ||
| 32 | $GLOBALS['msg'][] = "write $id - $data"; | ||
| 33 | $GLOBALS['test_array_session'][$id] = $data; | ||
| 34 | return true; | ||
| 35 | } | ||
| 36 | function sess_destroy($id) | ||
| 37 | { | ||
| 38 | $GLOBALS['msg'][] = "destroy $id"; | ||
| 39 | } | ||
| 40 | function sess_gc($lifetime) | ||
| 41 | { | ||
| 42 | } | ||
| 43 | |||
| 44 | session_set_save_handler ( "sess_open" , "sess_close" , "sess_read" , "sess_write" , "sess_destroy" , "sess_gc" ); | ||
| 45 | session_id(md5("testsession1")); | ||
| 46 | session_start(); | ||
| 47 | |||
| 48 | $_SESSION['test1'] = "test"; | ||
| 49 | $_SESSION['test2'] = 12345; | ||
| 50 | $_SESSION['test3'] = array(); | ||
| 51 | $_SESSION['test4'] = new StdClass(); | ||
| 52 | |||
| 53 | session_write_close(); | ||
| 54 | |||
| 55 | session_start(); | ||
| 56 | |||
| 57 | var_dump($_SESSION); | ||
| 58 | var_dump($msg); | ||
| 59 | |||
| 60 | ?> | ||
| 61 | --EXPECTF-- | ||
| 62 | array(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 | } | ||
| 74 | array(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 | } | ||
