xref: /PHP-5.6/ext/spl/tests/unserialize.phpt (revision bf7fed7e)
1--TEST--
2SPL: unserialize with no data (for PHPUnit)
3--FILE--
4<?php
5
6$types = array('SplDoublyLinkedList', 'SplObjectStorage', 'ArrayObject');
7
8foreach ($types as $type) {
9	// serialize an empty new object
10	$exp = serialize(new $type());
11	// hack to instanciate an object without constructor
12	$str = sprintf('C:%d:"%s":0:{}', strlen($type), $type);
13	$obj = unserialize($str);
14	var_dump($obj);
15	// serialize result
16	$out = serialize($obj);
17	// both should match
18	var_dump($exp === $out);
19}
20?>
21===DONE===
22--EXPECTF--
23object(SplDoublyLinkedList)#%d (2) {
24  ["flags":"SplDoublyLinkedList":private]=>
25  int(0)
26  ["dllist":"SplDoublyLinkedList":private]=>
27  array(0) {
28  }
29}
30bool(true)
31object(SplObjectStorage)#%d (1) {
32  ["storage":"SplObjectStorage":private]=>
33  array(0) {
34  }
35}
36bool(true)
37object(ArrayObject)#%d (1) {
38  ["storage":"ArrayObject":private]=>
39  array(0) {
40  }
41}
42bool(true)
43===DONE===
44