File: igbinary_043.phpt

package info (click to toggle)
php-igbinary 3.2.16-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,024 kB
  • sloc: ansic: 3,373; xml: 1,106; pascal: 10; makefile: 2; php: 2; sh: 1
file content (58 lines) | stat: -rw-r--r-- 1,020 bytes parent folder | download | duplicates (7)
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
55
56
57
58
--TEST--
Object serialization with compact strings
--SKIPIF--
<?php
	if (!extension_loaded("igbinary")) {
		print "skip";
	}
?>
--INI--
igbinary.compact_strings=Off
--FILE--
<?php
class Foo {
}

class Bar {
}


$expected_array = array();
for ($i = 0; $i < 10; $i++) {
	$expected_array['foo_' . $i] = new Foo;
	$expected_array['bar_' . $i] = new Bar;
}

$actual_array = igbinary_unserialize(igbinary_serialize($expected_array));

$error = 'OK';

foreach ($expected_array as $key => $object) {
	if (!isset($actual_array[$key])) {
		$error = 'ERROR';
		echo "Key $key is missing from result.\n";
		echo "Expected key/value:\n";
		var_dump($key, $object);
		var_dump($object);

		break;
	}

	if (!is_object($actual_array[$key]) ||
		get_class($object) !== get_class($actual_array[$key])) {
		$error = 'ERROR';
		echo "Array mismatch on $key\n";
		echo "Expected key/value:\n";
		var_dump($key, $object);
		echo "Actual key/value:\n";
		var_dump($key, $actual_array[$key]);

		break;
	}

}

echo $error, "\n";

--EXPECT--
OK