summaryrefslogtreecommitdiff
path: root/ext/session/tests/session_set_save_handler_class_006.phpt
blob: 3f86437207a11ca43f0b7ef1e0863a45ee544eea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
--TEST--
Test session_set_save_handler() : using objects in close
--INI--
session.save_handler=files
session.name=PHPSESSID
--SKIPIF--
<?php include('skipif.inc'); ?>
--FILE--
<?php

ob_start();

/*
 * Prototype : bool session_set_save_handler(SessionHandler $handler [, bool $register_shutdown_function = true])
 * Description : Sets user-level session storage functions
 * Source code : ext/session/session.c
 */

echo "*** Testing session_set_save_handler() : using objects in close ***\n";

class MySession7_Foo {
	public $state = 'ok';
	function __destruct() {
		$this->state = 'destroyed';
	}
}

class MySession7 extends SessionHandler {
	public $foo;
	public function close() {
		var_dump($this->foo);
		@var_dump($GLOBALS['bar']);
		return parent::close();
	}
}

$bar = new MySession7_Foo;
$handler = new MySession7;
$handler->foo = new MySession7_Foo;
session_set_save_handler($handler);
session_start();

ob_end_flush();
?>
--EXPECTF--
*** Testing session_set_save_handler() : using objects in close ***
object(MySession7_Foo)#%d (%d) {
  ["state"]=>
  string(2) "ok"
}
object(MySession7_Foo)#%d (%d) {
  ["state"]=>
  string(2) "ok"
}