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
|