xref: /PHP-7.2/ext/wddx/tests/004.phpt (revision 75b07963)
1--TEST--
2wddx session serializer handler (serialize)
3--SKIPIF--
4<?php
5	if (!extension_loaded("wddx")) die("skip Wddx module not loaded");
6	if (!extension_loaded('session')) die('skip Session module not enabled');
7
8	// following test code stolen from ext/session/skipif.inc
9	$save_path = ini_get("session.save_path");
10	if ($save_path) {
11		if (!file_exists($save_path)) {
12			die("skip Session save_path doesn't exist");
13		}
14
15		if ($save_path && !@is_writable($save_path)) {
16			if (($p = strpos($save_path, ';')) !== false) {
17				$save_path = substr($save_path, ++$p);
18			}
19			if (!@is_writable($save_path)) {
20				die("skip\n");
21			}
22		}
23	}
24?>
25--INI--
26precision=14
27session.serialize_handler=wddx
28session.use_cookies=0
29session.cache_limiter=
30session.save_handler=files
31--FILE--
32<?php
33	class foo {
34		public $bar = "ok";
35		public $invisible = 'you don\'t see me!';
36
37		function method() { $this->yes = "done"; }
38
39		public function __sleep() { return array('bar', 'yes'); }
40	}
41
42	session_start();
43
44	$_SESSION['data'] = array(
45		'test1' => true,
46		'test2' => 'some string',
47		'test3' => 654321,
48		'test4' => array(
49			'some string',
50			true,
51			null
52		),
53	);
54
55	$_SESSION['class'] = new foo();
56	$_SESSION['class']->method();
57
58	var_dump(session_encode());
59
60	session_destroy();
61?>
62--EXPECT--
63string(550) "<wddxPacket version='1.0'><header/><data><struct><var name='data'><struct><var name='test1'><boolean value='true'/></var><var name='test2'><string>some string</string></var><var name='test3'><number>654321</number></var><var name='test4'><array length='3'><string>some string</string><boolean value='true'/><null/></array></var></struct></var><var name='class'><struct><var name='php_class_name'><string>foo</string></var><var name='bar'><string>ok</string></var><var name='yes'><string>done</string></var></struct></var></struct></data></wddxPacket>"
64