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