1--TEST--
2Test session_set_save_handler() function : using closures as callbacks
3--INI--
4session.save_path=
5session.name=PHPSESSID
6session.save_handler=files
7--SKIPIF--
8<?php include('skipif.inc'); ?>
9--FILE--
10<?php
11
12ob_start();
13
14echo "*** Testing session_set_save_handler() : using closures as callbacks ***\n";
15
16require_once "save_handler_closures.inc";
17var_dump(session_module_name());
18var_dump(session_module_name(FALSE));
19var_dump(session_module_name("blah"));
20var_dump(session_module_name("foo"));
21
22$path = __DIR__ . '/session_set_save_handler_closures';
23@mkdir($path);
24session_save_path($path);
25session_set_save_handler($open_closure, $close_closure, $read_closure, $write_closure, $destroy_closure, $gc_closure);
26
27session_start();
28$_SESSION["Blah"] = "Hello World!";
29$_SESSION["Foo"] = FALSE;
30$_SESSION["Guff"] = 1234567890;
31var_dump($_SESSION);
32
33session_write_close();
34session_unset();
35var_dump($_SESSION);
36
37echo "Starting session again..!\n";
38session_id($session_id);
39session_set_save_handler($open_closure, $close_closure, $read_closure, $write_closure, $destroy_closure, $gc_closure);
40session_start();
41$_SESSION['Bar'] = 'Foo';
42var_dump($_SESSION);
43session_write_close();
44
45echo "Cleanup\n";
46session_start();
47session_destroy();
48
49ob_end_flush();
50@rmdir($path);
51?>
52--EXPECTF--
53*** Testing session_set_save_handler() : using closures as callbacks ***
54string(%d) "%s"
55
56Warning: session_module_name(): Session handler module "" cannot be found in %s on line %d
57bool(false)
58
59Warning: session_module_name(): Session handler module "blah" cannot be found in %s on line %d
60bool(false)
61
62Warning: session_module_name(): Session handler module "foo" cannot be found in %s on line %d
63bool(false)
64Open [%s,PHPSESSID]
65Read [%s,%s]
66array(3) {
67  ["Blah"]=>
68  string(12) "Hello World!"
69  ["Foo"]=>
70  bool(false)
71  ["Guff"]=>
72  int(1234567890)
73}
74Write [%s,%s,Blah|s:12:"Hello World!";Foo|b:0;Guff|i:1234567890;]
75Close [%s,PHPSESSID]
76array(3) {
77  ["Blah"]=>
78  string(12) "Hello World!"
79  ["Foo"]=>
80  bool(false)
81  ["Guff"]=>
82  int(1234567890)
83}
84Starting session again..!
85Open [%s,PHPSESSID]
86Read [%s,%s]
87array(4) {
88  ["Blah"]=>
89  string(12) "Hello World!"
90  ["Foo"]=>
91  bool(false)
92  ["Guff"]=>
93  int(1234567890)
94  ["Bar"]=>
95  string(3) "Foo"
96}
97Write [%s,%s,Blah|s:12:"Hello World!";Foo|b:0;Guff|i:1234567890;Bar|s:3:"Foo";]
98Close [%s,PHPSESSID]
99Cleanup
100Open [%s,PHPSESSID]
101Read [%s,%s]
102Destroy [%s,%s]
103Close [%s,PHPSESSID]
104