xref: /PHP-7.2/ext/wddx/tests/005.phpt (revision 75b07963)
1--TEST--
2wddx session serializer handler (deserialize)
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
36		function method() { $this->yes = "done"; }
37	}
38
39	session_start();
40
41	session_decode("<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>");
42
43	var_dump($_SESSION);
44
45	session_destroy();
46?>
47--EXPECT--
48array(2) {
49  ["data"]=>
50  array(4) {
51    ["test1"]=>
52    bool(true)
53    ["test2"]=>
54    string(11) "some string"
55    ["test3"]=>
56    int(654321)
57    ["test4"]=>
58    array(3) {
59      [0]=>
60      string(11) "some string"
61      [1]=>
62      bool(true)
63      [2]=>
64      NULL
65    }
66  }
67  ["class"]=>
68  object(foo)#1 (2) {
69    ["bar"]=>
70    string(2) "ok"
71    ["yes"]=>
72    string(4) "done"
73  }
74}
75